Browse Source

Allow to deactivate participants

Baptiste Jonglez 10 years ago
parent
commit
71cf2bc9bb
1 changed files with 14 additions and 11 deletions
  1. 14 11
      manage_participants.py

+ 14 - 11
manage_participants.py

@@ -15,23 +15,26 @@ db = SQLAlchemy(app)
 
 def show_participants():
     for p in Participant.query.all():
-        print("[{}] {} ({}) is {} "
-              "and has UUID {}".format(p.id,
-                                       p.name,
-                                       p.contact,
-                                       "active" if p.active else "inactive",
-                                       p.uuid))
-
-def activate_participant(id):
+        print("[{}] {}, {} ({}) is {} "
+              "and has UUID {} ({})".format(p.id,
+                                            p.name,
+                                            p.country,
+                                            p.contact,
+                                            "active" if p.active else "inactive",
+                                            p.uuid,
+                                            p.comment))
+
+def toggle_participant(id):
     p = Participant.query.get(id)
-    p.active = True
+    p.active = not p.active
     db.session.merge(p)
     db.session.commit()
-    print("Activated participant {}".format(p))
+    print("{}ctivated participant {}".format("A" if p.active else "Dea",
+                                             p))
 
 
 if __name__ == '__main__':
     if len(sys.argv) > 1:
-        activate_participant(int(sys.argv[1]))
+        toggle_participant(int(sys.argv[1]))
     else:
         show_participants()