Exemple #1
0
def show_quote(quote_id):
    if check_if_database_up():
        if check_size() == 0:
            return render_template('oops.html')
        else:
            specific = Quotes.query.get_or_404(quote_id)
            return render_template('quote.html',specific=specific)
Exemple #2
0
def index():
    if check_if_database_up():
        if check_size() == 0:
            return render_template('oops.html')
        else:
            quotes = Quotes.query.order_by(Quotes.id.desc())
            if not quotes:
                error = 'Nothing to see here. Move along'
            else:
                error = ''
            return render_template('index.html',quotes=quotes,error=error)
Exemple #3
0
def submit_quote():
    if check_if_database_up():
        if check_size() == 0:
            return render_template('oops.html')
        else:
            form = EntryForm(request.form)
            if request.method=='POST':
                new_body = preserve_whitespace(form.body.data)
                new_quote = Quotes(new_body,form.tags.data,form.by.data,False)
                db.session.add(new_quote)
                db.session.commit()
                return redirect(url_for('index'))
            return render_template('submit.html',form=form)
Exemple #4
0
def login():
    if check_if_database_up():
        if check_size() == 0:
            return render_template('oops.html')
        else:
            form = LoginForm(request.form)
            if request.method=='POST':
                check_user = Operators.query.filter_by(email=form.email.data).first()
                if check_user:
                    pass_check = check_password_hash(check_user.password,form.password.data)
                    if pass_check:
                        session['logged_in'] = True
                        return redirect(url_for('index'))
                    else:
                        flash('Incorrect Password')
                else:
                    flash('Incorrect Username')          
            return render_template('login.html', form=form)
Exemple #5
0
def tags():
    if check_if_database_up():
        if check_size() == 0:
            return render_template('oops.html')
        else:
            return render_template('tags.html')