def handle_submit(self, converted): context = self.context request = self.request userid = authenticated_userid(request) # *will be* modified event objectEventNotify(ObjectWillBeModifiedEvent(context)) context.title = converted['title'] context.text = converted['text'] context.description = extract_description(converted['text']) # tags and attachments set_tags(context, request, converted['tags']) creator = userid attachments_folder = context['attachments'] upload_attachments(converted['attachments'], attachments_folder, creator, request) # modified context.modified_by = userid objectEventNotify(ObjectModifiedEvent(context)) self.filestore.clear() location = resource_url(context, request) msg = "?status_message=Page%20edited" return HTTPFound(location=location+msg)
def handle_submit(self, converted): context = self.context request = self.request workflow = self.workflow # *will be* modified event objectEventNotify(ObjectWillBeModifiedEvent(context)) if 'security_state' in converted: if workflow is not None: workflow.transition_to_state(context, request, converted['security_state']) context.title = converted['title'] context.text = converted['text'] context.description = extract_description(converted['text']) # Tags and attachments set_tags(context, request, converted['tags']) creator = authenticated_userid(request) attachments_folder = context['attachments'] upload_attachments( filter(lambda x: x is not None, converted['attachments']), attachments_folder, creator, request) # modified context.modified_by = authenticated_userid(request) objectEventNotify(ObjectModifiedEvent(context)) location = resource_url(context, request) self.filestore.clear() return HTTPFound(location=location)
def handle_submit(self, converted): request = self.request context = self.context #create the news item and store it creator = authenticated_userid(request) newsitem = create_content( INewsItem, title=converted['title'], text=converted['text'], creator=creator, publication_date=converted['publication_date'], caption=converted['caption'], ) name = make_unique_name(context, converted['title']) context[name] = newsitem # tags, attachments, and photos set_tags(newsitem, request, converted['tags']) attachments_folder = newsitem['attachments'] upload_attachments(converted['attachments'], attachments_folder, creator, request) try: handle_photo_upload(newsitem, converted) except Invalid, e: raise ValidationError(**e.error_dict)
def handle_submit(self, converted): request = self.request context = self.context # *will be* modified event objectEventNotify(ObjectWillBeModifiedEvent(context)) simple_fields = ['title', 'text', 'caption', 'publication_date'] for field in simple_fields: setattr(context, field, converted[field]) # save tags, attachments, photo set_tags(context, request, converted['tags']) userid = authenticated_userid(request) attachments_folder = context['attachments'] upload_attachments(converted['attachments'], attachments_folder, userid, request) handle_photo_upload(context, converted) self.filestore.clear # mark as modified context.modified_by = userid objectEventNotify(ObjectModifiedEvent(context)) location = resource_url(context, request) msg = "?status_message=News%20Item%20edited" return HTTPFound(location=location + msg)
def handle_submit(self, converted): context = self.context request = self.request userid = authenticated_userid(request) # *will be* modified event objectEventNotify(ObjectWillBeModifiedEvent(context)) context.title = converted['title'] context.text = converted['text'] context.description = extract_description(converted['text']) # tags and attachments set_tags(context, request, converted['tags']) creator = userid attachments_folder = context['attachments'] upload_attachments(converted['attachments'], attachments_folder, creator, request) # modified context.modified_by = userid objectEventNotify(ObjectModifiedEvent(context)) self.filestore.clear() location = resource_url(context, request) msg = "?status_message=Page%20edited" return HTTPFound(location=location + msg)
def handle_submit(self, converted): context = self.context request = self.request workflow = self.workflow name = make_unique_name(context, converted['title']) creator = authenticated_userid(request) topic = create_content(IForumTopic, converted['title'], converted['text'], creator, ) topic.description = extract_description(converted['text']) context[name] = topic # Set up workflow if workflow is not None: workflow.initialize(topic) if 'security_state' in converted: workflow.transition_to_state(topic, request, converted['security_state']) # send the temp images to their final place relocate_temp_images(topic, request) # Tags and attachments set_tags(topic, request, converted['tags']) if support_attachments(topic): upload_attachments(converted['attachments'], topic['attachments'], creator, request) location = resource_url(topic, request) return HTTPFound(location=location)
def handle_submit(self, converted): request = self.request context = self.context #create the news item and store it creator = authenticated_userid(request) newsitem = create_content( INewsItem, title=converted['title'], text=converted['text'], creator=creator, publication_date=converted['publication_date'], caption=converted['caption'], ) name = make_unique_name(context, converted['title']) context[name] = newsitem # tags, attachments, and photos set_tags(newsitem, request, converted['tags']) attachments_folder = newsitem['attachments'] upload_attachments(converted['attachments'], attachments_folder, creator, request) handle_photo_upload(newsitem, converted) self.filestore.clear() location = model_url(newsitem, request) return HTTPFound(location=location)
def handle_submit(self, converted): context = self.context request = self.request workflow = self.workflow # *will be* modified event objectEventNotify(ObjectWillBeModifiedEvent(context)) if workflow is not None: if 'security_state' in converted: workflow.transition_to_state(context, request, converted['security_state']) context.title = converted['title'] context.text = converted['text'] context.description = extract_description(converted['text']) # Save the tags on it set_tags(context, request, converted['tags']) # Save new attachments creator = authenticated_userid(request) if support_attachments(context): upload_attachments(converted['attachments'], context['attachments'], creator, request) # Modified context.modified_by = authenticated_userid(request) objectEventNotify(ObjectModifiedEvent(context)) location = model_url(context, request, query={'status_message':'Forum Topic Edited'}) return HTTPFound(location=location)
def handle_submit(self, converted): context = self.context request = self.request workflow = self.workflow # *will be* modified event objectEventNotify(ObjectWillBeModifiedEvent(context)) if workflow is not None: if 'security_state' in converted: workflow.transition_to_state(context, request, converted['security_state']) context.title = converted['title'] context.text = converted['text'] context.description = extract_description(converted['text']) # Save the tags on it set_tags(context, request, converted['tags']) # Save new attachments creator = authenticated_userid(request) if support_attachments(context): upload_attachments(converted['attachments'], context['attachments'], creator, request) # Modified context.modified_by = authenticated_userid(request) objectEventNotify(ObjectModifiedEvent(context)) location = resource_url(context, request, query={'status_message':'Forum Topic Edited'}) return HTTPFound(location=location)
def handle_submit(self, converted): request = self.request context = self.context #create the news item and store it creator = authenticated_userid(request) newsitem = create_content( INewsItem, title=converted['title'], text=converted['text'], creator=creator, publication_date=converted['publication_date'], caption=converted['caption'], ) name = make_unique_name(context, converted['title']) context[name] = newsitem relocate_temp_images(newsitem, request) # tags, attachments, and photos set_tags(newsitem, request, converted['tags']) attachments_folder = newsitem['attachments'] upload_attachments(converted['attachments'], attachments_folder, creator, request) try: handle_photo_upload(newsitem, converted) except Invalid, e: raise ValidationError(**e.error_dict)
def handle_submit(self, converted): context = self.context request = self.request # create the page and store it creator = authenticated_userid(request) page = create_content( IPage, converted['title'], converted['text'], extract_description(converted['text']), creator, ) name = make_unique_name(context, converted['title']) context[name] = page # tags and attachments set_tags(page, request, converted['tags']) attachments_folder = page['attachments'] upload_attachments(converted['attachments'], attachments_folder, creator, request) relocate_temp_images(page, request) # update ordering if in ordered container if hasattr(context, 'ordering'): context.ordering.add(name) location = resource_url(page, request) self.filestore.clear() return HTTPFound(location=location)
def handle_submit(self, converted): context = self.context request = self.request # create the page and store it creator = authenticated_userid(request) page = create_content(IPage, converted['title'], converted['text'], extract_description(converted['text']), creator, ) name = make_unique_name(context, converted['title']) context[name] = page # tags and attachments set_tags(page, request, converted['tags']) attachments_folder = page['attachments'] upload_attachments(converted['attachments'], attachments_folder, creator, request) relocate_temp_images(page, request) # update ordering if in ordered container if hasattr(context, 'ordering'): context.ordering.add(name) location = resource_url(page, request) self.filestore.clear() return HTTPFound(location=location)
def handle_submit(self, converted): request = self.request context = self.context # *will be* modified event objectEventNotify(ObjectWillBeModifiedEvent(context)) simple_fields = ['title', 'text', 'caption', 'publication_date'] for field in simple_fields: setattr(context, field, converted[field]) # save tags, attachments, photo set_tags(context, request, converted['tags']) userid = authenticated_userid(request) attachments_folder = context['attachments'] upload_attachments(converted['attachments'], attachments_folder, userid, request) handle_photo_upload(context, converted) self.filestore.clear # mark as modified context.modified_by = userid objectEventNotify(ObjectModifiedEvent(context)) location = resource_url(context, request) msg = "?status_message=News%20Item%20edited" return HTTPFound(location=location+msg)
def handle_submit(self, converted): context = self.context request = self.request parent = context.__parent__ creator = authenticated_userid(request) comment = create_content( IComment, 'Re: %s' % parent.title, converted['add_comment'], extract_description(converted['add_comment']), creator, ) next_id = parent['comments'].next_id parent['comments'][next_id] = comment workflow = get_workflow(IComment, 'security', context) if workflow is not None: workflow.initialize(comment) if 'security_state' in converted: workflow.transition_to_state(comment, request, converted['security_state']) if support_attachments(comment): upload_attachments(converted['attachments'], comment, creator, request) relocate_temp_images(comment, request) if converted.get('sendalert'): alerts = queryUtility(IAlerts, default=Alerts()) alerts.emit(comment, request) location = resource_url(parent, request) msg = 'Comment added' location = '%s?status_message=%s' % (location, urllib.quote(msg)) self.filestore.clear() return HTTPFound(location=location)
def handle_submit(self, converted): context = self.context request = self.request workflow = self.workflow name = make_unique_name(context, converted['title']) creator = authenticated_userid(request) topic = create_content(IForumTopic, converted['title'], converted['text'], creator, ) topic.description = extract_description(converted['text']) context[name] = topic # Set up workflow if workflow is not None: workflow.initialize(topic) if 'security_state' in converted: workflow.transition_to_state(topic, request, converted['security_state']) # Tags and attachments set_tags(context, request, converted['tags']) if support_attachments(topic): upload_attachments(converted['attachments'], topic['attachments'], creator, request) location = model_url(topic, request) return HTTPFound(location=location)
def handle_submit(self, converted): # base class does some validation and simple massaging super(AddCalendarEventFormController, self).handle_submit(converted) # we create the event and handle other details context = self.context request = self.request creator = authenticated_userid(request) attendees = converted.get('attendees') or [] calendar_event = create_content(ICalendarEvent, converted['title'], converted['start_date'], converted['end_date'], creator, converted['text'], converted['location'], attendees, converted['contact_name'], converted['contact_email'], calendar_category=converted['category'], ) calendar_event.description = extract_description(converted['text']) calname = make_unique_name(context, calendar_event.title) context[calname] = calendar_event # set up workflow workflow = get_workflow(ICalendarEvent, 'security', context) if workflow is not None: workflow.initialize(calendar_event) if 'security_state' in converted: workflow.transition_to_state(calendar_event, request, converted['security_state']) # save tags and attachments set_tags(calendar_event, request, converted['tags']) upload_attachments(converted['attachments'], calendar_event['attachments'], creator, request) # send alert if converted.get('sendalert', False): alerts = queryUtility(IAlerts, default=Alerts()) alerts.emit(calendar_event, request) self.filestore.clear() return HTTPFound(location=model_url(calendar_event, request))
def handle_submit(self, converted): context = self.context request = self.request workflow = self.workflow name = make_unique_name(context, converted['title']) creator = authenticated_userid(request) blogentry = create_content( IBlogEntry, converted['title'], converted['text'], extract_description(converted['text']), creator, ) context[name] = blogentry # Set up workflow if workflow is not None: workflow.initialize(blogentry) if 'security_state' in converted: workflow.transition_to_state(blogentry, request, converted['security_state']) # Tags, attachments, alerts, images set_tags(blogentry, request, converted['tags']) attachments_folder = blogentry['attachments'] upload_attachments(filter(lambda x: x is not None, converted['attachments']), attachments_folder, creator, request) relocate_temp_images(blogentry, request) if converted['sendalert']: alerts = queryUtility(IAlerts, default=Alerts()) alerts.emit(blogentry, request) location = resource_url(blogentry, request) self.filestore.clear() return HTTPFound(location=location)
def handle_submit(self, converted): # base class does some validation and simple massaging super(EditCalendarEventFormController, self).handle_submit(converted) context = self.context request = self.request # *will be* modified event objectEventNotify(ObjectWillBeModifiedEvent(context)) if self.workflow is not None: if 'security_state' in converted: self.workflow.transition_to_state(context, request, converted['security_state']) context.title = converted['title'] context.startDate = converted['start_date'] context.endDate = converted['end_date'] context.text = converted['text'] context.location = converted['location'] context.attendees = converted.get('attendees') or [] context.contact_name = converted['contact_name'] context.contact_email = converted['contact_email'] context.calendar_category = converted['category'] context.description = extract_description(converted['text']) # Save the tags on it set_tags(context, request, converted['tags']) # Save new attachments userid = authenticated_userid(request) attachments_folder = context['attachments'] upload_attachments(converted['attachments'], attachments_folder, userid, request) # Modified context.modified_by = userid objectEventNotify(ObjectModifiedEvent(context)) self.filestore.clear() location = model_url(context, request) msg = "?status_message=Calendar%20Event%20edited" return HTTPFound(location='%s%s' % (location, msg))
def handle_submit(self, converted): context = self.context request = self.request workflow = get_workflow(IComment, 'security', context) objectEventNotify(ObjectWillBeModifiedEvent(context)) if workflow is not None: if 'security_state' in converted: workflow.transition_to_state(context, request, converted['security_state']) context.text = converted['add_comment'] context.description = extract_description(context.text) creator = authenticated_userid(request) if support_attachments(context): upload_attachments(converted['attachments'], context, creator, request) context.modified_by = creator objectEventNotify(ObjectModifiedEvent(context)) location = resource_url(context, request) self.filestore.clear() return HTTPFound(location=location)
def handle_submit(self, converted): context = self.context request = self.request workflow = self.workflow name = make_unique_name(context, converted['title']) creator = authenticated_userid(request) blogentry = create_content( IBlogEntry, converted['title'], converted['text'], extract_description(converted['text']), creator, ) context[name] = blogentry # Set up workflow if workflow is not None: workflow.initialize(blogentry) if 'security_state' in converted: workflow.transition_to_state(blogentry, request, converted['security_state']) # Tags, attachments, alerts, images set_tags(blogentry, request, converted['tags']) attachments_folder = blogentry['attachments'] upload_attachments( filter(lambda x: x is not None, converted['attachments']), attachments_folder, creator, request) relocate_temp_images(blogentry, request) if converted['sendalert']: alerts = queryUtility(IAlerts, default=Alerts()) alerts.emit(blogentry, request) location = resource_url(blogentry, request) self.filestore.clear() return HTTPFound(location=location)
def handle_submit(self, converted): context = self.context request = self.request workflow = self.workflow name = make_unique_name(context, converted['title']) creator = authenticated_userid(request) topic = create_content( IForumTopic, converted['title'], converted['text'], creator, ) topic.description = extract_description(converted['text']) context[name] = topic # Set up workflow if workflow is not None: workflow.initialize(topic) if 'security_state' in converted: workflow.transition_to_state(topic, request, converted['security_state']) # send the temp images to their final place relocate_temp_images(topic, request) # Tags and attachments set_tags(topic, request, converted['tags']) if support_attachments(topic): upload_attachments(converted['attachments'], topic['attachments'], creator, request) if 'sendalert' in converted and converted['sendalert']: alerts = queryUtility(IAlerts, default=Alerts()) alerts.emit(topic, request) location = resource_url(topic, request) return HTTPFound(location=location)