Add the Page object to the context of each view. Update templates to make
use of the newly-available page.long_name and page.short_name.
Patch by: Todd Larsen
Review by: to-be-reviewed
--- a/app/soc/templates/soc/base.html Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/templates/soc/base.html Sat Oct 18 01:47:02 2008 +0000
@@ -18,9 +18,16 @@
{% block stylesheet %}
<link rel="stylesheet" href="/soc/content/css/soc.css" type="text/css"/>
{% endblock %}
- <title>{% block page_title %}Google Open Source Programs{% endblock %}</title>
+ <title>
+ {% block page_title %}
+ {% if page %}
+{{ page.long_name }}
+ {% else %}
+<Missing Page Object>
+ {% endif %}
+ {% endblock %}
+ </title>
{% block scripts %}{% endblock %}
-
</head>
<body>
@@ -53,7 +60,16 @@
</div>
<div id="title">
- {% block header_title %}Google Open Source Programs{% endblock %}
+ {% block header_title %}
+ {% if page %}
+{% comment %}
+TODO(tlarsen): replace this with breadcrumbs
+{% endcomment %}
+ {{ page.short_name }}
+ {% else %}
+<Missing Page Object>
+ {% endif %}
+ {% endblock %}
</div>
<div id="breadcrumbs">
{% block breadcrumbs %}{% endblock %}
--- a/app/soc/templates/soc/group/list/all.html Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/templates/soc/group/list/all.html Sat Oct 18 01:47:02 2008 +0000
@@ -13,12 +13,6 @@
limitations under the License.
{% endcomment %}
{% load forms_helpers %}
-{% block page_title %}
-Site: {{ entity_type_plural }} List
-{% endblock %}
-{% block header_title %}
-{{ entity_type_plural }} List
-{% endblock %}
{% block body %}
<p>
<p>
--- a/app/soc/templates/soc/group/profile/edit.html Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/templates/soc/group/profile/edit.html Sat Oct 18 01:47:02 2008 +0000
@@ -17,21 +17,6 @@
<script type="text/javascript" src="/tiny_mce/tiny_mce_src.js"></script>
{% endblock %}
-{% block page_title %}
-{% if existing_entity %}
-Site: Modify Existing {{ entity_type }}
-{% else %}
-Site: Create New {{ entity_type }}
-{% endif %}
-{% endblock %}
-{% block header_title %}
-{% if entity %}
-Modify Existing {{ entity_type }}
-{% else %}
-Create a New {{ entity_type }}
-{% endif %}
-{% endblock %}
-
{% block body %}
<p>
<p>
--- a/app/soc/templates/soc/group/profile/public.html Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/templates/soc/group/profile/public.html Sat Oct 18 01:47:02 2008 +0000
@@ -13,9 +13,8 @@
limitations under the License.
{% endcomment %}
{% load forms_helpers %}
-{% block page_title %}{{ entity_type }} Public Profile{% endblock %}
{% block header_title %}
-{{ entity_type }} Public Profile for {{ entity.name }}
+{{ page.short_name }} for {{ entity.name }}
{% endblock %}
{% block body %}
<p>
--- a/app/soc/templates/soc/site/docs/edit.html Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/templates/soc/site/docs/edit.html Sat Oct 18 01:47:02 2008 +0000
@@ -16,19 +16,10 @@
{% block scripts %}
<script type="text/javascript" src="/tiny_mce/tiny_mce_src.js"></script>
{% endblock %}
-{% block page_title %}
+{% block header_title %}
+{{ page.short_name }}
{% if existing_doc %}
- Site: Modify Existing Document
- {% else %}
- Site: Create New Document
- {% endif %}
-{% endblock %}
-{% block header_title %}
- {% if existing_doc %}
- Modify Existing Document
<a href="/docs/show/{{ existing_doc.partial_path }}/{{ existing_doc.link_name }}">"{{ existing_doc.title }}"</a>
- {% else %}
- Create a New Document
{% endif %}
{% endblock %}
--- a/app/soc/templates/soc/site/docs/list/all.html Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/templates/soc/site/docs/list/all.html Sat Oct 18 01:47:02 2008 +0000
@@ -13,12 +13,6 @@
limitations under the License.
{% endcomment %}
{% load forms_helpers %}
-{% block page_title %}
-Site: Documents List
-{% endblock %}
-{% block header_title %}
-Documents List
-{% endblock %}
{% block body %}
<p>
<p>
--- a/app/soc/templates/soc/site/user/list/all.html Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/templates/soc/site/user/list/all.html Sat Oct 18 01:47:02 2008 +0000
@@ -13,12 +13,6 @@
limitations under the License.
{% endcomment %}
{% load forms_helpers %}
-{% block page_title %}
-Site: Users List
-{% endblock %}
-{% block header_title %}
-Site: Users List
-{% endblock %}
{% block body %}
<p>
<p>
--- a/app/soc/templates/soc/site/user/profile/edit.html Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/templates/soc/site/user/profile/edit.html Sat Oct 18 01:47:02 2008 +0000
@@ -13,19 +13,11 @@
limitations under the License.
{% endcomment %}
{% load forms_helpers %}
-{% block page_title %}
+{% block header_title %}
+ {{ page.short_name }}
{% if existing_user %}
- Site: Modify Existing User Profile
- {% else %}
- Site: Create New User Profile
- {% endif %}
-{% endblock %}
-{% block header_title %}
- {% if existing_user %}
- Modify Existing User Profile for {{ existing_user.nick_name }}
- <a href="mailto:{{ existing_user.id.email }} "><{{ existing_user.id.email }}></a>
- {% else %}
- Create a New User Profile
+for {{ existing_user.nick_name }}
+<a href="mailto:{{ existing_user.id.email }} "><{{ existing_user.id.email }}></a>
{% endif %}
{% endblock %}
{% block body %}
--- a/app/soc/templates/soc/site/user/profile/lookup.html Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/templates/soc/site/user/profile/lookup.html Sat Oct 18 01:47:02 2008 +0000
@@ -13,12 +13,6 @@
limitations under the License.
{% endcomment %}
{% load forms_helpers %}
-{% block page_title %}
-Developer: Look Up an Existing User Profile
-{% endblock %}
-{% block header_title %}
-Look Up an Existing User Profile
-{% endblock %}
{% block body %}
<p>
<p>
--- a/app/soc/views/simple.py Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/views/simple.py Sat Oct 18 01:47:02 2008 +0000
@@ -61,9 +61,14 @@
template = helper.templates.makeSiblingTemplatesList(template, 'public.html')
+ # TODO(tlarsen): fix getUniversalContext() so that it is back to being a
+ # dict merge of missing defaults (as discussed at length in recent code
+ # reviews)
if not context:
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
+
try:
if link_name:
user = id_user.getUserFromLinkNameOr404(link_name)
--- a/app/soc/views/site/docs/edit.py Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/views/site/docs/edit.py Sat Oct 18 01:47:02 2008 +0000
@@ -132,6 +132,7 @@
# create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
if request.method == 'POST':
form = CreateForm(request.POST)
@@ -194,8 +195,9 @@
except soc.views.out_of_band.AccessViolationResponse, alt_response:
return alt_response.response()
-# create default template context for use with any templates
+ # create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
doc = None # assume that no Document entity will be found
--- a/app/soc/views/site/docs/list.py Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/views/site/docs/list.py Sat Oct 18 01:47:02 2008 +0000
@@ -60,6 +60,7 @@
# create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
offset, limit = helper.lists.cleanListParameters(
offset=request.GET.get('offset'), limit=request.GET.get('limit'))
--- a/app/soc/views/site/home.py Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/views/site/home.py Sat Oct 18 01:47:02 2008 +0000
@@ -53,7 +53,8 @@
"""
# create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
-
+ context['page'] = page
+
site_settings = models.site_settings.logic.getFromFields(
path=models.site_settings.logic.DEF_SITE_SETTINGS_PATH)
--- a/app/soc/views/site/sponsor/list.py Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/views/site/sponsor/list.py Sat Oct 18 01:47:02 2008 +0000
@@ -59,6 +59,7 @@
# create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
offset, limit = helper.lists.cleanListParameters(
offset=request.GET.get('offset'), limit=request.GET.get('limit'))
--- a/app/soc/views/site/sponsor/profile.py Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/views/site/sponsor/profile.py Sat Oct 18 01:47:02 2008 +0000
@@ -113,6 +113,7 @@
# create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
logged_in_id = users.get_current_user()
user = models.user.logic.getFromFields(email=logged_in_id.email())
@@ -208,7 +209,7 @@
def create(request, page=None, template=DEF_SITE_SPONSOR_PROFILE_CREATE_TMPL):
"""create() view is same as edit() view, but with no link_name supplied.
"""
- return edit(request, page, link_name=None, template=template)
+ return edit(request, page=page, link_name=None, template=template)
@decorators.view
@@ -236,6 +237,7 @@
# create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
existing_sponsor = None
--- a/app/soc/views/site/user/list.py Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/views/site/user/list.py Sat Oct 18 01:47:02 2008 +0000
@@ -59,6 +59,7 @@
# create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
offset, limit = helper.lists.cleanListParameters(
offset=request.GET.get('offset'), limit=request.GET.get('limit'))
@@ -67,7 +68,7 @@
users = models.user.logic.getForLimitAndOffset(limit + 1, offset=offset)
context['pagination_form'] = helper.lists.makePaginationForm(request, limit)
-
+
list_templates = {'list_main': 'soc/list/list_main.html',
'list_pagination': 'soc/list/list_pagination.html',
'list_row': 'soc/site/user/list/user_row.html',
--- a/app/soc/views/site/user/profile.py Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/views/site/user/profile.py Sat Oct 18 01:47:02 2008 +0000
@@ -118,6 +118,7 @@
# create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
user = None # assume that no User entity will be found
form = None # assume blank form needs to be displayed
@@ -277,6 +278,7 @@
# create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
user = None # assume that no User entity will be found
@@ -426,6 +428,7 @@
# create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
if request.method == 'POST':
form = CreateForm(request.POST)
--- a/app/soc/views/sponsor/profile.py Sat Oct 18 01:35:08 2008 +0000
+++ b/app/soc/views/sponsor/profile.py Sat Oct 18 01:47:02 2008 +0000
@@ -52,6 +52,7 @@
"""
# create default template context for use with any templates
context = helper.responses.getUniversalContext(request)
+ context['page'] = page
try:
link_name_sponsor = soc.logic.models.sponsor.logic.getIfFields(