app/soc/views/models/program.py
changeset 2787 8408741aee63
parent 2784 801eee4eda9a
child 2812 9280179e34fd
equal deleted inserted replaced
2786:b06313c87817 2787:8408741aee63
   586 
   586 
   587     super(View, self)._editPost(request, entity, fields)
   587     super(View, self)._editPost(request, entity, fields)
   588 
   588 
   589     if not entity:
   589     if not entity:
   590       # there is no existing entity so create a new timeline
   590       # there is no existing entity so create a new timeline
   591       fields['timeline'] = self._params['logic'].createTimelineForType(fields)
   591       fields['timeline'] = self._createTimelineForType(fields)
   592     else:
   592     else:
   593       # use the timeline from the entity
   593       # use the timeline from the entity
   594       fields['timeline'] = entity.timeline
   594       fields['timeline'] = entity.timeline
       
   595 
       
   596   def _createTimelineForType(self, fields):
       
   597     """Creates and stores a timeline model for the given type of program.
       
   598     """
       
   599 
       
   600     workflow = fields['workflow']
       
   601 
       
   602     timeline_logic = program_logic.logic.TIMELINE_LOGIC[workflow]
       
   603 
       
   604     properties = timeline_logic.getKeyFieldsFromFields(fields)
       
   605     key_name = timeline_logic.getKeyNameFromFields(properties)
       
   606 
       
   607     properties['scope'] = fields['scope']
       
   608 
       
   609     timeline = timeline_logic.updateOrCreateFromKeyName(properties, key_name)
       
   610     return timeline
   595 
   611 
   596   @decorators.merge_params
   612   @decorators.merge_params
   597   def getExtraMenus(self, id, user, params=None):
   613   def getExtraMenus(self, id, user, params=None):
   598     """Returns the extra menu's for this view.
   614     """Returns the extra menu's for this view.
   599 
   615