provile_views: hide delegation section for guest delegates, fixes #3634
This commit is contained in:
parent
c26751db6b
commit
6ded756009
|
@ -234,6 +234,12 @@ class FullProfileView(TemplateResponseMixin, View):
|
|||
('password_change_form', PasswordChangeView),
|
||||
)
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if models.is_guest(request.user):
|
||||
self.subviews = filter(lambda s: s[0] != 'delegate_form', self.subviews)
|
||||
print self.subviews
|
||||
return super(FullProfileView, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
ctx = {}
|
||||
for var_name, view_class in self.subviews:
|
||||
|
|
|
@ -18,68 +18,70 @@
|
|||
|
||||
{% crispy profile_form profile_form.helper %}
|
||||
|
||||
<h3 id="delegate">{% trans "Delegations" %}</h3>
|
||||
{% if delegate_form %}
|
||||
<h3 id="delegate">{% trans "Delegations" %}</h3>
|
||||
|
||||
<h4>Délégations attribuées</h4>
|
||||
<h4>Délégations attribuées</h4>
|
||||
|
||||
{% if delegations %}
|
||||
<form method="post" action=".">
|
||||
{% csrf_token %}
|
||||
<table id="delegations">
|
||||
<thead>
|
||||
<tr>
|
||||
<th id="firstname">Prénom</th>
|
||||
<th id="lastname">Nom</th>
|
||||
<th id="email">Courriel</th>
|
||||
<th id="username">Identifiant</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for delegation in delegations %}
|
||||
<tr class="{% cycle 'odd' 'even' %}">
|
||||
<td>{{ delegation.to.first_name }}</td>
|
||||
<td>{{ delegation.to.last_name }}</td>
|
||||
<td>{{ delegation.to.email }}</td>
|
||||
<td>{{ delegation.to.username }}</td>
|
||||
<td><input type="image" name="delegate-delete-{{ delegation.to.username }}" src="{{ STATIC_URL }}/docbow/css/images/poubelle.png" alt="{% trans "Delete" %}"/></td>
|
||||
</tr>
|
||||
<tr class="last-connection {% cycle 'odd' 'even' %}">
|
||||
{% if delegation.journals %}
|
||||
<td colspan="5">Dernière(s) connexion(s): {% for connection_time in delegation.journals %}
|
||||
{{ connection_time }}
|
||||
{% if not forloop.last %}, {% endif %}
|
||||
{% endfor %}</td>
|
||||
{% else %}
|
||||
{% if delegation.to.date_joined != delegation.to.last_login %}
|
||||
<td colspan="5">Dernière connexion: {{ delegation.to.last_login }}</td>
|
||||
{% else %}
|
||||
<td colspan="5">Aucune connexion.</td>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
{% else %}
|
||||
<p>Aucune délégation attribuée</p>
|
||||
{% endif %}
|
||||
{% if delegations %}
|
||||
<form method="post" action=".">
|
||||
{% csrf_token %}
|
||||
<table id="delegations">
|
||||
<thead>
|
||||
<tr>
|
||||
<th id="firstname">Prénom</th>
|
||||
<th id="lastname">Nom</th>
|
||||
<th id="email">Courriel</th>
|
||||
<th id="username">Identifiant</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for delegation in delegations %}
|
||||
<tr class="{% cycle 'odd' 'even' %}">
|
||||
<td>{{ delegation.to.first_name }}</td>
|
||||
<td>{{ delegation.to.last_name }}</td>
|
||||
<td>{{ delegation.to.email }}</td>
|
||||
<td>{{ delegation.to.username }}</td>
|
||||
<td><input type="image" name="delegate-delete-{{ delegation.to.username }}" src="{{ STATIC_URL }}/docbow/css/images/poubelle.png" alt="{% trans "Delete" %}"/></td>
|
||||
</tr>
|
||||
<tr class="last-connection {% cycle 'odd' 'even' %}">
|
||||
{% if delegation.journals %}
|
||||
<td colspan="5">Dernière(s) connexion(s): {% for connection_time in delegation.journals %}
|
||||
{{ connection_time }}
|
||||
{% if not forloop.last %}, {% endif %}
|
||||
{% endfor %}</td>
|
||||
{% else %}
|
||||
{% if delegation.to.date_joined != delegation.to.last_login %}
|
||||
<td colspan="5">Dernière connexion: {{ delegation.to.last_login }}</td>
|
||||
{% else %}
|
||||
<td colspan="5">Aucune connexion.</td>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
{% else %}
|
||||
<p>Aucune délégation attribuée</p>
|
||||
{% endif %}
|
||||
|
||||
<h4>{% trans "Create a new delegation" %}</h4>
|
||||
<div id="new-delegation-form">
|
||||
{% crispy delegate_form delegate_form.helper %}
|
||||
</div>
|
||||
<h4>{% trans "Create a new delegation" %}</h4>
|
||||
<div id="new-delegation-form">
|
||||
{% crispy delegate_form delegate_form.helper %}
|
||||
</div>
|
||||
|
||||
<h4>{% trans "Received delegations" %}</h4>
|
||||
{% if received_delegations %}
|
||||
<ul id="received-delegations">
|
||||
{% for delegation in received_delegations %}
|
||||
<li>{% firstof delegation.by.get_full_name delegation.by.username %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p>Aucune délégation reçue</p>
|
||||
<h4>{% trans "Received delegations" %}</h4>
|
||||
{% if received_delegations %}
|
||||
<ul id="received-delegations">
|
||||
{% for delegation in received_delegations %}
|
||||
<li>{% firstof delegation.by.get_full_name delegation.by.username %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p>Aucune délégation reçue</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<h3 id="password-change">{% trans "Changing password" %}</h3>
|
||||
|
|
Loading…
Reference in New Issue