Created response helper respond() function that is used to generate base templates and it's child templates (handles sign in/out links, user name etc).
Updated User model helper text.
Added basic user profile view (not finished yet).
Added css entries for buttons and added buttons background.
Added /user/profile and /user/profile/linkname support in urls.py.
--- a/app/soc/content/css/soc.css Tue Aug 19 22:37:40 2008 +0000
+++ b/app/soc/content/css/soc.css Tue Aug 19 23:13:24 2008 +0000
@@ -108,7 +108,8 @@
}
th, td {
- padding: 0;
+ /*padding: 0;*/
+ padding:2px 5px;
vertical-align: top;
text-align: left;
}
@@ -130,6 +131,10 @@
td.formfieldheading {
font-weight: bold;
}
+
+ td.formfieldlabel {
+ font-weight: bold;
+ }
/* ---------------------------- */
@@ -188,6 +193,29 @@
padding-bottom: 25px;
}
+ #body .buttons {
+ margin-right: 4px;
+ margin-top: 20px;
+ }
+
+ #body a.button, input[type^="submit"], input[type^="button"] {
+ margin: 0;
+ padding: 2px 5px 2px 5px;
+ font-family: Arial, Sans-serif;
+ font-size: 12px;
+ text-decoration: none;
+ color: #222;
+ cursor: default;
+ background: #ddd url("/soc/content/images/button-background.gif") repeat-x 0 0;
+ border: 1px solid #aaa;
+ }
+
+ #body a.button:hover, input[type^="submit"]:hover, input[type^="button"]:hover {
+ border-color: #9cf #69e #69e #7af;
+ }
+
+
+
#footer {
clear: both;
text-align: center;
Binary file app/soc/content/images/button-background.gif has changed
--- a/app/soc/models/user.py Tue Aug 19 22:37:40 2008 +0000
+++ b/app/soc/models/user.py Tue Aug 19 23:13:24 2008 +0000
@@ -61,5 +61,5 @@
link_name = db.StringProperty(required=True,
verbose_name=ugettext_lazy('Link name'))
link_name.help_text = ugettext_lazy(
- 'Required field used in URLs to identify user.'
- 'Lower ASCII characters only')
+ 'Field used in URLs to identify user. '
+ 'Lower ASCII characters only.')
--- a/app/soc/templates/soc/base.html Tue Aug 19 22:37:40 2008 +0000
+++ b/app/soc/templates/soc/base.html Tue Aug 19 23:13:24 2008 +0000
@@ -27,8 +27,18 @@
<div id="login">
{% block login_links %}
- <a href="http://code.google.com/p/soc/issues/list">Report bugs</a> |
- <a href="/">Sign in</a>
+ {% if user %}
+ <b>{{ user.email }} ({{ user.nickname }})</b> |
+ {% endif %}
+ {% if is_dev %}
+ <a class="novisit" target="_blank" href="/_ah/admin">Admin</a> |
+ {% endif %}
+ <a class="novisit" href="http://code.google.com/p/soc/issues/list">Report bugs</a> |
+ {% if user %}
+ <a class="novisit" href="{{sign_out}}">Sign out</a>
+ {% else %}
+ <a class="novisit" href="{{sign_in}}">Sign in</a>
+ {% endif %}
{% endblock %}
</div>
@@ -45,6 +55,9 @@
<div id="title">
{% block header_title %}Google Open Source Programs{% endblock %}
</div>
+ <div id="breadcrumbs">
+ {% block breadcrumbs %}{% endblock %}
+ </div>
</div>
<div id="side" dir="ltr">
--- a/app/soc/templates/soc/templatetags/_field_as_table_row.html Tue Aug 19 22:37:40 2008 +0000
+++ b/app/soc/templates/soc/templatetags/_field_as_table_row.html Tue Aug 19 23:13:24 2008 +0000
@@ -26,7 +26,7 @@
</label>
</td>
<td class="formfieldrequired">
- {% if field.field.required %}required{% endif %}
+ {% if field.field.required %}(required){% endif %}
</td>
<td>
{{ field }}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/user/profile.html Tue Aug 19 23:13:24 2008 +0000
@@ -0,0 +1,36 @@
+{% 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 %}User Profile{% 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 %}
+ </table>
+ <div class="buttons">
+ <input style="font-weight: bold" type="submit" value="Save Changes"/></span>
+ <input type="button" onclick="location.href='/'" value="Cancel"/>
+ </div>
+</form>
+</p>
+{% endblock %}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/helpers/response_helpers.py Tue Aug 19 23:13:24 2008 +0000
@@ -0,0 +1,73 @@
+#!/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.
+
+"""Helpers used to display various views that are forms.
+"""
+
+__authors__ = [
+ '"Pawel Solyga" <pawel.solyga@gmail.com>',
+ ]
+
+import os
+
+from google.appengine.api import users
+from django import http
+from django import shortcuts
+
+IS_DEV = os.environ['SERVER_SOFTWARE'].startswith('Dev')
+
+# DeadlineExceededError can live in two different places
+try:
+ # When deployed
+ from google.appengine.runtime import DeadlineExceededError
+except ImportError:
+ # In the development server
+ from google.appengine.runtime.apiproxy_errors import DeadlineExceededError
+
+def respond(request, template, params=None):
+ """Helper to render a response, passing standard stuff to the response.
+
+ Args:
+ request: The request object.
+ template: The template name; '.html' is appended automatically.
+ params: A dict giving the template parameters; modified in-place.
+
+ Returns:
+ Whatever render_to_response(template, params) returns.
+
+ Raises:
+ Whatever render_to_response(template, params) raises.
+ """
+ if params is None:
+ params = {}
+
+ params['request'] = request
+ params['user'] = users.get_current_user()
+ params['is_admin'] = users.is_current_user_admin()
+ params['is_dev'] = IS_DEV
+ params['sign_in'] = users.create_login_url(request.path)
+ params['sign_out'] = users.create_logout_url(request.path)
+ try:
+ return shortcuts.render_to_response(template, params)
+ except DeadlineExceededError:
+ logging.exception('DeadlineExceededError')
+ return http.HttpResponse('DeadlineExceededError')
+ except MemoryError:
+ logging.exception('MemoryError')
+ return http.HttpResponse('MemoryError')
+ except AssertionError:
+ logging.exception('AssertionError')
+ return http.HttpResponse('AssertionError')
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/user/profile.py Tue Aug 19 23:13:24 2008 +0000
@@ -0,0 +1,72 @@
+#!/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 relevant to the User role.
+"""
+
+__authors__ = [
+ '"Pawel Solyga" <pawel.solyga@gmail.com>',
+ ]
+
+
+from google.appengine.api import users
+from django import http
+from django import shortcuts
+from django import newforms as forms
+
+from soc.models import user
+from soc.views.helpers import forms_helpers
+from soc.views.helpers import response_helpers
+
+
+class UserForm(forms_helpers.DbModelForm):
+ """Django form displayed when creating or editing a User.
+ """
+
+ class Meta:
+ """Inner Meta class that defines some behavior for the form.
+ """
+ #: db.Model subclass for which the form will gather information
+ model = user.User
+
+ #: list of model fields which will *not* be gathered by the form
+ exclude = ['id']
+
+
+def profile(request, linkname=None, template='soc/user/profile.html'):
+ """View for a User to modify the properties of a UserModel.
+
+ Args:
+ request: the standard django request object.
+ template: the template path to use for rendering the template.
+
+ Returns:
+ A subclass of django.http.HttpResponse which either contains the form to
+ be filled out, or a redirect to the correct view in the interface.
+ """
+ user = users.get_current_user()
+ if not user:
+ return http.HttpResponseRedirect(users.create_login_url(request.path))
+
+ form = UserForm()
+ if request.method=='POST':
+ form = UserForm(request.POST)
+
+ if not form.errors:
+ return http.HttpResponse('This would update the model')
+
+ return response_helpers.respond(request,
+ template, {'template': template, 'form': form})
--- a/app/urls.py Tue Aug 19 22:37:40 2008 +0000
+++ b/app/urls.py Tue Aug 19 23:13:24 2008 +0000
@@ -24,6 +24,8 @@
urlpatterns = patterns(
'',
(r'^$', 'soc.views.site.home.public'),
+ (r'^user/profile$','soc.views.user.profile'),
+ (r'^user/profile/(?P<linkname>[_0-9a-z]+)$','soc.views.user.profile'),
(r'^org/profile/(?P<program>ghop[_0-9a-z]+)/(?P<linkname>[_0-9a-z]+)/$',
'soc.views.person.profile.edit',
{'template': 'ghop/person/profile/edit.html'}),