# HG changeset patch
# User Todd Larsen
# Date 1224306697 0
# Node ID d94ec6f104ccac073d41f9d15617bb20c3c6c19e
# Parent ce8b3a9fa0de4d7b76bdc4de6691b5935d8b0dd9
Refactor various site views into more generic locations, in preparation for
using access permissions to decide the fuctionality in the view, instead of
having lots of cut-and-paste copies of the same view functions.
site/home.py into more generic home.py
site/settings.py into more generic settings.py
site/docs/list.py into more generic docs/list.py
site/docs/edit.py into more generic docs/edit.py
Patch by: Todd Larsen
Review by: to-be-reviewed
diff -r ce8b3a9fa0de -r d94ec6f104cc app/soc/logic/key_name.py
--- a/app/soc/logic/key_name.py Sat Oct 18 04:56:39 2008 +0000
+++ b/app/soc/logic/key_name.py Sat Oct 18 05:11:37 2008 +0000
@@ -67,10 +67,10 @@
if not path:
raise Error('"path" must be non-False: "%s"' % path)
- return 'SiteSettings:%s' % path
+ return nameHomeSettings(path, entity_type='SiteSettings')
-def nameHomeSettings(path):
+def nameHomeSettings(path, entity_type='HomeSettings'):
"""Returns a HomeSettings key name constructed from a supplied path.
Raises:
@@ -79,7 +79,7 @@
if not path:
raise Error('"path" must be non-False: "%s"' % path)
- return 'HomeSettings:%s' % path
+ return '%s:%s' % (entity_type, path)
def nameUser(email):
diff -r ce8b3a9fa0de -r d94ec6f104cc app/soc/logic/site/map.py
--- a/app/soc/logic/site/map.py Sat Oct 18 04:56:39 2008 +0000
+++ b/app/soc/logic/site/map.py Sat Oct 18 05:11:37 2008 +0000
@@ -30,15 +30,23 @@
from django.conf.urls import defaults
from django.utils import datastructures
+from soc.logic import models
from soc.logic import path_link_name
from soc.logic.site import page
+import soc.logic.models.site_settings
+
# Home Page view
home = page.Page(
page.Url(
r'^$',
- 'soc.views.site.home.public'),
+ 'soc.views.home.public',
+ kwargs={
+ 'path': models.site_settings.logic.DEF_SITE_SETTINGS_PATH,
+ 'entity_type': 'SiteSettings',
+ 'template': 'soc/site/home/public.html',
+ }),
'Google Open Source Programs',
# it should be obvious that every page comes from the home page
in_breadcrumb=False)
@@ -91,7 +99,12 @@
site_home = page.Page(
page.Url(
r'^site/home$',
- 'soc.views.site.home.public'),
+ 'soc.views.home.public',
+ kwargs={
+ 'path': models.site_settings.logic.DEF_SITE_SETTINGS_PATH,
+ 'entity_type': 'SiteSettings',
+ 'template': 'soc/site/home/public.html',
+ }),
'Google Open Source Programs',
# it should be obvious that every page comes from the home page
in_breadcrumb=False)
@@ -99,7 +112,11 @@
site_settings_edit = page.Page(
page.Url(
r'^site/settings/edit$',
- 'soc.views.site.settings.edit'),
+ 'soc.views.settings.edit',
+ kwargs={
+ 'path': models.site_settings.logic.DEF_SITE_SETTINGS_PATH,
+ 'logic': models.site_settings.logic,
+ }),
'Site: Settings',
short_name='Site Settings',
parent=home)
@@ -160,32 +177,32 @@
site_docs_create = page.Page(
page.Url(
- r'^site/docs/edit$',
- 'soc.views.site.docs.edit.create'),
+ r'^docs/edit$',
+ 'soc.views.docs.edit.create'),
'Site: Create New Document',
'Create Site Document',
parent=site_docs_sub_menu)
site_docs_edit = page.Page(
page.Url(
- r'^site/docs/edit/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
- 'soc.views.site.docs.edit.edit'),
+ r'^docs/edit/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
+ 'soc.views.docs.edit.edit'),
'Site: Modify Existing Document',
short_name='Modify Site Document',
parent=site_docs_sub_menu)
site_docs_delete = page.Page(
page.Url(
- r'^site/docs/%s/delete$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
- 'soc.views.site.docs.edit.delete'),
+ r'^docs/delete/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
+ 'soc.views.docs.edit.delete'),
'Site: Delete Existing Document',
short_name='Delete Site Document',
parent=site_docs_sub_menu)
site_docs_list = page.Page(
page.Url(
- r'^site/docs/list$',
- 'soc.views.site.docs.list.all'),
+ r'^docs/list$',
+ 'soc.views.docs.list.all'),
'Site: List of Documents',
short_name='List Site Documents',
parent=site_docs_sub_menu)
diff -r ce8b3a9fa0de -r d94ec6f104cc app/soc/templates/soc/docs/edit.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/docs/edit.html Sat Oct 18 05:11:37 2008 +0000
@@ -0,0 +1,59 @@
+{% 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 %}
+
+{% endblock %}
+{% block header_title %}
+{{ page.short_name }}
+ {% if existing_doc %}
+ "{{ existing_doc.title }}"
+ {% endif %}
+{% endblock %}
+
+{% block body %}
+
+
+{% block instructions %}
+Please use this form to edit the document.
+{% endblock %}
+
+
+
+{% endblock %}
diff -r ce8b3a9fa0de -r d94ec6f104cc app/soc/templates/soc/docs/list/all.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/docs/list/all.html Sat Oct 18 05:11:37 2008 +0000
@@ -0,0 +1,24 @@
+{% 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 %}
+{% load forms_helpers %}
+{% block body %}
+
+
+{% block instructions %}
+{% endblock %}
+
+{% include list_main %}
+
+{% endblock %}
diff -r ce8b3a9fa0de -r d94ec6f104cc app/soc/templates/soc/docs/list/docs_heading.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/docs/list/docs_heading.html Sat Oct 18 05:11:37 2008 +0000
@@ -0,0 +1,9 @@
+
+ Path |
+ Title |
+ Linkname |
+ Featured |
+ Created By |
+ Created On |
+ Modified |
+
diff -r ce8b3a9fa0de -r d94ec6f104cc app/soc/templates/soc/docs/list/docs_row.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/docs/list/docs_row.html Sat Oct 18 05:11:37 2008 +0000
@@ -0,0 +1,15 @@
+
+
+
+ |
+ {{ data_element.title }} |
+ {{ data_element.link_name }} |
+ {{ data_element.is_featured }} |
+ {{ data_element.author.link_name }} |
+ {{ data_element.created }} |
+ {{ data_element.modified }} |
+
diff -r ce8b3a9fa0de -r d94ec6f104cc app/soc/templates/soc/home/public.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/home/public.html Sat Oct 18 05:11:37 2008 +0000
@@ -0,0 +1,63 @@
+{% 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 home_settings.feed_url %}
+
+
+
+{% endif %}
+{% endblock %}
+
+{% block page_title %}
+{% if home_document %}
+{{ home_document.title }}
+{% else %}
+{{ page.long_name }}
+{% endif %}
+{% endblock %}
+
+{% block header_title %}
+{% if home_document %}
+{{ home_document.short_name }}
+{% else %}
+{{ page.short_name }}
+{% endif %}
+{% endblock %}
+
+{% block body %}
+ {% if home_document %}
+ {{ home_document.content|safe }}
+ Last updated on: {{ home_document.modified }}
+ {% else %}
+{% block missing_doc %}
+This is the default home page can be edited via Settings.
+{% endblock %}
+
+ {% endif %}
+ {% if home_settings.feed_url %}
+
+ {% endif %}
+{% endblock %}
\ No newline at end of file
diff -r ce8b3a9fa0de -r d94ec6f104cc app/soc/templates/soc/settings/edit.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/settings/edit.html Sat Oct 18 05:11:37 2008 +0000
@@ -0,0 +1,111 @@
+{% 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 body %}
+
+
+{% block instructions %}
+Please use this form to set basic home page settings.
+{% endblock %}
+
+
+
+