Show "Created by" read-only field in Sponsor Edit view. Fix function keyword arguments in sponsor/list.py to follow our PythonStyleGuide. Sponsor founder property is not updated anymore when editing Sponsor profile, it's just saved once when creating Sponsor profile.
Patch by: Pawel Solyga
Review by: to-be-reviewed
--- a/app/soc/templates/soc/group/profile/edit.html Wed Oct 15 13:54:00 2008 +0000
+++ b/app/soc/templates/soc/group/profile/edit.html Wed Oct 15 13:59:52 2008 +0000
@@ -44,6 +44,9 @@
{% field_as_table_row form.name %}
{% field_as_table_row form.link_name %}
{% field_as_table_row form.short_name %}
+ {% if form.created_by %}
+ {% field_as_table_row form.created_by %}
+ {% endif %}
{% field_as_table_row form.home_page %}
{% field_as_table_row form.email %}
{% field_as_table_row form.description %}
--- a/app/soc/views/site/sponsor/list.py Wed Oct 15 13:54:00 2008 +0000
+++ b/app/soc/views/site/sponsor/list.py Wed Oct 15 13:59:52 2008 +0000
@@ -52,7 +52,8 @@
offset=request.GET.get('offset'), limit=request.GET.get('limit'))
# Fetch one more to see if there should be a 'next' link
- sponsors = models.sponsor.logic.getForLimitAndOffset(limit + 1, offset=offset)
+ sponsors = models.sponsor.logic.getForLimitAndOffset(limit=limit + 1,
+ offset=offset)
context['pagination_form'] = helper.lists.makePaginationForm(request, limit)
@@ -62,7 +63,8 @@
'list_heading': 'soc/group/list/group_heading.html'}
context = helper.lists.setList(request, context, sponsors,
- offset, limit, list_templates)
+ offset=offset, limit=limit,
+ list_templates=list_templates)
context['group_type'] = 'Sponsor'
--- a/app/soc/views/site/sponsor/profile.py Wed Oct 15 13:54:00 2008 +0000
+++ b/app/soc/views/site/sponsor/profile.py Wed Oct 15 13:59:52 2008 +0000
@@ -72,6 +72,8 @@
"""Django form displayed when editing a Sponsor.
"""
link_name = forms.CharField(widget=helper.widgets.ReadOnlyInput())
+ created_by = forms.CharField(widget=helper.widgets.ReadOnlyInput(),
+ required=False)
def clean_link_name(self):
link_name = self.cleaned_data.get('link_name')
@@ -144,7 +146,8 @@
value = sponsor_form.cleaned_data.get(field)
fields[field] = value
- fields['founder'] = user
+ if not existing_sponsor:
+ fields['founder'] = user
form_ln = fields['link_name']
form_sponsor = models.sponsor.logic.updateOrCreateFromFields(fields, link_name=form_ln)
@@ -175,7 +178,9 @@
values=profile.SUBMIT_MESSAGES))
# populate form with the existing Sponsor entity
- sponsor_form = EditForm(instance=existing_sponsor)
+ founder_link_name = existing_sponsor.founder.link_name
+ sponsor_form = EditForm(instance=existing_sponsor,
+ initial={'created_by': founder_link_name})
else:
if request.GET.get(profile.SUBMIT_MSG_PARAM_NAME):
# redirect to aggressively remove 'Profile saved' query parameter