Ejemplo n.º 1
0
 def post(self):
     res = {}
     info = self.get_info()
     res['url'] = self.get_url()
     res.update(info)
     res['form'] = json.dumps(request.form) if request.form else None
     res['headers'] = dict(request.headers)
     res['headers']["Host"] = "sv.baidu.com"
     res["headers"] = json.dumps(res["headers"])
     profile = Profile.query.filter_by(uid=info["uid"]).first()
     if profile:
         profile.update(**res)
     else:
         profile = Profile()
         profile.create(**res)
     return "ok"
Ejemplo n.º 2
0
def add_or_update_profile_callback(room, event):
    username = event['sender']
    args = event['content']['body'].split()
    profile_name = args[1]
    profile_phone = args[2]
    profile_password = args[3]
    # TODO проверка, есть ли уже профиль с введенными данными.
    # TODO Если есть - вывести сообщение и return
    user = User.get_or_create(username=username)[0]
    profile = Profile.get_or_none(Profile.owner == user,
                                  Profile.name == profile_name)
    if profile:
        profile.phone_number = profile_phone
        profile.password = profile_password
        profile.save()
    else:
        profile = Profile.create(owner=user,
                                 name=profile_name,
                                 phone_number=profile_phone,
                                 password=profile_password)
    current_profile = CurrentProfile.get_or_none(user=user)
    if current_profile:
        current_profile.profile = profile
        current_profile.save()
    else:
        current_profile = CurrentProfile.create(user=user, profile=profile)
    connection = UmsConnection(profile_phone, profile_password)
    CONNECTIONS.append((profile, connection))
    captcha = connection.get_captcha()
    url = BOT.client.upload(captcha, 'image/png')
    room.send_text('Профиль добавлен, введите капчу командой captcha <key>')
    room.send_image(url, 'captcha.png')
Ejemplo n.º 3
0
 def post(self, **kwargs):
     redirect_url = self.redirect_path()
     if self.auth_current_user:
         return redirect(redirect_url)
     
     if self.form.validate():
         username = self.form.username.data
         password = self.form.password.data
         password_confirm = self.form.password_confirm.data
         email = self.form.email.data
         email_confirm = self.form.email_confirm.data
         
         if password != password_confirm:
             self.set_message('error', 'Password doesnt match', life=None)
             return self.get(**kwargs)
         
         if email != email_confirm:
             self.set_message('error', 'E-mail doesnt match', life=None)
             return self.get(**kwargs)
         
         auth_id = 'own|%s' % username
         user = self.auth_create_user(username, auth_id, password=password, email=email)
         if user:
             profile = Profile.create(user.key())
             if profile:
                 url = '/mail/verify/%s/' % user.key()
                 task = taskqueue.add(url=url, method='GET')
             self.auth_set_session(user.auth_id, user.session_id, '1')
             self.set_message('success', 'You are now registered', flash=True, life=5)
             return redirect(redirect_url)
         else:
             self.set_message('error', 'This username is taken', life=None)
             return self.get(**kwargs)
         
     self.set_message('error', 'A problem occurred!', life=None)
     return self.get(**kwargs)
Ejemplo n.º 4
0
    except Users.DoesNotExist:
        Users.create(pk=follower['pk'],
                     full_name=str(follower['full_name']),
                     has_anonymous_profile_picture=str(
                         follower['has_anonymous_profile_picture']),
                     is_private=str(follower['is_private']),
                     is_verified=str(follower['is_verified']),
                     profile_pic_url=str(follower['profile_pic_url']),
                     username=str(follower['username']),
                     insta_link='https://www.instagram.com/' +
                     str(follower['username']) + '/')
date = datetime.datetime.now()

for item in Profile.select().order_by(Profile.id.desc()).limit(1):
    previous_followers = list(map(int, item.followers.split()))
unfollow = set(previous_followers) - set(followers_ids)
follow = set(followers_ids) - set(previous_followers)
unfollow_len = len(unfollow)
follow_len = len(follow)
follow_str = " ".join(str(pk) for pk in follow)
unfollow_str = " ".join(str(pk) for pk in follow)
Friendship.create(
    date=date,
    followed=follow_str,
    followed_counter=follow_len,
    unfollowed=unfollow_str,
    unfollowed_counter=unfollow_len,
)
followers_string = " ".join(str(pk) for pk in followers_ids)
Profile.create(date=date, count=len(followers_ids), followers=followers_string)
 def create_one_user_profile(self, username, email, password):
     user = User.objects.create_user(username, email, password)
     user.save()
     profile = Profile.create(user)
     return profile