diff --git a/packet/commands.py b/packet/commands.py index ea3591a9..31f95909 100644 --- a/packet/commands.py +++ b/packet/commands.py @@ -194,7 +194,7 @@ def remove_sig(packet_id: int, username: str, is_member: bool) -> None: db.session.commit() print('Successfully unsigned packet') else: - print('Failed to unsign packet; {} is not an onfloor'.format(username)) + print('Failed to unsign packet; could not find signature') @app.cli.command('remove-member-sig') diff --git a/packet/routes/shared.py b/packet/routes/shared.py index 3508faa6..bd671bf8 100644 --- a/packet/routes/shared.py +++ b/packet/routes/shared.py @@ -27,12 +27,6 @@ def freshman_packet(packet_id, info=None): if packet is None: return 'Invalid packet or freshman', 404 else: - can_sign = packet.is_open() - - # If the packet is open and the user is an off-floor freshman set can_sign to False - if packet.is_open() and app.config['REALM'] != 'csh': - if info['uid'] not in map(lambda sig: sig.freshman_username, packet.fresh_signatures): - can_sign = False # The current user's freshman signature on this packet fresh_sig = list(filter( @@ -43,7 +37,6 @@ def freshman_packet(packet_id, info=None): return render_template('packet.html', info=info, packet=packet, - can_sign=can_sign, did_sign=packet.did_sign(info['uid'], app.config['REALM'] == 'csh'), required=packet.signatures_required(), received=packet.signatures_received(), diff --git a/packet/templates/active_packets.html b/packet/templates/active_packets.html index bd8fdc3e..3fa65640 100644 --- a/packet/templates/active_packets.html +++ b/packet/templates/active_packets.html @@ -20,7 +20,6 @@

Active Packets

{% if packets|length > 0 %} - {% set can_sign = info.onfloor or info.realm == "csh" %}
@@ -34,22 +33,24 @@

Active Packets

Signatures Signatures {% endif %} - {% if can_sign %} - Sign - {% endif %} + Sign {% for packet in packets %} + {% if info.is_upper %} + {% endif %} {{ get_rit_name(packet.freshman_username) }} {{ get_rit_name(packet.freshman_username) }} + {% if info.is_upper %} + {% endif %} {% if info.is_upper %} @@ -77,7 +78,6 @@

Active Packets

{% endif %} {% endif %} - {% if can_sign %} {% if not packet.did_sign_result and info.ritdn != packet.freshman_username %} {% endif %} - {% endif %} {% endfor %} diff --git a/packet/templates/include/admin/open_packets.html b/packet/templates/include/admin/open_packets.html index 275b622c..2db5d4b8 100644 --- a/packet/templates/include/admin/open_packets.html +++ b/packet/templates/include/admin/open_packets.html @@ -21,7 +21,7 @@ height="25"/> {{ get_rit_name(packet.freshman_username) }} - + {% if packet.signatures_received_result.total == packet.signatures_required_result.total %} 💯 {# 100% emoji #} {% else %} diff --git a/packet/templates/packet.html b/packet/templates/packet.html index f2bb98a3..a4de5039 100644 --- a/packet/templates/packet.html +++ b/packet/templates/packet.html @@ -10,7 +10,7 @@

{{ get_rit_name(packet.freshman_username) }}

- {% if can_sign and not did_sign %} + {% if not did_sign and info.ritdn != packet.freshman_username %}
{% endif %} - {% if info.is_upper or packet.freshman_username == info.ritdn or can_sign %} + {% if info.is_upper or packet.freshman_username == info.ritdn %}
- On-Floor Freshmen Signatures + Freshmen Signatures {% if info.is_upper or packet.freshman_username == info.ritdn %} {{ received.fresh }}/{{ required.fresh }} {% else %} diff --git a/packet/utils.py b/packet/utils.py index a6e91581..763c79e0 100644 --- a/packet/utils.py +++ b/packet/utils.py @@ -150,16 +150,9 @@ def sync_freshman(freshmen_list: dict) -> None: # Update the freshmen signatures of each open or future packet for packet in Packet.query.filter(Packet.end > datetime.now()).all(): - # Handle the freshmen that are no longer onfloor - for fresh_sig in filter(lambda fresh_sig: not fresh_sig.freshman.onfloor, packet.fresh_signatures): - FreshSignature.query.filter_by(packet_id=fresh_sig.packet_id, - freshman_username=fresh_sig.freshman_username).delete() - - # Add any new onfloor freshmen # pylint: disable=cell-var-from-loop current_fresh_sigs = set(map(lambda fresh_sig: fresh_sig.freshman_username, packet.fresh_signatures)) for list_freshman in filter(lambda list_freshman: list_freshman.rit_username not in current_fresh_sigs and - list_freshman.onfloor and list_freshman.rit_username != packet.freshman_username, freshmen_list.values()): db.session.add(FreshSignature(packet=packet, freshman=freshmen_in_db[list_freshman.rit_username])) @@ -173,7 +166,7 @@ def create_new_packets(base_date: date, freshmen_list: dict) -> None: start = datetime.combine(base_date, packet_start_time) end = datetime.combine(base_date, packet_end_time) + timedelta(days=14) - print('Fetching data from LDAP...') + app.logger.info('Fetching data from LDAP...') all_upper = list(filter( lambda member: not ldap.is_intromember(member) and not ldap.is_on_coop(member), ldap.get_active_members())) @@ -189,7 +182,7 @@ def create_new_packets(base_date: date, freshmen_list: dict) -> None: packets_starting_notification(start) # Create the new packets and the signatures for each freshman in the given CSV - print('Creating DB entries and sending emails...') + app.logger.info('Creating DB entries and sending emails...') for freshman in Freshman.query.filter(cast(Any, Freshman.rit_username).in_(freshmen_list)).all(): packet = Packet(freshman=freshman, start=start, end=end) db.session.add(packet) @@ -207,15 +200,14 @@ def create_new_packets(base_date: date, freshmen_list: dict) -> None: sig.drink_admin = member.uid in drink db.session.add(sig) - for onfloor_freshman in Freshman.query.filter_by(onfloor=True).filter(Freshman.rit_username != - freshman.rit_username).all(): - db.session.add(FreshSignature(packet=packet, freshman=onfloor_freshman)) + for frosh in Freshman.query.filter(Freshman.rit_username != freshman.rit_username).all(): + db.session.add(FreshSignature(packet=packet, freshman=frosh)) db.session.commit() def sync_with_ldap() -> None: - print('Fetching data from LDAP...') + app.logger.info('Fetching data from LDAP...') all_upper = {member.uid: member for member in filter( lambda member: not ldap.is_intromember(member) and not ldap.is_on_coop(member), ldap.get_active_members())} @@ -226,7 +218,7 @@ def sync_with_ldap() -> None: w_m = ldap.get_wiki_maintainers() drink = ldap.get_drink_admins() - print('Applying updates to the DB...') + app.logger.info('Applying updates to the DB...') for packet in Packet.query.filter(Packet.end > datetime.now()).all(): # Update the role state of all UpperSignatures for sig in filter(lambda sig: sig.member in all_upper, packet.upper_signatures):