Exemplo n.º 1
0
def insert_data():
    user = User(username='******', email="*****@*****.**", password="******")
    db.session.add(user)

    def add_bookmark(url, description, tags):
        db.session.add(Bookmark(url=url, description=description,
                                user=user, tags=tags))

    for name in ["python", "flask", "webdev", "programming", "training", "orm",
                 "databases", "news"]:
        db.session.add(Tag(name=name))
    db.session.commit()

    add_bookmark("http://www.pluralsight.com", "Pluralsite. Hard","training")
    add_bookmark("http://www.python.org", "Python - my favorite...", "python")
    add_bookmark("http://flask.pocoo.org", "Flask: web development", "flask")
    add_bookmark("http://www.reddit.com", "Reddit: frontpage", "")
    add_bookmark("http://www.sqlalchemy.org", "nice orm framework", "python,orm,databases")
    add_bookmark("http://werkzeug.pocoo.org/docs/", "Werkzeug", "")
    add_bookmark("http://jinja.pocoo.org", "Jinja templates", "programming,flask,webdev")
    add_bookmark("http://pythonhosted.org/Flask-SQLAlchemy", "", "orm")
    add_bookmark("http://www.initializr.com", " get up and running with HTML5", "webdev")
    add_bookmark("http://emacswiki.org", "all about emacs", "")
    add_bookmark("http://vimwiki.org", "", "vim")
    add_bookmark("http://orgmode.org", "productivity in text mode", "gtd")
    add_bookmark("http://ipython.org", "iipython. interactive compution", "python")
    add_bookmark("http://djangoproject.org", "django - another web framework", "")
    add_bookmark("http://", "", "")
    add_bookmark("http://stackoverflow.com", "", "")

    another_user = User(username="******", email="*****@*****.**", password="******")
    db.session.add(another_user)
    db.session.commit()
Exemplo n.º 2
0
def initdb():
    db.create_all()
    db.session.add(
        User(username='******', email='*****@*****.**', password='******'))
    db.session.add(User(username='******', email='*****@*****.**', password='******'))
    db.session.commit()
    print 'Initialized Database'
def initdb():
    db.create_all()
    db.session.add(User(username="******", email="*****@*****.**"))
    db.session.add(
        User(username="******", email="*****@*****.**"))
    db.session.commit()
    print "Initialized the database"
Exemplo n.º 4
0
    def setUp(self):
        thermos.admin._views = []  #Workaround for blueprint registration
        #rest_api.resources = [] #Workaround for blueprint registration
        self.db = thermos.db
        with self.app.app_context():
            self.db.create_all()
        self.client = self.app.test_client()

        self.test_user = User(username='******',
                              email='*****@*****.**',
                              password='******')

        self.db.session.add(self.test_user)
        bm = Bookmark(user=self.test_user,
                      url='http://hackaday.com',
                      description='A DIY hacking blog',
                      tags='one,two,three')
        self.db.session.add(bm)
        self.db.session.commit()

        other_user = User(username='******',
                          email='*****@*****.**',
                          password='******')
        self.db.session.add(other_user)
        bm2 = Bookmark(user=other_user,
                       url='http://phys.org',
                       description='A phyics news site',
                       tags='one,two,three')
        self.db.session.add(bm2)
        self.db.session.commit()
Exemplo n.º 5
0
def initdb():
    db.create_all()
    db.session.add(
        User(username='******', email='*****@*****.**', password='******'))
    db.session.add(
        User(username='******', email='*****@*****.**', password='******'))
    db.session.commit()
    print 'Initialized the database'
Exemplo n.º 6
0
def initdb():
    db.create_all()
    db.session.add(
        User(username="******", email='*****@*****.**', password='******'))
    db.session.add(
        User(username="******", email='*****@*****.**', password='******'))
    db.session.commit()
    print 'Initialzed the database'
