First Beta!
This commit is contained in:
parent
571390b7af
commit
ab68716e68
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
*.pyc
|
||||
.env
|
||||
|
||||
## No Databases
|
||||
*.sqlite*
|
@ -1,3 +1,10 @@
|
||||
# api
|
||||
|
||||
The AHosking.com API
|
||||
|
||||
## Getting Started
|
||||
|
||||
###
|
||||
1. Activate environment
|
||||
`.\.env\Scripts\activate`
|
||||
1.
|
8
api-workspace.code-workspace
Normal file
8
api-workspace.code-workspace
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
7
api/api/.env.sample
Normal file
7
api/api/.env.sample
Normal file
@ -0,0 +1,7 @@
|
||||
SECRET_KEY=django-insecure-7uajhmbt^@)mklk1ur=slkmn3*+9_cnfhww6wi8jg*h@qqd%6u
|
||||
DEBUG=True
|
||||
DATABASE_NAME=database
|
||||
DATABASE_USER=user
|
||||
DATABASE_PASSWORD=password
|
||||
DATABASE_HOST=localhost
|
||||
DATABASE_PORT=5432
|
0
api/api/__init__.py
Normal file
0
api/api/__init__.py
Normal file
16
api/api/asgi.py
Normal file
16
api/api/asgi.py
Normal file
@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for api 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/3.2/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'api.settings')
|
||||
|
||||
application = get_asgi_application()
|
137
api/api/settings.py
Normal file
137
api/api/settings.py
Normal file
@ -0,0 +1,137 @@
|
||||
"""
|
||||
Django settings for api project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 3.2.9.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.2/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/3.2/ref/settings/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import environ
|
||||
|
||||
env = environ.Env()
|
||||
environ.Env.read_env()
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = env("SECRET_KEY", default='django-insecure-7uajhmbt^@)mklk1ur=slkmn3*+9_cnfhww6wi8jg*h@qqd%6u')
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = env("DEBUG")
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'rest_framework',
|
||||
'rest_framework.authtoken',
|
||||
'django_filters',
|
||||
'bills.apps.BillsConfig',
|
||||
]
|
||||
|
||||
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 = 'api.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 = 'api.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': env("DATABASE_NAME"),
|
||||
'USER': env("DATABASE_USER"),
|
||||
'PASSWORD': env("DATABASE_PASSWORD"),
|
||||
'HOST': env("DATABASE_HOST"),
|
||||
'PORT': env("DATABASE_PORT"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.2/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/3.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
29
api/api/urls.py
Normal file
29
api/api/urls.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""api URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/3.2/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.conf.urls import url
|
||||
from django.contrib import admin
|
||||
from django.views.generic import TemplateView
|
||||
from django.urls import include, path
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
# url(r'^$', view=TemplateView.as_view(template_name='bills/home.html')),
|
||||
# url(r'^$', view=TemplateView.as_view(template_name='main_api/home.html')),
|
||||
path('', views.index, name='index'),
|
||||
path('bills/', include('bills.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
4
api/api/views.py
Normal file
4
api/api/views.py
Normal file
@ -0,0 +1,4 @@
|
||||
from django.http import HttpResponse
|
||||
|
||||
def index(request):
|
||||
return HttpResponse("Hi there! This is the API index")
|
16
api/api/wsgi.py
Normal file
16
api/api/wsgi.py
Normal file
@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for api 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/3.2/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'api.settings')
|
||||
|
||||
application = get_wsgi_application()
|
0
api/bills/__init__.py
Normal file
0
api/bills/__init__.py
Normal file
5
api/bills/admin.py
Normal file
5
api/bills/admin.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Bill
|
||||
|
||||
admin.site.register(Bill)
|
6
api/bills/apps.py
Normal file
6
api/bills/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BillsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'bills'
|
28
api/bills/migrations/0001_initial.py
Normal file
28
api/bills/migrations/0001_initial.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Generated by Django 3.2.9 on 2021-11-09 13:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Bill',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=64)),
|
||||
('type', models.CharField(max_length=64)),
|
||||
('due', models.DateTimeField(verbose_name='due_date')),
|
||||
('amount', models.FloatField(default='00.00')),
|
||||
('is_paid', models.BooleanField(default=False)),
|
||||
('paid_date', models.DateTimeField(verbose_name='paid_date')),
|
||||
('is_overdue', models.BooleanField(default=False)),
|
||||
('is_missed', models.BooleanField(default=False)),
|
||||
],
|
||||
),
|
||||
]
|
23
api/bills/migrations/0002_auto_20211119_2041.py
Normal file
23
api/bills/migrations/0002_auto_20211119_2041.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.2.9 on 2021-11-20 01:41
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bills', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='bill',
|
||||
name='due',
|
||||
field=models.DateField(verbose_name='due_date'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='bill',
|
||||
name='paid_date',
|
||||
field=models.DateField(blank=True, verbose_name='paid_date'),
|
||||
),
|
||||
]
|
18
api/bills/migrations/0003_alter_bill_paid_date.py
Normal file
18
api/bills/migrations/0003_alter_bill_paid_date.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.9 on 2021-11-20 01:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bills', '0002_auto_20211119_2041'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='bill',
|
||||
name='paid_date',
|
||||
field=models.DateField(blank=True, null=True, verbose_name='paid_date'),
|
||||
),
|
||||
]
|
0
api/bills/migrations/__init__.py
Normal file
0
api/bills/migrations/__init__.py
Normal file
18
api/bills/models.py
Normal file
18
api/bills/models.py
Normal file
@ -0,0 +1,18 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class Bill(models.Model):
|
||||
name = models.CharField(max_length=64)
|
||||
type = models.CharField(max_length=64)
|
||||
due = models.DateField('due_date')
|
||||
amount = models.FloatField(default='00.00')
|
||||
is_paid = models.BooleanField(default=False)
|
||||
paid_date = models.DateField('paid_date',null=True, blank=True)
|
||||
is_overdue = models.BooleanField(default=False)
|
||||
is_missed = models.BooleanField(default=False)
|
||||
|
||||
def overdue(self):
|
||||
return self.is_overdue
|
||||
|
||||
def __str__(self):
|
||||
return ("%s - %s" % (self.name, self.due))
|
3
api/bills/tests.py
Normal file
3
api/bills/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
12
api/bills/urls.py
Normal file
12
api/bills/urls.py
Normal file
@ -0,0 +1,12 @@
|
||||
from django.conf.urls import url
|
||||
from django.contrib import admin
|
||||
from django.views.generic import TemplateView
|
||||
from django.urls import include, path
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
path('', views.index, name='index'),
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
6
api/bills/views.py
Normal file
6
api/bills/views.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
|
||||
def index(request):
|
||||
return HttpResponse("Let there be bills!")
|
||||
# Create your views here.
|
22
api/manage.py
Normal file
22
api/manage.py
Normal file
@ -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', 'api.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()
|
8
requirements.txt
Normal file
8
requirements.txt
Normal file
@ -0,0 +1,8 @@
|
||||
asgiref==3.4.1
|
||||
Django==3.2.9
|
||||
django-environ==0.8.1
|
||||
django-filter==21.1
|
||||
djangorestframework==3.12.4
|
||||
psycopg2==2.9.1
|
||||
pytz==2021.3
|
||||
sqlparse==0.4.2
|
Loading…
Reference in New Issue
Block a user