diff --git a/billing/__init__.py b/billing/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/billing/admin.py b/billing/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/billing/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/billing/apps.py b/billing/apps.py new file mode 100644 index 0000000..7242aac --- /dev/null +++ b/billing/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BillingConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "billing" diff --git a/billing/migrations/__init__.py b/billing/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/billing/models.py b/billing/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/billing/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/billing/tests.py b/billing/tests.py new file mode 100644 index 0000000..cd30648 --- /dev/null +++ b/billing/tests.py @@ -0,0 +1,17 @@ +"""Billing model tests""" +from pprint import pprint + +from django.test import TestCase, Client + +from . import views + + +class DummyTestCase(TestCase): + """Placeholder test to get plumbing going""" + + def test_dummy_index(self): + """Placeholder test to setup plumbing""" + response = self.client.get("/") + pprint(response.content) + self.assertEqual(response.status_code, 200) + self.assertContains(response, bytes(views.RESPONSE, "utf-8")) diff --git a/billing/urls.py b/billing/urls.py new file mode 100644 index 0000000..fdaa1c1 --- /dev/null +++ b/billing/urls.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from django.urls import path + +from . import views + +urlpatterns = [path("", views.index, name="index")] diff --git a/billing/views.py b/billing/views.py new file mode 100644 index 0000000..043b2fb --- /dev/null +++ b/billing/views.py @@ -0,0 +1,23 @@ +# Hostea Billing: generate invoices, manage subscriptions, etc. +# Copyright © 2022 Aravinth Manivannan +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from django.shortcuts import render +from django.http import HttpResponse, HttpRequest + +RESPONSE = "hello akl;sdja;sdlkfj" + + +def index(_request: HttpRequest): + return HttpResponse(RESPONSE) diff --git a/payments/asgi.py b/payments/asgi.py index 8c68cc2..c9cae4a 100644 --- a/payments/asgi.py +++ b/payments/asgi.py @@ -11,6 +11,6 @@ import os from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'payments.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "payments.settings") application = get_asgi_application() diff --git a/payments/settings.py b/payments/settings.py index c5f793b..9a90656 100644 --- a/payments/settings.py +++ b/payments/settings.py @@ -20,7 +20,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-!#$3e)ertgo_)*^))*i05x8=&xd5s5$!0v4t1o78s0cc(38j%3' +SECRET_KEY = "django-insecure-!#$3e)ertgo_)*^))*i05x8=&xd5s5$!0v4t1o78s0cc(38j%3" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -31,56 +31,56 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", ] 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', + "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 = 'payments.urls' +ROOT_URLCONF = "payments.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', + "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 = 'payments.wsgi.application' +WSGI_APPLICATION = "payments.wsgi.application" # Database # https://docs.djangoproject.com/en/4.0/ref/settings/#databases DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql', - 'NAME': 'postgres', - 'HOST': 'localhost', - 'PORT': '5432', - 'PASSWORD': 'password', - 'USER': 'postgres', + "default": { + "ENGINE": "django.db.backends.postgresql", + "NAME": "postgres", + "HOST": "localhost", + "PORT": "5432", + "PASSWORD": "password", + "USER": "postgres", } } @@ -90,16 +90,16 @@ DATABASES = { AUTH_PASSWORD_VALIDATORS = [ { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, ] @@ -107,9 +107,9 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization # https://docs.djangoproject.com/en/4.0/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = "en-us" -TIME_ZONE = 'UTC' +TIME_ZONE = "UTC" USE_I18N = True @@ -119,9 +119,9 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.0/howto/static-files/ -STATIC_URL = 'static/' +STATIC_URL = "static/" # Default primary key field type # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/payments/urls.py b/payments/urls.py index cf1300d..ff11c9d 100644 --- a/payments/urls.py +++ b/payments/urls.py @@ -14,8 +14,6 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include -urlpatterns = [ - path('admin/', admin.site.urls), -] +urlpatterns = [path("admin/", admin.site.urls), path("", include("billing.urls"))] diff --git a/payments/wsgi.py b/payments/wsgi.py index ecd6a97..fcdfe2d 100644 --- a/payments/wsgi.py +++ b/payments/wsgi.py @@ -11,6 +11,6 @@ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'payments.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "payments.settings") application = get_wsgi_application()