Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions work-form-management/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Work Form Management System

A minimal Flask + SQLite app to maintain workflow, due list, priorities and stages.

Quick start (Windows):
1. Create a virtualenv: python -m venv .venv
2. Activate: .\.venv\Scripts\activate
3. Install: pip install -r requirements.txt
4. Run: set FLASK_APP=app.py && flask run

Use the web UI at http://127.0.0.1:5000 to add tasks, edit, mark complete, and view due dates.

Notes:
- Database is stored at work-form-management/instance/tasks.db
- Fields: title, description, status, workflow_stage, due_date, priority
Binary file not shown.
102 changes: 102 additions & 0 deletions work-form-management/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from flask import Flask, g, render_template, request, redirect, url_for
import sqlite3
import os
import datetime

BASE_DIR = os.path.dirname(__file__)
DB_PATH = os.path.join(BASE_DIR, 'instance', 'tasks.db')
os.makedirs(os.path.dirname(DB_PATH), exist_ok=True)

app = Flask(__name__)

def get_db():
db = getattr(g, '_database', None)
if db is None:
db = g._database = sqlite3.connect(DB_PATH)
db.row_factory = sqlite3.Row
return db

def init_db():
db = get_db()
db.execute('''CREATE TABLE IF NOT EXISTS tasks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
description TEXT,
status TEXT NOT NULL DEFAULT 'pending',
workflow_stage TEXT,
due_date TEXT,
priority INTEGER DEFAULT 3,
created_at TEXT,
updated_at TEXT
)''')
db.commit()

@app.teardown_appcontext
def close_connection(exception):
db = getattr(g, '_database', None)
if db is not None:
db.close()

@app.before_request
def before_request():
init_db()

@app.route('/')
def index():
db = get_db()
rows = db.execute('SELECT * FROM tasks ORDER BY due_date IS NULL, due_date, priority').fetchall()
tasks = [dict(r) for r in rows]
return render_template('index.html', tasks=tasks, today=str(datetime.date.today()))

@app.route('/add', methods=['GET','POST'])
def add():
if request.method == 'POST':
title = request.form['title'].strip()
description = request.form.get('description','').strip()
due_date = request.form.get('due_date') or None
workflow_stage = request.form.get('workflow_stage','Backlog')
priority = int(request.form.get('priority',3))
created = datetime.datetime.utcnow().isoformat()
db = get_db()
db.execute('INSERT INTO tasks (title, description, due_date, workflow_stage, priority, created_at, updated_at) VALUES (?,?,?,?,?,?,?)',
(title, description, due_date, workflow_stage, priority, created, created))
db.commit()
return redirect(url_for('index'))
return render_template('edit.html', task=None)

@app.route('/edit/<int:task_id>', methods=['GET','POST'])
def edit(task_id):
db = get_db()
if request.method == 'POST':
title = request.form['title'].strip()
description = request.form.get('description','').strip()
due_date = request.form.get('due_date') or None
workflow_stage = request.form.get('workflow_stage','Backlog')
priority = int(request.form.get('priority',3))
updated = datetime.datetime.utcnow().isoformat()
db.execute('UPDATE tasks SET title=?, description=?, due_date=?, workflow_stage=?, priority=?, updated_at=? WHERE id=?',
(title, description, due_date, workflow_stage, priority, updated, task_id))
db.commit()
return redirect(url_for('index'))
row = db.execute('SELECT * FROM tasks WHERE id=?', (task_id,)).fetchone()
if not row:
return redirect(url_for('index'))
task = dict(row)
return render_template('edit.html', task=task)

@app.route('/complete/<int:task_id>')
def complete(task_id):
db = get_db()
db.execute("UPDATE tasks SET status='done', updated_at=? WHERE id=?", (datetime.datetime.utcnow().isoformat(), task_id))
db.commit()
return redirect(url_for('index'))

@app.route('/delete/<int:task_id>')
def delete(task_id):
db = get_db()
db.execute('DELETE FROM tasks WHERE id=?', (task_id,))
db.commit()
return redirect(url_for('index'))

if __name__ == '__main__':
app.run(debug=True)
1 change: 1 addition & 0 deletions work-form-management/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Flask==3.0.0
12 changes: 12 additions & 0 deletions work-form-management/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
body{font-family:Segoe UI, Arial, sans-serif;background:#f7f7f7;color:#222}
.container{max-width:900px;margin:24px auto;padding:16px;background:#fff;border-radius:6px;box-shadow:0 2px 8px rgba(0,0,0,.06)}
header h1{margin:0}
nav{margin-top:6px}
table{width:100%;border-collapse:collapse;margin-top:12px}
th,td{padding:8px;border-bottom:1px solid #eee;text-align:left}
tr.overdue{background:#fff0f0}
tr.done{color:#888;text-decoration:line-through}
footer{margin-top:18px;color:#666}
label{display:block;margin:8px 0}
input[type=text], textarea, input[type=number]{width:100%;padding:6px;border:1px solid #ddd;border-radius:4px}
button{background:#0069d9;color:white;padding:8px 12px;border:none;border-radius:4px}
22 changes: 22 additions & 0 deletions work-form-management/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Work Form Management</title>
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
<div class="container">
<header>
<h1>Work Form Management</h1>
<nav><a href="/">Home</a> | <a href="/add">Add Task</a></nav>
</header>
<main>
{% block content %}{% endblock %}
</main>
<footer>
<small>Minimal app — customize as needed.</small>
</footer>
</div>
</body>
</html>
12 changes: 12 additions & 0 deletions work-form-management/templates/edit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends 'base.html' %}
{% block content %}
<h2>{% if task %}Edit Task{% else %}Add Task{% endif %}</h2>
<form method="post">
<label>Title<br><input name="title" required value="{{ task.title if task else '' }}"></label><br>
<label>Description<br><textarea name="description">{{ task.description if task else '' }}</textarea></label><br>
<label>Due date (YYYY-MM-DD)<br><input name="due_date" value="{{ task.due_date if task else '' }}"></label><br>
<label>Workflow stage<br><input name="workflow_stage" value="{{ task.workflow_stage if task else 'Backlog' }}"></label><br>
<label>Priority (1 high - 5 low)<br><input name="priority" type="number" min="1" max="5" value="{{ task.priority if task else 3 }}"></label><br>
<button type="submit">Save</button>
</form>
{% endblock %}
25 changes: 25 additions & 0 deletions work-form-management/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% extends 'base.html' %}
{% block content %}
<h2>Tasks</h2>
{% if tasks %}
<table>
<tr><th>Title</th><th>Stage</th><th>Due</th><th>Priority</th><th>Status</th><th>Actions</th></tr>
{% for t in tasks %}
<tr class="{% if t.status=='done' %}done{% elif t.due_date and t.due_date < today %}overdue{% endif %}">
<td>{{ t.title }}</td>
<td>{{ t.workflow_stage or 'Backlog' }}</td>
<td>{{ t.due_date or '-' }}</td>
<td>{{ t.priority or 3 }}</td>
<td>{{ t.status }}</td>
<td>
<a href="/edit/{{ t.id }}">Edit</a> |
<a href="/complete/{{ t.id }}">Complete</a> |
<a href="/delete/{{ t.id }}" onclick="return confirm('Delete?')">Delete</a>
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>No tasks yet. <a href="/add">Add one</a>.</p>
{% endif %}
{% endblock %}