示例#1
0
文件: handlers.py 项目: gage/proto
    def create_validate(self, query_dict, **kwargs):
        # user_identity can be email, username, user_id, phone_sms_e164
        if query_dict.get('username'):
            user_identity = query_dict.get('username')
        else:
            user_identity = query_dict.get('user_identity')
        try:
            if is_mongo_pk(user_identity):
                user = User.objects.get(id=user_identity)
                query_dict['use_system_gen_password'] = True
            elif user_identity.startswith('+'):
                user_profile = UserProfile.objects.get(phone_sms_e164=user_identity)
                user = user_profile.user
            elif email_re.match(user_identity):
                user = User.objects.get(email=user_identity)
            else:
                user = User.objects.get(username=user_identity)
        except User.DoesNotExist:
            raise api_errors.APIException(api_errors.ERROR_AUTH_USERNAME_NOT_EXIST)

        if not user.is_active:
            raise api_errors.APIException(api_errors.ERROR_REGISTRATION_NOT_ACTIVATE)

        query_dict['user'] = user
示例#2
0
文件: handlers.py 项目: gage/proto
 def read_validate(self, query_dict, object_id, **kwargs):
     if is_mongo_pk(object_id):
         query_dict['obj'] = SoundCloud.objects.get(id=object_id)
     else:
         obj = SoundCloud.objects.create_object_by_id(object_id)
         query_dict['obj'] = obj
示例#3
0
文件: handlers.py 项目: gage/proto
 def read_validate(self, query_dict, object_id, **kwargs):
     if is_mongo_pk(object_id):
         query_dict['obj'] = YoutubeVideo.objects.get(id=object_id)
     else:
         obj = YoutubeVideo.objects.create_youtube_object_by_id(object_id)
         query_dict['obj'] = obj