cofnięcie zmian z przesuwaniem listy
This commit is contained in:
29
app.py
29
app.py
@@ -1527,20 +1527,18 @@ def edit_my_list(list_id):
|
||||
next_page = request.args.get("next") or request.referrer
|
||||
|
||||
if request.method == "POST":
|
||||
move_to_month = request.form.get("move_to_month", "")
|
||||
|
||||
move_to_month = request.form.get("move_to_month")
|
||||
if move_to_month:
|
||||
try:
|
||||
year, month = map(int, move_to_month.split("-"))
|
||||
new_created_at = datetime(year, month, 1, tzinfo=timezone.utc)
|
||||
if l.created_at is None or l.created_at.year != year or l.created_at.month != month:
|
||||
l.created_at = new_created_at
|
||||
db.session.commit()
|
||||
flash(
|
||||
f"Zmieniono datę utworzenia listy na {new_created_at.strftime('%Y-%m-%d')}",
|
||||
"success",
|
||||
)
|
||||
return redirect(next_page or url_for("main_page"))
|
||||
l.created_at = new_created_at
|
||||
db.session.commit()
|
||||
flash(
|
||||
f"Zmieniono datę utworzenia listy na {new_created_at.strftime('%Y-%m-%d')}",
|
||||
"success",
|
||||
)
|
||||
return redirect(next_page or url_for("main_page"))
|
||||
except ValueError:
|
||||
flash("Nieprawidłowy format miesiąca", "danger")
|
||||
return redirect(next_page or url_for("main_page"))
|
||||
@@ -1577,26 +1575,15 @@ def edit_my_list(list_id):
|
||||
flash("Zaktualizowano dane listy", "success")
|
||||
return redirect(next_page or url_for("main_page"))
|
||||
|
||||
if l.created_at:
|
||||
selected_year = l.created_at.year
|
||||
selected_month = f"{l.created_at.month:02d}"
|
||||
else:
|
||||
now = datetime.now()
|
||||
selected_year = now.year
|
||||
selected_month = f"{now.month:02d}"
|
||||
|
||||
return render_template(
|
||||
"edit_my_list.html",
|
||||
list=l,
|
||||
receipts=receipts,
|
||||
categories=categories,
|
||||
selected_categories=selected_categories_ids,
|
||||
current_year=selected_year,
|
||||
current_month=selected_month,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@app.route("/delete_user_list/<int:list_id>", methods=["POST"])
|
||||
@login_required
|
||||
def delete_user_list(list_id):
|
||||
|
Reference in New Issue
Block a user