Anonymous avatar Anonymous committed d9d501f

Moved form_as_table_rows to transifex/tx-common.

This way it's reusable by other applications and more
easily called by loading the tx-common on top of the
template file.

Comments (0)

Files changed (9)

projects/templates/form_as_table_rows.html

-{% load i18n %}
-{% load forms_template_style %}
-{% if form %}
-    {% for field in form %}
-    <tr>
-    <th>{{ field.label }}: {% if field.field.required %}<span class="required">*</span>{% endif %}</th>
-    <td>
-        <p class="fieldp">{{ field }}</p>
-        {% if field.errors %}<p class="fielderrors">{{ field.errors }}</p>{% endif %}
-    </td>
-    <td><p class="helptext">{{ field.help_text }}</p></td>
-    </tr>
-    {% endfor %}
-{% endif %}

templates/contact_form/contact_form.html

 {% extends "base.html" %}
 {% load i18n %}
-{% load forms_template_style %}
+{% load tx-common %}
 
 {% block title %}{{ block.super }} | {% trans "Contact us" %}{% endblock %}
 {% block breadcrumb %}{{ block.super }} &raquo; {% trans "Contact us" %}{% endblock %}

templates/projects/component_form.html

 {% extends "projects/base.html" %}
-{% load forms_template_style %}
 {% load i18n %}
+{% load tx-common %}
 
 {% block title %}
 {% if not component %}{{ block.super }} | {{ project.name }} | {% trans "Add a component" %}

templates/projects/project_form.html

 {% extends "projects/base.html" %}
-{% load forms_template_style %}
 {% load i18n %}
+{% load tx-common %}
 
 {% block title %}
   {% if not project %}{{ block.super }} | {% trans "Add a project" %}

templates/releases/release_form.html

 {% extends "releases/base.html" %}
 {% load i18n %}
-{% load forms_template_style %}
+{% load tx-common %}
 
 {% block title %}
   {% if not release %}{{ block.super }} | {% trans "Add a release" %}

templates/txcollections/collection_form.html

 {% extends "txcollections/base.html" %}
 {% load i18n %}
-{% load forms_template_style %}
+{% load tx-common %}
 
 {% block title %}
   {% if not collection %}{{ block.super }} | {% trans "Add a collection" %}

templates/txcollections/release_form.html

 {% extends "txcollections/base.html" %}
 {% load i18n %}
-{% load forms_template_style %}
+{% load tx-common %}
 
 {% block extra_head %}
   <script type="text/javascript" src="/admin/jsi18n/"></script>

transifex/templates/form_as_table_rows.html

+{% load i18n %}
+{% load tx-common %}
+{% if form %}
+    {% for field in form %}
+    <tr>
+    <th>{{ field.label }}: {% if field.field.required %}<span class="required">*</span>{% endif %}</th>
+    <td>
+        <p class="fieldp">{{ field }}</p>
+        {% if field.errors %}<p class="fielderrors">{% for error in field.errors %}{{ error }}{% endfor %}</p>{% endif %}
+    </td>
+    <td><p class="helptext">{{ field.help_text }}</p></td>
+    </tr>
+    {% endfor %}
+{% endif %}

transifex/templatetags/tx-common.py

     """Return the version of Transifex"""
     return transifex.version
 
+# Forms
+
+@register.inclusion_tag("form_as_table_rows.html")
+def form_as_table_rows(form):
+    """
+    Create a form using HTML table rows.
+    """
+    return {"form": form}
+
 
 # Email Munger by cootetom
 # http://www.djangosnippets.org/snippets/1284/
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.