Refactoring of {site/home}_settings to make them use base.View
This makes the way for deleting the key_name.py module
--- a/app/django/core/urlresolvers.py Wed Nov 05 23:36:28 2008 +0000
+++ b/app/django/core/urlresolvers.py Wed Nov 05 23:38:00 2008 +0000
@@ -131,9 +131,9 @@
except ImportError, e:
mod_name, _ = get_mod_func(self._callback_str)
raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e))
- except AttributeError, e:
- mod_name, func_name = get_mod_func(self._callback_str)
- raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))
+ #except AttributeError, e:
+ #mod_name, func_name = get_mod_func(self._callback_str)
+ #raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))
return self._callback
callback = property(_get_callback)
--- a/app/soc/logic/models/home_settings.py Wed Nov 05 23:36:28 2008 +0000
+++ b/app/soc/logic/models/home_settings.py Wed Nov 05 23:38:00 2008 +0000
@@ -39,9 +39,6 @@
self._name = "HomeSettings"
self._model = soc.models.home_settings.HomeSettings
- # TODO: remove line below when HomeSettings is implemented using
- # views.models.base.View approach
- self._keyName = key_name.nameHomeSettings
self._skip_properties = []
def getKeyValues(self, entity):
@@ -62,5 +59,4 @@
return ['partial_path', 'link_name']
-
logic = Logic()
--- a/app/soc/logic/models/site_settings.py Wed Nov 05 23:36:28 2008 +0000
+++ b/app/soc/logic/models/site_settings.py Wed Nov 05 23:38:00 2008 +0000
@@ -43,10 +43,13 @@
self._name = "SiteSettings"
self._model = soc.models.site_settings.SiteSettings
- # TODO: remove line below when SiteSettings is implemented using
- # views.models.base.View approach
- self._keyName = key_name.nameSiteSettings
self._skip_properties = []
+ def getMainKeyValues(self):
+ """Returns the default key values for the site settings"""
+
+ return [self.DEF_SITE_SETTINGS_PARTIAL_PATH,
+ self.DEF_SITE_SETTINGS_LINK_NAME]
+
logic = Logic()
--- a/app/soc/logic/models/work.py Wed Nov 05 23:36:28 2008 +0000
+++ b/app/soc/logic/models/work.py Wed Nov 05 23:38:00 2008 +0000
@@ -39,11 +39,7 @@
self._name = "Work"
self._model = soc.models.work.Work
- # TODO: remove line below when Work is implemented using
- # views.models.base.View approach
- self._keyName = key_name.nameWork
self._skip_properties = []
- # TODO(tlarsen): write a nameWork method
def getKeyValues(self, entity):
"""See base.Logic.getKeyNameValues.
@@ -63,4 +59,5 @@
return ['link_name']
+
logic = Logic()
--- a/app/soc/logic/site/map.py Wed Nov 05 23:36:28 2008 +0000
+++ b/app/soc/logic/site/map.py Wed Nov 05 23:38:00 2008 +0000
@@ -37,13 +37,7 @@
home = page.Page(
page.Url(
r'^$',
- 'soc.views.home.public',
- kwargs={
- 'partial_path': models.site_settings.logic.DEF_SITE_SETTINGS_PARTIAL_PATH,
- 'link_name': models.site_settings.logic.DEF_SITE_SETTINGS_LINK_NAME,
- 'entity_type': 'SiteSettings',
- 'template': 'soc/home/public.html',
- }),
+ 'soc.views.models.site_settings.main_public'),
'Google Open Source Programs',
# it should be obvious that every page comes from the home page
in_breadcrumb=False)
@@ -99,42 +93,102 @@
# Site Home Page views
site_home = page.Page(
page.Url(
- r'^site/home$',
- 'soc.views.home.public',
- kwargs={
- 'partial_path': models.site_settings.logic.DEF_SITE_SETTINGS_PARTIAL_PATH,
- 'link_name': models.site_settings.logic.DEF_SITE_SETTINGS_LINK_NAME,
- 'entity_type': 'SiteSettings',
- 'template': 'soc/home/public.html',
- }),
+ r'^home$',
+ 'soc.views.models.site_settings.main_public'),
'Google Open Source Programs',
# it should be obvious that every page comes from the home page
in_breadcrumb=False)
+
site_sub_menu = page.NonPage(
'site-sub-menu',
'Site',
parent=home)
+home_settings_sub_menu = page.NonPage(
+ 'home-settings-sub-menu',
+ 'Home Settings',
+ parent=site_sub_menu)
+
+# Site Home Settings views
+home_settings_list = page.Page(
+ page.Url(
+ r'^home/list$',
+ 'soc.views.models.home_settings.list'),
+ 'Site: List Home Settings',
+ short_name='List Home Settings',
+ parent=home_settings_sub_menu)
+
+home_settings_create = page.Page(
+ page.Url(
+ r'^home/create$',
+ 'soc.views.models.home_settings.create'),
+ 'Site: Create New Home Settings',
+ short_name='Create Home Settings',
+ parent=home_settings_sub_menu)
+
+home_settings_edit = page.Page(
+ page.Url(
+ r'^home/edit/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
+ 'soc.views.models.home_settings.edit'),
+ 'Site: Settings',
+ short_name='Edit Site Settings',
+ parent=home_settings_sub_menu)
+
+home_settings_show = page.Page(
+ page.Url(
+ r'^home/show/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
+ 'soc.views.models.home_settings.public'),
+ 'Show Document',
+ parent=home)
+
+
site_settings_sub_menu = page.NonPage(
'site-settings-sub-menu',
'Site Settings',
parent=site_sub_menu)
-# Site User Profile views
+# Site Home Settings views
+site_settings_list = page.Page(
+ page.Url(
+ r'^site/list$',
+ 'soc.views.models.site_settings.list'),
+ 'Site: List Site Settings',
+ short_name='List Site Settings',
+ parent=site_settings_sub_menu)
+
+site_settings_create = page.Page(
+ page.Url(
+ r'^site/create$',
+ 'soc.views.models.site_settings.create'),
+ 'Site: Create New Site Settings',
+ short_name='Create Site Settings',
+ parent=site_settings_sub_menu)
+
site_settings_edit = page.Page(
page.Url(
- r'^settings/edit$',
- 'soc.views.site.settings.edit',
- kwargs={
- 'partial_path': models.site_settings.logic.DEF_SITE_SETTINGS_PARTIAL_PATH,
- 'link_name': models.site_settings.logic.DEF_SITE_SETTINGS_LINK_NAME,
- 'logic': models.site_settings.logic,
- }),
+ r'^site/edit$',
+ 'soc.views.models.site_settings.main_edit'),
+ 'Site: Settings',
+ short_name='Edit Main Site Settings',
+ parent=site_settings_sub_menu)
+
+site_settings_edit = page.Page(
+ page.Url(
+ r'^site/edit/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
+ 'soc.views.models.site_settings.edit'),
'Site: Settings',
short_name='Edit Site Settings',
parent=site_settings_sub_menu)
+site_settings_show = page.Page(
+ page.Url(
+ r'^site/show/%s$' % path_link_name.PATH_LINKNAME_ARGS_PATTERN,
+ 'soc.views.models.site_settings.public'),
+ 'Show Document',
+ parent=home)
+
+
# Site User Profile views
site_user_sub_menu = page.NonPage(
'site-user-sub-menu',
--- a/app/soc/templates/soc/home/public.html Wed Nov 05 23:36:28 2008 +0000
+++ b/app/soc/templates/soc/home/public.html Wed Nov 05 23:38:00 2008 +0000
@@ -1,4 +1,4 @@
-{% extends "soc/home_settings/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.
@@ -13,15 +13,50 @@
limitations under the License.
{% endcomment %}
+{% block scripts %}
+{% if home_settings.feed_url %}
+ <script type="text/javascript" src="http://www.google.com/jsapi"></script>
+ <script type="text/javascript" src="/soc/content/js/blog-080819.js"></script>
+ <script type="text/javascript">
+
+ google.load("feeds", "1");
+
+ function initialize() {
+ var blog = new BlogPreview(document.getElementById("blog"));
+ blog.show("{{ home_settings.feed_url }}");
+ }
+ google.setOnLoadCallback(initialize);
+
+ </script>
+{% 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 }}
+ <div id="lastmodified">Last updated on: {{ home_document.modified }}</div>
+ {% else %}
{% block missing_doc %}
-The contents of this default Site home page can be changed by
-<a href="/docs/edit">creating a new Document</a> or
-<a href="/docs/list">editing an existing Document</a> and then selecting
-that Document in the
-<a href="/settings/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="/settings/edit">Site Settings</a> interface.
-You need to sign in as site Developer in order to change
-<a href="/settings/edit">Site Settings</a>.
+This is the default home page can be edited via Settings.
{% endblock %}
+ {% endif %}
+ {% if home_settings.feed_url %}
+ <div id="blog"></div>
+ {% endif %}
+{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/home_settings/error.html Wed Nov 05 23:38:00 2008 +0000
@@ -0,0 +1,27 @@
+{% 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 page_title %}
+Default Home page
+{% endblock %}
+
+{% block header_title %}
+Default Home page
+{% endblock %}
+
+{% block body %}
+This is the default home page can be edited via Settings.<BR>
+You are seeing this page because the specified Home page could not be found.
+{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/home_settings/list/home_heading.html Wed Nov 05 23:38:00 2008 +0000
@@ -0,0 +1,4 @@
+<tr align="left">
+ <th class="first" align="right">Path</th>
+ <th>Home Document</th>
+</tr>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/home_settings/list/home_row.html Wed Nov 05 23:38:00 2008 +0000
@@ -0,0 +1,10 @@
+<tr class="off" onmouseover="this.className='on'" onmouseout="this.className='off'"
+onclick="document.location.href='/home/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}'" name="name">
+ <td align="right">
+ <div class="title">
+ <a class="noul"
+ href="/home/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}">{{ data_element.partial_path}}/{{ data_element.link_name }}</a>
+ </div>
+ </td>
+ <td><div class="link_name">{{ data_element.home.title }}</div></td>
+</tr>
--- a/app/soc/templates/soc/home_settings/public.html Wed Nov 05 23:36:28 2008 +0000
+++ b/app/soc/templates/soc/home_settings/public.html Wed Nov 05 23:38:00 2008 +0000
@@ -1,4 +1,4 @@
-{% extends "soc/base.html" %}
+{% extends "soc/home/public.html" %}
{% comment %}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -13,50 +13,15 @@
limitations under the License.
{% endcomment %}
-{% block scripts %}
-{% if home_settings.feed_url %}
- <script type="text/javascript" src="http://www.google.com/jsapi"></script>
- <script type="text/javascript" src="/soc/content/js/blog-080819.js"></script>
- <script type="text/javascript">
-
- google.load("feeds", "1");
-
- function initialize() {
- var blog = new BlogPreview(document.getElementById("blog"));
- blog.show("{{ home_settings.feed_url }}");
- }
- google.setOnLoadCallback(initialize);
-
- </script>
-{% endif %}
+{% block missing_doc %}
+The contents of this default Site home page can be changed by
+<a href="/docs/edit">creating a new Document</a> or
+<a href="/docs/list">editing an existing Document</a> and then selecting
+that Document in the
+<a href="/settings/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="/settings/edit">Site Settings</a> interface.
+You need to sign in as site Developer in order to change
+<a href="/settings/edit">Site Settings</a>.
{% 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 }}
- <div id="lastmodified">Last updated on: {{ home_document.modified }}</div>
- {% else %}
-{% block missing_doc %}
-This is the default home page can be edited via Settings.
-{% endblock %}
- {% endif %}
- {% if home_settings.feed_url %}
- <div id="blog"></div>
- {% endif %}
-{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/site_settings/list/site_heading.html Wed Nov 05 23:38:00 2008 +0000
@@ -0,0 +1,4 @@
+<tr align="left">
+ <th class="first" align="right">Path</th>
+ <th>Home Document</th>
+</tr>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/site_settings/list/site_row.html Wed Nov 05 23:38:00 2008 +0000
@@ -0,0 +1,10 @@
+<tr class="off" onmouseover="this.className='on'" onmouseout="this.className='off'"
+onclick="document.location.href='/site/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}'" name="name">
+ <td align="right">
+ <div class="title">
+ <a class="noul"
+ href="/site/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}">{{ data_element.partial_path}}/{{ data_element.link_name }}</a>
+ </div>
+ </td>
+ <td><div class="link_name">{{ data_element.home.title }}</div></td>
+</tr>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/user/edit.html Wed Nov 05 23:38:00 2008 +0000
@@ -0,0 +1,82 @@
+{% 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 header_title %}
+ {{ page.short_name }}
+ {% if existing_user %}
+for {{ existing_user.nick_name }}
+<a href="mailto:{{ existing_user.id.email }} "><{{ existing_user.id.email }}></a>
+ {% endif %}
+{% endblock %}
+{% block body %}
+<p>
+<p>
+{% block instructions %}
+Please use this form to alter basic site-wide settings for a User in Google Open Source Programs.
+{% endblock %}
+</p>
+<form method="POST">
+ {{ form.key_name }}
+ <table>
+ {% if existing_user %}
+ {% readonly_field_as_table_row "Id" existing_user.id %}
+ {% endif %}
+ {% field_as_table_row form.id %}
+{% if lookup_error %}
+<tr>
+ <td> </td>
+ <td colspan="3" class="formfielderror">
+ {{ lookup_error }}
+ </td>
+</tr>
+{% endif %}
+ {% field_as_table_row form.link_name %}
+ {% field_as_table_row form.nick_name %}
+ {% field_as_table_row form.is_developer %}
+ {% if existing_user.former_ids %}
+ <tr>
+ <td class="formfieldlabel">Former ids</td>
+ <td>
+ {% for former_id in existing_user.former_ids %}
+ {{ former_id }}<br />
+ {% endfor %}
+ </td>
+ <td class="formfieldrequired"> </td>
+ <td class="formfieldhelptext"> </td>
+ </tr>
+ {% endif %}
+ <tr>
+ <td colspan="4"> </td>
+ </tr>
+ <table>
+ <tr>
+ {% block submit_buttons %}
+ <td>
+ <input style="font-weight: bold" type="submit" value="Save Changes"/></span>
+ </td>
+ <td>
+ <input type="button" onclick="location.href='/'" value="Cancel"/>
+ </td>
+ {% if submit_error %}
+ <td class="formfielderror">
+ {{ submit_error }}
+ </td>
+ {% endif %}
+ {% endblock %}
+ </tr>
+ </table>
+</form>
+</p>
+{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/user/edit_self.html Wed Nov 05 23:38:00 2008 +0000
@@ -0,0 +1,53 @@
+{% 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 page_title %}User Profile{% endblock %}
+{% block header_title %}
+{% if user %}
+Modify Existing User Profile for {{ user.nick_name }} <a href="mailto:{{ id.email }} "><{{ id.email }}></a>
+{% else %}
+Create a New User Profile for <a href="mailto:{{ id.email }} "><{{ id.email }}></a>
+{% endif %}
+{% endblock %}
+{% block body %}
+<p>
+<p>
+{% block instructions %}
+Please use this form to set basic site-wide settings for your participation in Google Open Source Programs.
+{% endblock %}
+</p>
+<form method="POST">
+ <table>
+ {% field_as_table_row form.nick_name %}
+ {% field_as_table_row form.link_name %}
+ <tr>
+ <td colspan="4"> </td>
+ </tr>
+ </table>
+ <table>
+ <tr>
+ {% block submit_buttons %}
+ <td>
+ <input style="font-weight: bold" type="submit" value="Save Changes"/></span>
+ </td>
+ <td>
+ <input type="button" onclick="location.href='/'" value="Cancel"/>
+ </td>
+ {% endblock %}
+ </tr>
+ </table>
+</form>
+</p>
+{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/user/lookup.html Wed Nov 05 23:38:00 2008 +0000
@@ -0,0 +1,109 @@
+{% 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 %}
+<p>
+<p>
+{% block instructions %}
+Please use this form to look up an existing User in Google Open Source Programs.
+{% endblock %}
+</p>
+<form method="POST">
+ <table>
+{% if found_user %}
+{% readonly_field_as_table_row "Id" found_user.id %}
+{% endif %}
+{% if email_error %}
+<tr>
+ <td> </td>
+ <td colspan="3" class="formfielderror">
+ {{ email_error }}
+ </td>
+</tr>
+{% endif %}
+ {% field_as_table_row form.id %}
+{% if link_name_error %}
+<tr>
+ <td> </td>
+ <td colspan="3" class="formfielderror">
+ {{ link_name_error }}
+ </td>
+</tr>
+{% endif %}
+ {% field_as_table_row form.link_name %}
+{% if found_user %}
+ <tr>
+ <td class="formfieldlabel">Nick name</td>
+ <td>{{ found_user.nick_name }}</td>
+ <td class="formfieldrequired"> </td>
+ <td class="formfieldhelptext"> </td>
+ </tr>
+ <tr>
+ <td class="formfieldlabel">Is Developer</td>
+ <td>{{ found_user.is_developer }}</td>
+ <td class="formfieldrequired"> </td>
+ <td class="formfieldhelptext"> </td>
+ </tr>
+
+ {% if found_user.former_ids %}
+ <tr>
+ <td class="formfieldlabel">Former ids</td>
+ <td>
+ {% for former_id in found_user.former_ids %}
+ {{ former_id }}<br />
+ {% endfor %}
+ </td>
+ <td class="formfieldrequired"> </td>
+ <td class="formfieldhelptext"> </td>
+ </tr>
+ {% endif %}
+{% endif %}
+ <tr>
+ <td colspan="4"> </td>
+ </tr>
+ <tr>
+ <td>
+ <input type="submit" style="font-weight: bold" name="lookup" value="Look up User"/></span>
+ </td>
+ <td colspan="2"> </td>
+ <td>
+ {% if lookup_message %}<b><i>{{ lookup_message }}</i></b>{% else %} {% endif %}
+ </td>
+ </tr>
+{% if edit_link %}
+ <tr>
+ <td colspan="4"> </td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <a href="{{ edit_link }}">Edit the User profile of {{ found_user.nick_name }}.</a>
+ </td>
+ </tr>
+{% endif %}
+{% if lookup_link %}
+ <tr>
+ <td colspan="4"> </td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <a href="{{ lookup_link }}">The specified User was not found, but similar
+ Users are listed here.</a>
+ </td>
+ </tr>
+{% endif %}
+ </table>
+</form>
+</p>
+{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/user/public.html Wed Nov 05 23:38:00 2008 +0000
@@ -0,0 +1,27 @@
+{% 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 page_title %}User Public Profile{% endblock %}
+{% block header_title %}
+User Public Profile for {{ link_name_user.nick_name }}
+{% endblock %}
+{% block body %}
+<p>
+ <table>
+ {% readonly_field_as_table_row link_name_user.fields.nick_name.label link_name_user.nick_name %}
+ {% readonly_field_as_table_row link_name_user.fields.link_name.label link_name_user.link_name %}
+ </table>
+</p>
+{% endblock %}
--- a/app/soc/views/helper/access.py Wed Nov 05 23:36:28 2008 +0000
+++ b/app/soc/views/helper/access.py Wed Nov 05 23:38:00 2008 +0000
@@ -47,7 +47,7 @@
'Please <a href="%(sign_in)s">sign in</a> to continue.')
DEF_NO_USER_LOGIN_MSG_FMT = ugettext_lazy(
- 'Please create <a href="/user/profile">User Profile</a>'
+ 'Please create <a href="/user/edit">User Profile</a>'
' in order to view this page.')
DEF_DEV_LOGOUT_LOGIN_MSG_FMT = ugettext_lazy(
--- a/app/soc/views/models/base.py Wed Nov 05 23:36:28 2008 +0000
+++ b/app/soc/views/models/base.py Wed Nov 05 23:38:00 2008 +0000
@@ -55,7 +55,7 @@
' <a href="%(create)s">Create '
'a New %(entity_type)s</a> page.')
- def __init__(self, params=None, rights=None):
+ def __init__(self, params=None, rights=None, stop=False):
"""
Args:
@@ -104,6 +104,10 @@
context['page'] = page
entity = None
+ if not all(kwargs.values()):
+ #TODO: Change this into a proper redirect
+ return http.HttpResponseRedirect('/')
+
try:
key_fields = self._logic.getKeyFieldsFromDict(kwargs)
entity = self._logic.getIfFields(key_fields)
@@ -111,9 +115,7 @@
template = self._params['public_template']
return simple.errorResponse(request, page, error, template, context)
- if not entity:
- #TODO: Change this into a proper redirect
- return http.HttpResponseRedirect('/')
+ self._public(request, entity, context)
context['entity'] = entity
context['entity_type'] = self._params['name']
@@ -331,7 +333,18 @@
fields: the new field values
"""
- raise NotImplementedError
+ pass
+
+ def _public(self, request, entity, context):
+ """Performs any required processing to get an entities public page
+
+ Args:
+ request: the django request object
+ entity: the entity to make public
+ context: the context object
+ """
+
+ pass
def _editGet(self, request, entity, form):
"""Performs any required processing on the form to get its edit page
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/models/home_settings.py Wed Nov 05 23:38:00 2008 +0000
@@ -0,0 +1,184 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# 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.
+
+"""Views for Home Settings.
+"""
+
+__authors__ = [
+ '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+ ]
+
+
+from google.appengine.ext import db
+from google.appengine.api import users
+
+from django import forms
+from django.utils.translation import ugettext_lazy
+
+from soc.logic import dicts
+from soc.logic import validate
+from soc.views import helper
+from soc.views.helper import widgets
+from soc.views.models import base
+
+import soc.models.home_settings
+import soc.logic.models.home_settings
+import soc.logic.dicts
+import soc.views.helper
+import soc.views.helper.widgets
+
+
+class SettingsValidationForm(helper.forms.BaseForm):
+ """Django form displayed when creating or editing Settings.
+
+ This form includes validation functions for Settings fields.
+ """
+
+ # TODO(tlarsen): partial_path will be a hard-coded read-only
+ # field for some (most?) User Roles
+ doc_partial_path = forms.CharField(required=False,
+ label=soc.models.work.Work.partial_path.verbose_name,
+ help_text=soc.models.work.Work.partial_path.help_text)
+
+ # TODO(tlarsen): actually, using these two text fields to specify
+ # the Document is pretty cheesy; this needs to be some much better
+ # Role-scoped Document selector that we don't have yet
+ doc_link_name = forms.CharField(required=False,
+ label=soc.models.work.Work.link_name.verbose_name,
+ help_text=soc.models.work.Work.link_name.help_text)
+
+ def clean_feed_url(self):
+ feed_url = self.cleaned_data.get('feed_url')
+
+ if feed_url == '':
+ # feed url not supplied (which is OK), so do not try to validate it
+ return None
+
+ if not validate.isFeedURLValid(feed_url):
+ raise forms.ValidationError('This URL is not a valid ATOM or RSS feed.')
+
+ return feed_url
+
+
+class CreateForm(SettingsValidationForm):
+ """Django form displayed when creating or editing Settings.
+ """
+
+ class Meta:
+ """Inner Meta class that defines some behavior for the form.
+ """
+ #: db.Model subclass for which the form will gather information
+ model = soc.models.home_settings.HomeSettings
+
+ #: list of model fields which will *not* be gathered by the form
+ exclude = ['inheritance_line', 'home']
+
+
+class EditForm(CreateForm):
+ """Django form displayed a Document is edited.
+ """
+
+ pass
+
+
+class View(base.View):
+ """View methods for the Docs model
+ """
+
+ def __init__(self, original_params=None, original_rights=None, stop=False):
+ """Defines the fields and methods required for the base View class
+ to provide the user with list, public, create, edit and delete views.
+
+ Params:
+ original_params: a dict with params for this View
+ original_rights: a dict with right definitions for this View
+ """
+
+ params = {}
+ rights = {}
+
+ params['name'] = "HomeSetting"
+ params['name_short'] = "Home"
+ params['name_plural'] = "HomeSettings"
+
+ params['edit_form'] = EditForm
+ params['create_form'] = CreateForm
+
+ # TODO(tlarsen) Add support for Django style template lookup
+ params['edit_template'] = 'soc/models/edit.html'
+ params['public_template'] = 'soc/home_settings/public.html'
+ params['list_template'] = 'soc/models/list.html'
+
+ params['lists_template'] = {
+ 'list_main': 'soc/list/list_main.html',
+ 'list_pagination': 'soc/list/list_pagination.html',
+ 'list_row': 'soc/home_settings/list/home_row.html',
+ 'list_heading': 'soc/home_settings/list/home_heading.html',
+ }
+
+ params['delete_redirect'] = 'home/list'
+ params['create_redirect'] = 'home/edit'
+
+ params['save_message'] = [ugettext_lazy('Profile saved.')]
+
+ params['edit_params'] = {
+ self.DEF_SUBMIT_MSG_PARAM_NAME: self.DEF_SUBMIT_MSG_PROFILE_SAVED,
+ }
+
+ rights['list'] = [helper.access.checkIsDeveloper]
+ rights['delete'] = [helper.access.checkIsDeveloper]
+
+ params = dicts.merge(original_params, params)
+ rights = dicts.merge(original_rights, rights)
+
+ base.View.__init__(self, rights=rights, params=params, stop=stop)
+
+ self._logic = soc.logic.models.home_settings.logic
+
+ def _public(self, request, entity, context):
+ """
+ """
+
+ if not entity:
+ return
+
+ try:
+ home_doc = entity.home
+ except db.Error:
+ home_doc = None
+
+ if home_doc:
+ home_doc.content = helper.templates.unescape(home_doc.content)
+ context['home_document'] = home_doc
+
+ def _editGet(self, request, entity, form):
+ """See base.View._editGet().
+ """
+
+ try:
+ form.fields['doc_partial_path'].initial = entity.home.partial_path
+ form.fields['doc_link_name'].initial = entity.home.link_name
+ except db.Error:
+ pass
+
+
+view = View()
+
+create = view.create
+edit = view.edit
+delete = view.delete
+list = view.list
+public = view.public
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/models/site_settings.py Wed Nov 05 23:38:00 2008 +0000
@@ -0,0 +1,144 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# 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.
+
+"""Views for Site Settings.
+"""
+
+__authors__ = [
+ '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+ ]
+
+
+from google.appengine.ext import db
+from google.appengine.api import users
+
+from django import forms
+from django.utils.translation import ugettext_lazy
+
+from soc.logic import dicts
+from soc.logic import validate
+from soc.views import helper
+from soc.views.helper import widgets
+from soc.views.models import home_settings
+
+import soc.models.site_settings
+import soc.logic.models.site_settings
+import soc.logic.dicts
+import soc.views.helper
+import soc.views.helper.widgets
+
+
+class CreateForm(home_settings.SettingsValidationForm):
+ """Django form displayed when creating or editing Site Settings.
+ """
+
+ class Meta:
+ """Inner Meta class that defines some behavior for the form.
+ """
+ #: db.Model subclass for which the form will gather information
+ model = soc.models.site_settings.SiteSettings
+
+ #: list of model fields which will *not* be gathered by the form
+ exclude = ['inheritance_line', 'home']
+
+
+class EditForm(CreateForm):
+ """Django form displayed a Document is edited.
+ """
+
+ pass
+
+
+class View(home_settings.View):
+ """View methods for the Docs model
+ """
+
+ def __init__(self, original_params=None, original_rights=None):
+ """Defines the fields and methods required for the base View class
+ to provide the user with list, public, create, edit and delete views.
+
+ Params:
+ original_params: a dict with params for this View
+ original_rights: a dict with right definitions for this View
+ """
+
+ params = {}
+ rights = {}
+
+ params['name'] = "SiteSetting"
+ params['name_short'] = "Site"
+ params['name_plural'] = "SiteSettings"
+
+ params['edit_form'] = EditForm
+ params['create_form'] = CreateForm
+
+ params['lists_template'] = {
+ 'list_main': 'soc/list/list_main.html',
+ 'list_pagination': 'soc/list/list_pagination.html',
+ 'list_row': 'soc/site_settings/list/site_row.html',
+ 'list_heading': 'soc/site_settings/list/site_heading.html',
+ }
+
+ params['delete_redirect'] = 'site/list'
+ params['create_redirect'] = 'site/edit'
+
+ params = dicts.merge(original_params, params)
+ rights = dicts.merge(original_rights, rights)
+
+ home_settings.View.__init__(self, original_rights=rights, original_params=params, stop=True)
+
+ self._logic = soc.logic.models.site_settings.logic
+
+ def main_public(self, request, page=None, **kwargs):
+ """Displays the main site settings page
+
+ Args:
+ request: the standard Django HTTP request object
+ page: a soc.logic.site.page.Page object
+ kwargs: not used
+ """
+
+ keys = self._logic.getKeyFieldNames()
+ values = self._logic.getMainKeyValues()
+ key_values = dicts.zip(keys, values)
+
+ return self.public(request, page, **key_values)
+
+ def main_edit(self, request, page=None, **kwargs):
+ """Displays the edit page for the main site settings page
+
+ Args:
+ request: the standard Django HTTP request object
+ page: a soc.logic.site.page.Page object
+ kwargs: not used
+ """
+
+ keys = self._logic.getKeyFieldNames()
+ values = self._logic.getMainKeyValues()
+ key_values = dicts.zip(keys, values)
+
+ return self.edit(request, page, **key_values)
+
+
+view = View()
+
+create = view.create
+edit = view.edit
+delete = view.delete
+list = view.list
+public = view.public
+main_public = view.main_public
+main_edit = view.main_edit
--- a/app/soc/views/user/profile.py Wed Nov 05 23:36:28 2008 +0000
+++ b/app/soc/views/user/profile.py Wed Nov 05 23:38:00 2008 +0000
@@ -68,7 +68,7 @@
return link_name
-DEF_USER_PROFILE_EDIT_TMPL = 'soc/user/profile/edit.html'
+DEF_USER_PROFILE_EDIT_TMPL = 'soc/user/edit_self.html'
SUBMIT_MSG_PARAM_NAME = 's'