diff --git a/.perm_test_apache b/.perm_test_apache new file mode 100644 index 0000000..e69de29 diff --git a/.perm_test_exec b/.perm_test_exec new file mode 100644 index 0000000..e69de29 diff --git a/ai/__init__.py b/ai/__init__.py new file mode 100644 index 0000000..37a7b09 --- /dev/null +++ b/ai/__init__.py @@ -0,0 +1,3 @@ +"""Helpers for interacting with the Flatlogic AI proxy from Django code.""" + +from .local_ai_api import LocalAIApi, create_response, request, decode_json_from_response # noqa: F401 diff --git a/ai/local_ai_api.py b/ai/local_ai_api.py new file mode 100644 index 0000000..bcff732 --- /dev/null +++ b/ai/local_ai_api.py @@ -0,0 +1,420 @@ +""" +LocalAIApi — lightweight Python client for the Flatlogic AI proxy. + +Usage (inside the Django workspace): + + from ai.local_ai_api import LocalAIApi + + response = LocalAIApi.create_response({ + "input": [ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Summarise this text in two sentences."}, + ], + "text": {"format": {"type": "json_object"}}, + }) + + if response.get("success"): + data = LocalAIApi.decode_json_from_response(response) + # ... + +# Typical successful payload (truncated): +# { +# "id": "resp_xxx", +# "status": "completed", +# "output": [ +# {"type": "reasoning", "summary": []}, +# {"type": "message", "content": [{"type": "output_text", "text": "Your final answer here."}]} +# ], +# "usage": { "input_tokens": 123, "output_tokens": 456 } +# } + +The helper automatically injects the project UUID header and falls back to +reading executor/.env if environment variables are missing. +""" + +from __future__ import annotations + +import json +import os +import time +import ssl +from typing import Any, Dict, Iterable, Optional +from urllib import error as urlerror +from urllib import request as urlrequest + +__all__ = [ + "LocalAIApi", + "create_response", + "request", + "fetch_status", + "await_response", + "extract_text", + "decode_json_from_response", +] + + +_CONFIG_CACHE: Optional[Dict[str, Any]] = None + + +class LocalAIApi: + """Static helpers mirroring the PHP implementation.""" + + @staticmethod + def create_response(params: Dict[str, Any], options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: + return create_response(params, options or {}) + + @staticmethod + def request(path: Optional[str] = None, payload: Optional[Dict[str, Any]] = None, + options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: + return request(path, payload or {}, options or {}) + + @staticmethod + def extract_text(response: Dict[str, Any]) -> str: + return extract_text(response) + + @staticmethod + def decode_json_from_response(response: Dict[str, Any]) -> Optional[Dict[str, Any]]: + return decode_json_from_response(response) + + +def create_response(params: Dict[str, Any], options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: + """Signature compatible with the OpenAI Responses API.""" + options = options or {} + payload = dict(params) + + if not isinstance(payload.get("input"), list) or not payload["input"]: + return { + "success": False, + "error": "input_missing", + "message": 'Parameter "input" is required and must be a non-empty list.', + } + + cfg = _config() + if not payload.get("model"): + payload["model"] = cfg["default_model"] + + initial = request(options.get("path"), payload, options) + if not initial.get("success"): + return initial + + data = initial.get("data") + if isinstance(data, dict) and "ai_request_id" in data: + ai_request_id = data["ai_request_id"] + poll_timeout = int(options.get("poll_timeout", 300)) + poll_interval = int(options.get("poll_interval", 5)) + return await_response(ai_request_id, { + "interval": poll_interval, + "timeout": poll_timeout, + "headers": options.get("headers"), + "timeout_per_call": options.get("timeout"), + }) + + return initial + + +def request(path: Optional[str], payload: Dict[str, Any], options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: + """Perform a raw request to the AI proxy.""" + cfg = _config() + options = options or {} + + resolved_path = path or options.get("path") or cfg["responses_path"] + if not resolved_path: + return { + "success": False, + "error": "project_id_missing", + "message": "PROJECT_ID is not defined; cannot resolve AI proxy endpoint.", + } + + project_uuid = cfg["project_uuid"] + if not project_uuid: + return { + "success": False, + "error": "project_uuid_missing", + "message": "PROJECT_UUID is not defined; aborting AI request.", + } + + if "project_uuid" not in payload and project_uuid: + payload["project_uuid"] = project_uuid + + url = _build_url(resolved_path, cfg["base_url"]) + opt_timeout = options.get("timeout") + timeout = int(cfg["timeout"] if opt_timeout is None else opt_timeout) + verify_tls = options.get("verify_tls", cfg["verify_tls"]) + + headers: Dict[str, str] = { + "Content-Type": "application/json", + "Accept": "application/json", + cfg["project_header"]: project_uuid, + } + extra_headers = options.get("headers") + if isinstance(extra_headers, Iterable): + for header in extra_headers: + if isinstance(header, str) and ":" in header: + name, value = header.split(":", 1) + headers[name.strip()] = value.strip() + + body = json.dumps(payload, ensure_ascii=False).encode("utf-8") + return _http_request(url, "POST", body, headers, timeout, verify_tls) + + +def fetch_status(ai_request_id: Any, options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: + """Fetch status for a queued AI request.""" + cfg = _config() + options = options or {} + + project_uuid = cfg["project_uuid"] + if not project_uuid: + return { + "success": False, + "error": "project_uuid_missing", + "message": "PROJECT_UUID is not defined; aborting status check.", + } + + status_path = _resolve_status_path(ai_request_id, cfg) + url = _build_url(status_path, cfg["base_url"]) + + opt_timeout = options.get("timeout") + timeout = int(cfg["timeout"] if opt_timeout is None else opt_timeout) + verify_tls = options.get("verify_tls", cfg["verify_tls"]) + + headers: Dict[str, str] = { + "Accept": "application/json", + cfg["project_header"]: project_uuid, + } + extra_headers = options.get("headers") + if isinstance(extra_headers, Iterable): + for header in extra_headers: + if isinstance(header, str) and ":" in header: + name, value = header.split(":", 1) + headers[name.strip()] = value.strip() + + return _http_request(url, "GET", None, headers, timeout, verify_tls) + + +def await_response(ai_request_id: Any, options: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: + """Poll status endpoint until the request is complete or timed out.""" + options = options or {} + timeout = int(options.get("timeout", 300)) + interval = int(options.get("interval", 5)) + if interval <= 0: + interval = 5 + per_call_timeout = options.get("timeout_per_call") + + deadline = time.time() + max(timeout, interval) + + while True: + status_resp = fetch_status(ai_request_id, { + "headers": options.get("headers"), + "timeout": per_call_timeout, + "verify_tls": options.get("verify_tls"), + }) + if status_resp.get("success"): + data = status_resp.get("data") or {} + if isinstance(data, dict): + status_value = data.get("status") + if status_value == "success": + return { + "success": True, + "status": 200, + "data": data.get("response", data), + } + if status_value == "failed": + return { + "success": False, + "status": 500, + "error": str(data.get("error") or "AI request failed"), + "data": data, + } + else: + return status_resp + + if time.time() >= deadline: + return { + "success": False, + "error": "timeout", + "message": "Timed out waiting for AI response.", + } + time.sleep(interval) + + +def extract_text(response: Dict[str, Any]) -> str: + """Public helper to extract plain text from a Responses payload.""" + return _extract_text(response) + + +def decode_json_from_response(response: Dict[str, Any]) -> Optional[Dict[str, Any]]: + """Attempt to decode JSON emitted by the model (handles markdown fences).""" + text = _extract_text(response) + if text == "": + return None + + try: + decoded = json.loads(text) + if isinstance(decoded, dict): + return decoded + except json.JSONDecodeError: + pass + + stripped = text.strip() + if stripped.startswith("```json"): + stripped = stripped[7:] + if stripped.endswith("```"): + stripped = stripped[:-3] + stripped = stripped.strip() + if stripped and stripped != text: + try: + decoded = json.loads(stripped) + if isinstance(decoded, dict): + return decoded + except json.JSONDecodeError: + return None + return None + + +def _extract_text(response: Dict[str, Any]) -> str: + payload = response.get("data") if response.get("success") else response.get("response") + if isinstance(payload, dict): + output = payload.get("output") + if isinstance(output, list): + combined = "" + for item in output: + content = item.get("content") if isinstance(item, dict) else None + if isinstance(content, list): + for block in content: + if isinstance(block, dict) and block.get("type") == "output_text" and block.get("text"): + combined += str(block["text"]) + if combined: + return combined + choices = payload.get("choices") + if isinstance(choices, list) and choices: + message = choices[0].get("message") + if isinstance(message, dict) and message.get("content"): + return str(message["content"]) + if isinstance(payload, str): + return payload + return "" + + +def _config() -> Dict[str, Any]: + global _CONFIG_CACHE # noqa: PLW0603 + if _CONFIG_CACHE is not None: + return _CONFIG_CACHE + + _ensure_env_loaded() + + base_url = os.getenv("AI_PROXY_BASE_URL", "https://flatlogic.com") + project_id = os.getenv("PROJECT_ID") or None + responses_path = os.getenv("AI_RESPONSES_PATH") + if not responses_path and project_id: + responses_path = f"/projects/{project_id}/ai-request" + + _CONFIG_CACHE = { + "base_url": base_url, + "responses_path": responses_path, + "project_id": project_id, + "project_uuid": os.getenv("PROJECT_UUID"), + "project_header": os.getenv("AI_PROJECT_HEADER", "project-uuid"), + "default_model": os.getenv("AI_DEFAULT_MODEL", "gpt-5-mini"), + "timeout": int(os.getenv("AI_TIMEOUT", "30")), + "verify_tls": os.getenv("AI_VERIFY_TLS", "true").lower() not in {"0", "false", "no"}, + } + return _CONFIG_CACHE + + +def _build_url(path: str, base_url: str) -> str: + trimmed = path.strip() + if trimmed.startswith("http://") or trimmed.startswith("https://"): + return trimmed + if trimmed.startswith("/"): + return f"{base_url}{trimmed}" + return f"{base_url}/{trimmed}" + + +def _resolve_status_path(ai_request_id: Any, cfg: Dict[str, Any]) -> str: + base_path = (cfg.get("responses_path") or "").rstrip("/") + if not base_path: + return f"/ai-request/{ai_request_id}/status" + if not base_path.endswith("/ai-request"): + base_path = f"{base_path}/ai-request" + return f"{base_path}/{ai_request_id}/status" + + +def _http_request(url: str, method: str, body: Optional[bytes], headers: Dict[str, str], + timeout: int, verify_tls: bool) -> Dict[str, Any]: + """ + Shared HTTP helper for GET/POST requests. + """ + req = urlrequest.Request(url, data=body, method=method.upper()) + for name, value in headers.items(): + req.add_header(name, value) + + context = None + if not verify_tls: + context = ssl.create_default_context() + context.check_hostname = False + context.verify_mode = ssl.CERT_NONE + + try: + with urlrequest.urlopen(req, timeout=timeout, context=context) as resp: + status = resp.getcode() + response_body = resp.read().decode("utf-8", errors="replace") + except urlerror.HTTPError as exc: + status = exc.getcode() + response_body = exc.read().decode("utf-8", errors="replace") + except Exception as exc: # pylint: disable=broad-except + return { + "success": False, + "error": "request_failed", + "message": str(exc), + } + + decoded = None + if response_body: + try: + decoded = json.loads(response_body) + except json.JSONDecodeError: + decoded = None + + if 200 <= status < 300: + return { + "success": True, + "status": status, + "data": decoded if decoded is not None else response_body, + } + + error_message = "AI proxy request failed" + if isinstance(decoded, dict): + error_message = decoded.get("error") or decoded.get("message") or error_message + elif response_body: + error_message = response_body + + return { + "success": False, + "status": status, + "error": error_message, + "response": decoded if decoded is not None else response_body, + } + + +def _ensure_env_loaded() -> None: + """Populate os.environ from executor/.env if variables are missing.""" + if os.getenv("PROJECT_UUID") and os.getenv("PROJECT_ID"): + return + + env_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".env")) + if not os.path.exists(env_path): + return + + try: + with open(env_path, "r", encoding="utf-8") as handle: + for line in handle: + stripped = line.strip() + if not stripped or stripped.startswith("#") or "=" not in stripped: + continue + key, value = stripped.split("=", 1) + key = key.strip() + value = value.strip().strip('\'"') + if key and not os.getenv(key): + os.environ[key] = value + except OSError: + pass diff --git a/config/__pycache__/__init__.cpython-311.pyc b/config/__pycache__/__init__.cpython-311.pyc index 3d6501c..2267fe8 100644 Binary files a/config/__pycache__/__init__.cpython-311.pyc and b/config/__pycache__/__init__.cpython-311.pyc differ diff --git a/config/__pycache__/settings.cpython-311.pyc b/config/__pycache__/settings.cpython-311.pyc index dadfaa7..fd34097 100644 Binary files a/config/__pycache__/settings.cpython-311.pyc and b/config/__pycache__/settings.cpython-311.pyc differ diff --git a/config/__pycache__/urls.cpython-311.pyc b/config/__pycache__/urls.cpython-311.pyc index 139db10..4067957 100644 Binary files a/config/__pycache__/urls.cpython-311.pyc and b/config/__pycache__/urls.cpython-311.pyc differ diff --git a/config/__pycache__/wsgi.cpython-311.pyc b/config/__pycache__/wsgi.cpython-311.pyc index 79ce690..d3b9986 100644 Binary files a/config/__pycache__/wsgi.cpython-311.pyc and b/config/__pycache__/wsgi.cpython-311.pyc differ diff --git a/core/__pycache__/__init__.cpython-311.pyc b/core/__pycache__/__init__.cpython-311.pyc index 3b7774e..90a7022 100644 Binary files a/core/__pycache__/__init__.cpython-311.pyc and b/core/__pycache__/__init__.cpython-311.pyc differ diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index 5e41572..20f0cc2 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/apps.cpython-311.pyc b/core/__pycache__/apps.cpython-311.pyc index 6435d92..4cf45f6 100644 Binary files a/core/__pycache__/apps.cpython-311.pyc and b/core/__pycache__/apps.cpython-311.pyc differ diff --git a/core/__pycache__/forms.cpython-311.pyc b/core/__pycache__/forms.cpython-311.pyc index f6e5c4e..f8814a7 100644 Binary files a/core/__pycache__/forms.cpython-311.pyc and b/core/__pycache__/forms.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index 5b41fe1..c9de752 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 4e4f113..bf27f4c 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 9d0ddd8..95959c2 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index 639ff3a..19afb57 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,8 +1,5 @@ from django.contrib import admin -from .models import Ticket +from .models import Article, TodoItem -@admin.register(Ticket) -class TicketAdmin(admin.ModelAdmin): - list_display = ('subject', 'status', 'priority', 'requester_email', 'created_at') - list_filter = ('status', 'priority') - search_fields = ('subject', 'requester_email', 'description') +admin.site.register(Article) +admin.site.register(TodoItem) \ No newline at end of file diff --git a/core/forms.py b/core/forms.py index 7a6b83b..01d237e 100644 --- a/core/forms.py +++ b/core/forms.py @@ -1,7 +1,25 @@ from django import forms -from .models import Ticket +from .models import TodoItem -class TicketForm(forms.ModelForm): +class TodoItemForm(forms.ModelForm): class Meta: - model = Ticket - fields = ['subject', 'requester_email', 'priority', 'description'] + model = TodoItem + fields = ['title', 'description', 'tags', 'status'] + widgets = { + 'title': forms.TextInput(attrs={ + 'class': 'form-control', + 'placeholder': 'Enter a new task...' + }), + 'description': forms.Textarea(attrs={ + 'class': 'form-control', + 'placeholder': 'Add a description...', + 'rows': 3 + }), + 'tags': forms.TextInput(attrs={ + 'class': 'form-control', + 'placeholder': 'e.g. urgent, project-x' + }), + 'status': forms.Select(attrs={ + 'class': 'form-control' + }) + } \ No newline at end of file diff --git a/core/migrations/0002_article_todoitem_delete_ticket.py b/core/migrations/0002_article_todoitem_delete_ticket.py new file mode 100644 index 0000000..3151336 --- /dev/null +++ b/core/migrations/0002_article_todoitem_delete_ticket.py @@ -0,0 +1,35 @@ +# Generated by Django 5.2.7 on 2025-11-19 21:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Article', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('content', models.TextField()), + ('created_at', models.DateTimeField(auto_now_add=True)), + ], + ), + migrations.CreateModel( + name='TodoItem', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('status', models.CharField(choices=[('todo', 'To Do'), ('inprogress', 'In Progress'), ('blocked', 'Blocked'), ('done', 'Done')], default='todo', max_length=20)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + ), + migrations.DeleteModel( + name='Ticket', + ), + ] diff --git a/core/migrations/0003_todoitem_description_todoitem_tags.py b/core/migrations/0003_todoitem_description_todoitem_tags.py new file mode 100644 index 0000000..db16dda --- /dev/null +++ b/core/migrations/0003_todoitem_description_todoitem_tags.py @@ -0,0 +1,23 @@ +# Generated by Django 5.2.7 on 2025-11-19 21:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0002_article_todoitem_delete_ticket'), + ] + + operations = [ + migrations.AddField( + model_name='todoitem', + name='description', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='todoitem', + name='tags', + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/core/migrations/__pycache__/0001_initial.cpython-311.pyc b/core/migrations/__pycache__/0001_initial.cpython-311.pyc index 64d8a55..5052f7b 100644 Binary files a/core/migrations/__pycache__/0001_initial.cpython-311.pyc and b/core/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/core/migrations/__pycache__/0002_article_todoitem_delete_ticket.cpython-311.pyc b/core/migrations/__pycache__/0002_article_todoitem_delete_ticket.cpython-311.pyc new file mode 100644 index 0000000..7933e9c Binary files /dev/null and b/core/migrations/__pycache__/0002_article_todoitem_delete_ticket.cpython-311.pyc differ diff --git a/core/migrations/__pycache__/0003_todoitem_description_todoitem_tags.cpython-311.pyc b/core/migrations/__pycache__/0003_todoitem_description_todoitem_tags.cpython-311.pyc new file mode 100644 index 0000000..57ced6d Binary files /dev/null and b/core/migrations/__pycache__/0003_todoitem_description_todoitem_tags.cpython-311.pyc differ diff --git a/core/migrations/__pycache__/__init__.cpython-311.pyc b/core/migrations/__pycache__/__init__.cpython-311.pyc index 58b1c14..a431c79 100644 Binary files a/core/migrations/__pycache__/__init__.cpython-311.pyc and b/core/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 78b60d1..aee7a5b 100644 --- a/core/models.py +++ b/core/models.py @@ -1,25 +1,26 @@ from django.db import models -class Ticket(models.Model): +class Article(models.Model): + title = models.CharField(max_length=200) + content = models.TextField() + created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return self.title + +class TodoItem(models.Model): STATUS_CHOICES = [ - ('open', 'Open'), - ('in_progress', 'In Progress'), - ('closed', 'Closed'), + ('todo', 'To Do'), + ('inprogress', 'In Progress'), + ('blocked', 'Blocked'), + ('done', 'Done'), ] - - PRIORITY_CHOICES = [ - ('low', 'Low'), - ('medium', 'Medium'), - ('high', 'High'), - ] - - subject = models.CharField(max_length=255) - status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='open') - priority = models.CharField(max_length=20, choices=PRIORITY_CHOICES, default='medium') - requester_email = models.EmailField() - description = models.TextField() + title = models.CharField(max_length=200) + description = models.TextField(blank=True, null=True) + tags = models.CharField(max_length=255, blank=True, null=True) + status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='todo') created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): - return self.subject \ No newline at end of file + return self.title diff --git a/core/templates/base.html b/core/templates/base.html new file mode 100644 index 0000000..354508d --- /dev/null +++ b/core/templates/base.html @@ -0,0 +1,41 @@ + + + + + + {% block title %}AI Task Manager{% endblock %} + + + + + {% load static %} + + + + + +
+ {% block content %} + {% endblock %} +
+ + + + \ No newline at end of file diff --git a/core/templates/core/article_detail.html b/core/templates/core/article_detail.html new file mode 100644 index 0000000..8820990 --- /dev/null +++ b/core/templates/core/article_detail.html @@ -0,0 +1,14 @@ +{% extends 'base.html' %} + +{% block title %}{{ article.title }}{% endblock %} + +{% block content %} +
+

