From d7bc8fc8168e340805a16da7f2332ba9d2f085dc Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Thu, 28 Dec 2017 14:43:43 +0100 Subject: [PATCH] Documentation de history. --- re2o/views.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/re2o/views.py b/re2o/views.py index 79e54d93..5008dbdb 100644 --- a/re2o/views.py +++ b/re2o/views.py @@ -51,7 +51,7 @@ def index(request): services[indice % 3].append(serv) return form({'services_urls': services}, 're2o/index.html', request) - +#: Binding the corresponding char sequence of history url to re2o models. HISTORY_BIND = { 'user' : users.models.User, 'ban' : users.models.Ban, @@ -88,7 +88,24 @@ HISTORY_BIND = { @login_required 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: model = HISTORY_BIND[object_name] except KeyError as e: