Exemplo n.º 1
0
    def handle_submit(self, converted):
        request = self.request
        context = self.context
        workflow = self.workflow
        wikipage = create_content(
            IWikiPage,
            converted['title'],
            converted['text'],
            extract_description(converted['text']),
            authenticated_userid(request),
            )

        name = make_name(context, converted['title'])
        context[name] = wikipage

        if workflow is not None:
            workflow.initialize(wikipage)
            if 'security_state' in converted:
                workflow.transition_to_state(wikipage,
                                             request,
                                             converted['security_state'])

        # Save the tags on it.
        set_tags(wikipage, request, converted['tags'])

        relocate_temp_images(wikipage, request)

        if converted['sendalert']:
            alerts = queryUtility(IAlerts, default=Alerts())
            alerts.emit(wikipage, request)

        msg = '?status_message=Wiki%20Page%20created'
        location = model_url(wikipage, request) + msg
        return HTTPFound(location=location)
Exemplo n.º 2
0
    def handle_submit(self, converted):
        request = self.request
        context = self.context
        workflow = self.workflow
        wikipage = create_content(
            IWikiPage,
            converted['title'],
            converted['text'],
            extract_description(converted['text']),
            authenticated_userid(request),
        )

        name = make_name(context, converted['title'])
        context[name] = wikipage

        if workflow is not None:
            workflow.initialize(wikipage)
            if 'security_state' in converted:
                workflow.transition_to_state(wikipage, request,
                                             converted['security_state'])

        # Save the tags on it.
        set_tags(wikipage, request, converted['tags'])

        relocate_temp_images(wikipage, request)

        if converted['sendalert']:
            alerts = queryUtility(IAlerts, default=Alerts())
            alerts.emit(wikipage, request)

        msg = '?status_message=Wiki%20Page%20created'
        location = resource_url(wikipage, request) + msg
        return HTTPFound(location=location)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
Arquivo: blog.py Projeto: lslaz1/karl
    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)
Exemplo n.º 11
0
    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)
Exemplo n.º 12
0
def add_comment_view(context, request):
    # This is NOT a self-posting form.  The BlogEntry has the form
    # that submits to this view.  Thus, we only need to handle
    # submission requests, then redirect back to the parent (the blog
    # entry).

    # Handle the Add Comment form
    #post_url = model_url(context, request, "comments/add_comment.html")
    form = AddCommentForm()
    # add the security state field if appropriate for the context
    workflow = get_workflow(IComment, 'security', context)

    if workflow is None:
        security_states = []
    else:
        security_states = get_security_states(workflow, None, request)

    if security_states:
        form.add_field('security_state', security_state_field)

    if 'form.cancel' in request.POST:
        return HTTPFound(location=model_url(context.__parent__, request))

    if 'form.submitted' in request.POST:
        converted = form.validate(request.POST)
        form.is_valid = True
        parent = context.__parent__
        creator = authenticated_userid(request)
        c = 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] = c
        if workflow is not None:
            workflow.initialize(c)
            if 'security_state' in converted:
                workflow.transition_to_state(c, request,
                                             converted['security_state'])

        if support_attachments(c):
            store_attachments(c, request.params, creator)
        relocate_temp_images(c, request)

        url = model_url(parent, request)
        msg = 'Comment added'
        url = url + '?status_message=%s' % urllib.quote(msg)

        blogentry = find_interface(context, IBlogEntry)
        if converted['sendalert']:
            alerts = queryUtility(IAlerts, default=Alerts())
            alerts.emit(c, request)

        return HTTPFound(location=url)

    # XXX Need different flow of control here, since it isn't
    # self-posting.

    else:
        raise Invalid('This is not a self-posting form. It is submit only.',
                      None, None)
Exemplo n.º 13
0
 def _call_fut(self, context, request):
     from karl.utilities.image import relocate_temp_images
     return relocate_temp_images(context, request)
Exemplo n.º 14
0
 def _call_fut(self, context, request):
     from karl.utilities.image import relocate_temp_images
     return relocate_temp_images(context, request)