8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-30 08:32:26 +00:00

Documentation de history.

This commit is contained in:
LEVY-FALK Hugo 2017-12-28 14:43:43 +01:00 committed by root
parent 41ba73ac70
commit a1df6136cb

View file

@ -51,7 +51,7 @@ def index(request):
services[indice % 3].append(serv) services[indice % 3].append(serv)
return form({'services_urls': services}, 're2o/index.html', request) return form({'services_urls': services}, 're2o/index.html', request)
#: Binding the corresponding char sequence of history url to re2o models.
HISTORY_BIND = { HISTORY_BIND = {
'user' : users.models.User, 'user' : users.models.User,
'ban' : users.models.Ban, 'ban' : users.models.Ban,
@ -88,7 +88,24 @@ HISTORY_BIND = {
@login_required @login_required
def history(request, object_name, object_id): def history(request, object_name, object_id):
""" Affichage de l'historique""" """Render history for a model.
The model is determined using the `HISTORY_BIND` dictionnary if none is
found, raises a Http404. The view checks if the user is allowed to see the
history using the `can_view` method of the model.
Args:
request: The request sent by the user.
object_name: Name of the model.
object_id: Id of the object you want to acces history.
Returns:
The rendered page of history if access is granted, else the user is
redirected to their profile page, with an error message.
Raises:
Http404: This kind of models doesn't have history.
"""
try: try:
model = HISTORY_BIND[object_name] model = HISTORY_BIND[object_name]
except KeyError as e: except KeyError as e: