def do_modify(self): is_new = isinstance(self.content, NonExistentContent) closed = self.meta.get('closed') Form = TicketSubmitForm if is_new else TicketUpdateForm if request.method in ['GET', 'HEAD']: form = Form.from_item(self) elif request.method == 'POST': form = Form.from_request(request) if form.validate(): meta, data = form._dump(self) try: self.modify(meta, data) except AccessDenied: abort(403) else: return redirect(url_for('.show_item', item_name=self.name)) # XXX When creating new item, suppress the "foo doesn't exist. Create it?" dummy content data_rendered = None if is_new else Markup(self.content._render_data()) return render_template(self.submit_template if is_new else self.modify_template, is_new=is_new, closed=closed, item_name=self.name, data_rendered=data_rendered, form=form, )
def do_modify(self): is_new = isinstance(self.content, NonExistentContent) closed = self.meta.get('closed') Form = TicketSubmitForm if is_new else TicketUpdateForm if request.method in ['GET', 'HEAD']: form = Form.from_item(self) elif request.method == 'POST': form = Form.from_request(request) if form.validate(): meta, data, message, data_file = form._dump(self) try: if not is_new and message: create_comment(self.meta, message) self.modify(meta, data) if data_file: file_upload(self, data_file) except AccessDenied: abort(403) else: try: fqname = CompositeName(self.meta[NAMESPACE], ITEMID, self.meta[ITEMID]) except KeyError: fqname = self.fqname return redirect(url_for('.show_item', item_name=fqname)) # XXX When creating new item, suppress the "foo doesn't exist. Create it?" dummy content data_rendered = None if is_new else Markup(self.content._render_data()) files = get_files(self) comments, roots = get_comments(self) suggested_tags = get_itemtype_specific_tags(ITEMTYPE_TICKET) return render_template( self.submit_template if is_new else self.modify_template, is_new=is_new, closed=closed, item_name=self.name, data_rendered=data_rendered, form=form, suggested_tags=suggested_tags, item=self, files=files, comments=comments, Markup=Markup, datetime=datetime, roots=roots, build_tree=build_tree, )
def do_modify(self): is_new = isinstance(self.content, NonExistentContent) closed = self.meta.get('closed') Form = TicketSubmitForm if is_new else TicketUpdateForm if request.method in ['GET', 'HEAD']: form = Form.from_item(self) elif request.method == 'POST': form = Form.from_request(request) if form.validate(): meta, data, message, data_file = form._dump(self) try: if not is_new and message: create_comment(self.meta, message) self.modify(meta, data) if data_file: file_upload(self, data_file) except AccessDenied: abort(403) else: try: fqname = CompositeName(self.meta[NAMESPACE], ITEMID, self.meta[ITEMID]) except KeyError: fqname = self.fqname return redirect(url_for('.show_item', item_name=fqname)) # XXX When creating new item, suppress the "foo doesn't exist. Create it?" dummy content data_rendered = None if is_new else Markup(self.content._render_data()) files = get_files(self) comments, roots = get_comments(self) suggested_tags = get_itemtype_specific_tags(ITEMTYPE_TICKET) return render_template(self.submit_template if is_new else self.modify_template, is_new=is_new, closed=closed, item_name=self.name, data_rendered=data_rendered, form=form, suggested_tags=suggested_tags, item=self, files=files, comments=comments, Markup=Markup, datetime=datetime, roots=roots, build_tree=build_tree, )
def do_modify(self): """ Process new ticket, changes to ticket meta data, and/or a new comment against original ticket description. User has clicked "Submit ticket" or "Update ticket" button to get here. If user clicks Save button to add a comment to a prior comment it is not processed here - see /+comment in views.py. """ is_new = isinstance(self.content, NonExistentContent) closed = self.meta.get('closed') Form = TicketSubmitForm if is_new else TicketUpdateForm if request.method in ['GET', 'HEAD']: form = Form.from_item(self) elif request.method == 'POST': form = Form.from_request(request) if form.validate(): meta, data, message, data_file = form._dump( self ) # saves new ticket revision if ticket meta has changed try: if not is_new and message: # user created a new comment create_comment(self.meta, message) if is_new: self.modify(meta, data) if data_file: file_upload(self, data_file) except AccessDenied: abort(403) else: try: fqname = CompositeName(self.meta[NAMESPACE], ITEMID, self.meta[ITEMID]) except KeyError: fqname = self.fqname return redirect(url_for('.show_item', item_name=fqname)) if is_new: data_rendered = None files = {} roots = [] comments = {} else: data_rendered = Markup(self.content._render_data()) files = get_files(self) comments, roots = get_comments(self) suggested_tags = get_itemtype_specific_tags(ITEMTYPE_TICKET) ordered_comments = [] # list of tuples [(comment, indent),,, ] for root in roots: ordered_comments += [ (root, 0), ] + build_tree(comments, root, [], 0) return render_template( self.submit_template if is_new else self.modify_template, is_new=is_new, closed=closed, item_name=self.name, data_rendered=data_rendered, form=form, suggested_tags=suggested_tags, item=self, files=files, datetime=datetime.datetime, ordered_comments=ordered_comments, render_comment_data=render_comment_data, )