app/soc/views/models/program.py
changeset 2812 9280179e34fd
parent 2787 8408741aee63
child 2813 6f7af233b5b0
equal deleted inserted replaced
2811:c8901482dc9c 2812:9280179e34fd
    16 
    16 
    17 """Views for Programs.
    17 """Views for Programs.
    18 """
    18 """
    19 
    19 
    20 __authors__ = [
    20 __authors__ = [
       
    21     '"Madhusudan.C.S" <madhusudancs@gmail.com>',
    21     '"Daniel Hans" <daniel.m.hans@gmail.com>',
    22     '"Daniel Hans" <daniel.m.hans@gmail.com>',
    22     '"Sverre Rabbelier" <sverre@rabbelier.nl>',
    23     '"Sverre Rabbelier" <sverre@rabbelier.nl>',
    23     '"Lennard de Rijk" <ljvderijk@gmail.com>',
    24     '"Lennard de Rijk" <ljvderijk@gmail.com>',
    24   ]
    25   ]
    25 
    26 
   584     """See base._editPost().
   585     """See base._editPost().
   585     """
   586     """
   586 
   587 
   587     super(View, self)._editPost(request, entity, fields)
   588     super(View, self)._editPost(request, entity, fields)
   588 
   589 
   589     if not entity:
   590     if entity:
   590       # there is no existing entity so create a new timeline
   591       # there is no existing entity so create a new timeline
   591       fields['timeline'] = self._createTimelineForType(fields)
   592       fields['timeline'] = self._params['logic'].createTimelineForType(fields)
   592     else:
   593     else:
   593       # use the timeline from the entity
   594       # use the timeline from the entity
   594       fields['timeline'] = entity.timeline
   595       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
       
   611 
   596 
   612   @decorators.merge_params
   597   @decorators.merge_params
   613   def getExtraMenus(self, id, user, params=None):
   598   def getExtraMenus(self, id, user, params=None):
   614     """Returns the extra menu's for this view.
   599     """Returns the extra menu's for this view.
   615 
   600