Merge with Pawel's tip.
authorLennard de Rijk <ljvderijk@gmail.com>
Thu, 04 Jun 2009 22:08:11 +0200
changeset 2391 c9283c3102ce
parent 2388 eb1a6abdb056 (diff)
parent 2390 723dfa4811e8 (current diff)
child 2392 b53e1cdb0398
Merge with Pawel's tip.
app/soc/content/css/soc-090421.css
--- 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
--- 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 %}
+		<a href={{ edit_redirect }}> (Edit this {{entity_type}})</a>
+	{% endif %}
 {% endblock %}
 
 {% block body %}
-<div id="created">Last modified on {{ entity.modified }} by {{ entity.modified_by.name }}</div>
-<div id="content">{{ entity.content|safe }}</div>
+	<div id="created">Last modified on {{ entity.modified }} by {{ entity.modified_by.name }}</div>
+	<div id="content">{{ entity.content|safe }}</div>
 {% endblock %}
--- 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
--- 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 %}
+		<a href={{ home_document_edit_redirect }}> (Click here to Edit Home Page)</a>
+	{% endif %}
 {% else %}
 {{ page_name }}
 {% endif %}
--- 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
--- 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().
     """
--- 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().