Example #1
0
def create_administrator():
    print "####### CREATE ADMINISTRATOR #######"
    username = raw_input(
        "Username (leave blank to use 'administrator'):") or "administrator"
    email = raw_input("Email address (leave blank to use '" +
                      app.config['FLASK_ADMIN'] +
                      "'):") or app.config['FLASK_ADMIN']
    password = raw_input("Password:"******"Password (again):")

    administrator_json = {
        "email": email,
        "username": username,
        "password": password,
        "password2": re_password
    }
    valid, errors = RegistrationForm.check(administrator_json)
    if valid:
        user = User(email=email,
                    username=username,
                    password=password,
                    confirmed=True)
        db.session.add(user)
        db.session.commit()
        user.set_roles(Role.ADMINISTRATOR)
        print "Administrator created successfully."
    else:
        print "Fail to create Administrator!", errors
Example #2
0
    def setUp(self):
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
        with app.app_context():
            db.drop_all()
            db.create_all()

        # Create mock user
        password = bcrypt.generate_password_hash("password")
        self.user = User("test_user_1", password)
        self.user2 = User("test_user_3", password)
        db.session.add(self.user)
        db.session.add(self.user2)
        db.session.commit()
    def setUp(self):
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
        with app.app_context():
            db.drop_all()
            db.create_all()

        # Create mock user
        password = bcrypt.generate_password_hash("password")
        self.user = User("test_user_1", password)
        self.user2 = User("test_user_2", password)
        self.player = Player(self.user, "Lannister")
        self.player2 = Player(self.user2, "Stark")
        self.town = Town(self.player2, "Winterfell", knights=1)
        self.attack = Attack(self.player, self.town, None, cavalry=100)
        db.session.add(self.user)
        db.session.add(self.user2)
        db.session.commit()
Example #4
0
def create_account():
    if (request.form):
        account_details = request.form
    else:
        account_details = request.get_json()
    username = account_details['username']
    password = bcrypt.generate_password_hash(account_details['password'])
    user = User(username, password, dogecoin=0)
    db.session.add(user)
    try:
        db.session.commit()
        return "<meta http-equiv='refresh' content='3;URL=auth/login' />Account created successfully. Login in 3 seconds.", 200
    except:
        return "<meta http-equiv='refresh' content='3;URL=auth/login' />Oops! Something went wrong. Try again in 3 seconds."
Example #5
0
    def setUp(self):
        self.app = app.test_client()

        app.config['TESTING'] = True
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
        with app.app_context():
            db.drop_all()
            db.create_all()

        password = bcrypt.generate_password_hash("password")
        self.user = User("test", password)
        self.player = Player(self.user, "Lannister")

        db.session.add(self.user)
        db.session.commit()
        self.user = User.query.first()
 def setUp(self):
     self.user = User("Jaime", "pass")
     self.player = Player(self.user, "")
     self.town = Town(self.player, "King's landing", farm=2)
 def setUp(self):
     self.user = User("Jaime", "pass")
Example #8
0
from app.db import db
from app.auth.models.user import User
from app.assign.models.user_info import UserInfo
from app import create_app

app = create_app()
with app.app_context():
    db.create_all()

    memo = User('memo', 'pass', '*****@*****.**')

    memow = User('memo2', 'pass', '*****@*****.**')

    db.session.add(memo)
    db.session.add(memow)

    db.session.commit()

    memo_info = UserInfo(memo, 30, "pass", "pass")
    memow_info = UserInfo(memow, 60, "pass", "pass")

    db.session.add(memo_info)
    db.session.add(memow_info)

    db.session.commit()