Parcourir la source

Small fixes in the manual isp creation form, improve map popup

Gu1 il y a 11 ans
Parent
commit
84ac9ae3ab
2 fichiers modifiés avec 18 ajouts et 4 suppressions
  1. 5 2
      ffdnispdb/forms.py
  2. 13 2
      ffdnispdb/templates/map_popup.html

+ 5 - 2
ffdnispdb/forms.py

@@ -1,6 +1,7 @@
 from functools import partial
 import itertools
 import urlparse
+from datetime import datetime
 from flask.ext.wtf import Form
 from wtforms import Form as InsecureForm
 from wtforms import (TextField, DateField, DecimalField, IntegerField, SelectField,
@@ -142,10 +143,10 @@ class ProjectForm(Form):
         optstr('description', self.description.data)
         optstr('logoURL', self.logo_url.data)
         optstr('website', self.website.data)
-        optstr('otherWebsites', dict(((w['name'], w['url']) for w in self.other_websites.data)))
+        optstr('otherWebsites', dict(((w['name'], w['url']) for w in self.other_websites.data if w['name'])))
         optstr('email', self.contact_email.data)
         optstr('mainMailingList', self.main_ml.data)
-        optstr('creationDate', self.creation_date.data)
+        optstr('creationDate', self.creation_date.data.isoformat())
         optstr('progressStatus', self.step.data)
         optstr('memberCount', self.member_count.data)
         optstr('subscriberCount', self.subscriber_count.data)
@@ -171,6 +172,8 @@ class ProjectForm(Form):
         set_attr('contact_email', 'email')
         set_attr('main_ml', 'mainMailingList')
         set_attr('creation_date', 'creationDate')
+        if hasattr(obj, 'creation_date'):
+            obj.creation_date=datetime.strptime(obj.creation_date, '%Y-%m-%d')
         set_attr('step', 'progressStatus')
         set_attr('member_count', 'memberCount')
         set_attr('subscriber_count', 'subscriberCount')

+ 13 - 2
ffdnispdb/templates/map_popup.html

@@ -1,6 +1,17 @@
+{% macro field(name) -%}
+<strong>{{ name|capitalize }}</strong>
+{%- endmacro %}
 {% if isp.shortname -%}
-<strong>{{ isp.shortname }}</strong><br />
+<a href="{{ url_for('project', projectid=isp.id) }}"><strong>{{ isp.shortname }}</strong></a><br />
 {{ isp.name }}
 {% else -%}
-<strong>{{ isp.name }}</strong>
+<a href="{{ url_for('project', projectid=isp.id) }}"><strong>{{ isp.name }}</strong></a>
 {% endif %}
+<ul style="margin: 10px 0 10px 5px; list-style-type: none;">
+{%- if isp.json.memberCount %}
+<li>{{ field(_("members")) }}: {{ isp.json.memberCount }}</li>
+{%- endif %}
+{%- if isp.json.subscriberCount %}
+<li>{{ field(_("subscribers")) }}: {{ isp.json.subscriberCount }}</li>
+{%- endif %}
+</ul>