Browse Source

Add country and comment fields for participants

Baptiste Jonglez 10 years ago
parent
commit
8a4c52d694
5 changed files with 58 additions and 8 deletions
  1. 28 0
      migrations/versions/176d9148f7c_.py
  2. 10 3
      peerfinder.py
  3. 2 0
      templates/home.html
  4. 11 4
      templates/participant.html
  5. 7 1
      templates/results.html

+ 28 - 0
migrations/versions/176d9148f7c_.py

@@ -0,0 +1,28 @@
+"""empty message
+
+Revision ID: 176d9148f7c
+Revises: 213ec18f5d8
+Create Date: 2014-09-25 22:58:50.961489
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '176d9148f7c'
+down_revision = '213ec18f5d8'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+    ### commands auto generated by Alembic - please adjust! ###
+    op.add_column('participant', sa.Column('comment', sa.String(), nullable=True))
+    op.add_column('participant', sa.Column('country', sa.String(), nullable=True))
+    ### end Alembic commands ###
+
+
+def downgrade():
+    ### commands auto generated by Alembic - please adjust! ###
+    op.drop_column('participant', 'country')
+    op.drop_column('participant', 'comment')
+    ### end Alembic commands ###

+ 10 - 3
peerfinder.py

@@ -89,6 +89,10 @@ class Participant(db.Model):
     name = db.Column(db.String)
     name = db.Column(db.String)
     # Mostly free-form (nick, mail address, ...)
     # Mostly free-form (nick, mail address, ...)
     contact = db.Column(db.String)
     contact = db.Column(db.String)
+    # Optional
+    country = db.Column(db.String)
+    # Free-form (peering technology, DSL or fiber, etc)
+    comment = db.Column(db.String)
     # Whether we accept this participant or not
     # Whether we accept this participant or not
     active = db.Column(db.Boolean)
     active = db.Column(db.Boolean)
     # Many-to-many relationship
     # Many-to-many relationship
@@ -97,10 +101,12 @@ class Participant(db.Model):
         backref=db.backref('participants', lazy='dynamic'),
         backref=db.backref('participants', lazy='dynamic'),
         lazy='dynamic')
         lazy='dynamic')
 
 
-    def __init__(self, name, contact):
+    def __init__(self, name, contact, country, comment):
         self.uuid = str(uuid4())
         self.uuid = str(uuid4())
         self.name = name
         self.name = name
         self.contact = contact
         self.contact = contact
+        self.country = country
+        self.comment = comment
         self.active = False
         self.active = False
 
 
     def __str__(self):
     def __str__(self):
@@ -199,8 +205,9 @@ def submit_job():
 
 
 @app.route('/create/participant', methods=['POST'])
 @app.route('/create/participant', methods=['POST'])
 def create_participant():
 def create_participant():
-    if {'name', 'contact'}.issubset(request.form) and request.form['name']:
+    fields = ['name', 'contact', 'country', 'comment']
-        participant = Participant(request.form['name'], request.form['contact'])
+    if set(fields).issubset(request.form) and request.form['name']:
+        participant = Participant(*(request.form[f] for f in fields))
         db.session.add(participant)
         db.session.add(participant)
         db.session.commit()
         db.session.commit()
         return render_template('participant.html', participant=participant,
         return render_template('participant.html', participant=participant,

+ 2 - 0
templates/home.html

@@ -121,6 +121,8 @@ to peer.</p>
 <form action="/create/participant" method="POST">
 <form action="/create/participant" method="POST">
 Machine name (required): <input type="text" name="name" /><br />
 Machine name (required): <input type="text" name="name" /><br />
 Mean of contacting you, like IRC nick, mail address, ... (optional): <input type="text" name="contact" /><br />
 Mean of contacting you, like IRC nick, mail address, ... (optional): <input type="text" name="contact" /><br />
+Country code where this machine is located (optional): <input type="text" name="country" /><br />
+Free-form comment, like tunnel technology (GRE, OpenVPN, ...), or things like &quot;very shitty DSL&quot; (optional): <input type="text" name="comment" /><br />
 <input type="submit" value="Register" />
 <input type="submit" value="Register" />
 </form>
 </form>
 
 

+ 11 - 4
templates/participant.html

@@ -7,10 +7,17 @@
 It will be used to identify you to the measurement platform when you submit
 It will be used to identify you to the measurement platform when you submit
 reports, so you should keep it secret.</p>
 reports, so you should keep it secret.</p>
 
 
-<p>The machine name you provided is <strong>&quot;{{ participant.name
+<p>The information you provided:
-}}&quot;</strong>, and the contact you gave is <strong>&quot;{{
+
-participant.contact }}&quot;</strong>.  They will appear on measurement
+<ul>
-results.  If you wish to change one of them, contact us manually.</p>
+  <li>machine name: <strong>{{ participant.name }}</strong></li>
+  <li>contact: <strong>{{ participant.contact }}</strong></li>
+  <li>country: <strong>{{ participant.country }}</strong></li>
+  <li>comment: <strong>{{ participant.comment }}</strong></li>
+</ul>
+
+This information will appear on measurement results.  If you wish to
+change one of them, contact us manually.</p>
 
 
 <p>Please note that new participants are manually moderated, so you should
 <p>Please note that new participants are manually moderated, so you should
 ping on IRC to make sure your access is validated.  You can already setup
 ping on IRC to make sure your access is validated.  You can already setup

+ 7 - 1
templates/results.html

@@ -11,6 +11,7 @@
     <th>Jitter</th>
     <th>Jitter</th>
     <th>Packet loss</th>
     <th>Packet loss</th>
     <th>Source</th>
     <th>Source</th>
+    <th>Comment</th>
     <th>Contact</th>
     <th>Contact</th>
     <th>Date</th>
     <th>Date</th>
   </tr>
   </tr>
@@ -27,7 +28,12 @@
         {{ packetloss|round(2) }}%
         {{ packetloss|round(2) }}%
       </span>
       </span>
     </td>
     </td>
-    <td>{{ r.participant.name }}</td>
+    <td>{{ r.participant.name }}
+      {% if r.participant.country is not none() %}
+      ({{ r.participant.country }})
+      {% endif %}
+    </td>
+    <td>{{ r.participant.comment|default("", True) }}</td>
     <td>{{ r.participant.contact }}</td>
     <td>{{ r.participant.contact }}</td>
     <td>{{ r.date.strftime('%Y-%m-%d %H:%M') }}</td>
     <td>{{ r.date.strftime('%Y-%m-%d %H:%M') }}</td>
   </tr>
   </tr>