From bdfa5cab2aa3613edef48626c57cd86cc489e50e Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 8 Aug 2022 12:09:43 +0000 Subject: [PATCH] Basic framework --- .gitignore | 5 ++ README.md | 5 ++ api/__init__.py | 0 api/admin.py | 3 + api/apps.py | 6 ++ api/migrations/__init__.py | 0 api/models.py | 3 + api/tests.py | 3 + api/views.py | 3 + datastore/__init__.py | 0 datastore/admin.py | 3 + datastore/apps.py | 6 ++ datastore/migrations/__init__.py | 0 datastore/models.py | 3 + datastore/tests.py | 3 + datastore/views.py | 3 + dumuzid/__init__.py | 0 dumuzid/asgi.py | 16 +++++ dumuzid/settings.py | 114 +++++++++++++++++++++++++++++++ dumuzid/urls.py | 21 ++++++ dumuzid/wsgi.py | 16 +++++ manage.py | 22 ++++++ requirements.txt | 7 ++ 23 files changed, 242 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 api/__init__.py create mode 100644 api/admin.py create mode 100644 api/apps.py create mode 100644 api/migrations/__init__.py create mode 100644 api/models.py create mode 100644 api/tests.py create mode 100644 api/views.py create mode 100644 datastore/__init__.py create mode 100644 datastore/admin.py create mode 100644 datastore/apps.py create mode 100644 datastore/migrations/__init__.py create mode 100644 datastore/models.py create mode 100644 datastore/tests.py create mode 100644 datastore/views.py create mode 100644 dumuzid/__init__.py create mode 100644 dumuzid/asgi.py create mode 100644 dumuzid/settings.py create mode 100644 dumuzid/urls.py create mode 100644 dumuzid/wsgi.py create mode 100755 manage.py create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9359400 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +venv/ +*.pyc +__pycache__/ +settings.ini +db.sqlite3 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..050b0c2 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Dumuzid + +[Dumuzid](https://en.wikipedia.org/wiki/Dumuzid) is an implementation of some Adonis APIs to be used in the development of [pyadonis](https://kumig.it/kumisystems/pyadonis) and [AcadeMon](https://kumig.it/kumisystems/academon). + +It is not intended to be, and will never be, a full replacement of any Adonis feature – instead, it is supposed to produce API output compatible to that of Adonis such as to be able to test other software without having to send requests to a live (production or testing) instance of Adonis. \ No newline at end of file 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/migrations/__init__.py b/api/migrations/__init__.py new file mode 100644 index 0000000..e69de29 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/views.py b/api/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/api/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/datastore/__init__.py b/datastore/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/datastore/admin.py b/datastore/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/datastore/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/datastore/apps.py b/datastore/apps.py new file mode 100644 index 0000000..04a74d6 --- /dev/null +++ b/datastore/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class DatastoreConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'datastore' diff --git a/datastore/migrations/__init__.py b/datastore/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/datastore/models.py b/datastore/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/datastore/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/datastore/tests.py b/datastore/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/datastore/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/datastore/views.py b/datastore/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/datastore/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/dumuzid/__init__.py b/dumuzid/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dumuzid/asgi.py b/dumuzid/asgi.py new file mode 100644 index 0000000..f0b43e6 --- /dev/null +++ b/dumuzid/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for dumuzid project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dumuzid.settings') + +application = get_asgi_application() diff --git a/dumuzid/settings.py b/dumuzid/settings.py new file mode 100644 index 0000000..293626a --- /dev/null +++ b/dumuzid/settings.py @@ -0,0 +1,114 @@ + +from pathlib import Path + +from autosecretkey import AutoSecretKey + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + +CONFIG_PATH = BASE_DIR / "settings.ini" + +ASK = AutoSecretKey(CONFIG_PATH) +MONSTERCONFIG = MonsterConfig(CONFIG_PATH) +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + 'datastore', + 'api', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'dumuzid.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'dumuzid.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/4.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.1/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/dumuzid/urls.py b/dumuzid/urls.py new file mode 100644 index 0000000..05897c8 --- /dev/null +++ b/dumuzid/urls.py @@ -0,0 +1,21 @@ +"""dumuzid URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/dumuzid/wsgi.py b/dumuzid/wsgi.py new file mode 100644 index 0000000..12b6810 --- /dev/null +++ b/dumuzid/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for dumuzid project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dumuzid.settings') + +application = get_wsgi_application() diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..f011a6c --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dumuzid.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..219e6a0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +Django + +django-autosecretkey + +# For MySQL + +mysqlclient \ No newline at end of file