Skip to content

Commit b37a415

Browse files
author
App Generator
committed
Bump Codebase Version & Improvements
1 parent f5363f2 commit b37a415

36 files changed

+11143
-18582
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ package-lock.json
2424
staticfiles/*
2525
!staticfiles/.gitkeep
2626
.vscode/symbols.json
27+
28+
core/static/assets/node_modules
29+
core/static/assets/yarn.lock
30+
core/static/assets/.temp

Dockerfile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
FROM python:3.6
1+
FROM python:3.9
22

3-
COPY manage.py gunicorn-cfg.py requirements.txt .env ./
4-
COPY app app
5-
COPY authentication authentication
6-
COPY core core
3+
COPY . .
74

8-
RUN pip install -r requirements.txt
5+
# set environment variables
6+
ENV PYTHONDONTWRITEBYTECODE 1
7+
ENV PYTHONUNBUFFERED 1
98

10-
RUN python manage.py makemigrations
9+
# install python dependencies
10+
RUN pip install --upgrade pip
11+
RUN pip install --no-cache-dir -r requirements.txt
12+
13+
# running migrations
1114
RUN python manage.py migrate
1215

13-
EXPOSE 5005
16+
# gunicorn
1417
CMD ["gunicorn", "--config", "gunicorn-cfg.py", "core.wsgi"]
18+
File renamed without changes.
File renamed without changes.
File renamed without changes.

app/config.py renamed to apps/app/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55

66
from django.apps import AppConfig
77

8+
89
class MyConfig(AppConfig):
9-
name = 'cfg'
10+
name = 'apps.app'
11+
label = 'apps_app'
File renamed without changes.
File renamed without changes.
File renamed without changes.

app/urls.py renamed to apps/app/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
from django.urls import path, re_path
7-
from app import views
7+
from apps.app import views
88

99
urlpatterns = [
1010

app/views.py renamed to apps/app/views.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,42 @@
33
Copyright (c) 2019 - present AppSeed.us
44
"""
55

6+
from django import template
67
from django.contrib.auth.decorators import login_required
7-
from django.shortcuts import render, get_object_or_404, redirect
8+
from django.http import HttpResponse, HttpResponseRedirect
89
from django.template import loader
9-
from django.http import HttpResponse
10-
from django import template
10+
from django.urls import reverse
11+
1112

1213
@login_required(login_url="/login/")
1314
def index(request):
14-
15-
context = {}
16-
context['segment'] = 'index'
15+
context = {'segment': 'index'}
1716

18-
html_template = loader.get_template( 'index.html' )
17+
html_template = loader.get_template('index.html')
1918
return HttpResponse(html_template.render(context, request))
2019

20+
2121
@login_required(login_url="/login/")
2222
def pages(request):
2323
context = {}
2424
# All resource paths end in .html.
2525
# Pick out the html file name from the url. And load that template.
2626
try:
27-
28-
load_template = request.path.split('/')[-1]
27+
28+
load_template = request.path.split('/')[-1]
29+
30+
if load_template == 'admin':
31+
return HttpResponseRedirect(reverse('admin:index'))
2932
context['segment'] = load_template
30-
31-
html_template = loader.get_template( load_template )
33+
34+
html_template = loader.get_template(load_template)
3235
return HttpResponse(html_template.render(context, request))
33-
36+
3437
except template.TemplateDoesNotExist:
3538

36-
html_template = loader.get_template( 'page-404.html' )
39+
html_template = loader.get_template('page-404.html')
3740
return HttpResponse(html_template.render(context, request))
3841

3942
except:
40-
41-
html_template = loader.get_template( 'page-500.html' )
43+
html_template = loader.get_template('page-500.html')
4244
return HttpResponse(html_template.render(context, request))
File renamed without changes.
File renamed without changes.

authentication/config.py renamed to apps/authentication/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55

66
from django.apps import AppConfig
77

8+
89
class AuthConfig(AppConfig):
9-
name = 'authcfg'
10+
name = 'apps.auth'
11+
label = 'apps_auth'

authentication/forms.py renamed to apps/authentication/forms.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,50 @@
77
from django.contrib.auth.forms import UserCreationForm
88
from django.contrib.auth.models import User
99

10+
1011
class LoginForm(forms.Form):
1112
username = forms.CharField(
1213
widget=forms.TextInput(
1314
attrs={
14-
"placeholder" : "Username",
15+
"placeholder": "Username",
1516
"class": "form-control"
1617
}
1718
))
1819
password = forms.CharField(
1920
widget=forms.PasswordInput(
2021
attrs={
21-
"placeholder" : "Password",
22+
"placeholder": "Password",
2223
"class": "form-control"
2324
}
2425
))
2526

27+
2628
class SignUpForm(UserCreationForm):
2729
username = forms.CharField(
2830
widget=forms.TextInput(
2931
attrs={
30-
"placeholder" : "Username",
32+
"placeholder": "Username",
3133
"class": "form-control"
3234
}
3335
))
3436
email = forms.EmailField(
3537
widget=forms.EmailInput(
3638
attrs={
37-
"placeholder" : "Email",
39+
"placeholder": "Email",
3840
"class": "form-control"
3941
}
4042
))
4143
password1 = forms.CharField(
4244
widget=forms.PasswordInput(
4345
attrs={
44-
"placeholder" : "Password",
46+
"placeholder": "Password",
4547
"class": "form-control"
4648
}
4749
))
4850
password2 = forms.CharField(
4951
widget=forms.PasswordInput(
5052
attrs={
51-
"placeholder" : "Password check",
53+
"placeholder": "Password check",
5254
"class": "form-control"
5355
}
5456
))
File renamed without changes.
File renamed without changes.
File renamed without changes.

authentication/views.py renamed to apps/authentication/views.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33
Copyright (c) 2019 - present AppSeed.us
44
"""
55

6-
from django.shortcuts import render
7-
86
# Create your views here.
97
from django.shortcuts import render, redirect
108
from django.contrib.auth import authenticate, login
11-
from django.contrib.auth.models import User
12-
from django.forms.utils import ErrorList
13-
from django.http import HttpResponse
149
from .forms import LoginForm, SignUpForm
1510

11+
1612
def login_view(request):
1713
form = LoginForm(request.POST or None)
1814

@@ -27,16 +23,16 @@ def login_view(request):
2723
if user is not None:
2824
login(request, user)
2925
return redirect("/")
30-
else:
31-
msg = 'Invalid credentials'
26+
else:
27+
msg = 'Invalid credentials'
3228
else:
33-
msg = 'Error validating the form'
29+
msg = 'Error validating the form'
3430

35-
return render(request, "accounts/login.html", {"form": form, "msg" : msg})
31+
return render(request, "accounts/login.html", {"form": form, "msg": msg})
3632

37-
def register_user(request):
3833

39-
msg = None
34+
def register_user(request):
35+
msg = None
4036
success = False
4137

4238
if request.method == "POST":
@@ -47,14 +43,14 @@ def register_user(request):
4743
raw_password = form.cleaned_data.get("password1")
4844
user = authenticate(username=username, password=raw_password)
4945

50-
msg = 'User created - please <a href="/login">login</a>.'
46+
msg = 'User created - please <a href="/login">login</a>.'
5147
success = True
52-
53-
#return redirect("/login/")
48+
49+
# return redirect("/login/")
5450

5551
else:
56-
msg = 'Form is not valid'
52+
msg = 'Form is not valid'
5753
else:
5854
form = SignUpForm()
5955

60-
return render(request, "accounts/register.html", {"form": form, "msg" : msg, "success" : success })
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'

core/settings.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import os
77
from decouple import config
88
from unipath import Path
9-
import dj_database_url
109

1110
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1211
BASE_DIR = Path(__file__).parent
@@ -30,7 +29,7 @@
3029
'django.contrib.sessions',
3130
'django.contrib.messages',
3231
'django.contrib.staticfiles',
33-
'app' # Enable the inner app
32+
'apps.app' # Enable the inner app
3433
]
3534

3635
MIDDLEWARE = [
@@ -45,7 +44,7 @@
4544
]
4645

4746
ROOT_URLCONF = 'core.urls'
48-
LOGIN_REDIRECT_URL = "home" # Route defined in app/urls.py
47+
LOGIN_REDIRECT_URL = "home" # Route defined in app/urls.py
4948
LOGOUT_REDIRECT_URL = "home" # Route defined in app/urls.py
5049
TEMPLATE_DIR = os.path.join(CORE_DIR, "core/templates") # ROOT dir for templates
5150

@@ -73,7 +72,7 @@
7372
DATABASES = {
7473
'default': {
7574
'ENGINE': 'django.db.backends.sqlite3',
76-
'NAME' : 'db.sqlite3',
75+
'NAME': 'db.sqlite3',
7776
}
7877
}
7978

@@ -95,7 +94,6 @@
9594
},
9695
]
9796

98-
9997
# Internationalization
10098
# https://docs.djangoproject.com/en/3.0/topics/i18n/
10199

0 commit comments

Comments
 (0)