[damned-lies] Move help icon inside the form in vertimus details
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Move help icon inside the form in vertimus details
- Date: Mon, 15 Aug 2011 15:46:44 +0000 (UTC)
commit 98e88476bb2796de5f791363cc6d4f1acd585c8d
Author: Claude Paroz <claude 2xlibre net>
Date: Sun Aug 14 22:53:07 2011 +0200
Move help icon inside the form in vertimus details
media/css/main.css | 10 ++++++++++
stats/templatetags/stats_extras.py | 18 ++++++++++++++++++
templates/vertimus/vertimus_detail.html | 7 +++----
vertimus/forms.py | 2 ++
4 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/media/css/main.css b/media/css/main.css
index 1c443c8..49fc762 100644
--- a/media/css/main.css
+++ b/media/css/main.css
@@ -266,6 +266,16 @@ p#show, p#hide {
color: #999;
}
+.help_link {
+ padding-left: 2em;
+}
+.help_link a {
+ border-bottom: 0 !important;
+}
+.help_link img {
+ vertical-align:top;
+}
+
.comment {
font-size: small;
font-style: italic;
diff --git a/stats/templatetags/stats_extras.py b/stats/templatetags/stats_extras.py
index 07fad51..e93dc07 100644
--- a/stats/templatetags/stats_extras.py
+++ b/stats/templatetags/stats_extras.py
@@ -1,4 +1,5 @@
from django import template
+from django.conf import settings
from django.utils.safestring import mark_safe
from django.utils.translation import get_language_bidi
@@ -83,3 +84,20 @@ def vis_stats(stat, scope='full'):
@register.filter
def is_video(fig):
return fig['path'].endswith('.ogv')
+
+ register filter
+def as_tr(field):
+ help_html = u''
+ if field.help_text:
+ help_html = u'<br /><span class="helptext">%s</span>' % field.help_text
+ help_link = u''
+ # This is a custom attribute possibly set in forms.py
+ if hasattr(field.field, 'help_link'):
+ help_link = '<span class="help_link"><a href="%s"><img src="%simg/help.png" alt="help icon" width="26"></a></span>' % (
+ field.field.help_link, settings.MEDIA_URL)
+ errors_html = u''
+ if field.errors:
+ errors_html = u'<ul class="errorlist">%s</ul>' % u''.join(["<li>%s</li>" % err for err in field.errors])
+ return mark_safe(u'<tr><th>%s:</th><td>%s%s%s%s</td></tr>' % (
+ field.label_tag(), errors_html, field.as_widget(), help_link, help_html)
+ )
diff --git a/templates/vertimus/vertimus_detail.html b/templates/vertimus/vertimus_detail.html
index 8b3f383..34c7c3c 100644
--- a/templates/vertimus/vertimus_detail.html
+++ b/templates/vertimus/vertimus_detail.html
@@ -180,9 +180,6 @@ $(document).ready(function() {
{% endif %}
{% if level == 0 %}
- <div class="float_right">
- <a href="{% url help 'vertimus_workflow' %}"><img src="{{ MEDIA_URL }}img/help.png" alt="help icon"></a>
- </div>
<h2>{% trans "New Action" %}</h2>
{% if action_form %}
@@ -190,7 +187,9 @@ $(document).ready(function() {
action="{% url vertimus_by_stats_id stats.id,language.id %}"
method="POST">
<table class="djform">
- {{ action_form.as_table }}
+ {% for field in action_form %}
+ {{ field|as_tr }}
+ {% endfor %}
<tr>
<td></td>
<td><input type="submit" value="{% trans "Submit" %}"></td>
diff --git a/vertimus/forms.py b/vertimus/forms.py
index a660a73..d3648e3 100644
--- a/vertimus/forms.py
+++ b/vertimus/forms.py
@@ -22,6 +22,7 @@
import os
from django import forms
+from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from vertimus.models import Action
from stats.utils import po_file_stats
@@ -50,6 +51,7 @@ class ActionForm(forms.Form):
def __init__(self, available_actions, *args, **kwargs):
super(ActionForm, self).__init__(*args, **kwargs)
self.fields['action'].choices = available_actions
+ self.fields['action'].help_link = reverse('help', args=['vertimus_workflow'])
def clean_file(self):
data = self.cleaned_data['file']
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]