def test_user_keys(self):
    '''
    classes.user:  Test that the User class returns the right keys.

    '''
    result = User('luiscape').info()

    for key in self.keys:
      self.assertIn(key, result.keys())
예제 #2
0
def fetchClassData(key=None, id=None):
    '''
  Loads data from specified CKAN object class.

  '''
    classes = {
        'users': User(id),
        'countries': Country(id),
        'datasets': Dataset(id),
        'revisions': Revision(id),
        'resources': Resource(id),
        'gallery_items': GalleryItem(id),
        'organizations': Organization(id)
    }

    #
    # Selects only the fields
    # of interest from the dictionary.
    #
    result = {k: classes[key].info()[k] for k in _fields(config, key)}
    return result
def signin():
    form = CustomerSigninForm()
    if request.method == 'POST':
        
        password=request.form['password']
        email=request.form['email']
        
        if email and password:
            user = User(email, password, mysql)
            if user.authenticated:
                login_user(user)
                session['logged_in'] = True
                session['user email'] = user.get_id() 
                session['user name'] = user.get_user_name()
                return render_template('account_management.html', accountInfo = { "name" : user.get_user_name(), "email" : user.get_id(), "counts" : session['counts']})

            else:
                session['logged_in'] = False
                return render_template('signin.html', form=form)
    else:
        session['logged_in'] = False
        return render_template('signin.html', form=form)
예제 #4
0
	def setUp(self):
		self.user = User('ariana', '*****@*****.**', 'abcde')
예제 #5
0
def register():
    form = RegistrationForm()

    if request.method == 'POST':
        if form.validate_on_submit():

            try:
                theanonid = random_user_name_anon()
                now = datetime.utcnow()
                cryptedpwd = User.cryptpassword(password=form.password.data)

                # add user to db
                newuser = User(user_name=form.user_name.data,
                               email=form.email.data,
                               password_hash=cryptedpwd,
                               wallet_pin='0',
                               profileimage='',
                               bannerimage='',
                               member_since=now,
                               admin=0,
                               admin_role=0,
                               bio='',
                               last_seen=now,
                               locked=0,
                               fails=0,
                               confirmed=0,
                               anon_id=theanonid,
                               anon_mode=0,
                               over_age=0,
                               agree_to_tos=True,
                               banned=0,
                               color_theme=3,
                               post_style=1)
                db.session.add(newuser)
                db.session.commit()

                # profile info
                userbio = UserPublicInfo(user_id=newuser.id,
                                         bio='',
                                         short_bio='')

                stats_for_bch = UserStatsBCH(
                    user_name=newuser.user_name,
                    user_id=newuser.id,
                    # given to posters/commenters
                    total_donated_to_postcomments_bch=0,
                    total_donated_to_postcomments_usd=0,
                    # recieved from posting
                    total_recievedfromposts_bch=0,
                    total_recievedfromposts_usd=0,
                    # recieved from comments
                    total_recievedfromcomments_bch=0,
                    total_recievedfromcomments_usd=0,
                    # given to charities
                    total_donated_to_cause_bch=0,
                    total_donated_to_cause_usd=0,
                )

                stats_for_user = UserStats(user_name=newuser.user_name,
                                           user_id=newuser.id,
                                           post_upvotes=0,
                                           post_downvotes=0,
                                           comment_upvotes=0,
                                           comment_downvotes=0,
                                           total_posts=0,
                                           total_comments=0,
                                           user_level=1,
                                           user_exp=0,
                                           user_width_next_level='0')

                users_timers = UserTimers(user_name=newuser.user_name,
                                          user_id=newuser.id,
                                          account_created=now,
                                          last_post=now,
                                          last_common_creation=now,
                                          last_comment=now,
                                          last_report=now)

                # add to db
                db.session.add(userbio)
                db.session.add(users_timers)
                db.session.add(stats_for_user)
                db.session.add(stats_for_bch)

                # commit
                db.session.commit()
                # make a user a directory
                getusernodelocation = userimagelocation(x=newuser.id)
                userfolderlocation = os.path.join(UPLOADED_FILES_DEST,
                                                  current_disk, 'user',
                                                  getusernodelocation,
                                                  str(newuser.id))
                mkdir_p(path=userfolderlocation)
                # login new user

                try:
                    # bitcoin cash
                    bch_create_wallet(user_id=newuser.id)
                except:
                    pass

                login_user(newuser)
                current_user.is_authenticated()
                current_user.is_active()

                flash(
                    "Successfully Registered."
                    "  If you want to access your wallet,"
                    " you will need to confirm your email.  If you used an invalid email,"
                    " you can change this in account settings.",
                    category="success")
                return redirect(url_for('welcome'))
            except Exception as e:

                return redirect((request.args.get('next', request.referrer)))

        else:
            for errors in form.user_name.errors:
                flash(errors, category="danger")
            for errors in form.password.errors:
                flash(errors, category="danger")
            for errors in form.passwordtwo.errors:
                flash(errors, category="danger")
            for errors in form.passwordtwo.errors:
                flash(errors, category="danger")

            return redirect((request.args.get('next', request.referrer)))
    return render_template('users/register.html', form=form)
예제 #6
0
    def setUp(self):

        self.user = User('*****@*****.**', 'password', 'joy')
        self.slist = SList('joybirthday')
        self.item = Item('cake', 2000)
예제 #7
0
 def setUp(self):
     self.user = User('dottie', '*****@*****.**', 'abcdefg')