Template fine-grained permissioning

Rather than use user.is_authenticated, rely on certain permissions being
set for the user. This allows us to open up the developer side and not
assume everyone is a package maintainer.

Allow all logged-in users to still view todo lists, but don't show the
complete/incomplete links (only the text) unless they are allowed to
mess with todo lists.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-03-03 14:59:04 -06:00
parent 710ec0a9de
commit 8b77efbfab
3 changed files with 9 additions and 5 deletions

View File

@ -26,7 +26,7 @@ <h4>Package Actions</h4>
title="Testing package details for {{ tp.pkgname }}">{{ tp.pkgver }}-{{ tp.pkgrel }}</a>
in testing</span></li>
{% endif %}{% endwith %}
{% if user.is_authenticated %}
{% if perms.main.change_package %}
<li><a href="unflag/" title="Unflag this package">Click here to unflag</a></li>
<li><a href="unflag/all/" title="Unflag all matching pkgbase">Click here to unflag all split packages</a></li>
{% endif %}
@ -40,7 +40,7 @@ <h4>Package Actions</h4>
<li><a href="download/" title="Download {{ pkg.pkgname }} from mirror">Download From Mirror</a></li>
</ul>
{% if user.is_authenticated %}
{% if perms.main.change_package %}
<form id="pkg-action" method="post" action="/packages/update/">{% csrf_token %}
<div><input type="hidden" name="pkgid" value="{{ pkg.id }}" /></div>
<p>{% if user in pkg.maintainers %}

View File

@ -71,7 +71,7 @@ <h3>Package Search</h3>
<table class="results">
<thead>
<tr>
{% if user.is_authenticated %}
{% if perms.main.change_package %}
<th>&nbsp;</th>
{% endif %}
<th><a href="/packages/{% buildsortqs "arch" %}"
@ -91,7 +91,7 @@ <h3>Package Search</h3>
<tbody>
{% for pkg in package_list %}
<tr class="{% cycle 'odd' 'even' %}">
{% if user.is_authenticated %}
{% if perms.main.change_package %}
<td><input type="checkbox" name="pkgid" value="{{ pkg.id }}" /></td>
{% endif %}
<td>{{ pkg.arch.name }}</td>
@ -134,7 +134,7 @@ <h3>Package Search</h3>
</div>
{% endif %}
{% if user.is_authenticated %}
{% if perms.main.change_package %}
<p><input title="Adopt selected packages" type="submit" id="adopt-btn"
name="adopt" value="Adopt Packages" />
<input title="Orphan selected packages" type="submit" id="disown-btn"

View File

@ -38,6 +38,7 @@ <h2>Todo List: {{ list.name }}</h2>
<td>{{ pkg.pkg.repo.name|capfirst }}</td>
<td>{{ pkg.pkg.maintainers|join:', ' }}</td>
<td>
{% if perms.main.change_todolistpkg %}
{% if pkg.complete %}
<a href="/todo/flag/{{ list.id }}/{{ pkg.id }}/"
class="status-link complete" title="Toggle completion status">Complete</a>
@ -45,6 +46,9 @@ <h2>Todo List: {{ list.name }}</h2>
<a href="/todo/flag/{{ list.id }}/{{ pkg.id }}/"
class="status-link incomplete" title="Toggle completion status">Incomplete</a>
{% endif %}
{% else %}
{% if pkg.complete %}<span class="complete">Complete</span>{% else %}<span class="incomplete">Incomplete</span>{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}