damned-lies r1260 - in trunk: . people templates templates/languages templates/vertimus vertimus



Author: claudep
Date: Mon Dec 29 23:06:20 2008
New Revision: 1260
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1260&view=rev

Log:
2008-12-30  Claude Paroz  <claude 2xlibre net>

	* people/forms.py:
	* people/views.py: Catch error if user is added multiple times in the same
	team.
	* templates/languages/language_release_stats.html:
	* templates/stats_show.html:
	* templates/vertimus/vertimus_detail.html:
	* vertimus/urls.py:
	* vertimus/views.py: Pass language.id to vertimus_by_stats_id, because
	when stats is the POT file, there is no other mean to retrieve the
	language.

Modified:
   trunk/ChangeLog
   trunk/people/forms.py
   trunk/people/views.py
   trunk/templates/languages/language_release_stats.html
   trunk/templates/stats_show.html
   trunk/templates/vertimus/vertimus_detail.html
   trunk/vertimus/urls.py
   trunk/vertimus/views.py

Modified: trunk/people/forms.py
==============================================================================
--- trunk/people/forms.py	(original)
+++ trunk/people/forms.py	Mon Dec 29 23:06:20 2008
@@ -11,6 +11,7 @@
 class JoinTeamForm(forms.Form):
     def __init__(self, *args, **kwargs):
         super(JoinTeamForm, self).__init__(*args, **kwargs)
+        # FIXME: exclude team to which user is already member
         self.fields['teams'] = forms.ModelChoiceField(queryset=Team.objects.all())
 
 class RegistrationForm(forms.Form):

Modified: trunk/people/views.py
==============================================================================
--- trunk/people/views.py	(original)
+++ trunk/people/views.py	Mon Dec 29 23:06:20 2008
@@ -19,7 +19,9 @@
 # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from django.shortcuts import render_to_response, get_object_or_404
+from django.utils.translation import ugettext as _
 from django.template import RequestContext
+from django.db import IntegrityError
 from people.models import Person
 from teams.models import Role
 from people.forms import JoinTeamForm, EditProfileForm
@@ -41,7 +43,10 @@
             if request.user.username == person.username:
                 team = join_form.cleaned_data['teams']
                 new_role = Role(team=team, person=person) # role default to translator
-                new_role.save()
+                try:
+                    new_role.save()
+                except IntegrityError:
+                    messages.append(_("You are already member of this team."))
             else:
                 messages.append(_("Sorry, you're not allowed to modify this user."))
     else:

Modified: trunk/templates/languages/language_release_stats.html
==============================================================================
--- trunk/templates/languages/language_release_stats.html	(original)
+++ trunk/templates/languages/language_release_stats.html	Mon Dec 29 23:06:20 2008
@@ -39,11 +39,11 @@
           {% if dom.1.partial_po %}
             {# This is a partial po, indented, with the domain description #}
             <td class="leftcell" style="padding-left:2em; padding-right:2em;">
-            <a href="{% url vertimus-stats-id-view dom.1.id %}">{{ dom.1.domain.description }}</a>
+            <a href="{% url vertimus-stats-id-view dom.1.id language.id %}">{{ dom.1.domain.description }}</a>
           {% else %}
             <td class="leftcell">
             {% if not dom.1.is_fake %}
-              <a href="{% url vertimus-stats-id-view dom.1.id %}">{{ dom.1.module_description }}</a>
+              <a href="{% url vertimus-stats-id-view dom.1.id language.id %}">{{ dom.1.module_description }}</a>
             {% else %}
               <em>{{ dom.1.module_description }}</em>
             {% endif %}

Modified: trunk/templates/stats_show.html
==============================================================================
--- trunk/templates/stats_show.html	(original)
+++ trunk/templates/stats_show.html	Mon Dec 29 23:06:20 2008
@@ -37,7 +37,7 @@
     {% for line in stat %}
     {% if not forloop.first %}
     <tr>
-      <td class="leftcell"><a href="{% url vertimus-stats-id-view line.id %}">{{ line.get_lang }}</a>
+      <td class="leftcell"><a href="{% url vertimus-stats-id-view line.id line.language.id %}">{{ line.get_lang }}</a>
         {% with line.most_important_message as msg %} 
         {% if msg %}
         <img src="{{ msg.get_icon }}" title="{{ msg.get_description }}" alt="{{ msg.type }}" />

Modified: trunk/templates/vertimus/vertimus_detail.html
==============================================================================
--- trunk/templates/vertimus/vertimus_detail.html	(original)
+++ trunk/templates/vertimus/vertimus_detail.html	Mon Dec 29 23:06:20 2008
@@ -85,7 +85,7 @@
 <h2>{% trans "New Action" %}</h2>
 
 {% if action_form %}
-  <form enctype="multipart/form-data" action="{% url vertimus-stats-id-view stats.id %}" method="POST">
+  <form enctype="multipart/form-data" action="{% url vertimus-stats-id-view stats.id language.id %}" method="POST">
     <table class="djform">
       {{ action_form.as_table }}
       <tr><td></td>

Modified: trunk/vertimus/urls.py
==============================================================================
--- trunk/vertimus/urls.py	(original)
+++ trunk/vertimus/urls.py	Mon Dec 29 23:06:20 2008
@@ -1,7 +1,7 @@
 from django.conf.urls.defaults import *
 
 urlpatterns = patterns('vertimus.views',
-    url(r'^(?P<stats_id>\d+)', 'vertimus_by_stats_id', name='vertimus-stats-id-view'),
+    url(r'^(?P<stats_id>\d+)/(?P<lang_id>\d+)$', 'vertimus_by_stats_id', name='vertimus-stats-id-view'),
     url(r'^(?P<branch_id>\d+)/(?P<domain_id>\d+)/(?P<language_id>\d+)', 'vertimus_by_ids', name='vertimus-ids-view'),
-    url(r'^(?P<module_name>[\w\-\.]+)/(?P<branch_name>[\w\-]+)/(?P<domain_name>[\w\-]+)/(?P<locale_name>[\w\- ]+)', 'vertimus_by_names', name='vertimus-names-view')
+    url(r'^(?P<module_name>[\w\+\-\.]+)/(?P<branch_name>[\w\-]+)/(?P<domain_name>[\w\-]+)/(?P<locale_name>[\w\- ]+)', 'vertimus_by_names', name='vertimus-names-view')
 )

Modified: trunk/vertimus/views.py
==============================================================================
--- trunk/vertimus/views.py	(original)
+++ trunk/vertimus/views.py	Mon Dec 29 23:06:20 2008
@@ -30,10 +30,11 @@
 from vertimus.models import StateDb, ActionDb, ActionAbstract
 from vertimus.forms import ActionForm
 
-def vertimus_by_stats_id(request, stats_id):
+def vertimus_by_stats_id(request, stats_id, lang_id):
     """Access to Vertimus view by a Statistics ID"""
     stats = get_object_or_404(Statistics, pk=stats_id)
-    return vertimus(request, stats.branch, stats.domain, stats.language, stats)
+    lang = get_object_or_404(Language, pk=lang_id)
+    return vertimus(request, stats.branch, stats.domain, lang, stats)
 
 def vertimus_by_ids(request, branch_id, domain_id, language_id):
     """Access to Vertimus view by Branch, Domain and language IDs"""



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]