示例#1
0
文件: index.py 项目: KasaiDot/bangumi
def create_or_login(resp):
    user = User.query.filter_by(google_account=resp.email).first()
    if user is None:
        user = User(nickname=resp.nickname or resp.fullname, google_account=resp.email,
                    openid=resp.identity_url)
        if user.register():
            flash(u"You've successfully registered and signed in!")
        else:
            flash(u'Register failed!')
            return redirect(oid.get_next_url())
    else:
        flash("You've successfully logged in!")
    session['user_id'] = user.id
    g.user = user
    return redirect(oid.get_next_url())
示例#2
0
文件: index.py 项目: ececleon/bangumi
def create_or_login(resp):
    user = User.query.filter_by(google_account=resp.email).first()
    if user is None:
        user = User(nickname=resp.nickname or resp.fullname,
                    google_account=resp.email,
                    openid=resp.identity_url)
        if user.register():
            flash(u"You've successfully registered and signed in!")
        else:
            flash(u'Register failed!')
            return redirect(oid.get_next_url())
    else:
        flash("You've successfully logged in!")
    session['user_id'] = user.id
    g.user = user
    return redirect(oid.get_next_url())
示例#3
0
 def test_like(self):
     User(nickname='kxxoling',
          openid='',
          google_account='*****@*****.**').register()
     Anime(cn_name=u'JOJO', name=u'JOJO的奇妙冒险').create()
     anime = Anime.query.all()[0]
     anime.add_recommend(
         ActorQuote(anime_id=1, actor_line='', actor_pic='', actor=''))
     user = User.query.all()[0]
     quote = ActorQuote.query.all()[0]
     user.like(quote)
     assert ActorQuote.query.all()[0].likes == 1
示例#4
0
 def test_update(self):
     user = User(nickname='kxxoling',
                 openid='',
                 google_account='*****@*****.**')
     user.register()
     user.update()
     assert User.query.filter_by(nickname='kxxoling')[0] is not None
示例#5
0
 def test_update_role(self):
     user = User(nickname='kxxoling',
                 openid='',
                 google_account='*****@*****.**')
     user.register()
     user.update_role(3)
     role2 = User.query.filter_by(nickname='kxxoling')[0].role
     assert role2 == 3
示例#6
0
 def test_delete(self):
     user = User(nickname='kxxoling',
                 openid='',
                 google_account='*****@*****.**')
     user.register()
     for user in User.query.all():
         user.delete()
     assert User.query.count() == 0
示例#7
0
文件: run.py 项目: ececleon/bangumi
#! -*- coding: utf8 -*-
from website import app
from website.models.models import Anime, ActorQuote, AnimeReview, Torrent, User

if __name__ == '__main__':
    User(
        'kxxoling',
        'https://www.google.com/accounts/o8/id?id=AItOawnbfJtiF3G0UihMZZ06LyoJjKM2L3bp4LQ',
        '*****@*****.**').create()
    Anime(u'化物语', u'化物语', finished=1, name=u'化物语').create()
    Anime(u'囮物语', u'物语系列', finished=1, name=u'物语系列').create()
    Anime(u'物语系列(二)', u'物语系列(二)', finished=1, name=u'物语系列(二)').create()
    Anime(u'虫师 续章', u'虫师 续章', finished=1, name=u'虫师 续章').create()
    assert Anime.query.count >= 4
    ActorQuote(u'好奇心就像蟑螂——随意的打听不想被人触及的秘密。让人郁闷到不行。伤脑筋的恶心虫子。', 1,
               actor=u'战场原黑仪').create()
    ActorQuote(
        u'不过,心神荡漾的荡字,是个很不错的词。你知道吗?草字头下一个汤。我觉得,这要比草字头下一个明的萌字更上一层楼。'
        u'作为次世代的敏感单词,它很受期待哟。比如、女仆荡漾、猫耳荡漾之类。',
        1,
        actor=u'战场原黑仪').create()
    ActorQuote(
        u'喜欢的东西变得厌倦了,喜欢的东西变得讨厌了——这很难受吧,这很无趣吧?一般来说,十份现在的讨厌,加上过去十份的喜欢,'
        u'就会变成二十份的讨厌了吧?这种事——会让人屈服呢',
        1,
        actor=u'战场原黑仪').create()
    ActorQuote(u'好、好厉害。没想到竟然是这么变态的……果然不愧为历哥哥……真不是盖的……不、不对,可是。这个也……',
               2,
               actor=u'千石抚子').create()
    ActorQuote(u'如、如果抚子不可爱的话……月火你在那时候就不跟抚子做朋友……了吗?', 2, actor=u'千石抚子').create()
    ActorQuote(u'呀啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊!',
示例#8
0
 def test_update_role(self):
     user = User(nickname='kxxoling', openid='', google_account='*****@*****.**')
     user.register()
     user.update_role(3)
     role2 = User.query.filter_by(nickname='kxxoling')[0].role
     assert role2 == 3
示例#9
0
 def test_delete(self):
     user = User(nickname='kxxoling', openid='', google_account='*****@*****.**')
     user.register()
     for user in User.query.all():
         user.delete()
     assert User.query.count() == 0
示例#10
0
 def test_update(self):
     user = User(nickname='kxxoling', openid='', google_account='*****@*****.**')
     user.register()
     user.update()
     assert User.query.filter_by(nickname='kxxoling')[0] is not None