-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage_projects.py
56 lines (43 loc) · 1.57 KB
/
manage_projects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from testate import Card, app, DBUser, db
import sys
def run(cmd):
if cmd == 'ls':
print('project name \t| #milestones \t| visible')
for card in Card.query.group_by(Card.project_name):
print(f'{card.project_name} \t| {len(card.milestones)} \t| {card.is_visible}')
elif cmd == 'rm':
pname = input('Projekt? ')
for card in Card.query.filter(Card.project_name == pname):
print(f'delete card {card.id} of {card.student_name}')
card.delete()
elif cmd == 'hide':
pname = input('Projekt? ')
for card in Card.query.filter(Card.project_name == pname):
print(f'hiding card of {card.student_name}')
card.visibility(False)
elif cmd == 'show':
pname = input('Projekt? ')
for card in Card.query.filter(Card.project_name == pname):
print(f'unhiding card of {card.student_name}')
card.visibility(True)
elif cmd == 'add_teacher':
username = input('User? ')
user = DBUser.query.get(username)
if not user:
print("User not found")
return
pname = input('Projekt? ')
for card in Card.query.filter(Card.project_name == pname):
print("Adding card", card)
user.cards.append(card)
db.session.commit()
else:
print(f'unsupported command')
def main():
if len(sys.argv) != 2:
print("ls, rm, add_teacher, hide or show?")
return
with app.app_context():
run(sys.argv[1])
if __name__ == '__main__':
main()