1. Daniel Greenfeld
  2. transifex

Commits

Diego Búrigo Zacarão  committed ffa59b7

Lock info also for the team pages

  • Participants
  • Parent commits d0763be
  • Branches default

Comments (0)

Files changed (2)

File transifex/addons/locks/views.py

View file
 from transifex.projects.models import Project
 from transifex.resources.models import Resource
 from transifex.resources.utils import invalidate_template_cache
+from transifex.teams.models import Team
 from transifex.txcommon.decorators import one_perm_required_or_403
 
 from permissions import pr_resource_language_lock
 
     It uses a json response to be used with Ajax requests.
     """
+    response={}
     if request.method == 'POST':
-        resource = get_object_or_404(Resource, slug=resource_slug,
-            project__slug=project_slug)
+        resource = get_object_or_404(Resource.objects.select_related('project'),
+            slug=resource_slug, project__slug=project_slug)
         language = get_object_or_404(Language, code=language_code)
+        team = Team.objects.get_or_none(resource.project, language_code)
 
-        response={}
         try:
             lock = Lock.objects.create_update(resource, language, request.user)
             invalidate_template_cache('resource_details_lang', project_slug,
                 resource_slug, language_code)
             invalidate_template_cache('resource_details', project_slug,
                     resource_slug)
+            if team:
+                invalidate_template_cache('team_details', team.id,
+                    resource.id)
             response['status'] = "OK"
             response['message'] = _("Lock created.")
             response['timeuntil'] = timeuntil(lock.expires)
 
     It uses a json response to be used with Ajax requests.
     """
+    response={}
     if request.method == 'POST':
-        resource = get_object_or_404(Resource, slug=resource_slug,
-            project__slug=project_slug)
+        resource = get_object_or_404(Resource.objects.select_related('project'),
+            slug=resource_slug, project__slug=project_slug)
         language = get_object_or_404(Language, code=language_code)
+        team = Team.objects.get_or_none(resource.project, language_code)
 
-        response={}
         lock = Lock.objects.get_valid(resource, language)
         if lock:
             try:
                     resource_slug, language_code)
                 invalidate_template_cache('resource_details', project_slug,
                     resource_slug)
+                if team:
+                    invalidate_template_cache('team_details', team.id,
+                        resource.id)
                 response['status'] = "OK"
                 response['message'] = _("Lock removed.")
             except LockError, e:

File transifex/templates/teams/team_detail.html

View file
   <tr id="stat_row_{{forloop.counter}}" title="{% trans 'click for translation' %}">
   {% cache 604800 team_details team.id stat.resource.id LANGUAGE_CODE %}
         <td>
-		  <span class="clickable">{{ stat.resource.project.name }} &rarr; {{ stat.resource.name }}</span>
+        <span class="clickable">{{ stat.resource.project.name }} &rarr; {{ stat.resource.name }}</span>
+        {% if stat.lock.valid %}
+            <img class="tipsy_enable bullet" src="{{ STATIC_URL }}images/icons/bullet_lock.png" title="{% trans "Locked" %}"/>
+        {% else %}
+          {% if stat.resource.accept_translations %}
+            <img class="tipsy_enable bullet" src="{{ STATIC_URL }}images/icons/bullet_green.png" title="{% trans "Accepting translations" %}"/>
+          {% else %}
+            <img class="tipsy_enable bullet" src="{{ STATIC_URL }}images/icons/bullet_delete.png" title="{% trans "Not accepting translations at the moment" %}"/>
+          {% endif %}
+        {% endif %}
         </td>
         <td>
         {% with 200 as barwidth %}