Exemplo n.º 1
0
    def get_widgets(self, resource, context):
        cgu_description = MSG(u"I'm agree with the conditions general of use")
        if context.query['abspath']:
            # on review module
            review_module = resource
        else:
            # on product review
            review_module = get_module(resource, ShopModule_Review.class_id)

        cgu = review_module.get_resource('cgu')
        cgu_link = context.get_link(cgu)
        return [
            HiddenWidget('abspath', title=None),
            TextWidget('title', title=MSG(u'Review title')),
            NoteWidget('note', title=MSG(u'Note'), has_empty_option=False),
            MultilineWidget('description', title=MSG(u'Your review')),
            TextWidget('advantages', title=MSG(u'Advantages')),
            TextWidget('disadvantages', title=MSG(u'Disadvantages')),
            FileWidget('images', title=MSG(u'Images')),
            SelectRadio('recommended',
                        title=MSG(u'Recommendation'),
                        has_empty_option=False,
                        is_inline=True),
            BooleanCheckBox_CGU('cgu',
                                title=MSG(u'Conditions of use'),
                                link=cgu_link,
                                description=cgu_description)
        ]
Exemplo n.º 2
0
    def get_widgets(self, resource, context):
        cgu_description = MSG(u"I'm agree with the conditions general of use")
        review_module = get_module(resource, ShopModule_Review.class_id)
        cgu = review_module.get_resource('cgu')
        cgu_link = context.get_link(cgu)

        return [
            MultilineWidget('description', title=MSG(u'Your report')),
            BooleanCheckBox_CGU('cgu',
              title=MSG(u'Conditions of use'),
              link=cgu_link, description=cgu_description)]
Exemplo n.º 3
0
    def action(self, resource, context, form):
        name = self.get_new_resource_name(form)
        # Get product in which we have to add review
        if form['abspath']:
            product = context.root.get_resource(form['abspath'])
            # Does product has a container for reviews ?
            reviews = product.get_resource('reviews', soft=True)
            if reviews is None:
                cls = ShopModule_Reviews
                reviews = product.make_resource(cls, product, 'reviews')
        else:
            reviews = resource
            product = reviews.parent
        # Create the reviews
        cls = ShopModule_AReview
        child = cls.make_resource(cls, reviews, name)
        # The metadata
        metadata = child.metadata
        language = resource.get_content_language(context)

        # Anonymous, if user is not authenticated, the review is set
        # as anonymous.
        if context.user:
            metadata.set_property('author', context.user.name)
        # Workflow
        review_module = get_module(resource, ShopModule_Review.class_id)
        state = review_module.get_property('areview_default_state')

        metadata.set_property('title', form['title'])
        metadata.set_property('ctime', datetime.now())
        metadata.set_property('state', state)
        metadata.set_property('remote_ip', context.get_remote_ip())
        metadata.set_property('description', form['description'], language)
        metadata.set_property('note', int(form['note']))
        metadata.set_property('recommended', form['recommended'])
        for key in ['advantages', 'disadvantages']:
            metadata.set_property(key, form[key])

        # Add images
        image = form['images']  # XXX not yet multiple
        if image:
            image = review_module.create_new_image(context, image)
            metadata.set_property('images', str(child.get_pathto(image)))

        # XXX Alert webmaster
        if state == 'private':
            # XXX Add pending message.
            goto = context.get_link(product)
            message = MSG(u'Your review has been added.')
        else:
            goto = context.get_link(reviews)
            message = MSG(u'Review has been added')
        return context.come_back(message, goto=goto)
Exemplo n.º 4
0
    def action(self, resource, context, form):
        name = self.get_new_resource_name(form)
        # Get product in which we have to add review
        if form['abspath']:
            product = context.root.get_resource(form['abspath'])
            # Does product has a container for reviews ?
            reviews = product.get_resource('reviews', soft=True)
            if reviews is None:
                cls = ShopModule_Reviews
                reviews = product.make_resource(cls, product, 'reviews')
        else:
            reviews = resource
            product = reviews.parent
        # Create the reviews
        cls = ShopModule_AReview
        child = cls.make_resource(cls, reviews, name)
        # The metadata
        metadata = child.metadata
        language = resource.get_content_language(context)

        # Anonymous, if user is not authenticated, the review is set
        # as anonymous.
        if context.user:
            metadata.set_property('author', context.user.name)
        # Workflow
        review_module = get_module(resource, ShopModule_Review.class_id)
        state = review_module.get_property('areview_default_state')

        metadata.set_property('title', form['title'])
        metadata.set_property('ctime', datetime.now())
        metadata.set_property('state', state)
        metadata.set_property('remote_ip', context.get_remote_ip())
        metadata.set_property('description', form['description'], language)
        metadata.set_property('note', int(form['note']))
        metadata.set_property('recommended', form['recommended'])
        for key in ['advantages', 'disadvantages']:
            metadata.set_property(key, form[key])

        # Add images
        image = form['images'] # XXX not yet multiple
        if image:
            image = review_module.create_new_image(context, image)
            metadata.set_property('images', str(child.get_pathto(image)))

        # XXX Alert webmaster
        if state == 'private':
            # XXX Add pending message.
            goto = context.get_link(product)
            message = MSG(u'Your review has been added.')
        else:
            goto = context.get_link(reviews)
            message = MSG(u'Review has been added')
        return context.come_back(message, goto=goto)
Exemplo n.º 5
0
    def get_widgets(self, resource, context):
        cgu_description = MSG(u"I'm agree with the conditions general of use")
        review_module = get_module(resource, ShopModule_Review.class_id)
        cgu = review_module.get_resource('cgu')
        cgu_link = context.get_link(cgu)

        return [
            MultilineWidget('description', title=MSG(u'Your report')),
            BooleanCheckBox_CGU('cgu',
                                title=MSG(u'Conditions of use'),
                                link=cgu_link,
                                description=cgu_description)
        ]
Exemplo n.º 6
0
    def get_widgets(self, resource, context):
        cgu_description = MSG(u"I'm agree with the conditions general of use")
        if context.query['abspath']:
            # on review module
            review_module = resource
        else:
            # on product review
            review_module = get_module(resource, ShopModule_Review.class_id)

        cgu = review_module.get_resource('cgu')
        cgu_link = context.get_link(cgu)
        return [
            HiddenWidget('abspath', title=None),
            TextWidget('title', title=MSG(u'Review title')),
            NoteWidget('note', title=MSG(u'Note'), has_empty_option=False),
            MultilineWidget('description', title=MSG(u'Your review')),
            TextWidget('advantages', title=MSG(u'Advantages')),
            TextWidget('disadvantages', title=MSG(u'Disadvantages')),
            FileWidget('images', title=MSG(u'Images')),
            SelectRadio('recommended', title=MSG(u'Recommendation'),
                        has_empty_option=False, is_inline=True),
            BooleanCheckBox_CGU('cgu',
              title=MSG(u'Conditions of use'),
              link=cgu_link, description=cgu_description)]
Exemplo n.º 7
0
 def access(self):
     context = get_context()
     module = get_module(context.resource, ShopModule_Review.class_id)
     if module.get_property('must_be_authenticated_to_post'):
         return 'is_authenticated'
     return True
Exemplo n.º 8
0
 def access(self):
     context = get_context()
     module = get_module(context.resource, ShopModule_Review.class_id)
     if module.get_property('must_be_authenticated_to_post'):
         return 'is_authenticated'
     return True