Now showing link to edit the home page document on the home page.
This will only show up if you have the right to edit the document.
Update issue 271
Now also working for home pages.
--- a/app/soc/templates/soc/presence/home.html Thu Jun 04 20:21:15 2009 +0200
+++ b/app/soc/templates/soc/presence/home.html Thu Jun 04 21:58:05 2009 +0200
@@ -40,7 +40,10 @@
{% block header_title %}
{% if home_document %}
-{{ home_document.title }}
+{{ home_document.title }}
+ {% if home_document_edit_redirect %}
+ <a href={{ home_document_edit_redirect }}> (Click here to Edit Home Page)</a>
+ {% endif %}
{% else %}
{{ page_name }}
{% endif %}
--- a/app/soc/views/models/presence.py Thu Jun 04 20:21:15 2009 +0200
+++ b/app/soc/views/models/presence.py Thu Jun 04 21:58:05 2009 +0200
@@ -33,6 +33,7 @@
from soc.views import helper
from soc.views.helper import access
from soc.views.helper import decorators
+from soc.views.helper import redirects
from soc.views.helper import widgets
from soc.views.models import base
@@ -130,7 +131,28 @@
home_doc.content = helper.templates.unescape(home_doc.content)
context['home_document'] = home_doc
- return True
+ # check if the current user is allowed edit the home document
+ rights = self._params['rights']
+
+ allowed_to_edit = False
+
+ try:
+ # use the IsDocumentWritable check because we have no django args
+ rights.checkIsDocumentWritable({'key_name': home_doc.key().name(),
+ 'prefix': home_doc.prefix,
+ 'scope_path': home_doc.scope_path,
+ 'link_id': home_doc.link_id},
+ 'key_name')
+ allowed_to_edit = True
+ except:
+ pass
+
+ if allowed_to_edit:
+ # put the link to edit to home document in context
+ context['home_document_edit_redirect'] = redirects.getEditRedirect(
+ home_doc, {'url_name': 'document'})
+
+ return super(View, self)._public(request, entity, context)
def _editGet(self, request, entity, form):
"""See base.View._editGet().