class TaskDuplicateView(BaseFormView): """ Task duplication view """ schema = get_duplicate_schema() @property def title(self): return u"Dupliquer {0} {1}".format(self.label, self.context.name) def before(self, form): BaseFormView.before(self, form) task_add_js.need() def submit_success(self, appstruct): logger.debug("# Duplicating a document #") project_id = appstruct.pop('project_id') appstruct['project'] = Project.get(project_id) customer_id = appstruct.pop('customer_id') appstruct['customer'] = Customer.get(customer_id) task = self.context.duplicate(user=self.request.user, **appstruct) if hasattr(self, "_after_task_duplicate"): self._after_task_duplicate(task, appstruct) self.dbsession.add(task) self.dbsession.flush() logger.debug( u"The {t.type_} {t.id} has been duplicated to {new_t.id}".format( t=self.context, new_t=task)) return HTTPFound( self.request.route_path('/%ss/{id}' % self.context.type_, id=task.id))
class TaskDuplicateView(BaseFormView): """ Task duplication view """ schema = get_duplicate_schema() @property def title(self): return u"Dupliquer {0} {1}".format(self.label, self.context.name) def before(self, form): BaseFormView.before(self, form) task_add_js.need() def submit_success(self, appstruct): logger.debug("# Duplicating a document #") name = appstruct['name'] phase_id = appstruct['phase_id'] phase = Phase.get(phase_id) project_id = appstruct['project_id'] project = Project.get(project_id) customer_id = appstruct['customer_id'] customer = Customer.get(customer_id) task = self.context.duplicate( self.request.user, project, phase, customer, ) task.name = name task.course = appstruct['course'] self.dbsession.add(task) self.dbsession.flush() logger.debug( u"The {t.type_} {t.id} has been duplicated to {new_t.id}".format( t=self.context, new_t=task)) return HTTPFound( self.request.route_path('/%ss/{id}' % self.context.type_, id=task.id))