def initdb():
    db.create_all()
    db.session.add(
        User(username="******", email="*****@*****.**", password="******"))

    db.session.add(
        User(username="******", email="*****@*****.**", password="******"))

    db.session.commit()
    print 'Initialized the database'
Exemplo n.º 8
0
def initdb():
    db.create_all()
    db.session.add(
        User(username="******",
             email="*****@*****.**",
             password="******"))
    db.session.add(
        User(username="******",
             email="*****@*****.**",
             password="******"))
    db.session.commit()
    print('initialized the database')
Exemplo n.º 9
0
def initdb():
    db.create_all()
    db.session.add(
        User(username="******",
             email="*****@*****.**",
             password="******"))
    db.session.add(
        User(username="******",
             email="*****@*****.**",
             password="******"))
    db.session.commit()
    print 'Initialized the database'
Exemplo n.º 10
0
def initdb():
    db.create_all()
    db.session.add(
        User(username='******',
             email='*****@*****.**',
             password='******'))
    db.session.add(
        User(username='******',
             email='*****@*****.**',
             password='******'))
    db.session.commit()
    print('Initialized the database')
Exemplo n.º 11
0
def initdb():
    db.create_all()
    db.session.add(
        User(username="******",
             email="*****@*****.**",
             password="******"))

    db.session.add(
        User(username="******", email="*****@*****.**", password="******"))

    db.session.commit()
    print('Initialized the database')
Exemplo n.º 12
0
def add():
    form = BookmarkForm()
    application.logger.info('Route to /add')
    application.logger.debug('no reroute from root to /add')
    if form.validate_on_submit():
        url = form.url.data
        description = form.description.data
        user = form.user.data
        application.logger.info(str(url), str(description), str(user))
        print(db.session)
        bkusr = User.query.filter_by(username=user).first()
        if not bkusr and user:
            bkusr = User(username=user, email=user + "@thermos.com")
            db.session.add(bkusr)
        tags = form.tags.data
        bkm = Bookmark(url=url,
                       description=description,
                       user=bkusr or current_user,
                       bkmrkusername=bkusr.username,
                       tags=tags)
        db.session.add(bkm)
        db.session.commit()
        storebookmark(url, user, description)
        # if request.method == "POST":
        #     url = request.form.get("url")
        #     user = request.form.get("user")
        #     storebookmark(url, user)
        application.logger.info("Added url for user url: {}, user: {}".format(
            url, user or "Debabrata"))
        flash("Bookmarked url: {} for user: {}".format(
            url, user if user else "Debabrata(Default)"))
        return redirect(url_for("index"))
    return render_template("bookmarkform.html", form=form)
Exemplo n.º 13
0
 def create_user(self):
     username = '******'.format(self.usernumber())
     if not User.query.filter_by(username=username).first():
         db.session.add(User(username=username, email="{}@example.com".format(username), password=username))
     else:
         print '{} already exists'.format(username)
     return User.get_by_username(username)
Exemplo n.º 14
0
def insert_data():
    # Add users
    xarisd = User(username='******',
                  email='*****@*****.**',
                  password='******')

    db.session.add(xarisd)

    matina = User(username='******',
                  email='*****@*****.**',
                  password='******')
    db.session.add(matina)

    db.session.commit()

    # Add tags
    for name in [
            "python",
            "flask",
            "webdev",
            "views",
            "forms",
            "html5",
    ]:
        db.session.add(Tag(name=name))
    db.session.commit()

    def add_bookmark(url, description, tags):
        db.session.add(
            Bookmark(url=url, description=description, tags=tags, user=xarisd))

    add_bookmark('http://flask.pocoo.org/', 'Flask', 'flask,python')
    add_bookmark('http://jinja.pocoo.org/', 'Jinja2', 'flask,python,views')
    add_bookmark('http://www.initializr.com', 'Initializr', 'html5,webdev')
    add_bookmark('http://flask.pocoo.org/docs/0.10/quickstart/#url-building',
                 'Url building in Flask', 'html5,webdev,flask,python')
    add_bookmark('https://pypi.python.org/pypi/Flask-Bootstrap',
                 'Flask-Bootstrap extension', 'html5,webdev,flask,python')
    add_bookmark(
        'http://jinja.pocoo.org/docs/dev/templates/'
        '#list-of-control-structures', 'Control structures in Jinja2',
        'flask,python,views')
    add_bookmark('https://flask-wtf.readthedocs.org/en/latest/',
                 'Flask-WTF documentation', 'python,flask,html5,webdev,forms')

    db.session.commit()
    print('Initialized the database')
