Create a new 'home' view for Presences
authorSverre Rabbelier <srabbelier@gmail.com>
Fri, 23 Jan 2009 15:29:42 +0000
changeset 921 e499cc2641f6
parent 920 39badbfb80be
child 922 ca683f467bea
Create a new 'home' view for Presences This also restores the 'show' view for Presences as there is no need to hide it with the 'home' view anymore. Patch by: Sverre Rabbelier
app/soc/templates/soc/home/public.html
app/soc/templates/soc/presence/home.html
app/soc/templates/soc/presence/public.html
app/soc/templates/soc/site/home.html
app/soc/views/models/presence.py
app/soc/views/models/site.py
--- a/app/soc/templates/soc/home/public.html	Fri Jan 23 12:00:48 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-{% extends "soc/base.html" %}
-{% comment %}
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-{% endcomment %}
-
-{% block scripts %}
-{% if entity.feed_url %}
-    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
-    <script type="text/javascript" src="/soc/content/js/blog-081117.js"></script>
-    <script type="text/javascript">
-
-    google.load("feeds", "1");
-
-    function initialize() {
-      var blog = new BlogPreview(document.getElementById("blog"));
-      blog.show("{{ entity.feed_url }}", 3);
-    }
-    google.setOnLoadCallback(initialize);
-
-    </script>
-{% endif %}
-{% endblock %}
-
-{% block page_title %}
-{% if home_document %}
-{{ home_document.title }}
-{% else %}
-{{ page_name }}
-{% endif %}
-{% endblock %}
-
-{% block header_title %}
-{% if home_document %}
-{{ home_document.short_name }}
-{% else %}
-{{ page_name }}
-{% endif %}
-{% endblock %}
-
-{% block body %}
- {% if home_document %}
-  <div id="created">Last modified on {{ home_document.modified }} by {{ home_document.modified_by.name }}</div>
-  {{ home_document.content|safe }}
- {% else %}
-{% block missing_doc %}
-This is the default home page can be edited via <a href="/site/edit">Edit Site Settings</a>.<br />
-{% endblock %}
- {% endif %}
- {% if entity.feed_url %}
-    <div id="blog"></div>
- {% endif %}
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/presence/home.html	Fri Jan 23 15:29:42 2009 +0000
@@ -0,0 +1,62 @@
+{% extends "soc/base.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+
+{% block scripts %}
+{% if entity.feed_url %}
+    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
+    <script type="text/javascript" src="/soc/content/js/blog-081117.js"></script>
+    <script type="text/javascript">
+
+    google.load("feeds", "1");
+
+    function initialize() {
+      var blog = new BlogPreview(document.getElementById("blog"));
+      blog.show("{{ entity.feed_url }}", 3);
+    }
+    google.setOnLoadCallback(initialize);
+
+    </script>
+{% endif %}
+{% endblock %}
+
+{% block page_title %}
+{% if home_document %}
+{{ home_document.title }}
+{% else %}
+{{ page_name }}
+{% endif %}
+{% endblock %}
+
+{% block header_title %}
+{% if home_document %}
+{{ home_document.short_name }}
+{% else %}
+{{ page_name }}
+{% endif %}
+{% endblock %}
+
+{% block body %}
+ {% if home_document %}
+  <div id="created">Last modified on {{ home_document.modified }} by {{ home_document.modified_by.name }}</div>
+  {{ home_document.content|safe }}
+ {% else %}
+{% block missing_doc %}
+This is the default home page, it can be edited via <a href="/site/edit">Edit Site Settings</a>.<br />
+{% endblock %}
+ {% endif %}
+ {% if entity.feed_url %}
+    <div id="blog"></div>
+ {% endif %}
+{% endblock %}
--- a/app/soc/templates/soc/presence/public.html	Fri Jan 23 12:00:48 2009 +0000
+++ b/app/soc/templates/soc/presence/public.html	Fri Jan 23 15:29:42 2009 +0000
@@ -1,4 +1,4 @@
-{% extends "soc/home/public.html" %}
+{% extends "soc/base.html" %}
 {% comment %}
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
@@ -12,16 +12,22 @@
 See the License for the specific language governing permissions and
 limitations under the License.
 {% endcomment %}
+{% load forms_helpers %}
 
-{% block missing_doc %}
-The contents of this default Site home page can be changed by
-<a href="/document/edit">creating a new Document</a> or
-<a href="/document/list">editing an existing Document</a> and then selecting
-that Document in the
-<a href="/site/edit">Site Settings</a> interface.
-Other elements of this page, such as a feed to be displayed below this
-content, can also be set using the
-<a href="/site/edit">Site Settings</a> interface.
-You need to sign in as site Developer in order to change
-<a href="/site/edit">Site Settings</a>.
+{% block header_title %}
+{{ page_name }} for {{ entity.link_id }}
 {% endblock %}
+
+{% block body %}
+<p>
+ <table>
+  {% readonly_field_as_table_row entity.fields.link_id.label entity.link_id %}
+  {% readonly_field_as_table_row entity.fields.home.label entity.home.key.name %}
+  {% readonly_field_as_table_row entity.fields.feed_url.label entity.feed_url %}
+  {% readonly_field_as_table_row entity.fields.tos.label entity.tos %}
+  {% readonly_field_as_table_row entity.fields.ga_tracking_num.label entity.ga_tracking_num %}
+  {% readonly_field_as_table_row entity.fields.gmaps_api_key.label entity.gmaps_api_key %}
+  <!-- TODO(pawel.solyga) make this generic -->
+ </table>
+</p>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/site/home.html	Fri Jan 23 15:29:42 2009 +0000
@@ -0,0 +1,27 @@
+{% extends "soc/presence/home.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+
+{% block missing_doc %}
+The contents of this default Site home page can be changed by
+<a href="/document/edit">creating a new Document</a> or
+<a href="/document/list">editing an existing Document</a> and then selecting
+that Document in the
+<a href="/site/edit">Site Settings</a> interface.
+Other elements of this page, such as a feed to be displayed below this
+content, can also be set using the
+<a href="/site/edit">Site Settings</a> interface.
+You need to sign in as site Developer in order to change
+<a href="/site/edit">Site Settings</a>.
+{% endblock %}
--- a/app/soc/views/models/presence.py	Fri Jan 23 12:00:48 2009 +0000
+++ b/app/soc/views/models/presence.py	Fri Jan 23 15:29:42 2009 +0000
@@ -33,6 +33,7 @@
 from soc.logic.models import document as document_logic
 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.models import base
 
@@ -58,6 +59,7 @@
     new_params = {}
 
     new_params['extra_dynaexclude'] = ['home', 'tos']
+    new_params['home_template'] = 'soc/presence/home.html'
 
     new_params['create_extra_dynafields'] = {
         # override some editors
@@ -78,6 +80,22 @@
 
     super(View, self).__init__(params=params)
 
+  @decorators.check_access
+  def home(self, request, access_type,
+             page_name=None, params=None, **kwargs):
+    """See base.View.public().
+
+    Overrides public_template to point at 'home_template'.
+    """
+
+    new_params = {}
+    new_params['public_template'] = self._params['home_template']
+
+    params = dicts.merge(params, new_params)
+
+    return self.public(request, access_type,
+                       page_name=page_name, params=params, **kwargs)
+
   def _public(self, request, entity, context):
     """See base.View._public().
     """
--- a/app/soc/views/models/site.py	Fri Jan 23 12:00:48 2009 +0000
+++ b/app/soc/views/models/site.py	Fri Jan 23 15:29:42 2009 +0000
@@ -62,7 +62,8 @@
     new_params['sidebar_defaults'] = [('/%s/edit', 'Edit %(name)s', 'edit')]
     new_params['sidebar_heading'] = new_params['name_short']
 
-    new_params['public_template'] = 'soc/home/public.html'
+    new_params['public_template'] = 'soc/presence/public.html'
+    new_params['home_template'] = 'soc/site/home.html'
 
     new_params['create_extra_dynafields'] = {
         'link_id': forms.CharField(widget=forms.HiddenInput, required=True),
@@ -121,7 +122,7 @@
     values = self._logic.getKeyValues(None)
     key_values = dicts.zip(keys, values)
 
-    return self.public(request, "show", page_name, **key_values)
+    return self.home(request, "home", page_name=page_name, **key_values)
 
   def mainEdit(self, request, page_name=None, **kwargs):
     """Displays the edit page for the main site settings page.
@@ -138,7 +139,7 @@
     # Site singleton, so pass in None to match parent method footprint.
     values = self._logic.getKeyValues(None)
     key_values = dicts.zip(keys, values)
-    
+
     return self.edit(request, "edit", page_name, seed=key_values, **key_values)