1. Daniel Greenfeld
  2. transifex

Commits

Diego Búrigo Zacarão  committed c703773

Hiding links by the user permissions on the template

  • Participants
  • Parent commits 81e87d8
  • Branches default

Comments (0)

Files changed (9)

File templates/projects/component_detail.html

View file
  • Ignore whitespace
 
 {% block body_main %}
   <div class="obj_bigdetails">
-  {% if request.user.is_authenticated %}
+  {% if request.user.is_authenticated and perms.projects.add_component %}
   <div class="editlinks"><p class="i16 edit"><a href="{% url component_edit project_slug=component.project.slug component_slug=component.slug %}">{% trans "Edit" %}</a></p></div>
   {% endif %}
   <h2 class="name">{{ component.project.name }} &raquo; {{ component.name }}</h2>
     {% if request.user.is_authenticated %}<tr>
       <th class="i16 maintainer">{% trans "Maintainer actions:" %}</th>
       <td>
+       {% if perms.projects.refresh_stats %}
         <form action="{% url component_set_stats component.project.slug component.slug %}" class="microform">
             <input title="{% trans "Refresh and re-calculate statistics. It can take some time." %}" class="i16 stats_edit" value="{% trans "Refresh cache" %}" type="submit">
         </form>
+        {% endif %}
+        {% if perms.projects.clear_cache %}
         <form action="{% url component_clear_cache component.project.slug component.slug %}" class="microform">
             <input title="{% trans "Reset Transifex's local data for a clean pull" %}" class="i16 cache_empty" value="{% trans "Clear cache" %}" type="submit">
         </form>
+        {% endif %}
       </td>
     </tr>{% endif %}
   </table>
 
 {% comp_stats_table component.trans.get_stats %}
 
-{% if request.user.is_authenticated and component.allows_submission %}
+{% if request.user.is_authenticated and component.allows_submission and perms.projects.submit_file %}
    {% include "projects/component_submit_new_file.html" %}
 {% endif %}
 
 
 {% block content_footer %}
   <div id="content_footer_center">
-    {% if request.user.is_authenticated %}
+    {% if request.user.is_authenticated and perms.projects.delete_component %}
     <div class="deletelink">
       <span class="i16 delete"><a href="{% url component_delete project_slug=component.project.slug component_slug=component.slug %}">{% trans "Delete component" %}</a></span>
     </div>

File templates/projects/component_list.html

View file
  • Ignore whitespace
 
 <div id="components" class="components">
 
-  {% if request.user.is_authenticated %}
+  {% if request.user.is_authenticated and perms.projects.add_component %}
   <div class="editlinks"><span class="i16 add">
     <a href="{% url component_create project_slug=project.slug %}">{% trans "Add" %}</a></span>
   </p></div>
   {% for comp in components|slice:"0:4" %}
     <div class="entry">
       <p class="name"><a href="{{ comp.get_absolute_url }}">{{ comp.name }}</a>
-      {% if request.user.is_authenticated %}
       <sup class="entry_metalink">
-        (<a href="{% url component_edit project_slug=project.slug component_slug=comp.slug %}">{% trans "edit" %}</a>, 
-        <a href="{% url component_delete project_slug=project.slug component_slug=comp.slug %}">{% trans "del" %}</a>)
+       {% if request.user.is_authenticated and perms.projects.change_component %}
+         <a href="{% url component_edit project_slug=project.slug component_slug=comp.slug %}">{% trans "edit" %}</a>
+       {% endif %}
+       {% if request.user.is_authenticated and perms.projects.delete_component %}
+         , <a href="{% url component_delete project_slug=project.slug component_slug=comp.slug %}">{% trans "del" %}</a>
+       {% endif %}
       </sup>
-      {% endif %}
       </p>
       <p class="description">{{ comp.description|truncatewords:"10" }}</p></li>
     </div>

File templates/projects/project_detail.html

View file
  • Ignore whitespace
   <div class="obj_bigdetails">
   <h2 class="name">{{ project.name }}</h2>
 
