Commit 416cf0af authored by chirac's avatar chirac
Browse files

Affiche l'historique des alias mail (très utile oui)

parent 438e8ce7
......@@ -65,7 +65,8 @@
<td>{{ alias.alias }}</td>
<td>{{ alias.redirection }}</td>
<td><a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-mailalias' alias.id %}"><i class="glyphicon glyphicon-hdd"></i> Editer</a>
<a class="btn btn-danger btn-sm" role="button" href="{% url 'users:del-mailalias' alias.id %}"><i class="glyphicon glyphicon-trash"></i> Supprimer</a></td>
<a class="btn btn-danger btn-sm" role="button" href="{% url 'users:del-mailalias' alias.id %}"><i class="glyphicon glyphicon-trash"></i> Supprimer</a>
<a class="btn btn-info btn-sm" role="button" href="{% url 'users:history' 'alias' alias.id %}"><i class="glyphicon glyphicon-repeat"></i> Historique</a></td>
</tr>
{% endfor %}
</table>
......
......@@ -22,6 +22,7 @@ urlpatterns = [
url(r'^reset_password/$', views.reset_password, name='reset-password'),
url(r'^history/(?P<object>user)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^history/(?P<object>listright)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^history/(?P<object>alias)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^$', views.index, name='index'),
]
......
......@@ -259,9 +259,9 @@ def edit_mailalias(request, mailaliasid):
mailalias = MailAliasForm(request.POST or None, instance=mailalias_instance)
if mailalias.is_valid():
with transaction.atomic(), reversion.create_revision():
mailalias.save()
mailalias = mailalias.save()
reversion.set_user(request.user)
reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in mailalias.changed_data))
reversion.set_comment("Alias modifié (%s vers %s)" % (mailalias.alias,mailalias.redirection))
messages.success(request, "Alias modifié")
return redirect("/users/profil/" + str(mailalias_instance.user.id))
return form({'userform': mailalias}, 'users/user.html', request)
......@@ -314,6 +314,15 @@ def history(request, object, id):
if not request.user.has_perms(('bureau',)) and object_instance != request.user:
messages.error(request, "Vous ne pouvez pas afficher l'historique d'un autre user que vous sans droit bureau")
return redirect("/users/profil/" + str(request.user.id))
elif object == 'alias':
try:
object_instance = MailAlias.objects.get(pk=id)
except MailAlias.DoesNotExist:
messages.error(request, "Alias inexistant")
return redirect("/users/")
if not request.user.has_perms(('bureau',)) and object_instance != request.user:
messages.error(request, "Vous ne pouvez pas afficher l'historique d'un autre user que vous sans droit bureau")
return redirect("/users/profil/" + str(request.user.id))
elif object == 'listright' and request.user.has_perms(('bureau',)):
try:
object_instance = ListRight.objects.get(pk=id)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment