# HG changeset patch # User Lennard de Rijk # Date 1244139675 -7200 # Node ID 3a6302dd346be71982016468b66a0e142e819c72 # Parent f230254557428e008e481e8da20d9507eddc18bb Added link to edit the Document on the Document's public page. This link will only show if the user is allowed to edit the document. Fixes issue 271. Update issue 271 Owner: ljvderijk diff -r f23025455742 -r 3a6302dd346b app/soc/templates/soc/document/public.html --- a/app/soc/templates/soc/document/public.html Thu Jun 04 18:21:04 2009 +0200 +++ b/app/soc/templates/soc/document/public.html Thu Jun 04 20:21:15 2009 +0200 @@ -14,14 +14,17 @@ {% endcomment %} {% block page_title %} -{{ entity.title }} + {{ entity.title }} {% endblock %} {% block header_title %} -{{ entity.title }} + {{ entity.title }} + {% if edit_redirect %} + (Edit this {{entity_type}}) + {% endif %} {% endblock %} {% block body %} -
Last modified on {{ entity.modified }} by {{ entity.modified_by.name }}
-
{{ entity.content|safe }}
+
Last modified on {{ entity.modified }} by {{ entity.modified_by.name }}
+
{{ entity.content|safe }}
{% endblock %} diff -r f23025455742 -r 3a6302dd346b app/soc/views/models/document.py --- a/app/soc/views/models/document.py Thu Jun 04 18:21:04 2009 +0200 +++ b/app/soc/views/models/document.py Thu Jun 04 20:21:15 2009 +0200 @@ -123,6 +123,30 @@ return super(View, self).list(request, access_type, page_name=page_name, params=params, filter=kwargs) + def _public(self, request, entity, context): + """Performs any processing needed for the Document's public page. + + For args see base.View._public(). + """ + + # check if the current user is allowed to visit the edit page + rights = self._params['rights'] + + allowed_to_edit = False + try: + # use the IsDocumentWritable check because we have no django args + rights.checkIsDocumentWritable({'key_name': entity.key().name()}, + 'key_name') + allowed_to_edit = True + except: + pass + + if allowed_to_edit: + context['edit_redirect'] = redirects.getEditRedirect( + entity, {'url_name': 'document'}) + + return super(View, self)._public(request, entity, context) + def _editPost(self, request, entity, fields): """See base.View._editPost(). """