{{ article.title }}

+

Published on {{ article.created_at|date:"F d, Y" }}

+
+
+ {{ article.content|safe }} +
+
+{% endblock %} diff --git a/core/templates/core/index.html b/core/templates/core/index.html index f4e4991..ed0a715 100644 --- a/core/templates/core/index.html +++ b/core/templates/core/index.html @@ -1,157 +1,81 @@ - - +{% extends 'base.html' %} +{% load static %} - - - - {{ project_name }} - {% if project_description %} - - - - {% endif %} - {% if project_image_url %} - - - {% endif %} - - - - - - - -
-
-

Analyzing your requirements and generating your website…

-
- Loading… +
+
+
+
+

Add a New Task

+
+ {% csrf_token %} +
+ {{ form.title.label_tag }} + {{ form.title }} +
+
+ {{ form.description.label_tag }} + {{ form.description }} +
+
+ {{ form.tags.label_tag }} + {{ form.tags }} +
+
+ {{ form.status.label_tag }} + {{ form.status }} +
+ +
-

Appwizzy AI is collecting your requirements and applying the first changes.

-

This page will refresh automatically as the plan is implemented.

-

- Runtime: Django {{ django_version }} · Python {{ python_version }} — - UTC {{ current_time|date:"Y-m-d H:i:s" }} -

