Exemplo n.º 1
0
def archive():
    if 'username' not in session:
        return redirect('/login')
    crimes = CrimeModel(db.get_connection()).get_all()
    form = SearchForm()
    if form.validate_on_submit():
        searchtext = form.searchtext.data
        crimes = CrimeModel(db.get_connection()).findcrime(searchtext)
    return render_template('archive.html',
                           username=session['username'],
                           form=form,
                           crimes=crimes)
Exemplo n.º 2
0
def crimes():
    if 'username' not in session:
        return redirect('/login')
    crimes = CrimeModel(db.get_connection()).get_lasts()
    return render_template('crimes.html',
                           username=session['username'],
                           crimes=crimes)
Exemplo n.º 3
0
def add_crime():
    if 'username' not in session:
        return redirect('/login')
    form = AddCrimeForm()
    if form.validate_on_submit():
        crime_name = form.crime_name.data
        crime_text = form.crime_text.data
        photo = form.photo.data
        crime_likes = 0
        rm = CrimeModel(db.get_connection())
        rm.insert(crime_name, crime_text,
                  str(datetime.datetime.now().strftime("%d-%m-%Y %H:%M")),
                  crime_likes, photo, session['username'])
        return redirect("/crimes")
    return render_template('add_crime.html',
                           title='Дневник питания',
                           form=form,
                           username=session['username'])
Exemplo n.º 4
0
def like_act(crime_id):
    rm = CrimeModel(db.get_connection())
    rm.like(crime_id)
    return redirect("/crimes")