Пример #1
0
    def setUp(self):
        # clean DB
        db.users.drop()
        db.events.drop()
        db.groups.drop()

        # create normal user
        a = unicode(uuid.uuid1())
        u = User.create(username=u'test',
                        password=u'test',
                        roles=[u'authenticated'],
                        signup_email=u'test@localhost',
                        activation_key=a,
                        active=True)
        #print u
        self.assertNotEqual(u, None)

        # create a moderator
        a = unicode(uuid.uuid1())
        u = User.create(username=u'mod',
                        password=u'mod',
                        roles=[u'authenticated', u'moderator'],
                        signup_email=u'mod@localhost',
                        activation_key=a,
                        active=True)
        #print u
        self.assertNotEqual(u, None)
Пример #2
0
    def setUp(self):
        # clean DB
        db.users.drop()
        db.events.drop()
        db.groups.drop()

        # create normal user
        a = unicode(uuid.uuid1())
        u = User.create(username=u'test',
                        password=u'test',
                        roles=[u'authenticated'],
                        signup_email=u'test@localhost',
                        activation_key=a,
                        active=True)
        #print u
        self.assertNotEqual(u, None)

        # create a moderator
        a = unicode(uuid.uuid1())
        u = User.create(username=u'mod',
                        password=u'mod',
                        roles=[u'authenticated', u'moderator'],
                        signup_email=u'mod@localhost',
                        activation_key=a,
                        active=True)
        #print u
        self.assertNotEqual(u, None)
Пример #3
0
 def adduser(user, password, email, moderator=False):
     # create normal user
     a = unicode(uuid.uuid1())
     u = User.create(username=unicode(user),
                     password=unicode(password),
                     signup_email=unicode(email),
                     activation_key=a,
                     )
     u.active = True
     if moderator:
         u.roles.append(u"moderator")
     u.save()
Пример #4
0
 def adduser(user, password, email, moderator=False):
     # create normal user
     a = unicode(uuid.uuid1())
     u = User.create(
         username=unicode(user),
         password=unicode(password),
         signup_email=unicode(email),
         activation_key=a,
     )
     u.active = True
     if moderator:
         u.roles.append(u"moderator")
     u.save()
Пример #5
0
def login():
    form = Login_Form(username=request.args.get("username", None),
                     next=request.args.get("next", None))
    if form.validate_on_submit():
        user, authenticated = User.authenticate(form.username.data,
                                                form.password.data)
        if user and authenticated:
            login_user(user)
            flash("Logged in successfully.")
            return redirect( url_for('accounts.profile',
                                     username=user.username))
        flash("Sorry, wrong credentials")
    return render_template('accounts/login.html', form=form)
Пример #6
0
def login():
    form = Login_Form(username=request.args.get("username", None),
                      next=request.args.get("next", None))
    if form.validate_on_submit():
        user, authenticated = User.authenticate(form.username.data,
                                                form.password.data)
        if user and authenticated:
            login_user(user)
            flash("Logged in successfully.")
            return redirect(url_for('accounts.profile',
                                    username=user.username))
        flash("Sorry, wrong credentials")
    return render_template('accounts/login.html', form=form)
Пример #7
0
 def test_create_user_and_login_without_activation(self):
     a = unicode(uuid.uuid1())
     p = db.Profile()
     u = User.create(username=u'test99',
                     password=u'test99',
                     signup_email=u'test@localhost',
                     activation_key=a,
                     )
     self.assertNotEqual(u, None)
     response = self.client.post("/users/login",
                                 data={'username': '******',
                                       'password': '******'})
     self.assert200(response)
     assert "Sorry, wrong credentials" in response.data
Пример #8
0
 def create_user(self, username):
     u = User.create( username=username, password=u'hallo',
                      signup_email=u'planlos-test1@localhost')
Пример #9
0
 def create_user(self, username):
     u = User.create(username=username,
                     password=u'hallo',
                     signup_email=u'planlos-test1@localhost')
Пример #10
0
def profile(username):
    user = User.get_by_name(username)
    userprofile = user.profile
    return render_template('accounts/profile.html',
                           user=user,
                           profile=profile)
Пример #11
0
def profile(username):
    user = User.get_by_name(username)
    userprofile = user.profile
    return render_template('accounts/profile.html', user=user, profile=profile)