Exemplo n.º 15
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        invalidUsername = User.getByUsername(form.username.data)
        invalidEmail = User.getByEmail(form.email.data)
        if invalidUsername is None and invalidEmail is None:
            db.session.add(user)
            db.session.commit()
            flash('Welcome, {}! Please login.'.format(user.username))
            return redirect(url_for('login'))
        elif invalidUsername:
            flash('Username has already been registered by another user.')
        elif invalidEmail:
            flash(
                'E-mail address has already been registered by another user.')
    return render_template("signup.html", form=form)
Exemplo n.º 16
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.get_by_username(form.username.data)
        if user is not None and user.check_password(form.password.data):
            login_user(user, form.remember_me.data)
            flash("Logged in successfully as {}.".format(user.username))
            return redirect(request.args.get('next') or url_for('user', username=user.username))
        flash('Incorrect username or password.')
    return render_template("login.html", form=form)
Exemplo n.º 17
0
def insert_data():
    mickey = User(username="******", email="*****@*****.**", password="******")
    db.session.add(mickey)

    minnie = User(username="******", email="*****@*****.**", password="******")
    db.session.add(minnie)

    tag1 = Tag(name="news")
    db.session.add(tag1)

    tag2 = Tag(name="music")
    db.session.add(tag2)

    db.session.add(Bookmark(url="https://www.cnn.com", description="cnn", user=mickey, tags="news"))
    db.session.add(Bookmark(url="https://www.mtv.com", description="mtv", user=minnie, tags="music, news"))

    db.session.commit()

    print('Initialized the database')
Exemplo n.º 18
0
def insert_data():
    adi = User(username="******", email="*****@*****.**", password="******")
    db.session.add(adi)

    def add_bookmark(url, description, tags):
        db.session.add(
            Bookmark(url=url, description=description, user=adi, tags=tags))

    for name in ["python", "flask", "webdev", "programming"]:
        db.session.add(Tag(name=name))

    db.session.commit()

    add_bookmark("http://www.google.com", "Google", "python, flask, webdev")

    sri = User(username="******", email="*****@*****.**", password="******")
    db.session.add(sri)
    db.session.commit()
    print("Initialized the database")
Exemplo n.º 19
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        usr = User.get_by_username(form.username.data)
        if user is not None and usr.check_password(form.password.data):
            login_user(usr, form.remember_me.data)
            flash("Logged in successfully as {}.".format(usr.username))
            return redirect(request.args.get('next') or url_for('user', username=usr.username))
        flash("Incorret username or password")
    return render_template("login.html", form=form)
Exemplo n.º 20
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash(f'Welcome {user.username}!, Please login to continue')
        return redirect(url_for('login'))
    return render_template('signup.html', form=form)
Exemplo n.º 21
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Welcome, {}! Please login.'.format(user.username))
        return redirect(url_for('login'))
    return render_template("signup.html", form=form)
Exemplo n.º 22
0
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash("Welcome {} to Thermos App. Please login now to your account.".
              format(user.username))
        return redirect(url_for("login"))
    return render_template("signup.html", form=form)
