diff --git a/conditional/blueprints/cache_management.py b/conditional/blueprints/cache_management.py index fad5924c..a90cd99f 100644 --- a/conditional/blueprints/cache_management.py +++ b/conditional/blueprints/cache_management.py @@ -12,7 +12,6 @@ from conditional.util.ldap import ldap_get_current_students from conditional.util.ldap import ldap_get_intro_members from conditional.util.ldap import ldap_get_member -from conditional.util.ldap import ldap_get_onfloor_members from conditional.util.user_dict import user_dict_is_eval_director, user_dict_is_rtp logger = structlog.get_logger() @@ -52,7 +51,6 @@ def clear_members_cache(): ldap_get_active_members.cache_clear() ldap_get_current_students.cache_clear() ldap_get_intro_members.cache_clear() - ldap_get_onfloor_members.cache_clear() def clear_committee_cache(): diff --git a/conditional/blueprints/dashboard.py b/conditional/blueprints/dashboard.py index 0a440af7..b3e7d884 100644 --- a/conditional/blueprints/dashboard.py +++ b/conditional/blueprints/dashboard.py @@ -16,8 +16,7 @@ from conditional.util.major_project import get_project_list from conditional.util.member import gatekeep_values, get_freshman_data, get_voting_members, \ get_cm, get_hm, is_gatekeep_active, req_cm -from conditional.util.user_dict import user_dict_is_intromember, \ - user_dict_is_onfloor +from conditional.util.user_dict import user_dict_is_intromember logger = structlog.get_logger() @@ -40,14 +39,11 @@ def display_dashboard(user_dict=None): can_vote = get_voting_members() - on_floor = user_dict_is_onfloor(user_dict) - data = {} data['username'] = uid data['active'] = ldap_is_uid_active(uid) data['bad_standing'] = ldap_is_uid_bad_standing(uid) - data['onfloor'] = on_floor data['voting'] = bool(uid in can_vote) data['voting_count'] = {"Voting Members": len(can_vote), @@ -74,14 +70,10 @@ def display_dashboard(user_dict=None): data['spring'] = spring - # only show housing if member has onfloor status - if on_floor: - housing = {} - housing['points'] = user_dict['account'].housingPoints - housing['room'] = user_dict['account'].roomNumber - housing['queue_pos'] = get_queue_position(uid) - else: - housing = None + housing = {} + housing['points'] = user_dict['account'].housingPoints + housing['room'] = user_dict['account'].roomNumber + housing['queue_pos'] = get_queue_position(uid) data['housing'] = housing diff --git a/conditional/blueprints/housing.py b/conditional/blueprints/housing.py index 5931664b..bb078cb4 100644 --- a/conditional/blueprints/housing.py +++ b/conditional/blueprints/housing.py @@ -28,7 +28,7 @@ def display_housing(user_dict=None): log.info('Display Housing Board') housing = {} - onfloors = ldap.get_group_member_attributes(groups=['onfloor', 'current_student'], + members = ldap.get_group_member_attributes(groups=['current_student'], attributes=['cn', 'roomNumber']) onfloor_freshmen = FreshmanAccount.query.filter( FreshmanAccount.room_number is not None @@ -36,7 +36,7 @@ def display_housing(user_dict=None): room_list = set() - for member in onfloors: + for member in members: if 'roomNumber' not in member: continue diff --git a/conditional/blueprints/member_management.py b/conditional/blueprints/member_management.py index fe3c1119..f961b2fc 100644 --- a/conditional/blueprints/member_management.py +++ b/conditional/blueprints/member_management.py @@ -1,7 +1,6 @@ import csv import io from datetime import datetime -from distutils.util import strtobool # pylint: disable=no-name-in-module,import-error,deprecated-module import structlog from flask import Blueprint, request, jsonify, make_response @@ -20,27 +19,22 @@ from conditional.models.models import MemberHouseMeetingAttendance from conditional.models.models import HouseMeeting from conditional.models.models import EvalSettings -from conditional.models.models import OnFloorStatusAssigned from conditional.models.models import SpringEval from conditional.models.models import CurrentCoops from conditional.blueprints.cache_management import clear_members_cache -from conditional.util.ldap import ldap_get_active_member_uids, ldap_get_onfloor_member_uids, ldap_is_eval_director +from conditional.util.ldap import ldap_get_active_member_uids, ldap_is_eval_director from conditional.util.ldap import ldap_is_active -from conditional.util.ldap import ldap_is_onfloor from conditional.util.ldap import ldap_set_roomnumber from conditional.util.ldap import ldap_set_active from conditional.util.ldap import ldap_set_inactive -from conditional.util.ldap import ldap_set_onfloor from conditional.util.ldap import ldap_set_housingpoints from conditional.util.ldap import ldap_set_current_student from conditional.util.ldap import ldap_set_non_current_student from conditional.util.ldap import ldap_get_active_members from conditional.util.ldap import ldap_get_member from conditional.util.ldap import ldap_get_current_students -from conditional.util.ldap import _ldap_add_member_to_group as ldap_add_member_to_group -from conditional.util.ldap import _ldap_remove_member_from_group as ldap_remove_member_from_group from conditional.util.flask import render_template from conditional.models.models import attendance_enum @@ -63,18 +57,19 @@ def display_member_management(user_dict=None): return "must be eval director", 403 active_members = set(ldap_get_active_member_uids()) - onfloor_members = set(ldap_get_onfloor_member_uids()) member_list = ldap.get_group_member_attributes(groups=["current_student"], attributes=['uid', 'housingPoints', 'roomNumber', 'displayName']) + on_floor_member_count = 0 + for member in member_list: member['name'] = member['displayName'] member['active'] = member['uid'] in active_members - member['onfloor'] = member['uid'] in onfloor_members if 'roomNumber' in member: member['room'] = member['roomNumber'] + on_floor_member_count += 1 freshmen = FreshmanAccount.query @@ -84,12 +79,12 @@ def display_member_management(user_dict=None): freshmen_list.append({ "id": freshman_user.id, "name": freshman_user.name, - "onfloor": freshman_user.onfloor_status, "room": "" if freshman_user.room_number is None else freshman_user.room_number, "eval_date": freshman_user.eval_date }) - print(freshmen_list) + if freshman_user.room_number is not None: + on_floor_member_count += 1 settings = EvalSettings.query.first() if settings: @@ -105,9 +100,9 @@ def display_member_management(user_dict=None): username=user_dict['username'], active=member_list, num_current=len(member_list), + num_onfloor=on_floor_member_count, num_active=len(active_members), num_fresh=len(freshmen_list), - num_onfloor=len(onfloor_members), freshmen=freshmen_list, site_lockdown=lockdown, accept_dues_until=accept_dues_until, @@ -180,7 +175,6 @@ def member_management_adduser(user_dict=None): post_data = request.get_json() name = post_data['name'] - onfloor_status = post_data['onfloor'] room_number = post_data['roomNumber'] log.info(f'Create Freshman Account for {name}') @@ -188,7 +182,7 @@ def member_management_adduser(user_dict=None): if room_number == "": room_number = None - db.session.add(FreshmanAccount(name, onfloor_status, room_number)) + db.session.add(FreshmanAccount(name, room_number)) db.session.flush() db.session.commit() return jsonify({"success": True}), 200 @@ -213,7 +207,6 @@ def member_management_uploaduser(user_dict=None): for new_user in csv_input: name = new_user[0] - onfloor_status = strtobool(new_user[1]) if new_user[2]: room_number = new_user[2] @@ -226,7 +219,7 @@ def member_management_uploaduser(user_dict=None): rit_username = None log.info(f'Create Freshman Account for {name} via CSV Upload') - db.session.add(FreshmanAccount(name, onfloor_status, room_number, None, rit_username)) + db.session.add(FreshmanAccount(name, room_number, None, rit_username)) db.session.flush() db.session.commit() @@ -261,24 +254,10 @@ def edit_uid(uid, flask_request, username): current_account = ldap_get_member(username) if ldap_is_eval_director(current_account): room_number = post_data['roomNumber'] - onfloor_status = post_data['onfloorStatus'] housing_points = post_data['housingPoints'] - log.info(f'Edit {uid} - Room: {post_data['roomNumber']} On-Floor: {post_data['onfloorStatus']} Points: {post_data['housingPoints']}') #pylint: disable=line-too-long + log.info(f'Edit {uid} - Room: {post_data['roomNumber']} Points: {post_data['housingPoints']}') #pylint: disable=line-too-long ldap_set_roomnumber(account, room_number) - if onfloor_status: - # If a OnFloorStatusAssigned object exists, don't make another - if not ldap_is_onfloor(account): - db.session.add(OnFloorStatusAssigned(uid, datetime.now())) - ldap_add_member_to_group(account, "onfloor") - else: - for ofs in OnFloorStatusAssigned.query.filter(OnFloorStatusAssigned.uid == uid): - db.session.delete(ofs) - db.session.flush() - db.session.commit() - - if ldap_is_onfloor(account): - ldap_remove_member_from_group(account, "onfloor") ldap_set_housingpoints(account, housing_points) # Only update if there's a diff @@ -305,7 +284,7 @@ def edit_fid(uid, flask_request): log = logger.new(request=flask_request, auth_dict={'username': uid}) post_data = flask_request.get_json() - log.info(f'Edit freshman-{uid} - Room: {post_data['roomNumber']} On-Floor: {post_data['onfloorStatus']} Eval: {post_data['evalDate']} SigMiss: {post_data['sigMissed']}') #pylint: disable=line-too-long + log.info(f'Edit freshman-{uid} - Room: {post_data['roomNumber']} Eval: {post_data['evalDate']} SigMiss: {post_data['sigMissed']}') #pylint: disable=line-too-long name = post_data['name'] @@ -314,7 +293,6 @@ def edit_fid(uid, flask_request): else: room_number = post_data['roomNumber'] - onfloor_status = post_data['onfloorStatus'] eval_date = post_data['evalDate'] if post_data['sigMissed'] == "": @@ -325,7 +303,6 @@ def edit_fid(uid, flask_request): FreshmanAccount.query.filter(FreshmanAccount.id == uid).update({ 'name': name, 'eval_date': datetime.strptime(eval_date, "%Y-%m-%d"), - 'onfloor_status': onfloor_status, 'room_number': room_number, 'signatures_missed': sig_missed }) @@ -375,7 +352,6 @@ def get_hm_date(hm_id): 'name': acct.name, 'eval_date': acct.eval_date.strftime("%Y-%m-%d"), 'missed_hm': hms_missed, - 'onfloor_status': acct.onfloor_status, 'room_number': acct.room_number, 'sig_missed': acct.signatures_missed }), 200 @@ -401,7 +377,6 @@ def get_hm_date(hm_id): { 'name': account.displayName, 'room_number': account.roomNumber, - 'onfloor_status': ldap_is_onfloor(account), 'housing_points': account.housingPoints, 'active_member': ldap_is_active(account), 'missed_hm': hms_missed, @@ -498,9 +473,6 @@ def member_management_upgrade_user(user_dict=None): log.info(f'Duplicate house meeting attendance! fid: {fid}, uid: {uid}, id: {fhm.meeting_id}') new_account = ldap_get_member(uid) - if acct.onfloor_status: - db.session.add(OnFloorStatusAssigned(uid, datetime.now())) - ldap_set_onfloor(new_account) if acct.room_number: ldap_set_roomnumber(new_account, acct.room_number) diff --git a/conditional/models/models.py b/conditional/models/models.py index 604ea423..a7b7581f 100644 --- a/conditional/models/models.py +++ b/conditional/models/models.py @@ -13,16 +13,14 @@ class FreshmanAccount(db.Model): id = Column(Integer, primary_key=True) name = Column(String(64), nullable=False) eval_date = Column(Date, nullable=False) - onfloor_status = Column(Boolean) room_number = Column(String) signatures_missed = Column(Integer) rit_username = Column(String(10), nullable=True) - def __init__(self, name, onfloor, room=None, missed=None, rit_username=None): # pylint: disable=too-many-positional-arguments + def __init__(self, name, room=None, missed=None, rit_username=None): # pylint: disable=too-many-positional-arguments self.name = name today = date.fromtimestamp(time.time()) self.eval_date = today + timedelta(weeks=6) - self.onfloor_status = onfloor self.room_number = room self.signatures_missed = missed self.rit_username = rit_username @@ -242,14 +240,14 @@ def __init__(self, uid, semester): self.semester = semester -class OnFloorStatusAssigned(db.Model): - __tablename__ = 'onfloor_datetime' +class HousingQueueAssignment(db.Model): + __tablename__ = 'housing_queue_assignment' uid = Column(String(32), primary_key=True) - onfloor_granted = Column(DateTime, primary_key=True) + housing_queue_joined = Column(DateTime, primary_key=True) def __init__(self, uid, time_granted): self.uid = uid - self.onfloor_granted = time_granted + self.housing_queue_joined = time_granted class Conditional(db.Model): diff --git a/conditional/templates/dashboard.html b/conditional/templates/dashboard.html index 2b5c160b..db7444a5 100644 --- a/conditional/templates/dashboard.html +++ b/conditional/templates/dashboard.html @@ -20,12 +20,6 @@
{{username}}@csh.rit.edu
Inactive {% endif %} - {% if onfloor %} - On-floor Status - {% else %} - Off-floor Status - {% endif %} - {% if voting %} Voting {% else %} diff --git a/conditional/templates/financial.html b/conditional/templates/financial.html index e9ec5ab5..4d80595a 100644 --- a/conditional/templates/financial.html +++ b/conditional/templates/financial.html @@ -10,14 +10,13 @@

Financial

table of every member - Name, username, onfloor status, checkbox, submit button + Name, username, checkbox, submit button checkbox for active (if dues are paid)
- @@ -27,7 +26,6 @@

Financial

- diff --git a/conditional/templates/member_management.html b/conditional/templates/member_management.html index 4c94f56f..3dfdbe4c 100644 --- a/conditional/templates/member_management.html +++ b/conditional/templates/member_management.html @@ -17,7 +17,7 @@

Administration

{{num_active}}
Active Members
-
+
{{num_onfloor}}
On-Floor Members
@@ -76,13 +76,6 @@

Add Users

-
- - -
- @@ -109,7 +102,6 @@

Freshman Management

- @@ -122,9 +114,6 @@

Freshman Management

{{f['name']}} - @@ -155,7 +144,6 @@

- @@ -172,9 +160,6 @@

- @@ -212,13 +197,6 @@
-
- - -
-
-
- - -
-

Missed House Meetings

name uidonfloor DUES CHECKBOX SUBMIT BUTTON
{{m['name']}} {{m['onfloor']}}
NameOn Floor Room Evaluation Date
- {% if f['onfloor'] %} ✓ {% endif %} - {{f['room']}} {{f['eval_date']}}
Name ActiveOn Floor Room Points
{% if m['active'] %} ★ {% endif %} - {% if m['onfloor'] %} ✓ {% endif %} - {% if m['room'] %}{{m['room']}}{% endif %} {{m['housingPoints']}}