Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions mailman/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def main():
help='Select the assignment',
required=True)

oopsie_parser = command_parsers.add_parser('oopsie')
oopsie_parser.add_argument('-u', '--username',
help='Check if a student used an Oopsie',
required=True)

# Dictionary containing the desired command and all flags with their values
kwargs = vars(parser.parse_args())
# Subparsers store their name in the destination `'command'`
Expand Down Expand Up @@ -55,6 +60,15 @@ def missing(assignment):
if user.username not in submitted:
print(user.username)

def oopsie(username):
try:
query = db.Oopsie.get(db.Oopsie.user == username)
time = datetime.fromtimestamp(query.timestamp).astimezone().isoformat()
print(f'{username} has used an oopsie on assignment: '
f'{query.assignment} at {time}.')
except peewee.DoesNotExist:
print(f'{username} has not used an oopsie.')


if __name__ == '__main__':
main()