Skip to content

Conversation

@hongthanh2001-2025
Copy link

Related Tickets

WHAT

  • Change number items completed/total in admin page.

HOW

  • I edit js file, inject not_vary_normal items in calculate function.

WHY

  • Because in previous version - number just depends on normal items. But in new version, we have state and confirm_state depends on both normal + not_normal items.

Evidence (Screenshot or Video)

@hongthanh2001-2025
Copy link
Author

hongthanh2001-2025 commented Sep 30, 2025

from flask import Flask, render_template, request, redirect, url_for
import json, os

app = Flask(name)

FILE = "don_thu.json"

Đọc dữ liệu từ file

def doc_don():
if os.path.exists(FILE):
with open(FILE, "r", encoding="utf-8") as f:
return json.load(f)
return []

Ghi dữ liệu vào file

def ghi_don(ds_don):
with open(FILE, "w", encoding="utf-8") as f:
json.dump(ds_don, f, ensure_ascii=False, indent=4)

@app.route("/")
def index():
ds_don = doc_don()
return render_template("index.html", ds_don=ds_don)

@app.route("/them", methods=["GET", "POST"])
def them():
if request.method == "POST":
ds_don = doc_don()
don = {
"ma_don": request.form["ma_don"],
"nguoi_gui": request.form["nguoi_gui"],
"loai_don": request.form["loai_don"],
"noi_dung": request.form["noi_dung"],
"trang_thai": "Đã tiếp nhận"
}
ds_don.append(don)
ghi_don(ds_don)
return redirect(url_for("index"))
return render_template("them.html")

@app.route("/capnhat/<ma_don>", methods=["GET", "POST"])
def capnhat(ma_don):
ds_don = doc_don()
for don in ds_don:
if don["ma_don"] == ma_don:
if request.method == "POST":
don["trang_thai"] = request.form["trang_thai"]
ghi_don(ds_don)
return redirect(url_for("index"))
return render_template("capnhat.html", don=don)
return "Không tìm thấy đơn"

if name == "main":
app.run(debug=True)
🔹 3. Giao diện HTML (thư mục templates/)
templates/index.html
html
Sao chép mã

<title>Quản lý đơn</title>

📋 Danh sách đơn

➕ Thêm đơn mới {% for don in ds_don %} {% endfor %}
Mã đơn Người gửi Loại đơn Nội dung Trạng thái Hành động
{{ don.ma_don }} {{ don.nguoi_gui }} {{ don.loai_don }} {{ don.noi_dung }} {{ don.trang_thai }} Cập nhật
templates/them.html html Sao chép mã <title>Thêm đơn</title>

➕ Thêm đơn khiếu nại / tố cáo

Mã đơn:
Người gửi:
Loại đơn: Khiếu nại Tố cáo
Nội dung:
<textarea name="noi_dung"></textarea>
Lưu templates/capnhat.html html Sao chép mã <title>Cập nhật đơn</title>

🔄 Cập nhật đơn {{ don.ma_don }}

Trạng thái: Đã tiếp nhận Đang xử lý Đã giải quyết
Cập nhật

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant