예제 #1
0
 def fetch_params():
     is_draft = Parser.bool('json', 'is_draft', optional=True) or False
     if is_draft:
         REVIEW_TEXT_MIN_LENGTH = None
     entity_id = Parser.uuid('json', 'entity_id')
     entity_type = Parser.string('json',
                                 'entity_type',
                                 valid_values=ENTITY_TYPES)
     text = Parser.string('json',
                          'text',
                          min=REVIEW_TEXT_MIN_LENGTH,
                          max=REVIEW_TEXT_MAX_LENGTH,
                          optional=True)
     rating = Parser.int('json',
                         'rating',
                         min=REVIEW_RATING_MIN,
                         max=REVIEW_RATING_MAX,
                         optional=True)
     license_choice = Parser.string('json', 'license_choice')
     language = Parser.string(
         'json', 'language', min=2, max=3, optional=True) or 'en'
     if text is None and rating is None:
         raise InvalidRequest(desc='Review must have either text or rating')
     if language and language not in supported_languages:
         raise InvalidRequest(desc='Unsupported language')
     if db_review.list_reviews(user_id=user.id, entity_id=entity_id)[1]:
         raise InvalidRequest(
             desc='You have already published a review for this album')
     return entity_id, entity_type, text, rating, license_choice, language, is_draft
예제 #2
0
 def fetch_params():
     is_draft = Parser.bool('json', 'is_draft', optional=True) or False
     if is_draft:
         REVIEW_MIN_LENGTH = None
     entity_id = Parser.uuid('json', 'entity_id')
     entity_type = Parser.string('json', 'entity_type', valid_values=ENTITY_TYPES)
     text = Parser.string('json', 'text', min=REVIEW_MIN_LENGTH, max=REVIEW_MAX_LENGTH)
     license_choice = Parser.string('json', 'license_choice')
     language = Parser.string('json', 'language', min=2, max=3, optional=True) or 'en'
     if language and language not in supported_languages:
         raise InvalidRequest(desc='Unsupported language')
     if Review.query.filter_by(user=user, entity_id=entity_id).count():
         raise InvalidRequest(desc='You have already published a review for this album')
     return entity_id, entity_type, text, license_choice, language, is_draft
예제 #3
0
 def fetch_params():
     is_draft = Parser.bool('json', 'is_draft', optional=True) or False
     if is_draft:
         REVIEW_MIN_LENGTH = None
     entity_id = Parser.uuid('json', 'entity_id')
     entity_type = Parser.string('json', 'entity_type', valid_values=ENTITY_TYPES)
     text = Parser.string('json', 'text', min=REVIEW_MIN_LENGTH, max=REVIEW_MAX_LENGTH)
     license_choice = Parser.string('json', 'license_choice')
     language = Parser.string('json', 'language', min=2, max=3, optional=True) or 'en'
     if language and language not in supported_languages:
         raise InvalidRequest(desc='Unsupported language')
     if Review.query.filter_by(user=user, entity_id=entity_id).count():
         raise InvalidRequest(desc='You have already published a review for this album')
     return entity_id, entity_type, text, license_choice, language, is_draft
예제 #4
0
 def fetch_params():
     is_draft = Parser.bool('json', 'is_draft', optional=True) or False
     if is_draft:
         REVIEW_TEXT_MIN_LENGTH = None
     entity_id = Parser.uuid('json', 'entity_id')
     entity_type = Parser.string('json', 'entity_type', valid_values=ENTITY_TYPES)
     text = Parser.string('json', 'text', min=REVIEW_TEXT_MIN_LENGTH, max=REVIEW_TEXT_MAX_LENGTH, optional=True)
     rating = Parser.int('json', 'rating', min=REVIEW_RATING_MIN, max=REVIEW_RATING_MAX, optional=True)
     license_choice = Parser.string('json', 'license_choice')
     language = Parser.string('json', 'language', min=2, max=3, optional=True) or 'en'
     if text is None and rating is None:
         raise InvalidRequest(desc='Review must have either text or rating')
     if language and language not in supported_languages:
         raise InvalidRequest(desc='Unsupported language')
     if db_review.list_reviews(user_id=user.id, entity_id=entity_id)[1]:
         raise InvalidRequest(desc='You have already published a review for this album')
     return entity_id, entity_type, text, rating, license_choice, language, is_draft
예제 #5
0
 def fetch_params():
     vote = Parser.bool('json', 'vote')
     return vote
예제 #6
0
 def fetch_params():
     display_name = Parser.string('json', 'display_name', optional=True)
     email = Parser.email('json', 'email', optional=True)
     show_gravatar = Parser.bool('json', 'show_gravatar', optional=True)
     return display_name, email, show_gravatar
예제 #7
0
 def fetch_params():
     display_name = Parser.string('json', 'display_name', optional=True)
     email = Parser.email('json', 'email', optional=True)
     show_gravatar = Parser.bool('json', 'show_gravatar', optional=True)
     return display_name, email, show_gravatar
예제 #8
0
 def fetch_params():
     vote = Parser.bool('json', 'vote')
     return vote