Skip to content

Commit 7c56051

Browse files
authored
Merge pull request #376 from ComputerScienceHouse/develop
constitution
2 parents 5e67335 + 1456759 commit 7c56051

File tree

5 files changed

+15
-31
lines changed

5 files changed

+15
-31
lines changed

packet/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def remove_sig(packet_id: int, username: str, is_member: bool) -> None:
194194
db.session.commit()
195195
print('Successfully unsigned packet')
196196
else:
197-
print('Failed to unsign packet; {} is not an onfloor'.format(username))
197+
print('Failed to unsign packet; could not find signature')
198198

199199

200200
@app.cli.command('remove-member-sig')

packet/routes/shared.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ def freshman_packet(packet_id, info=None):
2727
if packet is None:
2828
return 'Invalid packet or freshman', 404
2929
else:
30-
can_sign = packet.is_open()
31-
32-
# If the packet is open and the user is an off-floor freshman set can_sign to False
33-
if packet.is_open() and app.config['REALM'] != 'csh':
34-
if info['uid'] not in map(lambda sig: sig.freshman_username, packet.fresh_signatures):
35-
can_sign = False
3630

3731
# The current user's freshman signature on this packet
3832
fresh_sig = list(filter(
@@ -43,7 +37,6 @@ def freshman_packet(packet_id, info=None):
4337
return render_template('packet.html',
4438
info=info,
4539
packet=packet,
46-
can_sign=can_sign,
4740
did_sign=packet.did_sign(info['uid'], app.config['REALM'] == 'csh'),
4841
required=packet.signatures_required(),
4942
received=packet.signatures_received(),

packet/templates/active_packets.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ <h4 class="page-title">Active Packets</h4>
2020
</div>
2121
<div id="eval-blocks">
2222
{% if packets|length > 0 %}
23-
{% set can_sign = info.onfloor or info.realm == "csh" %}
2423
<div id="eval-table">
2524
<div class="card">
2625
<div class="card-body table-fill">
@@ -34,22 +33,24 @@ <h4 class="page-title">Active Packets</h4>
3433
<th>Signatures</th>
3534
<th>Signatures</th>
3635
{% endif %}
37-
{% if can_sign %}
38-
<th>Sign</th>
39-
{% endif %}
36+
<th>Sign</th>
4037
</tr>
4138
</thead>
4239
<tbody>
4340
{% for packet in packets %}
4441
<tr {% if packet.did_sign_result %}style="background-color: #4caf505e" {% endif %}>
4542
<td data-priority="1">
43+
{% if info.is_upper %}
4644
<a href="{{ url_for('freshman_packet', packet_id=packet.id) }}">
45+
{% endif %}
4746
<img class="eval-user-img"
4847
alt="{{ get_rit_name(packet.freshman_username) }}"
4948
src="{{ get_rit_image(packet.freshman_username) }}"
5049
width="25"
5150
height="25"/> {{ get_rit_name(packet.freshman_username) }}
51+
{% if info.is_upper %}
5252
</a>
53+
{% endif %}
5354
</td>
5455
{% if info.is_upper %}
5556
<td data-sort="{{ packet.signatures_received_result.member_total }}">
@@ -77,7 +78,6 @@ <h4 class="page-title">Active Packets</h4>
7778
{% endif %}
7879
</td>
7980
{% endif %}
80-
{% if can_sign %}
8181
<td class="sign-packet" align="right" data-priority="1">
8282
{% if not packet.did_sign_result and info.ritdn != packet.freshman_username %}
8383
<button class="btn btn-sm btn-primary sign-button"
@@ -92,7 +92,6 @@ <h4 class="page-title">Active Packets</h4>
9292
</button>
9393
{% endif %}
9494
</td>
95-
{% endif %}
9695
</tr>
9796
{% endfor %}
9897
</tbody>

packet/templates/packet.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<h3>{{ get_rit_name(packet.freshman_username) }}</h3>
1111
</div>
1212
<div class="col">
13-
{% if can_sign and not did_sign %}
13+
{% if not did_sign and info.ritdn != packet.freshman_username %}
1414
<button class="btn btn-primary sign-button"
1515
data-packet_id="{{ packet.id }}"
1616
data-freshman_name="{{ get_rit_name(packet.freshman_username) }}">Sign
@@ -105,10 +105,10 @@ <h5>Upperclassmen Score - {{ '%0.2f' % upper_score }}%</h5>
105105
</div>
106106
</div>
107107
{% endif %}
108-
{% if info.is_upper or packet.freshman_username == info.ritdn or can_sign %}
108+
{% if info.is_upper or packet.freshman_username == info.ritdn %}
109109
<div class="card mb-2">
110110
<div class="card-header">
111-
<b>On-Floor Freshmen Signatures</b>
111+
<b>Freshmen Signatures</b>
112112
{% if info.is_upper or packet.freshman_username == info.ritdn %}
113113
<b class="signature-count">{{ received.fresh }}/{{ required.fresh }}</b>
114114
{% else %}

packet/utils.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,9 @@ def sync_freshman(freshmen_list: dict) -> None:
150150

151151
# Update the freshmen signatures of each open or future packet
152152
for packet in Packet.query.filter(Packet.end > datetime.now()).all():
153-
# Handle the freshmen that are no longer onfloor
154-
for fresh_sig in filter(lambda fresh_sig: not fresh_sig.freshman.onfloor, packet.fresh_signatures):
155-
FreshSignature.query.filter_by(packet_id=fresh_sig.packet_id,
156-
freshman_username=fresh_sig.freshman_username).delete()
157-
158-
# Add any new onfloor freshmen
159153
# pylint: disable=cell-var-from-loop
160154
current_fresh_sigs = set(map(lambda fresh_sig: fresh_sig.freshman_username, packet.fresh_signatures))
161155
for list_freshman in filter(lambda list_freshman: list_freshman.rit_username not in current_fresh_sigs and
162-
list_freshman.onfloor and
163156
list_freshman.rit_username != packet.freshman_username,
164157
freshmen_list.values()):
165158
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:
173166
start = datetime.combine(base_date, packet_start_time)
174167
end = datetime.combine(base_date, packet_end_time) + timedelta(days=14)
175168

176-
print('Fetching data from LDAP...')
169+
app.logger.info('Fetching data from LDAP...')
177170
all_upper = list(filter(
178171
lambda member: not ldap.is_intromember(member) and not ldap.is_on_coop(member), ldap.get_active_members()))
179172

@@ -189,7 +182,7 @@ def create_new_packets(base_date: date, freshmen_list: dict) -> None:
189182
packets_starting_notification(start)
190183

191184
# Create the new packets and the signatures for each freshman in the given CSV
192-
print('Creating DB entries and sending emails...')
185+
app.logger.info('Creating DB entries and sending emails...')
193186
for freshman in Freshman.query.filter(cast(Any, Freshman.rit_username).in_(freshmen_list)).all():
194187
packet = Packet(freshman=freshman, start=start, end=end)
195188
db.session.add(packet)
@@ -207,15 +200,14 @@ def create_new_packets(base_date: date, freshmen_list: dict) -> None:
207200
sig.drink_admin = member.uid in drink
208201
db.session.add(sig)
209202

210-
for onfloor_freshman in Freshman.query.filter_by(onfloor=True).filter(Freshman.rit_username !=
211-
freshman.rit_username).all():
212-
db.session.add(FreshSignature(packet=packet, freshman=onfloor_freshman))
203+
for frosh in Freshman.query.filter(Freshman.rit_username != freshman.rit_username).all():
204+
db.session.add(FreshSignature(packet=packet, freshman=frosh))
213205

214206
db.session.commit()
215207

216208

217209
def sync_with_ldap() -> None:
218-
print('Fetching data from LDAP...')
210+
app.logger.info('Fetching data from LDAP...')
219211
all_upper = {member.uid: member for member in filter(
220212
lambda member: not ldap.is_intromember(member) and not ldap.is_on_coop(member), ldap.get_active_members())}
221213

@@ -226,7 +218,7 @@ def sync_with_ldap() -> None:
226218
w_m = ldap.get_wiki_maintainers()
227219
drink = ldap.get_drink_admins()
228220

229-
print('Applying updates to the DB...')
221+
app.logger.info('Applying updates to the DB...')
230222
for packet in Packet.query.filter(Packet.end > datetime.now()).all():
231223
# Update the role state of all UpperSignatures
232224
for sig in filter(lambda sig: sig.member in all_upper, packet.upper_signatures):

0 commit comments

Comments
 (0)