From 6616fefbab312cb08a26fedc58d94666d3da5a8a Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Sun, 4 Dec 2011 15:49:37 +0000 Subject: [PATCH] eve_api templates updated, forms now more flexable and easier to manage --- app/eve_api/templates/eve_api/add.html | 25 ++-- app/eve_api/templates/eve_api/alliance.html | 56 +++---- app/eve_api/templates/eve_api/character.html | 139 ++++++++---------- .../templates/eve_api/character_list.html | 14 +- .../templates/eve_api/corporation.html | 54 ++++--- app/eve_api/templates/eve_api/formfield.html | 12 ++ app/eve_api/templates/eve_api/update.html | 23 +-- app/eve_api/templatetags/add_class.py | 21 +++ 8 files changed, 192 insertions(+), 152 deletions(-) create mode 100644 app/eve_api/templates/eve_api/formfield.html create mode 100644 app/eve_api/templatetags/add_class.py diff --git a/app/eve_api/templates/eve_api/add.html b/app/eve_api/templates/eve_api/add.html index b40c693..6fe300e 100644 --- a/app/eve_api/templates/eve_api/add.html +++ b/app/eve_api/templates/eve_api/add.html @@ -1,24 +1,25 @@ {% extends "base.html" %} -{% load gargoyle_tags %} - {% block title %}Add EVE API Key{% endblock %} {% block content %} + -{% ifswitch eve-cak %}

Please fill in your API key details and a optional description. You can create a API key on the API support site

-{% else %} -

Please fill in your API key as provided on the EVE Online API page and a optional description.

-{% endifswitch %}
- -{{ form.as_table }} -
-
-{% csrf_token %} - + + + + {% include "eve_api/formfield.html" with field=form.api_user_id %} + {% include "eve_api/formfield.html" with field=form.api_key class="xxlarge"%} + + + {% csrf_token %} + +
{% endblock %} diff --git a/app/eve_api/templates/eve_api/alliance.html b/app/eve_api/templates/eve_api/alliance.html index bff0fcf..319ad1c 100644 --- a/app/eve_api/templates/eve_api/alliance.html +++ b/app/eve_api/templates/eve_api/alliance.html @@ -4,30 +4,36 @@ {% load naturaltimediff %} {% block content %} -
-

{{ alliance.name }}

- - - -

Corporations

- - - - - - - - {% for corp in corporations %} - - {% endfor %} -
NameMembersAverage SPAPI CoverageDirector Key?
{{ corp }}{{ corp.member_count }}{{ corp.average_sp|intcomma }}{{ corp.api_key_coverage|floatformat:2 }}%{{ corp.director_api_keys.count }}
+ + +

+

+

+ +

Corporations

+ + + + + + + {% for corp in corporations %} + + {% endfor %} + +
NameMembersAverage SPAPI CoverageDirector Key?
{{ corp }}{{ corp.member_count }}{{ corp.average_sp|intcomma }}{{ corp.api_key_coverage|floatformat:2 }}%{{ corp.director_api_keys.count }}
+ + + + + + {% endblock %} diff --git a/app/eve_api/templates/eve_api/character.html b/app/eve_api/templates/eve_api/character.html index c66dc21..2a07bf5 100644 --- a/app/eve_api/templates/eve_api/character.html +++ b/app/eve_api/templates/eve_api/character.html @@ -9,64 +9,57 @@
-
-

Attributes

+
+

Attributes

-
    -
  • Race: {{ character.get_race_display }}
  • - {% if character.gender %}
  • Gender: {{ character.get_gender_display }}
  • {% endif %} -
  • Corporation: {{ character.corporation.name }}
  • - {% if character.corporation.alliance %}
  • Alliance: {{ character.corporation.alliance.name }}
  • {% endif %} -
  • Joined Corporation: {{ character.corporation_date|date:"Y/m/d H:i:s" }}
  • -
  • Security Status: {{ character.security_status|floatformat:2 }}
  • -
  • Director: {{ character.director }}
  • - {% if character.current_training %} -
  • Training: {{ character.current_training.skill.name}} to Level
  • - {% endif %} -