- -
- - \ No newline at end of file +
+
+

Your To-Do List

+
+
+ + + + + + + + + + + + {% for item in todo_list %} + + + + + + + + {% empty %} + + + + {% endfor %} + +
TaskDescriptionTagsStatusCreated
{{ item.title }}{{ item.description|default:"" }} + {% if item.tags %} + {% for tag in item.tags.split|slice:":3" %} + {{ tag }} + {% endfor %} + {% endif %} + {{ item.get_status_display }}{{ item.created_at|date:"M d, Y" }}
No tasks yet. Add one above!
+
+
+ + +{% endblock %} diff --git a/core/templates/core/kanban.html b/core/templates/core/kanban.html new file mode 100644 index 0000000..20a81de --- /dev/null +++ b/core/templates/core/kanban.html @@ -0,0 +1,41 @@ +{% extends 'base.html' %} +{% load static %} +{% load core_tags %} + +{% block title %}AI Task Manager - Kanban Board{% endblock %} + +{% block content %} +
+

Kanban Board

+

Visualize your tasks and track progress.

+
+ +
+
+ {% for status_value, status_display in status_choices %} +
+

{{ status_display }}

+
+ {% for item in tasks_by_status|get_item:status_value %} +
+
+
{{ item.title }}
+

{{ item.description|default:""|truncatewords:15 }}