-  {% if request.user.is_authenticated %}
+  {% if request.user.is_authenticated and perms.projects.change_project %}
   <div class="editlinks"><p class="i16 edit"><a href="{% url project_edit project_slug=project.slug %}">{% trans "Edit" %}</a></p></div>
   {% endif %}
   
 
 {% block content_footer %}
   <div id="content_footer_center">
-    {% if request.user.is_authenticated %}
+    {% if request.user.is_authenticated and perms.projects.delete_project %}
     <div class="deletelink">
       <span class="i16 delete"><a href="{% url project_delete project_slug=project.slug %}">{% trans "Delete project" %}</a></span>
     </div>

File templates/projects/project_list.html

View file
  • Ignore whitespace
 {% endblock %}
 
 {% block content_header_sec %}
-    {% if request.user.is_authenticated %}
+    {% if request.user.is_authenticated and perms.projects.add_project %}
     <div class="addproject content_header_sec">
       <span class="i16 add"><a href="{% url project_create %}">{% trans "Add a new project" %}</a></span>
     </div>

File translations/templates/comp_stats_table.html

View file
  • Ignore whitespace
            <a class="i16 view nodecoration_icon" title="{% trans "View " %}{{stat.filename}}" href="{{file_view_url}}"></a>
            <a class="i16 link nodecoration_icon" title="{% trans "Download " %}{{stat.filename}}" href="{{file_raw_url}}"></a>
            {% pofile_lock stat.object.project.slug stat.object.slug stat %}
-           {% if current_user.is_authenticated  and stat.object.allows_submission %}{% include "projects/component_submit.html" %}{% endif %}
+           {% if current_user.is_authenticated and stat.object.allows_submission and perms.translations.add_pofilelock %}{% include "projects/component_submit.html" %}{% endif %}
         </td>
       </tr>
    {% endfor %}

File translations/templates/lang_stats_table.html

View file
  • Ignore whitespace
            <a class="i16 view nodecoration_icon" title="{% trans "View " %}{{stat.filename}}" href="{{file_view_url}}"></a>
            <a class="i16 link nodecoration_icon" title="{% trans "Download " %}{{stat.filename}}" href="{{file_raw_url}}"></a>
            {% pofile_lock stat.object.project.slug stat.object.slug stat %}
-           {% if current_user.is_authenticated and component.allows_submission %}{% include "projects/component_submit.html" %}{% endif %}
-        </td>
+           {% if current_user.is_authenticated and stat.object.allows_submission and perms.translations.add_pofilelock %}{% include "projects/component_submit.html" %}{% endif %}
+         </td>
       </tr>
    {% endfor %}
    </tbody>

File translations/templates/pofile_lock.html

View file
  • Ignore whitespace
     <span class="stat_message">({{ owner }})</span>
   {% endifequal %}
 {% else %}
-  {% if current_user.is_authenticated %}
+  {% if current_user.is_authenticated and perms.translations.add_pofilelock %}
     <a class="i16 lock_none nodecoration_icon" title="{% trans "Lock this file to notify others you're working with it." %}" href="{{ toggle_lock_url }}"></a>
   {% else %}
     <span class="i16 lock_none nodecoration_icon" title="{% trans "This file is unlocked. Most likely noone is working with it right now." %}" href="{{ toggle_lock_url }}"></span>

File translations/templatetags/locks.py

View file
  • Ignore whitespace
     return {'project': project,
             'component': component,
             'pofile': pofile,
-            'current_user': context['current_user']}
+            'current_user': context['current_user'],
+            'perms': context['perms']}
 register.inclusion_tag('pofile_lock.html', takes_context=True)(pofile_lock)

File translations/templatetags/statistics.py

View file
  • Ignore whitespace
     """
 
     return {'stats': stats,
-            'current_user': context['request'].user}
+            'current_user': context['request'].user,
+            'perms': context['perms']}
 register.inclusion_tag('comp_stats_table.html', takes_context=True)(comp_stats_table)
 
 @register.inclusion_tag("project_stats_table.html")
     """
 
     return {'stats': stats,
-            'current_user': context['request'].user}
+            'current_user': context['request'].user,
+            'perms': context['perms']}
 register.inclusion_tag('lang_stats_table.html', takes_context=True)(lang_stats_table)
 
 @register.inclusion_tag("release_stats_table.html")