# HG changeset patch # User Lennard de Rijk # Date 1244146091 -7200 # Node ID c9283c3102cee2cdf56c3099a5a96301e9488c2f # Parent eb1a6abdb05666dad446f61f38a20eba70f8c8ae# Parent 723dfa4811e868f18cd5220af776e64e8477b7cc Merge with Pawel's tip. diff -r 723dfa4811e8 -r c9283c3102ce app/soc/logic/helper/notifications.py --- a/app/soc/logic/helper/notifications.py Thu Jun 04 20:55:30 2009 +0200 +++ b/app/soc/logic/helper/notifications.py Thu Jun 04 22:08:11 2009 +0200 @@ -272,13 +272,14 @@ messageProperties = { 'to_name': user_entity.name, 'sender_name': sender_name, - 'site_name': site_name, 'to': to, 'sender': sender, 'subject': DEF_WELCOME_MSG_FMT % { 'site_name': site_name, 'name': user_entity.name - } + }, + 'site_name': site_name, + 'site_location': 'http://%s' % os.environ['HTTP_HOST'], } # send out the message using the default welcome template diff -r 723dfa4811e8 -r c9283c3102ce app/soc/templates/soc/document/public.html --- a/app/soc/templates/soc/document/public.html Thu Jun 04 20:55:30 2009 +0200 +++ b/app/soc/templates/soc/document/public.html Thu Jun 04 22:08:11 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 723dfa4811e8 -r c9283c3102ce app/soc/templates/soc/mail/welcome.html --- a/app/soc/templates/soc/mail/welcome.html Thu Jun 04 20:55:30 2009 +0200 +++ b/app/soc/templates/soc/mail/welcome.html Thu Jun 04 22:08:11 2009 +0200 @@ -16,7 +16,7 @@ {% block content %} Welcome to {{ site_name }}. If you are reading this it means you have successfully registered as a user -on our website. +on {{ site_location }}. {% ifequal site_name "Melange" %} Currently Melange is still under development, if you run into any trouble you diff -r 723dfa4811e8 -r c9283c3102ce app/soc/templates/soc/presence/home.html --- a/app/soc/templates/soc/presence/home.html Thu Jun 04 20:55:30 2009 +0200 +++ b/app/soc/templates/soc/presence/home.html Thu Jun 04 22:08:11 2009 +0200 @@ -40,7 +40,10 @@ {% block header_title %} {% if home_document %} -{{ home_document.title }} +{{ home_document.title }} + {% if home_document_edit_redirect %} + (Click here to Edit Home Page) + {% endif %} {% else %} {{ page_name }} {% endif %} diff -r 723dfa4811e8 -r c9283c3102ce app/soc/views/helper/access.py --- a/app/soc/views/helper/access.py Thu Jun 04 20:55:30 2009 +0200 +++ b/app/soc/views/helper/access.py Thu Jun 04 22:08:11 2009 +0200 @@ -1512,7 +1512,7 @@ @allowSidebar @allowDeveloper def checkIsDocumentReadable(self, django_args, key_name_field=None): - """Checks whether a document is readable. + """Checks whether a document is readable by the current user. Args: django_args: a dictionary with django's arguments @@ -1531,7 +1531,7 @@ @denySidebar @allowDeveloper def checkIsDocumentWritable(self, django_args, key_name_field=None): - """Checks whether a document is writable. + """Checks whether a document is writable by the current user. Args: django_args: a dictionary with django's arguments diff -r 723dfa4811e8 -r c9283c3102ce app/soc/views/models/document.py --- a/app/soc/views/models/document.py Thu Jun 04 20:55:30 2009 +0200 +++ b/app/soc/views/models/document.py Thu Jun 04 22:08:11 2009 +0200 @@ -123,6 +123,34 @@ 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(), + 'prefix': entity.prefix, + 'scope_path': entity.scope_path, + 'link_id': entity.link_id}, + 'key_name') + allowed_to_edit = True + except: + pass + + if allowed_to_edit: + # add the document edit redirect to the context + 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(). """ diff -r 723dfa4811e8 -r c9283c3102ce app/soc/views/models/presence.py --- a/app/soc/views/models/presence.py Thu Jun 04 20:55:30 2009 +0200 +++ b/app/soc/views/models/presence.py Thu Jun 04 22:08:11 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().