Skip to content

Commit

Permalink
backend API
Browse files Browse the repository at this point in the history
  • Loading branch information
sky1122 committed Nov 12, 2022
0 parents commit c714fa8
Show file tree
Hide file tree
Showing 40 changed files with 596 additions and 0 deletions.
Empty file added APIProject/__init__.py
Empty file.
Binary file added APIProject/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added APIProject/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file added APIProject/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added APIProject/__pycache__/wsgi.cpython-310.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions APIProject/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for APIProject 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', 'APIProject.settings')

application = get_asgi_application()
130 changes: 130 additions & 0 deletions APIProject/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
"""
Django settings for APIProject project.
Generated by 'django-admin startproject' using Django 4.1.3.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""

from pathlib import Path

# 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/4.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-b#!#_mq(^l0@$dx!4hfe)ywmx3%@nl!xslj$u2jhcn&+36q0ph'

# 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',
'rest_framework',
'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 = 'APIProject.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 = 'APIProject.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myinfo',
'USER': 'admin',
'PASSWORD': 'MySQLadmin',
'HOST': 'database-1.cgclbrbzdxbi.us-east-2.rds.amazonaws.com',
'PORT': '3306'
}
}


# 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'
25 changes: 25 additions & 0 deletions APIProject/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""APIProject 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, include

# 1.
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('api.urls')),
]

# ./frontend/src/index.js --output-path ./frontend/static/frontend/main.js
16 changes: 16 additions & 0 deletions APIProject/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for APIProject 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', 'APIProject.settings')

application = get_wsgi_application()
Empty file added api/__init__.py
Empty file.
Binary file added api/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/serializers.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/views.cpython-310.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions api/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib import admin
from .models import Member, Team
# Register your models here.
admin.site.register(Member)
admin.site.register(Team)
6 changes: 6 additions & 0 deletions api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'api'
44 changes: 44 additions & 0 deletions api/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 4.1.3 on 2022-11-10 22:40

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Team',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200, unique=True)),
('description', models.CharField(max_length=200)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name='Member',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('email', models.CharField(max_length=200)),
('password', models.CharField(max_length=200)),
('phone', models.CharField(max_length=200)),
('address', models.CharField(max_length=200)),
('city', models.CharField(max_length=200)),
('state', models.CharField(max_length=200)),
('country', models.CharField(max_length=200)),
('zipcode', models.CharField(max_length=200)),
('status', models.CharField(max_length=200)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.team')),
],
),
]
24 changes: 24 additions & 0 deletions api/migrations/0002_alter_member_phone_alter_member_team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.1.3 on 2022-11-10 23:11

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('api', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='member',
name='phone',
field=models.CharField(max_length=200, unique=True),
),
migrations.AlterField(
model_name='member',
name='team',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='api.team'),
),
]
17 changes: 17 additions & 0 deletions api/migrations/0003_remove_member_password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.1.3 on 2022-11-11 01:47

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0002_alter_member_phone_alter_member_team'),
]

operations = [
migrations.RemoveField(
model_name='member',
name='password',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 4.1.3 on 2022-11-11 04:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0003_remove_member_password'),
]

operations = [
migrations.AlterField(
model_name='member',
name='address',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='member',
name='city',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='member',
name='country',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='member',
name='state',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='member',
name='status',
field=models.CharField(blank=True, max_length=200),
),
migrations.AlterField(
model_name='member',
name='zipcode',
field=models.CharField(blank=True, max_length=200),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Generated by Django 4.1.3 on 2022-11-11 05:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0004_alter_member_address_alter_member_city_and_more'),
]

operations = [
migrations.RenameField(
model_name='member',
old_name='name',
new_name='first_name',
),
migrations.RemoveField(
model_name='member',
name='address',
),
migrations.RemoveField(
model_name='member',
name='city',
),
migrations.RemoveField(
model_name='member',
name='country',
),
migrations.RemoveField(
model_name='member',
name='state',
),
migrations.RemoveField(
model_name='member',
name='status',
),
migrations.RemoveField(
model_name='member',
name='zipcode',
),
migrations.AddField(
model_name='member',
name='last_name',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AddField(
model_name='member',
name='role',
field=models.CharField(choices=[('0', 'admin'), ('1', 'regular')], default='1', max_length=1),
),
]
Loading

0 comments on commit c714fa8

Please sign in to comment.