56 new_params['logic'] = soc.logic.models.timeline.logic |
56 new_params['logic'] = soc.logic.models.timeline.logic |
57 new_params['edit_template'] = 'soc/timeline/edit.html' |
57 new_params['edit_template'] = 'soc/timeline/edit.html' |
58 new_params['name'] = "Timeline" |
58 new_params['name'] = "Timeline" |
59 |
59 |
60 patterns = [(r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$', |
60 patterns = [(r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$', |
61 'soc.views.models.%(module_name)s.edit', |
61 '%(module_package)s.%(module_name)s.edit', |
62 "Edit %(name_short)s")] |
62 "Edit %(name_short)s")] |
63 |
63 |
64 new_params['create_extra_dynaproperties'] = { |
64 new_params['create_extra_dynaproperties'] = { |
65 'link_id': forms.CharField(widget=forms.HiddenInput) |
65 'link_id': forms.CharField(widget=forms.HiddenInput) |
66 } |
66 } |
70 |
70 |
71 params = dicts.merge(params, new_params) |
71 params = dicts.merge(params, new_params) |
72 |
72 |
73 super(View, self).__init__(params=params) |
73 super(View, self).__init__(params=params) |
74 |
74 |
75 for name, logic_value in program_logic.logic.TIMELINE_LOGIC.iteritems(): |
75 create_form = params_helper.getCreateForm(self._params, |
76 create_form = params_helper.getCreateForm(self._params, |
76 program_logic.logic.timeline_logic.getModel()) |
77 logic_value.getModel()) |
77 edit_form = dynaform.extendDynaForm( |
78 edit_form = dynaform.extendDynaForm( |
78 dynaform = create_form, |
79 dynaform = create_form, |
79 dynainclude = self._params['edit_dynainclude'], |
80 dynainclude = self._params['edit_dynainclude'], |
80 dynaexclude = self._params['edit_dynaexclude'], |
81 dynaexclude = self._params['edit_dynaexclude'], |
81 ) |
82 ) |
|
83 |
82 |
84 self._params['edit_form_%s' % name] = edit_form |
83 self._params['edit_form'] = edit_form |
85 |
84 |
86 def edit(self, request, access_type, |
85 def edit(self, request, access_type, |
87 page_name=None, params=None, seed=None, **kwargs): |
86 page_name=None, params=None, seed=None, **kwargs): |
88 """See base.View.edit. |
87 """See base.View.edit. |
89 """ |
88 """ |
95 |
94 |
96 key_fields = program_logic.logic.getKeyFieldsFromFields(kwargs) |
95 key_fields = program_logic.logic.getKeyFieldsFromFields(kwargs) |
97 |
96 |
98 program = program_logic.logic.getFromKeyFields(key_fields) |
97 program = program_logic.logic.getFromKeyFields(key_fields) |
99 if program: |
98 if program: |
100 workflow = program.workflow |
99 params['logic'] = program_logic.logic.timeline_logic |
101 params['edit_form'] = params["edit_form_%s" % workflow] |
|
102 params['logic'] = program_logic.logic.TIMELINE_LOGIC[workflow] |
|
103 |
100 |
104 return super(View, self).edit(request, access_type, page_name=page_name, |
101 return super(View, self).edit(request, access_type, page_name=page_name, |
105 params=params, seed=seed, **kwargs) |
102 params=params, seed=seed, **kwargs) |
106 |
103 |
107 def _editPost(self, request, entity, fields): |
104 def _editPost(self, request, entity, fields): |