-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
App Generator
committed
Sep 13, 2021
1 parent
12d7f07
commit a8516af
Showing
525 changed files
with
54,934 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# tests and coverage | ||
*.pytest_cache | ||
.coverage | ||
|
||
# database & logs | ||
*.db | ||
*.sqlite3 | ||
*.log | ||
|
||
# venv | ||
env | ||
venv | ||
|
||
# other | ||
.DS_Store | ||
|
||
# javascript | ||
package-lock.json | ||
|
||
staticfiles/* | ||
!staticfiles/.gitkeep | ||
.vscode/symbols.json | ||
|
||
core/static/assets/node_modules | ||
core/static/assets/yarn.lock | ||
core/static/assets/.temp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM python:3.9 | ||
|
||
COPY . . | ||
|
||
# set environment variables | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# install python dependencies | ||
RUN pip install --upgrade pip | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# running migrations | ||
RUN python manage.py migrate | ||
|
||
# gunicorn | ||
CMD ["gunicorn", "--config", "gunicorn-cfg.py", "core.wsgi"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: gunicorn core.wsgi --log-file=- |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django.apps import AppConfig | ||
|
||
|
||
class MyConfig(AppConfig): | ||
name = 'apps.app' | ||
label = 'apps_app' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django.db import models | ||
from django.contrib.auth.models import User | ||
|
||
# Create your models here. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django.urls import path, re_path | ||
from apps.app import views | ||
|
||
urlpatterns = [ | ||
|
||
# The home page | ||
path('', views.index, name='home'), | ||
|
||
# Matches any html file | ||
re_path(r'^.*\.*', views.pages, name='pages'), | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django import template | ||
from django.contrib.auth.decorators import login_required | ||
from django.http import HttpResponse, HttpResponseRedirect | ||
from django.template import loader | ||
from django.urls import reverse | ||
|
||
|
||
@login_required(login_url="/login/") | ||
def index(request): | ||
context = {'segment': 'index'} | ||
|
||
html_template = loader.get_template('index.html') | ||
return HttpResponse(html_template.render(context, request)) | ||
|
||
|
||
@login_required(login_url="/login/") | ||
def pages(request): | ||
context = {} | ||
# All resource paths end in .html. | ||
# Pick out the html file name from the url. And load that template. | ||
try: | ||
|
||
load_template = request.path.split('/')[-1] | ||
|
||
if load_template == 'admin': | ||
return HttpResponseRedirect(reverse('admin:index')) | ||
context['segment'] = load_template | ||
|
||
html_template = loader.get_template(load_template) | ||
return HttpResponse(html_template.render(context, request)) | ||
|
||
except template.TemplateDoesNotExist: | ||
|
||
html_template = loader.get_template('page-404.html') | ||
return HttpResponse(html_template.render(context, request)) | ||
|
||
except: | ||
html_template = loader.get_template('page-500.html') | ||
return HttpResponse(html_template.render(context, request)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django.apps import AppConfig | ||
|
||
|
||
class AuthConfig(AppConfig): | ||
name = 'apps.auth' | ||
label = 'apps_auth' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django import forms | ||
from django.contrib.auth.forms import UserCreationForm | ||
from django.contrib.auth.models import User | ||
|
||
|
||
class LoginForm(forms.Form): | ||
username = forms.CharField( | ||
widget=forms.TextInput( | ||
attrs={ | ||
"placeholder": "Username", | ||
"class": "form-control" | ||
} | ||
)) | ||
password = forms.CharField( | ||
widget=forms.PasswordInput( | ||
attrs={ | ||
"placeholder": "Password", | ||
"class": "form-control" | ||
} | ||
)) | ||
|
||
|
||
class SignUpForm(UserCreationForm): | ||
username = forms.CharField( | ||
widget=forms.TextInput( | ||
attrs={ | ||
"placeholder": "Username", | ||
"class": "form-control" | ||
} | ||
)) | ||
email = forms.EmailField( | ||
widget=forms.EmailInput( | ||
attrs={ | ||
"placeholder": "Email", | ||
"class": "form-control" | ||
} | ||
)) | ||
password1 = forms.CharField( | ||
widget=forms.PasswordInput( | ||
attrs={ | ||
"placeholder": "Password", | ||
"class": "form-control" | ||
} | ||
)) | ||
password2 = forms.CharField( | ||
widget=forms.PasswordInput( | ||
attrs={ | ||
"placeholder": "Password check", | ||
"class": "form-control" | ||
} | ||
)) | ||
|
||
class Meta: | ||
model = User | ||
fields = ('username', 'email', 'password1', 'password2') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
from django.urls import path | ||
from .views import login_view, register_user | ||
from django.contrib.auth.views import LogoutView | ||
|
||
urlpatterns = [ | ||
path('login/', login_view, name="login"), | ||
path('register/', register_user, name="register"), | ||
path("logout/", LogoutView.as_view(), name="logout") | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
# Create your views here. | ||
from django.shortcuts import render, redirect | ||
from django.contrib.auth import authenticate, login | ||
from .forms import LoginForm, SignUpForm | ||
|
||
|
||
def login_view(request): | ||
form = LoginForm(request.POST or None) | ||
|
||
msg = None | ||
|
||
if request.method == "POST": | ||
|
||
if form.is_valid(): | ||
username = form.cleaned_data.get("username") | ||
password = form.cleaned_data.get("password") | ||
user = authenticate(username=username, password=password) | ||
if user is not None: | ||
login(request, user) | ||
return redirect("/") | ||
else: | ||
msg = 'Invalid credentials' | ||
else: | ||
msg = 'Error validating the form' | ||
|
||
return render(request, "accounts/login.html", {"form": form, "msg": msg}) | ||
|
||
|
||
def register_user(request): | ||
msg = None | ||
success = False | ||
|
||
if request.method == "POST": | ||
form = SignUpForm(request.POST) | ||
if form.is_valid(): | ||
form.save() | ||
username = form.cleaned_data.get("username") | ||
raw_password = form.cleaned_data.get("password1") | ||
user = authenticate(username=username, password=raw_password) | ||
|
||
msg = 'User created - please <a href="/login">login</a>.' | ||
success = True | ||
|
||
# return redirect("/login/") | ||
|
||
else: | ||
msg = 'Form is not valid' | ||
else: | ||
form = SignUpForm() | ||
|
||
return render(request, "accounts/register.html", {"form": form, "msg": msg, "success": success}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AppsConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'apps' | ||
label = 'apps' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Copyright (c) 2019 - present AppSeed.us | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings') | ||
|
||
application = get_asgi_application() |
Oops, something went wrong.