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
def get_value(self, resource, context, name, datatype): if name == 'abspath': return context.query['abspath'] return NewInstance.get_value(self, resource, context, name, datatype)
def get_value(self, resource, context, name, datatypes): if name == 'category': return resource.get_abspath() return NewInstance.get_value(self, resource, context, name, datatypes)