Fills in the Founded By box in edit sponsor with the user's public name
Fixes Founded By being overwritten on edit by another user.
Patch by: Lennard de Rijk
--- a/app/soc/views/models/sponsor.py Sun Nov 23 18:48:28 2008 +0000
+++ b/app/soc/views/models/sponsor.py Mon Nov 24 18:31:46 2008 +0000
@@ -19,6 +19,7 @@
__authors__ = [
'"Sverre Rabbelier" <sverre@rabbelier.nl>',
+ '"Lennard de Rijk" <ljvderijk@gmail.com>',
'"Pawel Solyga" <pawel.solyga@gmail.com>',
]
@@ -129,6 +130,13 @@
base.View.__init__(self, params=params)
+ def _editGet(self, request, entity, form):
+ """See base.View._editGet().
+ """
+
+ # fill in the founded_by with data from the entity
+ form.fields['founded_by'].initial = entity.founder.name
+
def _editPost(self, request, entity, fields):
"""See base.View._editPost().
"""
@@ -136,7 +144,9 @@
account = users.get_current_user()
user = soc.logic.models.user.logic.getForFields({'account': account},
unique=True)
- fields['founder'] = user
+ if not entity:
+ # only if we are creating a new entity we should fill in founder
+ fields['founder'] = user
view = View()