Skip to content

Commit bf45148

Browse files
author
App Generator
committed
Initial Release
1 parent ba4f28c commit bf45148

File tree

259 files changed

+35623
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

259 files changed

+35623
-0
lines changed

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DEBUG=True
2+
SECRET_KEY=S3cr3t_K#Key
3+
SERVER=.appseed-srv1.com

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
5+
# tests and coverage
6+
*.pytest_cache
7+
.coverage
8+
9+
# database & logs
10+
*.db
11+
*.sqlite3
12+
*.log
13+
14+
# venv
15+
env
16+
venv
17+
18+
# other
19+
.DS_Store
20+
21+
# javascript
22+
package-lock.json
23+
24+
staticfiles/*
25+
!staticfiles/.gitkeep
26+
.vscode/symbols.json
27+
28+
apps/static/assets/node_modules
29+
apps/static/assets/yarn.lock
30+
apps/static/assets/.temp

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM python:3.9
2+
3+
COPY . .
4+
5+
# set environment variables
6+
ENV PYTHONDONTWRITEBYTECODE 1
7+
ENV PYTHONUNBUFFERED 1
8+
9+
# install python dependencies
10+
RUN pip install --upgrade pip
11+
RUN pip install --no-cache-dir -r requirements.txt
12+
13+
# running migrations
14+
RUN python manage.py migrate
15+
16+
# gunicorn
17+
CMD ["gunicorn", "--config", "gunicorn-cfg.py", "core.wsgi"]
18+

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 - present Creative-Tim / [AppSeed.us](https://appseed.us)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn core.wsgi --log-file=-

apps/__init__.py

Whitespace-only changes.

apps/authentication/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""

apps/authentication/admin.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django.contrib import admin
7+
8+
# Register your models here.

apps/authentication/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django.apps import AppConfig
7+
8+
9+
class AuthConfig(AppConfig):
10+
name = 'apps.auth'
11+
label = 'apps_auth'

apps/authentication/forms.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django import forms
7+
from django.contrib.auth.forms import UserCreationForm
8+
from django.contrib.auth.models import User
9+
10+
11+
class LoginForm(forms.Form):
12+
username = forms.CharField(
13+
widget=forms.TextInput(
14+
attrs={
15+
"placeholder": "Username",
16+
"class": "form-control"
17+
}
18+
))
19+
password = forms.CharField(
20+
widget=forms.PasswordInput(
21+
attrs={
22+
"placeholder": "Password",
23+
"class": "form-control"
24+
}
25+
))
26+
27+
28+
class SignUpForm(UserCreationForm):
29+
username = forms.CharField(
30+
widget=forms.TextInput(
31+
attrs={
32+
"placeholder": "Username",
33+
"class": "form-control"
34+
}
35+
))
36+
email = forms.EmailField(
37+
widget=forms.EmailInput(
38+
attrs={
39+
"placeholder": "Email",
40+
"class": "form-control"
41+
}
42+
))
43+
password1 = forms.CharField(
44+
widget=forms.PasswordInput(
45+
attrs={
46+
"placeholder": "Password",
47+
"class": "form-control"
48+
}
49+
))
50+
password2 = forms.CharField(
51+
widget=forms.PasswordInput(
52+
attrs={
53+
"placeholder": "Password check",
54+
"class": "form-control"
55+
}
56+
))
57+
58+
class Meta:
59+
model = User
60+
fields = ('username', 'email', 'password1', 'password2')
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""

apps/authentication/models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django.db import models
7+
8+
# Create your models here.

apps/authentication/tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django.test import TestCase
7+
8+
# Create your tests here.

apps/authentication/urls.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django.urls import path
7+
from .views import login_view, register_user
8+
from django.contrib.auth.views import LogoutView
9+
10+
urlpatterns = [
11+
path('login/', login_view, name="login"),
12+
path('register/', register_user, name="register"),
13+
path("logout/", LogoutView.as_view(), name="logout")
14+
]

apps/authentication/views.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
# Create your views here.
7+
from django.shortcuts import render, redirect
8+
from django.contrib.auth import authenticate, login
9+
from .forms import LoginForm, SignUpForm
10+
11+
12+
def login_view(request):
13+
form = LoginForm(request.POST or None)
14+
15+
msg = None
16+
17+
if request.method == "POST":
18+
19+
if form.is_valid():
20+
username = form.cleaned_data.get("username")
21+
password = form.cleaned_data.get("password")
22+
user = authenticate(username=username, password=password)
23+
if user is not None:
24+
login(request, user)
25+
return redirect("/")
26+
else:
27+
msg = 'Invalid credentials'
28+
else:
29+
msg = 'Error validating the form'
30+
31+
return render(request, "accounts/login.html", {"form": form, "msg": msg})
32+
33+
34+
def register_user(request):
35+
msg = None
36+
success = False
37+
38+
if request.method == "POST":
39+
form = SignUpForm(request.POST)
40+
if form.is_valid():
41+
form.save()
42+
username = form.cleaned_data.get("username")
43+
raw_password = form.cleaned_data.get("password1")
44+
user = authenticate(username=username, password=raw_password)
45+
46+
msg = 'User created - please <a href="/login">login</a>.'
47+
success = True
48+
49+
# return redirect("/login/")
50+
51+
else:
52+
msg = 'Form is not valid'
53+
else:
54+
form = SignUpForm()
55+
56+
return render(request, "accounts/register.html", {"form": form, "msg": msg, "success": success})

apps/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AppsConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'apps'
7+
label = 'apps'

apps/home/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""

apps/home/admin.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django.contrib import admin
7+
8+
# Register your models here.

apps/home/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django.apps import AppConfig
7+
8+
9+
class MyConfig(AppConfig):
10+
name = 'apps.home'
11+
label = 'apps_home'

apps/home/migrations/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""

apps/home/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django.db import models
7+
from django.contrib.auth.models import User
8+
9+
# Create your models here.
10+

apps/home/tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django.test import TestCase
7+
8+
# Create your tests here.

apps/home/urls.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django.urls import path, re_path
7+
from apps.home import views
8+
9+
urlpatterns = [
10+
11+
# The home page
12+
path('', views.index, name='home'),
13+
14+
# Matches any html file
15+
re_path(r'^.*\.*', views.pages, name='pages'),
16+
17+
]

apps/home/views.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# -*- encoding: utf-8 -*-
2+
"""
3+
Copyright (c) 2019 - present AppSeed.us
4+
"""
5+
6+
from django import template
7+
from django.contrib.auth.decorators import login_required
8+
from django.http import HttpResponse, HttpResponseRedirect
9+
from django.template import loader
10+
from django.urls import reverse
11+
12+
13+
@login_required(login_url="/login/")
14+
def index(request):
15+
context = {'segment': 'index'}
16+
17+
html_template = loader.get_template('home/index.html')
18+
return HttpResponse(html_template.render(context, request))
19+
20+
21+
@login_required(login_url="/login/")
22+
def pages(request):
23+
context = {}
24+
# All resource paths end in .html.
25+
# Pick out the html file name from the url. And load that template.
26+
try:
27+
28+
load_template = request.path.split('/')[-1]
29+
30+
if load_template == 'admin':
31+
return HttpResponseRedirect(reverse('admin:index'))
32+
context['segment'] = load_template
33+
34+
html_template = loader.get_template('home/' + load_template)
35+
return HttpResponse(html_template.render(context, request))
36+
37+
except template.TemplateDoesNotExist:
38+
39+
html_template = loader.get_template('home/page-404.html')
40+
return HttpResponse(html_template.render(context, request))
41+
42+
except:
43+
html_template = loader.get_template('home/page-500.html')
44+
return HttpResponse(html_template.render(context, request))

0 commit comments

Comments
 (0)