示例#1
0
 def setup(self):
     self.username = '******'
     self.password = '******'
     self.email = '*****@*****.**'
     User.create_user(username=self.username,
                      password=self.password,
                      email=self.email)
示例#2
0
 def setup(self):
     self.username = '******'
     self.password = '******'
     self.email = '*****@*****.**'
     User.create_user(
         username=self.username, password=self.password,
         email=self.email
     )
示例#3
0
 def delete(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if id in current_user.blocked_user_id:
         User.objects(id=current_user.id) \
             .update_one(pull__blocked_user_id=id)
     return '', 204
示例#4
0
 def delete(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if user in current_user.following:
         User.objects(id=current_user.id) \
             .update_one(pull__following=user.to_dbref())
         User.objects(id=id) \
             .update_one(pull__follower=current_user.to_dbref())
     return '', 204
示例#5
0
 def put(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if id not in current_user.blocked_user_id:
         User.objects(id=current_user.id) \
             .update_one(push__blocked_user_id=id)
         status_fields = generate_status_fields(OK)
     else:
         status_fields = generate_status_fields(EXISTING)
     return status_fields, 202
示例#6
0
 def put(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if user not in current_user.following:
         User.objects(id=current_user.id) \
             .update_one(push__following=user.to_dbref())
         User.objects(id=id) \
             .update_one(push__follower=current_user.to_dbref())
         status_fields = generate_status_fields(OK)
     else:
         status_fields = generate_status_fields(EXISTING)
     return status_fields, 202
示例#7
0
 def setup(self):
     self.users = []
     for x in range(3):
         self.users.append(
             User.create_user(username='******' + str(x),
                              password='******' + str(x),
                              email='user' + str(x) + '@a.com'))
示例#8
0
 def setup(self):
     self.users = []
     for x in range(3):
         self.users.append(
             User.create_user(
                 username='******' + str(x),
                 password='******' + str(x),
                 email='user' + str(x) + '@a.com'
             )
         )
示例#9
0
文件: user.py 项目: tmacjx/firefly
 def delete(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if user in current_user.following:
         current_user.update_one(pull_follwing=user)
         user.update_one(pull_follwer=current_user)
         status_fields = generate_status_fields(OK)
     else:
         status_fields = generate_status_fields(NOTFOUND)
     return status_fields, 204
示例#10
0
文件: user.py 项目: duoduo369/firefly
 def delete(self, id):
     user = User.objects(id=id).first()
     if user is None:
         status_fields = generate_status_fields(NOTFOUND)
         return status_fields, 404
     if user in current_user.following:
         current_user.update_one(pull_follwing=user)
         user.update_one(pull_follwer=current_user)
         status_fields = generate_status_fields(OK)
     else:
         status_fields = generate_status_fields(NOTFOUND)
     return status_fields, 204
示例#11
0
    def setup(self):
        c = Category.objects.create(
            name=u'python', description=u'描述', _slug=u'python-slug'
        )
        Post.objects.create(
            title=u'标题test', content=u'内容test', category=c
        )

        # login user
        self.username = '******'
        self.password = '******'
        self.email = '*****@*****.**'
        self.user = User.create_user(
            username=self.username, password=self.password,
            email=self.email
        )
示例#12
0
    def login(cls):
        user = User.objects.filter(email='*****@*****.**').first()
        if user is None:
            user = User.create_user('foo', '*****@*****.**', 'foobar')
        else:
            user.set_password('foobar')
            user.save()

        form = {
            'email': '*****@*****.**',
            'password': '******',
        }
        rv = client.post(url_for('home.login'),
                         data=form,
                         follow_redirects=True)
        assert current_user.is_authenticated()
        assert url_for('security.logout') in rv.data
示例#13
0
    def login(cls):
        user = User.objects.filter(email='*****@*****.**').first()
        if user is None:
            user = User.create_user('foo', '*****@*****.**', 'foobar')
        else:
            user.set_password('foobar')
            user.save()

        form = {
            'email': '*****@*****.**',
            'password': '******',
        }
        rv = client.post(
            url_for('home.login'), data=form,
            follow_redirects=True
        )
        assert current_user.is_authenticated()
        assert url_for('security.logout') in rv.data
示例#14
0
 def save(self):
     return User.create_user(
         username=self.username.data, email=self.email.data,
         password=self.password.data
     )
示例#15
0
文件: app.py 项目: guoyu07/firefly
 def load_user(user_id):
     return User.objects(_id=user_id)
示例#16
0
文件: app.py 项目: pino2046/firefly-1
 def load_user(user_id):
     return User.objects(_id=user_id)