mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 03:43:12 +00:00
Documentation de history.
This commit is contained in:
parent
e152103bc3
commit
d7bc8fc816
1 changed files with 19 additions and 2 deletions
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue