Addressed comments by Pawel and Todd
Patch by: Sverre Rabbelier
Reviewed by: to-be-reviewed
--- a/app/soc/logic/models/host.py Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/logic/models/host.py Thu Oct 23 05:21:26 2008 +0000
@@ -29,7 +29,7 @@
class Logic(base.Logic):
- """Logic methods for the Work model
+ """Logic methods for the Host model
"""
def __init__(self):
--- a/app/soc/logic/path_link_name.py Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/logic/path_link_name.py Thu Oct 23 05:21:26 2008 +0000
@@ -32,7 +32,6 @@
# zero or more of OR group
LINKNAME_PATTERN_CORE = r'[0-9a-z](?:[0-9a-z]|_[0-9a-z])*'
LINKNAME_ARG_PATTERN = r'(?P<link_name>%s)' % LINKNAME_PATTERN_CORE
-GENERIC_ARG_PATTERN = r'(?P<%%s>%s)' % LINKNAME_PATTERN_CORE
LINKNAME_PATTERN = r'^%s$' % LINKNAME_PATTERN_CORE
LINKNAME_REGEX = re.compile(LINKNAME_PATTERN)
--- a/app/soc/logic/site/map.py Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/logic/site/map.py Thu Oct 23 05:21:26 2008 +0000
@@ -250,17 +250,16 @@
short_name='List Site Sponsors',
parent=site_sponsor_sub_menu)
-# Host Group public view
+# Host public view
host_profile = page.Page(
page.Url(
- r'^host/profile/%s/%s$' %
- (path_link_name.GENERIC_ARG_PATTERN % 'sponsor_ln',
- path_link_name.GENERIC_ARG_PATTERN % 'user_ln'),
+ r'^host/profile/(?P<sponsor_ln>%(lnp)s)/(?P<user_ln>%(lnp)s)$' % {
+ 'lnp': path_link_name.LINKNAME_PATTERN_CORE},
'soc.views.models.host.public'),
'Host Public Profile',
parent=home)
-# Host Group Site views
+# Host Site views
site_host_sub_menu = page.NonPage(
'site-host-sub-menu',
'Site: Host Sub-Menu',
@@ -277,9 +276,8 @@
site_host_delete = page.Page(
page.Url(
- r'^site/host/delete/%s/%s$' %
- (path_link_name.GENERIC_ARG_PATTERN % 'sponsor_ln',
- path_link_name.GENERIC_ARG_PATTERN % 'user_ln'),
+ r'^site/host/delete/(?P<sponsor_ln>%(lnp)s)/(?P<user_ln>%(lnp)s)$' % {
+ 'lnp': path_link_name.LINKNAME_PATTERN_CORE},
'soc.views.models.host.delete'),
'Site: Delete Existing Host',
short_name='Delete Site Host',
@@ -287,9 +285,8 @@
site_host_edit = page.Page(
page.Url(
- r'^site/host/profile/%s/%s$' %
- (path_link_name.GENERIC_ARG_PATTERN % 'sponsor_ln',
- path_link_name.GENERIC_ARG_PATTERN % 'user_ln'),
+ r'^site/host/profile/(?P<sponsor_ln>%(lnp)s)/(?P<user_ln>%(lnp)s)$' % {
+ 'lnp': path_link_name.LINKNAME_PATTERN_CORE},
'soc.views.models.host.edit'),
'Site: Modify Existing Host',
short_name='Modify Site Host',
--- a/app/soc/models/base.py Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/models/base.py Thu Oct 23 05:21:26 2008 +0000
@@ -80,5 +80,4 @@
model = cls
cls._fields_cache = FieldsProxy()
- raise
return cls._fields_cache
--- a/app/soc/templates/soc/group/profile/public.html Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/templates/soc/group/profile/public.html Thu Oct 23 05:21:26 2008 +0000
@@ -13,9 +13,11 @@
limitations under the License.
{% endcomment %}
{% load forms_helpers %}
+
{% block header_title %}
{{ page.short_name }} for {{ entity.name }}
{% endblock %}
+
{% block body %}
<p>
<table>
--- a/app/soc/templates/soc/host/group_heading.html Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/templates/soc/host/group_heading.html Thu Oct 23 05:21:26 2008 +0000
@@ -1,5 +1,6 @@
<tr align="left">
- <th class="first" align="right">Name</th>
- <th>Sponsor</th>
- <th>Link name</th>
+ <th class="first" align="right">User linkname</th>
+ <th>Host linkname</th>
+ <th>Given name</th>
+ <th>Surname</th>
</tr>
--- a/app/soc/templates/soc/host/group_row.html Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/templates/soc/host/group_row.html Thu Oct 23 05:21:26 2008 +0000
@@ -1,9 +1,10 @@
<tr class="off" onmouseover="this.className='on'" onmouseout="this.className='off'"
-onclick="document.location.href='/site/{{ entity_type|lower }}/profile/{{ data_element.sponsor_ln }}/{{ data_element.user_ln }}'" name="name">
+onclick="document.location.href='/site/{{ entity_type|lower }}/profile/{{ data_element.sponsor.link_name }}/{{ data_element.user.link_name }}'" name="name">
<td align="right"><div class="name"><a class="noul"
- href="/site/{{ entity_type|lower }}/profile/{{ data_element.sponsor_ln }}/{{ data_element.user_ln }}">{{ data_element.given_name }} {{ data_element.surname}}</a>
+ href="/site/{{ entity_type|lower }}/profile/{{ data_element.sponsor.link_name }}/{{ data_element.user.link_name }}">{{ data_element.user.link_name }}</a>
</div>
</td>
- <td><div class="sponsor">{{ data_element.sponsor.link_name }}</div></td>
- <td><div class="link_name">{{ data_element.user.link_name }}</div></td>
+ <td><div class="sponsor_link_name">{{ data_element.sponsor.link_name }}</div></td>
+ <td><div class="given_name">{{ data_element.given_name }}</div></td>
+ <td><div class="surname">{{ data_element.surname }}</div></td>
</tr>
--- a/app/soc/templates/soc/host/public.html Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/templates/soc/host/public.html Thu Oct 23 05:21:26 2008 +0000
@@ -12,18 +12,26 @@
See the License for the specific language governing permissions and
limitations under the License.
{% endcomment %}
+{% load forms_helpers %}
{% block page_title %}
-{{ entity.title }}
+{{ entity.user.link_name }}
{% endblock %}
{% block header_title %}
-{{ entity.title }}
+{{ entity.user.link_name }}
{% endblock %}
{% block body %}
-<div id="createdon">Created on: {{ entity.created }}</div>
-<div id="createdby">Created by: {{ entity.author.nick_name }}</div>
-<div id="content">{{ entity.content|safe }}</div>
-<div id="lastmodified">Last updated on: {{ entity.modified }}</div>
+<p>
+ <table>
+ {% readonly_field_as_table_row entity.fields.given_name.label entity.given_name %}
+ {% readonly_field_as_table_row entity.fields.surname.label entity.surname %}
+ {% readonly_field_as_table_row entity.fields.display_name.label entity.display_name %}
+ {% readonly_field_as_table_row entity.fields.surname.label entity.surname %}
+ {% readonly_field_as_table_row entity.fields.display_name.label entity.display_name %}
+ {% readonly_field_as_table_row entity.fields.email.label entity.email %}
+ <!-- TODO(pawel.solyga) make this generic -->
+ </table>
+</p>
{% endblock %}
--- a/app/soc/templates/soc/models/edit.html Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/templates/soc/models/edit.html Thu Oct 23 05:21:26 2008 +0000
@@ -33,7 +33,7 @@
</p>
<form method="POST">
<table>
- {{ form.as_table }}
+ {{ form.as_table }}
<tr>
<td colspan="4"> </td>
</tr>
--- a/app/soc/views/models/base.py Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/views/models/base.py Thu Oct 23 05:21:26 2008 +0000
@@ -26,6 +26,7 @@
from django.utils.translation import ugettext_lazy
import soc.logic
+import soc.logic.dicts
import soc.logic.out_of_band
import soc.views.helper.lists
import soc.views.helper.responses
@@ -288,7 +289,7 @@
try:
entity = self._logic.getIfFields(**kwargs)
except soc.logic.out_of_band.ErrorResponse, error:
- template = self._params['create_template']
+ template = self._params['edit_template']
error.message = error.message + self.DEF_CREATE_NEW_ENTITY_MSG % {
'entity_type_lower' : self._params['name'].lower(),
'entity_type' : self._params['name'],
--- a/app/soc/views/models/host.py Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/views/models/host.py Thu Oct 23 05:21:26 2008 +0000
@@ -22,22 +22,15 @@
]
-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.host
import soc.logic.models.host
-import soc.logic.dicts
import soc.views.helper
-import soc.views.helper.widgets
class CreateForm(helper.forms.BaseForm):
@@ -102,7 +95,7 @@
# TODO(tlarsen) Add support for Django style template lookup
params['edit_template'] = 'soc/models/edit.html'
- params['public_template'] = 'soc/models/public.html'
+ params['public_template'] = 'soc/host/public.html'
params['list_template'] = 'soc/list/all.html'
params['lists_template'] = {
@@ -130,7 +123,7 @@
base.View.__init__(self, rights=rights, params=params)
def _editPost(self, request, entity, fields):
- """
+ """See base.View._editPost().
"""
fields['sponsor_ln'] = fields['sponsor'].link_name
--- a/app/soc/views/models/sponsor.py Wed Oct 22 17:18:57 2008 +0000
+++ b/app/soc/views/models/sponsor.py Thu Oct 23 05:21:26 2008 +0000
@@ -136,7 +136,9 @@
"""See base.View._editPost().
"""
- pass
+ id = users.get_current_user()
+ user = soc.logic.models.user.logic.getFromFields(email=id.email())
+ fields['founder'] = user
view = View()