134 |
134 |
135 def _editPost(self, request, entity, fields): |
135 def _editPost(self, request, entity, fields): |
136 """See base._editPost(). |
136 """See base._editPost(). |
137 """ |
137 """ |
138 |
138 |
|
139 super(View, self)._editPost(request, entity, fields) |
|
140 |
139 if not entity: |
141 if not entity: |
140 # there is no existing entity so create a new timeline |
142 # there is no existing entity so create a new timeline |
141 fields['timeline'] = self._createTimelineForType(fields) |
143 fields['timeline'] = self._createTimelineForType(fields) |
142 else: |
144 else: |
143 # use the timeline from the entity |
145 # use the timeline from the entity |
144 fields['timeline'] = entity.timeline |
146 fields['timeline'] = entity.timeline |
145 |
147 |
146 super(View, self)._editPost(request, entity, fields) |
|
147 |
|
148 def _createTimelineForType(self, fields): |
148 def _createTimelineForType(self, fields): |
149 """Creates and stores a timeline model for the given type of program. |
149 """Creates and stores a timeline model for the given type of program. |
150 """ |
150 """ |
151 |
151 |
152 workflow = fields['workflow'] |
152 workflow = fields['workflow'] |
153 |
153 |
154 timeline_logic = program_logic.logic.TIMELINE_LOGIC[workflow] |
154 timeline_logic = program_logic.logic.TIMELINE_LOGIC[workflow] |
155 |
155 |
156 key_name = self._logic.getKeyNameFromFields(fields) |
156 key_fields = timeline_logic.getKeyFieldsFromFields(fields) |
157 |
157 properties = key_fields.copy() |
158 properties = {'scope_path': key_name} |
158 properties['scope'] = fields['scope'] |
159 |
159 |
160 timeline = timeline_logic.updateOrCreateFromFields(properties, properties) |
160 timeline = timeline_logic.updateOrCreateFromFields(properties, properties) |
161 return timeline |
161 return timeline |
162 |
162 |
163 @decorators.merge_params |
163 @decorators.merge_params |