Merge remote-tracking branch 'origin/master'
# Conflicts: # models/Habit.py
This commit is contained in:
commit
119a31302c
32
app.py
32
app.py
@ -211,16 +211,6 @@ def habit_create():
|
|||||||
# Back to index
|
# Back to index
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
"""return render_template(
|
|
||||||
'habit.html',
|
|
||||||
title='Erstelle ein Habit',
|
|
||||||
name=name,
|
|
||||||
note=note,
|
|
||||||
times=times,
|
|
||||||
unit=unit,
|
|
||||||
errors=errors,
|
|
||||||
)"""
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/profile')
|
@app.route('/profile')
|
||||||
@login_required
|
@login_required
|
||||||
@ -300,28 +290,6 @@ def check_habit():
|
|||||||
for tracking in trackings:
|
for tracking in trackings:
|
||||||
if tracking.created_at.date() == datetime.date.today():
|
if tracking.created_at.date() == datetime.date.today():
|
||||||
delete_tracking = tracking
|
delete_tracking = tracking
|
||||||
"""
|
|
||||||
# day
|
|
||||||
if habit.unit == 0:
|
|
||||||
if tracking.created_at.date() == datetime.date.today():
|
|
||||||
delete_tracking = tracking
|
|
||||||
break
|
|
||||||
# week
|
|
||||||
elif habit.unit == 1:
|
|
||||||
if tracking.created_at.date().isocalendar()[1] == datetime.date.today().isocalendar()[1]:
|
|
||||||
delete_tracking = tracking
|
|
||||||
break
|
|
||||||
# month
|
|
||||||
elif habit.unit == 2:
|
|
||||||
if tracking.created_at.date().month == datetime.date.today().month:
|
|
||||||
delete_tracking = tracking
|
|
||||||
break
|
|
||||||
# year
|
|
||||||
elif habit.unit == 3:
|
|
||||||
if tracking.created_at.date().year == datetime.date.today().year:
|
|
||||||
delete_tracking = tracking
|
|
||||||
break
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not delete_tracking:
|
if not delete_tracking:
|
||||||
HabitTrackings.create(habit_id, 1)
|
HabitTrackings.create(habit_id, 1)
|
||||||
|
|||||||
@ -140,20 +140,22 @@ def get_slots(user_id: int):
|
|||||||
return slots
|
return slots
|
||||||
|
|
||||||
|
|
||||||
def update_habit(id: int, name: str, note: str, times: int, unit: int):
|
|
||||||
query = f"UPDATE habits SET name = {name}, note = {note}, times = {times}, unit = {unit} WHERE id = {id};"
|
|
||||||
conn = con3()
|
|
||||||
cursor = conn.cursor()
|
|
||||||
cursor.execute(query)
|
|
||||||
conn.close()
|
|
||||||
return cursor.lastrowid
|
|
||||||
|
|
||||||
|
|
||||||
def update_slot(id: int, slot: int):
|
def update_slot(id: int, slot: int):
|
||||||
query = f"UPDATE habits SET slot = {slot} WHERE id = {id};"
|
query = f"UPDATE habits SET slot = {slot} WHERE id = {id};"
|
||||||
conn = con3()
|
conn = con3()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
return cursor.lastrowid
|
||||||
|
|
||||||
|
|
||||||
|
def update_habit(id: int, name: str, note: str, times: int, unit: int):
|
||||||
|
query = f"UPDATE habits SET name = {name}, note = {note}, times = {times}, unit = {unit} WHERE id = {id};"
|
||||||
|
conn = con3()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute(query)
|
||||||
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
return cursor.lastrowid
|
return cursor.lastrowid
|
||||||
|
|
||||||
@ -210,4 +212,6 @@ def delete_habitTrackings(id: int):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
pass
|
habits = get_habits(1)
|
||||||
|
for habit in habits:
|
||||||
|
print(habit[6])
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import json
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user