コード例 #1
0
ファイル: schemas.py プロジェクト: horosin/mcod-backend
class ResendActivationEmail(Schema):
    """
        Password reset - flow start (reset my password)
    """
    email = fields.Email(required=True,
                         faker_type='email',
                         example='*****@*****.**')

    class Meta:
        strict = True
コード例 #2
0
ファイル: schemas.py プロジェクト: horosin/mcod-backend
class Registration(AccountUpdate):
    """
        User registration
    """
    email = fields.Email(required=True,
                         faker_type='email',
                         example='*****@*****.**')
    password1 = fields.Str(required=True,
                           faker_type='password',
                           example='Kai7!!phoom')
    password2 = fields.Str(required=True,
                           faker_type='password',
                           example='Kai7!!phoom')

    @validates_schema()
    def validate_passwords(self, data):
        if 'password1' in data:
            try:
                dj_validate_password(data['password1'])
            except DjangoValidationError as e:
                raise ValidationError(e.error_list[0].message,
                                      field_name='password1',
                                      code=e.error_list[0].code,
                                      field_names=[
                                          'password1',
                                      ])
            if 'password2' in data:
                if data['password1'] != data['password2']:
                    raise ValidationError(
                        _('Passwords not match'),
                        field_name='password1',
                        field_names=['password1', 'password2'])

    @post_load
    def prepare_data(self, data):
        data['password'] = data['password1']
        data.pop('password1')
        data.pop('password2')
        return data

    def clean(self, request, locations=None):
        cleaned = super().clean(request, locations=locations)
        usr = User.objects.get_or_none(email=cleaned['email'].strip())
        if usr:
            raise falcon.HTTPForbidden(
                description=_('Account for this email already exist'))

        # Model validation
        usr = User(**cleaned)
        self.clean_model(usr)
        return cleaned

    class Meta:
        strict = True
コード例 #3
0
ファイル: schemas.py プロジェクト: kaglowka/danyzespolapi
class ApplicationProposal(Schema):
    applicant_email = fields.Email(required=True)
    title = fields.Str(required=True,
                       error_messages=str_error_messages,
                       faker_type='application title',
                       example='Some App')
    url = fields.Url(required=True)
    notes = fields.Str(required=True)
    image = fields.Raw(required=False)
    datasets = fields.List(fields.Int(), required=False)

    class Meta:
        strict = True
コード例 #4
0
ファイル: schemas.py プロジェクト: horosin/mcod-backend
class Login(Schema):
    """
        Login request
    """
    email = fields.Email(required=True,
                         faker_type='email',
                         example='*****@*****.**')
    password = fields.Str(required=True,
                          faker_type='password',
                          example='Kai7!!phoom')

    class Meta:
        strict = True
コード例 #5
0
ファイル: schemas.py プロジェクト: horosin/mcod-backend
class ApplicationSuggestion(Schema):
    applicant_email = fields.Email(required=False)
    author = fields.Str(required=False)
    title = fields.Str(required=True,
                       faker_type='application title',
                       example='Some App')
    url = fields.Url(required=True)
    notes = fields.Str(required=True)
    image = fields.Base64(required=False,
                          max_size=settings.IMAGE_UPLOAD_MAX_SIZE)
    datasets = fields.List(fields.Int(), required=False)
    external_datasets = fields.Nested(ApplicationExternalData,
                                      required=False,
                                      many=True)
    keywords = fields.List(fields.Str(), required=False)

    class Meta:
        strict = True