11from packet import app , db
2- from packet .utils import before_request , packet_auth
2+ from packet .utils import before_request , packet_auth , notify_slack
33from packet .models import Packet , MiscSignature
44
55
@@ -10,25 +10,32 @@ def sign(packet_id, info):
1010 packet = Packet .by_id (packet_id )
1111
1212 if packet is not None and packet .is_open ():
13+ was_100 = packet .is_100 ()
1314 if app .config ["REALM" ] == "csh" :
1415 # Check if the CSHer is an upperclassman and if so, sign that row
1516 for sig in filter (lambda sig : sig .member == info ["uid" ], packet .upper_signatures ):
1617 sig .signed = True
1718 db .session .commit ()
1819 app .logger .info ("Member {} signed packet {} as an upperclassman" .format (info ["uid" ], packet_id ))
20+ if not was_100 and packet .is_100 ():
21+ notify_slack (packet .freshman .name )
1922 return "Success: Signed Packet: " + packet .freshman_username
2023
2124 # The CSHer is a misc so add a new row
2225 db .session .add (MiscSignature (packet = packet , member = info ["uid" ]))
2326 db .session .commit ()
2427 app .logger .info ("Member {} signed packet {} as a misc" .format (info ["uid" ], packet_id ))
28+ if not was_100 and packet .is_100 ():
29+ notify_slack (packet .freshman .name )
2530 return "Success: Signed Packet: " + packet .freshman_username
2631 else :
2732 # Check if the freshman is onfloor and if so, sign that row
2833 for sig in filter (lambda sig : sig .freshman_username == info ["uid" ], packet .fresh_signatures ):
2934 sig .signed = True
3035 db .session .commit ()
3136 app .logger .info ("Freshman {} signed packet {}" .format (info ["uid" ], packet_id ))
37+ if not was_100 and packet .is_100 ():
38+ notify_slack (packet .freshman .name )
3239 return "Success: Signed Packet: " + packet .freshman_username
3340
3441 app .logger .warn ("Failed to add {}'s signature to packet {}" .format (info ["uid" ], packet_id ))
0 commit comments