+
    +
  • Race: {{ character.get_race_display }}
  • + {% if character.gender %}
  • Gender: {{ character.get_gender_display }}
  • {% endif %} +
  • Corporation: {{ character.corporation.name }}
  • + {% if character.corporation.alliance %}
  • Alliance: {{ character.corporation.alliance.name }}
  • {% endif %} +
  • Joined Corporation: {{ character.corporation_date|date:"Y/m/d H:i:s" }}
  • +
  • Security Status: {{ character.security_status|floatformat:2 }}
  • +
  • Director: {{ character.director }} {% if character.director %}(Create a corporation API key){% endif %}
  • + {% if character.current_training %} +
  • Training: {{ character.current_training.skill.name}} to Level
  • + {% endif %} +
+ {% if character.attrib_intelligence %} +

Stats

+ + + + + + + + +
Intelligence {{ character.attrib_intelligence }}
Memory{{ character.attrib_memory }}
Charisma{{ character.attrib_charisma }}
Perception{{ character.attrib_perception }}
Willpower{{ character.attrib_willpower }}
+ {% endif %} +
- {% if character.attrib_intelligence %} -

Stats

- - - - - - - - - - - - -
StatValue
Intelligence {{ character.attrib_intelligence }}
Memory{{ character.attrib_memory }}
Charisma{{ character.attrib_charisma }}
Perception{{ character.attrib_perception }}
Willpower{{ character.attrib_willpower }}
+
+
+ +
+
+
+ {% if character.corporation.alliance %} + {% endif %} - -
- -
-
- -
-
-
- {% if character.corporation.alliance %} - - {% endif %} - -
-
+ +
+
- {% if skillTree %}

Skills

- Open All - Collapse All + Open All + Collapse All

@@ -88,38 +81,34 @@ {% if employmenthistory.count %}

Employment History

-
- - - - - {% for hist in employmenthistory %} - - {% endfor %} - +
CorporationJoin DateLeave Date
{{ hist.corporation.name }}{{ hist.start_date }}{% if hist.end_date %}{{ hist.end_date }}{% endif %}
+ + + + + {% for hist in employmenthistory %} + + {% endfor %} +
CorporationJoin DateLeave Date
{{ hist.corporation.name }}{{ hist.start_date }}{% if hist.end_date %}{{ hist.end_date }}{% endif %}
{% endif %} - - {% endblock %} diff --git a/app/eve_api/templates/eve_api/character_list.html b/app/eve_api/templates/eve_api/character_list.html index 87936b4..d4e6e3d 100644 --- a/app/eve_api/templates/eve_api/character_list.html +++ b/app/eve_api/templates/eve_api/character_list.html @@ -2,13 +2,6 @@ {% load humanize %} {% block content %} - - - @@ -41,6 +34,11 @@

You have no API keys linked to your auth account.

{% endif %} - + + {% endblock %} diff --git a/app/eve_api/templates/eve_api/corporation.html b/app/eve_api/templates/eve_api/corporation.html index 7366995..1fed768 100644 --- a/app/eve_api/templates/eve_api/corporation.html +++ b/app/eve_api/templates/eve_api/corporation.html @@ -6,32 +6,40 @@ {% block content %} -
-

{{ corporation.name }}

+ -
    -
  • Member Count: {{ corporation.member_count }}
  • -
  • Known Members: {{ corporation.eveplayercharacter_set.count }}
  • - {% if view_members %} -
  • Full Director API Available: {% if corporation.director_api_keys %}Yes{% else %}No{% endif %}
  • -
  • Members with API Keys: {{ corporation.api_keys }}
  • -
  • Members with Active API Keys: {{ corporation.active_api_keys }}
  • -
  • API Coverage: {{ corporation.api_key_coverage|floatformat:2 }}%
  • - {% endif %} -
+

