From 05398bdfd66bb749a06399d1b50f5f82b287ada2 Mon Sep 17 00:00:00 2001 From: calboo Date: Wed, 11 Feb 2026 13:29:51 +0100 Subject: [PATCH] add tasks driectly from tracker --- app.py | 42 +++++++++- templates/dashboard.html | 173 ++++++++++++++++++++++++++++++++++----- 2 files changed, 194 insertions(+), 21 deletions(-) diff --git a/app.py b/app.py index 77e4770..38bd592 100644 --- a/app.py +++ b/app.py @@ -148,11 +148,15 @@ def add_activity(): name = request.form['name'] color = request.form.get('color', '#3498db') + # Parse subcategories + subcats_str = request.form.get('subcategories_data', '') + subcategories = [s.strip() for s in subcats_str.split(',') if s.strip()] + activity_id = db.activities.insert_one({ 'user_id': get_user_id(), 'name': name, 'color': color, - 'subcategories': [] + 'subcategories': subcategories }).inserted_id # Add optional default tasks (Revised from list input) @@ -427,6 +431,42 @@ def create_task(): db.tasks.insert_one(task_doc) return redirect(url_for('tasks')) +@app.route('/create_task_quick', methods=['POST']) +def create_task_quick(): + if not is_logged_in(): return jsonify({'error': 'auth'}), 401 + + name = request.form['name'] + activity_id = request.form.get('activity_id') + subcategory = request.form.get('subcategory', '') + + # Check if there is an active time entry to link immediately + current_entry = db.time_entries.find_one({ + 'user_id': get_user_id(), + 'end_time': None + }) + + task_doc = { + 'user_id': get_user_id(), + 'name': name, + 'status': 'open', + 'is_template': False, + 'source': 'manual-quick', + 'created_at': datetime.now(), + 'comments': [], + 'subcategory': subcategory, + 'activity_id': ObjectId(activity_id) if activity_id else None, + # If we have an active entry matching this activity, link it for this session + 'time_entry_id': current_entry['_id'] if current_entry and str(current_entry['activity_id']) == activity_id else None + } + + new_id = db.tasks.insert_one(task_doc).inserted_id + + return jsonify({ + 'status': 'success', + 'task_id': str(new_id), + 'name': name + }) + @app.route('/task/', methods=['GET', 'POST']) def task_detail(task_id): if not is_logged_in(): return redirect(url_for('login')) diff --git a/templates/dashboard.html b/templates/dashboard.html index dc9ba43..7406094 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -184,25 +184,32 @@
00:00:00
- {% if tasks %}
-

Active Tasks

+
+

Active Tasks

+ + +
+
- {% for task in tasks %} - - {% endfor %} + {% if tasks %} + {% for task in tasks %} + + {% endfor %} + {% endif %}
- {% endif %}
@@ -214,6 +221,10 @@ +