+ {% if item.tags %} +
+ {% for tag in item.tags.split|slice:":3" %} + {{ tag }} + {% endfor %} +
+ {% endif %} +
+
+ {% empty %} +
No tasks in this stage.
+ {% endfor %} +
+
+ {% endfor %} +
+
+{% endblock %} diff --git a/core/templatetags/__init__.py b/core/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/templatetags/__pycache__/__init__.cpython-311.pyc b/core/templatetags/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..a47ce4e Binary files /dev/null and b/core/templatetags/__pycache__/__init__.cpython-311.pyc differ diff --git a/core/templatetags/__pycache__/core_tags.cpython-311.pyc b/core/templatetags/__pycache__/core_tags.cpython-311.pyc new file mode 100644 index 0000000..4bf6d0a Binary files /dev/null and b/core/templatetags/__pycache__/core_tags.cpython-311.pyc differ diff --git a/core/templatetags/core_tags.py b/core/templatetags/core_tags.py new file mode 100644 index 0000000..4b04b5c --- /dev/null +++ b/core/templatetags/core_tags.py @@ -0,0 +1,7 @@ +from django import template + +register = template.Library() + +@register.filter +def get_item(dictionary, key): + return dictionary.get(key) diff --git a/core/urls.py b/core/urls.py index 6299e3d..20837c1 100644 --- a/core/urls.py +++ b/core/urls.py @@ -1,7 +1,9 @@ from django.urls import path -from .views import home +from .views import index, article_detail, kanban_board urlpatterns = [ - path("", home, name="home"), + path("", index, name="index"), + path("kanban/", kanban_board, name="kanban_board"), + path("article//", article_detail, name="article_detail"), ] diff --git a/core/views.py b/core/views.py index c1a6d45..5ee7a4b 100644 --- a/core/views.py +++ b/core/views.py @@ -1,37 +1,42 @@ -import os -import platform - -from django import get_version as django_version -from django.shortcuts import render -from django.urls import reverse_lazy -from django.utils import timezone -from django.views.generic.edit import CreateView - -from .forms import TicketForm -from .models import Ticket - - -def home(request): - """Render the landing screen with loader and environment details.""" - host_name = request.get_host().lower() - agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic" - now = timezone.now() +from django.shortcuts import render, redirect +from .models import Article, TodoItem +from .forms import TodoItemForm +import time +def index(request): + if request.method == 'POST': + form = TodoItemForm(request.POST) + if form.is_valid(): + form.save() + return redirect('index') + else: + form = TodoItemForm() + + todo_list = TodoItem.objects.all().order_by('-created_at') + articles = Article.objects.all() + context = { - "project_name": "New Style", - "agent_brand": agent_brand, - "django_version": django_version(), - "python_version": platform.python_version(), - "current_time": now, - "host_name": host_name, - "project_description": os.getenv("PROJECT_DESCRIPTION", ""), - "project_image_url": os.getenv("PROJECT_IMAGE_URL", ""), + 'articles': articles, + 'todo_list': todo_list, + 'form': form, + 'timestamp': int(time.time()), } return render(request, "core/index.html", context) +def kanban_board(request): + tasks = TodoItem.objects.all().order_by('created_at') + tasks_by_status = { + status_value: list(filter(lambda t: t.status == status_value, tasks)) + for status_value, status_display in TodoItem.STATUS_CHOICES + } -class TicketCreateView(CreateView): - model = Ticket - form_class = TicketForm - template_name = "core/ticket_create.html" - success_url = reverse_lazy("home") + context = { + 'tasks_by_status': tasks_by_status, + 'status_choices': TodoItem.STATUS_CHOICES, + 'timestamp': int(time.time()), + } + return render(request, "core/kanban.html", context) + +def article_detail(request, article_id): + article = Article.objects.get(pk=article_id) + return render(request, "core/article_detail.html", {"article": article}) \ No newline at end of file diff --git a/static/css/custom.css b/static/css/custom.css new file mode 100644 index 0000000..776daea --- /dev/null +++ b/static/css/custom.css @@ -0,0 +1,155 @@ +/* custom.css */ + +:root { + --primary-color: #1A202C; + --secondary-color: #F7FAFC; + --accent-color: #4299E1; + --font-family-headings: 'Poppins', sans-serif; + --font-family-body: 'Inter', sans-serif; +} + +body { + font-family: var(--font-family-body); + background: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%); + color: #333; +} + +h1, h2, h3, h4, h5, h6 { + font-family: var(--font-family-headings); + color: var(--primary-color); +} + +.hero-section .display-4 { + font-weight: 600; +} + +.hero-section .lead { + color: #555; + font-size: 1.2rem; +} + +.btn-primary { + background-color: var(--accent-color); + border-color: var(--accent-color); + font-weight: 600; + padding: 0.75rem 1.5rem; + transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out; +} + +.btn-primary:hover { + background-color: #3182ce; /* A slightly darker shade of accent */ + border-color: #2c73b9; +} + +.card { + border: none; + border-radius: 0.75rem; +} + +.card-header { + border-bottom: 1px solid #e2e8f0; +} + +.form-control { + border-radius: 0.5rem; + padding: 0.75rem 1rem; +} + +.form-control:focus { + border-color: var(--accent-color); + box-shadow: 0 0 0 0.25rem rgba(66, 153, 225, 0.25); +} + +.table { + font-size: 0.95rem; +} + +.table th { + font-weight: 600; + color: #4a5568; + text-transform: uppercase; + letter-spacing: 0.05em; + border-bottom-width: 2px; +} + +.badge { + padding: 0.4em 0.7em; + font-size: 0.75rem; + font-weight: 700; + letter-spacing: 0.5px; +} + +.status-todo { + background-color: #e2e8f0; + color: #4a5568; +} + +.status-inprogress { + background-color: #bee3f8; + color: #2c5282; +} + +.status-blocked { + background-color: #fed7d7; + color: #9b2c2c; +} + +.status-done { + background-color: #c6f6d5; + color: #2f855a; +} + +/* Kanban Board Styles */ +.kanban-board-container { + overflow-x: auto; + padding: 1.5rem; + background-color: #e9ecef; /* Light grey background for the container */ +} + +.kanban-board { + display: grid; + grid-auto-flow: column; + grid-auto-columns: 280px; /* Fixed width for each column */ + gap: 1.5rem; + padding-bottom: 1rem; /* For scrollbar spacing */ +} + +.kanban-column { + flex: 1; + min-width: 280px; + max-width: 300px; + background-color: #f7fafc; + border-radius: 0.75rem; + box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); + display: flex; + flex-direction: column; +} + +.kanban-column .h5 { + font-weight: 600; +} + +.kanban-cards { + flex-grow: 1; + overflow-y: auto; + max-height: 60vh; /* Adjust as needed */ +} + +.kanban-card { + cursor: grab; + transition: box-shadow 0.2s ease-in-out, transform 0.2s ease-in-out; +} + +.kanban-card:hover { + box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); + transform: translateY(-3px); +} + +.kanban-card .card-title { + font-weight: 600; + color: #2d3748; +} + +.kanban-card .tags { + margin-top: 0.5rem; +} diff --git a/staticfiles/css/custom.css b/staticfiles/css/custom.css index 108056f..776daea 100644 --- a/staticfiles/css/custom.css +++ b/staticfiles/css/custom.css @@ -1,21 +1,155 @@ +/* custom.css */ :root { - --bg-color-start: #6a11cb; - --bg-color-end: #2575fc; - --text-color: #ffffff; - --card-bg-color: rgba(255, 255, 255, 0.01); - --card-border-color: rgba(255, 255, 255, 0.1); + --primary-color: #1A202C; + --secondary-color: #F7FAFC; + --accent-color: #4299E1; + --font-family-headings: 'Poppins', sans-serif; + --font-family-body: 'Inter', sans-serif; } + body { - margin: 0; - font-family: 'Inter', sans-serif; - background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end)); - color: var(--text-color); - display: flex; - justify-content: center; - align-items: center; - min-height: 100vh; - text-align: center; - overflow: hidden; - position: relative; + font-family: var(--font-family-body); + background: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%); + color: #333; +} + +h1, h2, h3, h4, h5, h6 { + font-family: var(--font-family-headings); + color: var(--primary-color); +} + +.hero-section .display-4 { + font-weight: 600; +} + +.hero-section .lead { + color: #555; + font-size: 1.2rem; +} + +.btn-primary { + background-color: var(--accent-color); + border-color: var(--accent-color); + font-weight: 600; + padding: 0.75rem 1.5rem; + transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out; +} + +.btn-primary:hover { + background-color: #3182ce; /* A slightly darker shade of accent */ + border-color: #2c73b9; +} + +.card { + border: none; + border-radius: 0.75rem; +} + +.card-header { + border-bottom: 1px solid #e2e8f0; +} + +.form-control { + border-radius: 0.5rem; + padding: 0.75rem 1rem; +} + +.form-control:focus { + border-color: var(--accent-color); + box-shadow: 0 0 0 0.25rem rgba(66, 153, 225, 0.25); +} + +.table { + font-size: 0.95rem; +} + +.table th { + font-weight: 600; + color: #4a5568; + text-transform: uppercase; + letter-spacing: 0.05em; + border-bottom-width: 2px; +} + +.badge { + padding: 0.4em 0.7em; + font-size: 0.75rem; + font-weight: 700; + letter-spacing: 0.5px; +} + +.status-todo { + background-color: #e2e8f0; + color: #4a5568; +} + +.status-inprogress { + background-color: #bee3f8; + color: #2c5282; +} + +.status-blocked { + background-color: #fed7d7; + color: #9b2c2c; +} + +.status-done { + background-color: #c6f6d5; + color: #2f855a; +} + +/* Kanban Board Styles */ +.kanban-board-container { + overflow-x: auto; + padding: 1.5rem; + background-color: #e9ecef; /* Light grey background for the container */ +} + +.kanban-board { + display: grid; + grid-auto-flow: column; + grid-auto-columns: 280px; /* Fixed width for each column */ + gap: 1.5rem; + padding-bottom: 1rem; /* For scrollbar spacing */ +} + +.kanban-column { + flex: 1; + min-width: 280px; + max-width: 300px; + background-color: #f7fafc; + border-radius: 0.75rem; + box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); + display: flex; + flex-direction: column; +} + +.kanban-column .h5 { + font-weight: 600; +} + +.kanban-cards { + flex-grow: 1; + overflow-y: auto; + max-height: 60vh; /* Adjust as needed */ +} + +.kanban-card { + cursor: grab; + transition: box-shadow 0.2s ease-in-out, transform 0.2s ease-in-out; +} + +.kanban-card:hover { + box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); + transform: translateY(-3px); +} + +.kanban-card .card-title { + font-weight: 600; + color: #2d3748; +} + +.kanban-card .tags { + margin-top: 0.5rem; }