Exemplo n.º 23
0
    def setUp(self):
        self.db = thermos.db
        self.db.create_all()
        self.client = self.app.test_client()

        u = User(username='******', email='*****@*****.**', password='******')
        bm = Bookmark(user=u, url="http://www.example.com", tags="one,two,three")
        self.db.session.add(u)
        self.db.session.add(bm)
        self.db.session.commit()

        self.client.post(url_for('auth.login'), data=dict(username='******', password='******'))
Exemplo n.º 24
0
def insert_data():
    aloysius = User(username="******",
                    email="*****@*****.**",
                    password="******")
    db.session.add(aloysius)

    def add_bookmark(url, description, tags):
        db.session.add(
            Bookmark(url=url,
                     description=description,
                     user=aloysius,
                     tags=tags))

    for name in [
            "python", "flask", "webdev", "programming", "training", "news",
            "orm", "databases", "emacs", "gtd", "django"
    ]:
        db.session.add(Tag(name=name))
    db.session.commit()

    add_bookmark("http://www.pluralsight.com",
                 "Pluralsight. Hardcore developer training.",
                 "training,programming,python,flask,webdev")
    add_bookmark("http://www.python.org", "Python - my favorite language",
                 "python")
    add_bookmark("http://flask.pocoo.org",
                 "Flask: Web development one drop at a time.",
                 "python,flask,webdev")
    add_bookmark("http://www.reddit.com", "Reddit. Frontpage of the internet",
                 "news,coolstuff,fun")
    add_bookmark("http://www.sqlalchemyorg", "Nice ORM framework",
                 "python,orm,databases")

    db.session.add(
        User(username="******",
             email="*****@*****.**",
             password="******"))
    db.session.commit()
    print 'Initialized the database...'
Exemplo n.º 25
0
def insert_data():
    name1 = User(username='******', email='*****@*****.**', password="******")
    db.session.add(name1)
    db.session.add(
        User(username='******', email='*****@*****.**', password="******"))

    def add_bookmark(url, description, tags):
        db.session.add(
            Bookmark(url=url, description=description, user=name1, tags=tags))

    for name in ["python", "webdev", "programming", "databases"]:
        db.session.add(Tag(name=name))

    db.session.commit()

    add_bookmark("http://www.pluralsight.com", "Pluralsight",
                 "programming, python")
    add_bookmark("http://www.python.org", "Python", "python")

    db.session.commit()

    print('Initialzed the database')
Exemplo n.º 26
0
    def setUp(self):
        thermos.admin._views = []  #Workaround for blueprint registration
        #rest_api.resources = [] #Workaround for blueprint registration
        self.db = thermos.db
        with self.app.app_context():
            self.db.create_all()
        self.client = self.app.test_client()

        self.test_user = User(username='******',
                              email='*****@*****.**',
                              password='******')

        self.db.session.add(self.test_user)
        self.db.session.commit()
Exemplo n.º 27
0
def insert_data():
    #db.create_all()
    aaron = User(username="******",
                 email="*****@*****.**",
                 password="******")
    db.session.add(aaron)

    def add_bookmark(url, description, tags):
        db.session.add(
            Bookmark(url=url, description=description, user=aaron, tags=tags))

    for name in [
            'python', 'questions', 'programming', 'training', 'news', 'orm',
            'data'
    ]:
        db.session.add(Tag(name=name))
    db.session.commit()

    add_bookmark('http://www.pluralsight.com',
                 'Pluralsight. Hardcore developer training.',
                 'training, programming')
    add_bookmark('http://www.python.org', 'Python - my favorite language',
                 'python')
    add_bookmark('http://www.reddit.com', 'Reddit. Frontpage of the internet',
                 'news')
    add_bookmark('http://www.sqlalchemy.org', 'Nice ORM framework', 'orm')
    add_bookmark('http://www.ipython.org', 'IPython. Interactive computing',
                 'data')
    add_bookmark('http://www.stackoverflow.com',
                 'For all your programmng questions', 'questions')

    oleg = User(username='******',
                email='*****@*****.**',
                password='******')
    db.session.add(oleg)
    db.session.commit()
