Added an elementary workflow choosing method to program creation.
Patch by: Lennard de Rijk
--- a/app/soc/logic/models/program.py Tue Jan 06 17:26:06 2009 +0000
+++ b/app/soc/logic/models/program.py Tue Jan 06 20:56:48 2009 +0000
@@ -19,6 +19,7 @@
__authors__ = [
'"Sverre Rabbelier" <sverre@rabbelier.nl>',
+ '"Lennard de Rijk" <ljvderijk@gmail.com>',
]
@@ -39,6 +40,24 @@
super(Logic, self).__init__(model=model, base_model=base_model,
scope_logic=scope_logic)
+
+ def getKeyValues(self, entity):
+ """See base.Logic.getKeyNameValues.
+ """
+
+ return [entity.scope_path, entity.workflow, entity.link_id]
+
+ def getKeyValuesFromFields(self, fields):
+ """See base.Logic.getKeyValuesFromFields.
+ """
+
+ return [fields['scope_path'], fields['workflow'], fields['link_id']]
+
+ def getKeyFieldNames(self):
+ """See base.Logic.getKeyFieldNames.
+ """
+
+ return ['scope_path', 'workflow', 'link_id']
logic = Logic()
--- a/app/soc/models/program.py Tue Jan 06 17:26:06 2009 +0000
+++ b/app/soc/models/program.py Tue Jan 06 20:56:48 2009 +0000
@@ -58,6 +58,13 @@
description = db.TextProperty(required=True,
verbose_name=ugettext_lazy('Description'))
description.example_text = ugettext_lazy('This is the program for GSoC 2009')
+
+ #: Required field storing the type of workflow this program has
+ workflow = db.StringProperty(required=True,
+ choices=['gsoc', 'ghop'],
+ verbose_name= ugettext_lazy('Type of workflow'))
+ workflow.example_text = ugettext_lazy('Project-based for GSoC type workflow, '
+ 'task-based for GHOP type workflow')
#: Required 1:1 relationship indicating the Program the Timeline
#: belongs to.
--- a/app/soc/views/models/program.py Tue Jan 06 17:26:06 2009 +0000
+++ b/app/soc/views/models/program.py Tue Jan 06 20:56:48 2009 +0000
@@ -19,6 +19,7 @@
__authors__ = [
'"Sverre Rabbelier" <sverre@rabbelier.nl>',
+ '"Lennard de Rijk" <ljvderijk@gmail.com>',
]
@@ -26,6 +27,7 @@
from soc.logic import cleaning
from soc.logic import dicts
+from soc.logic.models import timeline as timeline_logic
from soc.views import helper
from soc.views.helper import access
from soc.views.helper import redirects
@@ -34,6 +36,9 @@
from soc.views.models import sponsor as sponsor_view
from soc.views.sitemap import sidebar
+import gsoc.models.timeline
+import soc.models.timeline
+
import soc.logic.models.program
@@ -66,17 +71,34 @@
new_params['url_name'] = "program"
new_params['module_name'] = "program"
- new_params['extra_dynaexclude'] = ['home']
+ new_params['extra_dynaexclude'] = ['home', 'timeline']
new_params['create_extra_dynafields'] = {
'description': forms.fields.CharField(widget=helper.widgets.TinyMCE(
attrs={'rows':10, 'cols':40})),
'scope_path': forms.CharField(widget=forms.HiddenInput, required=True),
+ 'workflow' : forms.ChoiceField(choices=[('gsoc','Project-based'),
+ ('ghop','Task-based')], required=True),
'clean_link_id': cleaning.clean_link_id,
}
params = dicts.merge(params, new_params)
super(View, self).__init__(params=params)
+
+ def _editPost(self, request, entity, fields):
+ """See base._editPost().
+ """
+
+ fields['timeline'] = self._createTimelineForType(fields['workflow'])
+
+ def _createTimelineForType(self, type):
+ """Creates and stores a timeline model for the given type of program
+ """
+
+ timelines = {'gsoc' : gsoc.models.timeline.Timeline(),
+ 'ghop' : soc.models.timeline.Timeline()}
+
+ return timelines[type].put()
def getExtraMenus(self, request, params=None):
"""Returns the extra menu's for this view.