# HG changeset patch # User Sverre Rabbelier # Date 1231365468 0 # Node ID 16dcdb8f335702593b1cfad2150167e358922792 # Parent f86a76f52bf48a892ac362a876df62e328f4bcd8 Added an 'edit timeline' button to the program edit page Also made the create timeline functionality use the logic modules introduced in the previous commit. Patch by: Sverre Rabbelier diff -r f86a76f52bf4 -r 16dcdb8f3357 app/soc/templates/soc/program/edit.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/templates/soc/program/edit.html Wed Jan 07 21:57:48 2009 +0000 @@ -0,0 +1,21 @@ +{% extends "soc/models/edit.html" %} +{% comment %} +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% endcomment %} + +{% block submit_buttons %} +{{ block.super }} + + + +{% endblock %} diff -r f86a76f52bf4 -r 16dcdb8f3357 app/soc/views/models/program.py --- a/app/soc/views/models/program.py Wed Jan 07 21:57:12 2009 +0000 +++ b/app/soc/views/models/program.py Wed Jan 07 21:57:48 2009 +0000 @@ -27,7 +27,6 @@ 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 @@ -71,6 +70,8 @@ new_params['url_name'] = "program" new_params['module_name'] = "program" + new_params['edit_template'] = 'soc/program/edit.html' + new_params['extra_dynaexclude'] = ['home', 'timeline'] new_params['create_extra_dynafields'] = { 'description': forms.fields.CharField(widget=helper.widgets.TinyMCE( @@ -84,26 +85,36 @@ params = dicts.merge(params, new_params) super(View, self).__init__(params=params) - + def _editPost(self, request, entity, fields): """See base._editPost(). """ - + if not entity: # there is no existing entity so create a new timeline - fields['timeline'] = self._createTimelineForType(fields['workflow']) + fields['timeline'] = self._createTimelineForType(fields) else: # use the timeline from the entity fields['timeline'] = entity.timeline - - def _createTimelineForType(self, type): + + def _createTimelineForType(self, fields): """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() + + timelines = {'gsoc' : gsoc.logic.models.timeline.logic, + 'ghop' : soc.logic.models.timeline.logic,} + + workflow = fields['workflow'] + + timeline_logic = timelines[workflow] + + key_fields = self._logic.getKeyFieldsFromDict(fields) + key_name = self._logic.getKeyNameForFields(key_fields) + + properties = {'scope_path': key_name} + + timeline = timeline_logic.updateOrCreateFromFields(properties, properties) + return timeline def getExtraMenus(self, request, params=None): """Returns the extra menu's for this view.