--- a/app/soc/logic/models/timeline.py Mon Feb 23 18:26:00 2009 +0000
+++ b/app/soc/logic/models/timeline.py Mon Feb 23 18:27:14 2009 +0000
@@ -39,22 +39,4 @@
super(Logic, self).__init__(model=model, base_model=base_model,
scope_logic=scope_logic)
- def getKeyValuesFromEntity(self, entity):
- """See base.Logic.getKeyNameValues.
- """
-
- return [entity.scope_path]
-
- def getKeyValuesFromFields(self, fields):
- """See base.Logic.getKeyValuesFromFields.
- """
-
- return [fields['scope_path']]
-
- def getKeyFieldNames(self):
- """See base.Logic.getKeyFieldNames.
- """
-
- return ['scope_path']
-
logic = Logic()
--- a/app/soc/models/seed_db.py Mon Feb 23 18:26:00 2009 +0000
+++ b/app/soc/models/seed_db.py Mon Feb 23 18:27:14 2009 +0000
@@ -121,7 +121,9 @@
timeline_properties = {
'key_name': 'google/gsoc2009',
- 'scope_path': 'google/gsoc2009',
+ 'link_id': 'gsoc2009',
+ 'scope_path': 'google',
+ 'scope': google,
}
gsoc2009_timeline = Timeline(**timeline_properties)
@@ -150,7 +152,9 @@
timeline_properties = {
'key_name': 'google/ghop2009',
- 'scope_path': 'google/ghop2009',
+ 'link_id': 'ghop2009',
+ 'scope_path': 'google',
+ 'scope': google,
}
ghop2009_timeline = Timeline(**timeline_properties)
--- a/app/soc/models/timeline.py Mon Feb 23 18:26:00 2009 +0000
+++ b/app/soc/models/timeline.py Mon Feb 23 18:27:14 2009 +0000
@@ -26,16 +26,13 @@
from django.utils.translation import ugettext
-from soc.models import base
+from soc.models import linkable
-class Timeline(base.ModelWithFieldAttributes):
+class Timeline(linkable.Linkable):
"""The Timeline Model, representing the timeline for a Program.
"""
- scope_path = db.StringProperty(required=True,
- verbose_name=ugettext('Scope Path'))
-
program_start = db.DateTimeProperty(
verbose_name=ugettext('Program Start date'))
--- a/app/soc/views/helper/access.py Mon Feb 23 18:26:00 2009 +0000
+++ b/app/soc/views/helper/access.py Mon Feb 23 18:27:14 2009 +0000
@@ -1274,18 +1274,12 @@
"""Checks whether this program's timeline may be edited.
"""
- time_line_keyname = django_args['scope_path']
+ time_line_keyname = timeline_logic.getKeyFieldsFromFields(django_args)
timeline_entity = timeline_logic.getFromKeyName(time_line_keyname)
if not timeline_entity:
# timeline does not exists so deny
self.deny(django_args)
- split_keyname = time_line_keyname.rsplit('/')
-
- fields = {
- 'scope_path' : split_keyname[0],
- 'link_id' : split_keyname[1],
- }
-
+ fields = program_logic.getKeyFieldsFromFields(django_args)
self.checkIsHostForProgram(fields)
--- a/app/soc/views/models/program.py Mon Feb 23 18:26:00 2009 +0000
+++ b/app/soc/views/models/program.py Mon Feb 23 18:27:14 2009 +0000
@@ -136,6 +136,8 @@
"""See base._editPost().
"""
+ super(View, self)._editPost(request, entity, fields)
+
if not entity:
# there is no existing entity so create a new timeline
fields['timeline'] = self._createTimelineForType(fields)
@@ -143,8 +145,6 @@
# use the timeline from the entity
fields['timeline'] = entity.timeline
- super(View, self)._editPost(request, entity, fields)
-
def _createTimelineForType(self, fields):
"""Creates and stores a timeline model for the given type of program.
"""
@@ -153,9 +153,9 @@
timeline_logic = program_logic.logic.TIMELINE_LOGIC[workflow]
- key_name = self._logic.getKeyNameFromFields(fields)
-
- properties = {'scope_path': key_name}
+ key_fields = timeline_logic.getKeyFieldsFromFields(fields)
+ properties = key_fields.copy()
+ properties['scope'] = fields['scope']
timeline = timeline_logic.updateOrCreateFromFields(properties, properties)
return timeline
--- a/app/soc/views/models/timeline.py Mon Feb 23 18:26:00 2009 +0000
+++ b/app/soc/views/models/timeline.py Mon Feb 23 18:27:14 2009 +0000
@@ -62,6 +62,9 @@
'soc.views.models.%(module_name)s.edit',
"Edit %(name_short)s")]
+ new_params['create_extra_dynaproperties'] = {
+ 'link_id': forms.CharField(widget=forms.HiddenInput)
+ }
new_params['django_patterns_defaults'] = patterns
new_params['edit_dynaproperties'] = []
@@ -88,8 +91,10 @@
# TODO(pawel.solyga): If program doesn't exist for timeline display
# customized error message without pointing to 'Create Timeline'
-
- program = program_logic.logic.getFromKeyName(kwargs['scope_path'])
+
+ key_fields = program_logic.logic.getKeyFieldsFromFields(kwargs)
+
+ program = program_logic.logic.getFromKeyFields(key_fields)
if program:
params['edit_form'] = params["edit_form_%s" % program.workflow]