# HG changeset patch
# User Todd Larsen
# Date 1218473866 0
# Node ID 8c86470746fcd9a8aaa65904c24bd18cb7415986
# Parent d254d4577c30d06748663640c6d17aa7995505ba
Finished migrating the "proto" app (which only contained a Person profile edit
form) to the new combined trunk/app layout. Also, moved the form template
from profile.html to profile/edit.html, to follow the "one template per view"
approach (rather than have read-write vs. read-only logic in a single
template).
diff -r d254d4577c30 -r 8c86470746fc app/ghop/content/css/ghop.css
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ghop/content/css/ghop.css Mon Aug 11 16:57:46 2008 +0000
@@ -0,0 +1,36 @@
+/*
+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.
+ */
+
+body {
+ font-family: Verdana, Helvetica, sans-serif;
+ background-color: #DDDD00;
+}
+
+td.formfieldrequired {
+ font-style: italic;
+}
+
+td.formfieldhelptext {
+ font-style: italic;
+}
+
+td.formfielderror {
+ color: #FF0000;
+}
+
+td.formfieldheading {
+ font-weight: bold;
+}
diff -r d254d4577c30 -r 8c86470746fc app/ghop/content/images/ghop.jpg
Binary file app/ghop/content/images/ghop.jpg has changed
diff -r d254d4577c30 -r 8c86470746fc app/ghop/templates/ghop/person/profile.html
--- a/app/ghop/templates/ghop/person/profile.html Mon Aug 11 16:44:47 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-{% extends 'soc/person/profile.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 'stylesheet' %}
-
-{% endblock %}
-{% block 'logo' %}
-
-{% endblock %}
diff -r d254d4577c30 -r 8c86470746fc app/ghop/templates/ghop/person/profile/edit.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/ghop/templates/ghop/person/profile/edit.html Mon Aug 11 16:57:46 2008 +0000
@@ -0,0 +1,26 @@
+{% extends 'soc/person/profile/edit.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 'stylesheet' %}
+
+{% endblock %}
+{% block 'logo' %}
+
+{% endblock %}
+{% block 'greeting' %}
+Welcome, {{linkname}} ({{user.nickname}}).
+{% endblock %}
+{% block 'instructions' %}
+Please update your profile for the {{program}} program:
+{% endblock %}
diff -r d254d4577c30 -r 8c86470746fc app/settings.py
--- a/app/settings.py Mon Aug 11 16:44:47 2008 +0000
+++ b/app/settings.py Mon Aug 11 16:57:46 2008 +0000
@@ -93,7 +93,8 @@
ROOT_PATH = os.path.dirname(__file__)
TEMPLATE_DIRS = (
# TODO(proto): customize the template search directories
- os.path.join(ROOT_PATH, 'proto', 'templates'),
+ os.path.join(ROOT_PATH, 'ghop', 'templates'),
+ os.path.join(ROOT_PATH, 'gsoc', 'templates'),
os.path.join(ROOT_PATH, 'soc', 'templates'),
)
diff -r d254d4577c30 -r 8c86470746fc app/soc/templates/soc/person/profile.html
--- a/app/soc/templates/soc/person/profile.html Mon Aug 11 16:44:47 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-{% 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 %}
-
-
-
- Profile
- {% block 'stylesheet' %}{% endblock %}
-
-
-
-
-
-
diff -r d254d4577c30 -r 8c86470746fc app/soc/templates/soc/person/profile/edit.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/person/profile/edit.html Mon Aug 11 16:57:46 2008 +0000
@@ -0,0 +1,113 @@
+{% 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 %}
+
+
+
+ Profile
+ {% block 'stylesheet' %}{% endblock %}
+
+
+
+
+
+
+
+
diff -r d254d4577c30 -r 8c86470746fc app/soc/views/person/__init__.py
diff -r d254d4577c30 -r 8c86470746fc app/soc/views/person/profile.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/person/profile.py Mon Aug 11 16:57:46 2008 +0000
@@ -0,0 +1,91 @@
+#!/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 of Person entity contents, a "profile".
+
+edit: read-write form for modifying Person fields
+
+TODO:
+public: read-only view of "public-only" Person fields
+"""
+
+__authors__ = [
+ '"Augie Fackler" ',
+ '"Todd Larsen" ',
+ ]
+
+
+from google.appengine.api import users
+from django import http
+from django import shortcuts
+from django import newforms as forms
+
+from soc.models import person
+from soc.views.helpers import forms_helpers
+
+
+class EditForm(forms_helpers.DbModelForm):
+ """Django form displayed when creating or editing a Person.
+ """
+
+ class Meta:
+ """Inner Meta class that defines some behavior for the form.
+ """
+ #: db.Model subclass for which the form will gather information
+ model = person.Person
+
+ #: list of model fields which will *not* be gathered by the form
+ exclude = ['user']
+
+
+def edit(request, program=None, linkname=None,
+ template='soc/person/profile/edit.html'):
+ """View for a Person to modify the properties of a Person Model.
+
+ 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))
+
+ # TODO(tlarsen)
+ # if program:
+ # query for the human-readable program name and pass that to the form
+
+ # TODO(tlarsen)
+ # if linkname:
+ # query for a site-wide user profile for a friendly display name
+ # to use in the greeting
+ # else:
+ # use user to query for a site-wide user profile for a friendly
+ # display name to use in the greeting
+
+ form = EditForm()
+ if request.method=='POST':
+ form = EditForm(request.POST)
+
+ if not form.errors:
+ return http.HttpResponse('This would update the model')
+
+ return shortcuts.render_to_response(
+ template, dictionary={'template': template, 'form': form, 'user': user,
+ 'program': program, 'linkname': linkname})
diff -r d254d4577c30 -r 8c86470746fc app/urls.py
--- a/app/urls.py Mon Aug 11 16:44:47 2008 +0000
+++ b/app/urls.py Mon Aug 11 16:57:46 2008 +0000
@@ -22,6 +22,9 @@
urlpatterns = patterns(
'',
- (r'^person/profile/$', 'soc.views.person.profile',
- {'template': 'proto/person/profile.html'}),
+ (r'^org/profile/(?Pghop[_0-9a-z]+)/(?P[_0-9a-z]+)/$',
+ 'soc.views.person.profile.edit',
+ {'template': 'ghop/person/profile/edit.html'}),
+ (r'^org/profile/(?P[_0-9a-z]+)/(?P[_0-9a-z]+)/$',
+ 'soc.views.person.profile.edit'),
)