+

    +
  • Member Count: {{ corporation.member_count }}
  • +
  • Known Members: {{ corporation.eveplayercharacter_set.count }}
  • + {% if view_members %} +
  • Full Director API Available: {% if corporation.director_api_keys %}Yes{% else %}No{% endif %}
  • +
  • Members with API Keys: {{ corporation.api_keys }}
  • +
  • Members with Active API Keys: {{ corporation.active_api_keys }}
  • +
  • API Coverage: {{ corporation.api_key_coverage|floatformat:2 }}%
  • + {% endif %} +
+

- {% if view_members %} - - - {% autopaginate members 20 %} - {% for char in members %} - - {% endfor %} -
NameSkillpointsJoin DateDirector?Roles?API Key?Key Active?
{{ char.name }}{% if char.total_sp %}{{ char.total_sp|intcomma }} SP{% endif %}{{ char.corporation_date }}{% if char.director %}Yes{% endif %}{% if char.eveaccount_set.count %}{% if char.roles.count %}Yes{% else %}No{% endif %}{% endif %}{% if char.eveaccount_set.count %}Yes{% else %}No{% endif %}{% if char.active_key %}Yes{% else %}No{% endif %}
- {% paginate %} +{% if view_members %} +{% autopaginate members 25 %} + + + + + + {% for char in members %} + + {% endfor %} + +
NameSkillpointsJoin DateDirector?Roles?API Key?Key Active?
{{ char.name }}{% if char.total_sp %}{{ char.total_sp|intcomma }} SP{% endif %}{{ char.corporation_date }}{% if char.director %}Yes{% endif %}{% if char.eveaccount_set.count %}{% if char.roles.count %}Yes{% else %}No{% endif %}{% endif %}{% if char.eveaccount_set.count %}Yes{% else %}No{% endif %}{% if char.active_key %}Yes{% else %}No{% endif %}
-

Export as CSV

- {% endif %} +

{% paginate %}

+ +

Export as CSV

+{% endif %}
diff --git a/app/eve_api/templates/eve_api/formfield.html b/app/eve_api/templates/eve_api/formfield.html new file mode 100644 index 0000000..1f664a9 --- /dev/null +++ b/app/eve_api/templates/eve_api/formfield.html @@ -0,0 +1,12 @@ +{% load add_class %} + +
+ {{ field.label_tag }} +
+ {% if class %}{{ field|add_class:class }}{% else %}{{ field }}{% endif %} + {% if field.help_text %} + {{ field.help_text }} + {% endif %} +
+
+ diff --git a/app/eve_api/templates/eve_api/update.html b/app/eve_api/templates/eve_api/update.html index 5622e9b..f2c8801 100644 --- a/app/eve_api/templates/eve_api/update.html +++ b/app/eve_api/templates/eve_api/update.html @@ -3,17 +3,22 @@ {% block title %}Update EVE API Key{% endblock %} {% block content %} -

Please update your API key as provided on the EVE Online API -page and a optional description.

+ + +

Please update your API key as provided on the EVE Online API page and a optional description.

- -{{ form.as_table }} -
-
-{% csrf_token %} - + + + {% include "eve_api/formfield.html" with field=form.api_user_id %} + {% include "eve_api/formfield.html" with field=form.api_key class="xxlarge" %} + {% include "eve_api/formfield.html" with field=form.description class="xxlarge" %} + + {% csrf_token %} + +
{% endblock %} diff --git a/app/eve_api/templatetags/add_class.py b/app/eve_api/templatetags/add_class.py new file mode 100644 index 0000000..dae3d13 --- /dev/null +++ b/app/eve_api/templatetags/add_class.py @@ -0,0 +1,21 @@ +import re +from django.utils.safestring import mark_safe +from django import template +register = template.Library() + +class_re = re.compile(r'(?<=class=["\'])(.*)(?=["\'])') +@register.filter +def add_class(value, css_class): + string = unicode(value) + match = class_re.search(string) + if match: + m = re.search(r'^%s$|^%s\s|\s%s\s|\s%s$' % (css_class, css_class, + css_class, css_class), + match.group(1)) + print match.group(1) + if not m: + return mark_safe(class_re.sub(match.group(1) + " " + css_class, + string)) + else: + return mark_safe(string.replace('>', ' class="%s">' % css_class)) + return value