Exemplo n.º 28
0
def login():
    form = LoginForm()
    if form.validate_on_submit():

        #login and validate useer:
        user = User.getuserbyusername(username=form.username.data)
        if user is not None and user._checkpassword(form.password.data):
            login_user(user, form.remember_me.data)
            flash("Logged in Successfully as {}".format(user.username))
            return redirect(
                request.args.get('next')
                or url_for("user", username=user.username))
        flash(
            "Incorrect User Details entered or User Not found. Please try again or signup."
        )

    return render_template("login.html", form=form)
Exemplo n.º 29
0
    def setUp(self):
        self.db = thermos.db
        self.db.create_all()
        # test_client instance will let us make requests keeps track of cookies etc so we can login
        self.client = self.app.test_client()

        u = User(username='******', email='*****@*****.**', password='******')
        bm = Bookmark(user=u,
                      url="http://www.example.com",
                      tags="one,two,three")
        self.db.session.add(u)
        self.db.session.add(bm)
        self.db.session.commit()

        # login as user we just created
        self.client.post(url_for('auth.login'),
                         data=dict(username='******', password='******'))
Exemplo n.º 30
0
def insert_data():
    record_annotation(module="jobs", action="insert_data", text="Data initialization")
    def add_bookmark(user, url, description, tags):
        print 'adding bookmark user:{} url:{} desc:{} tags:{}'.format(user, url, description, tags)
        db.session.add(Bookmark(url=url, description=description, user=user, tags=tags))

    db.session.add(User(username="******", email="*****@*****.**", password="******"))
    db.session.add(User(username="******", email="*****@*****.**", password="******"))
    db.session.add(User(username="******", email="*****@*****.**", password="******"))
    db.session.add(User(username="******", email="*****@*****.**", password="******"))
    db.session.add(User(username="******", email="*****@*****.**", password="******"))
    db.session.add(Bookmark_flag(value=1))

    ins_user = User.get_by_username("rjanuary")

    add_bookmark(ins_user,'http://www.google.com','Google - Search Engine','search, all the stuff, yea!')
    add_bookmark(ins_user,'http://www.python.org','Primary Python site','programming,knowledge')

    db.session.commit()
    print 'Initialized the database'
Exemplo n.º 31
0
def insert_data():
    """
    creates database
    """
    db.create_all()
    zubidlo = User(username='******', email='*****@*****.**', password="******")
    db.session.add(zubidlo)

    def add_bookmark(url, description, tags):
        db.session.add(Bookmark(url=url, description=description, user=zubidlo, tags=tags))

    for name in ['python', 'flask', 'programming']:
        db.session.add(Tag(name=name))

    add_bookmark("http://www.pluralsight.com", "Hardcore development traininng.", "programming")
    add_bookmark("http://www.python.org", "My favourite language", "python")
    add_bookmark("http://www.flask.pocaa.org", "Web development", "flask")

    db.session.commit()
    print "inserted the data"
Exemplo n.º 32
0
    def setUp(self):
        self.db = thermos.db
        self.db.create_all()
        self.client = self.app.test_client()

        password = '******'
        u = User(nm_firstName='Camila',
                 nm_lastName='Serrão',
                 nm_userName='******',
                 nm_email='*****@*****.**',
                 nm_passwordHash=password)
        bm = Bookmark(user=u,
                      nm_url='http://example.com',
                      nm_description='Just an example',
                      tags='one,two,three')

        self.db.session.add(u)
        self.db.session.add(bm)
        self.db.session.commit()

        self.client.post(url_for('auth.login'),
                         data=dict(nm_userName='******', password='******'))
Exemplo n.º 33
0
def initdb():
    db.create_all()
    db.session.add(User(username="******", email="*****@*****.**"))
    db.session.commit()
    print 'Initialized the database'