From 4d2e04435a46f725f71ea6b79dd9dac28bc82d27 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sun, 24 Oct 2021 16:51:04 +0200 Subject: [PATCH] Minor work on frontend generation Basic status API --- TODO.md | 14 +------------- api/__init__.py | 0 api/admin.py | 3 +++ api/apps.py | 6 ++++++ api/models.py | 3 +++ api/tests.py | 3 +++ api/urls.py | 0 api/views.py | 6 ++++++ frontend/classes.py | 15 +++++++++++++++ frontend/features.py | 0 frontend/templatetags/navigation.py | 11 +++++++++++ kumify/settings.py | 30 +++++++++++++++++------------ 12 files changed, 66 insertions(+), 25 deletions(-) create mode 100644 api/__init__.py create mode 100644 api/admin.py create mode 100644 api/apps.py create mode 100644 api/models.py create mode 100644 api/tests.py create mode 100644 api/urls.py create mode 100644 api/views.py create mode 100644 frontend/classes.py create mode 100644 frontend/features.py diff --git a/TODO.md b/TODO.md index 2b20f8f..cdfe967 100644 --- a/TODO.md +++ b/TODO.md @@ -6,11 +6,6 @@ [_] Allow configuration as single user instance [_] User profiles / names / gateway config / time zone settings -## mood module - -[_] Missing mood views -[_] Statistics / graphs - ## cbt module [_] Complete thought record creation @@ -20,14 +15,7 @@ ## msgio module [_] Implement Telegram webhooks - -## dreams module - -[x] New dream page -[x] Edit dream page -[x] Delete dream page -[x] Statistics / template tags -[_] Check for copy-paste errors in pages +[_] Implement Matrix messaging ## meds module diff --git a/api/__init__.py b/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/api/admin.py b/api/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/api/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/api/apps.py b/api/apps.py new file mode 100644 index 0000000..66656fd --- /dev/null +++ b/api/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ApiConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'api' diff --git a/api/models.py b/api/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/api/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/api/tests.py b/api/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/api/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/api/urls.py b/api/urls.py new file mode 100644 index 0000000..e69de29 diff --git a/api/views.py b/api/views.py new file mode 100644 index 0000000..c7b6047 --- /dev/null +++ b/api/views.py @@ -0,0 +1,6 @@ +from django.views.generic import View +from django.http import JsonResponse + +class StatusView(View): + def get(self, request): + return JsonResponse({"status": "OK", "messages": []}) \ No newline at end of file diff --git a/frontend/classes.py b/frontend/classes.py new file mode 100644 index 0000000..e7af559 --- /dev/null +++ b/frontend/classes.py @@ -0,0 +1,15 @@ +class NavSection: + def __init__(self, name, order=100): + self.name = name + self.order = order + self.items = [] + + def add_item(self, item): + self.items.append(item) + +class NavItem: + def __init__(self, name, url, icon="fas fa-fw fa-smile", title=None): + self.name = name + self.url = url + self.icon = icon + self.title = title or name \ No newline at end of file diff --git a/frontend/features.py b/frontend/features.py new file mode 100644 index 0000000..e69de29 diff --git a/frontend/templatetags/navigation.py b/frontend/templatetags/navigation.py index 6f4f7c0..c6406e5 100644 --- a/frontend/templatetags/navigation.py +++ b/frontend/templatetags/navigation.py @@ -1,9 +1,20 @@ from django import template +from django.conf import settings + +from importlib import import_module register = template.Library() @register.simple_tag def sidebar_nav(): + sections = [] + + for module in settings.CORE_MODULES + settings.ENABLED_MODULES: + try: + features = import_module(f"{module}.features") + except: + pass + return """