예제 #1
0
    def _get_form(self, resource, context):
        form = NewInstance._get_form(self, resource, context)

        # Check if the user has already fill a review
        query = self._get_current_reviews_query(context, form)
        author_query = PhraseQuery('shop_module_review_author',
                                   context.user.name)
        query = AndQuery(query, author_query)
        if len(context.root.search(query)):
            raise FormError, ERROR(u'You already have filled a review.')

    #    form = NewInstance._get_form(self, resource, context)
    # Check images
        image = form['images']  # XXX not yet multiple
        if image:
            filename, mimetype, body = image
            if mimetype.startswith('image/') is False:
                raise FormError, MSG_UNEXPECTED_MIMETYPE(mimetype=mimetype)

        return form
예제 #2
0
파일: review.py 프로젝트: hforge/shop
    def _get_form(self, resource, context):
        form = NewInstance._get_form(self, resource, context)

        # Check if the user has already fill a review
        query = self._get_current_reviews_query(context, form)
        author_query = PhraseQuery('shop_module_review_author',
                                   context.user.name)
        query = AndQuery(query, author_query)
        if len(context.root.search(query)):
            raise FormError, ERROR(u'You already have filled a review.')

    #    form = NewInstance._get_form(self, resource, context)
        # Check images
        image = form['images'] # XXX not yet multiple
        if image:
            filename, mimetype, body = image
            if mimetype.startswith('image/') is False:
                raise FormError, MSG_UNEXPECTED_MIMETYPE(mimetype=mimetype)

        return form
예제 #3
0
 def get_value(self, resource, context, name, datatype):
     if name == 'abspath':
         return context.query['abspath']
     return NewInstance.get_value(self, resource, context, name, datatype)
예제 #4
0
 def get_value(self, resource, context, name, datatypes):
     if name == 'category':
         return resource.get_abspath()
     return NewInstance.get_value(self, resource, context, name, datatypes)
예제 #5
0
파일: review.py 프로젝트: hforge/shop
 def get_value(self, resource, context, name, datatype):
     if name == 'abspath':
         return context.query['abspath']
     return NewInstance.get_value(self, resource, context, name, datatype)