Browse Source

Add a management script for participants

Baptiste Jonglez 10 years ago
parent
commit
e8ae12698b
1 changed files with 37 additions and 0 deletions
  1. 37 0
      manage_participants.py

+ 37 - 0
manage_participants.py

@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+
+import sys
+
+from flask import Flask
+from flask.ext.sqlalchemy import SQLAlchemy
+
+from peerfinder import Participant
+
+
+app = Flask(__name__)
+app.config.from_pyfile('config.py')
+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):
+    p = Participant.query.get(id)
+    p.active = True
+    db.session.merge(p)
+    db.session.commit()
+    print("Activated participant {}".format(p))
+
+
+if __name__ == '__main__':
+    if len(sys.argv) > 1:
+        activate_participant(int(sys.argv[1]))
+    else:
+        show_participants()