Skip to content

Commit

Permalink
Bump Codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
App Generator committed Sep 17, 2021
1 parent 1d25d34 commit 636a11b
Show file tree
Hide file tree
Showing 275 changed files with 52,751 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DEBUG=True
SECRET_KEY=S3cr3t_K#Key
SERVER=boilerplate-code-django-dashboard.appseed.us
EMAIL_HOST="" # smtp.gmail.com
EMAIL_HOST_USER="" # your_email@address
EMAIL_HOST_PASSWORD="" # your_app_password
31 changes: 31 additions & 0 deletions .gitignore
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

apps/static/assets/node_modules
apps/static/assets/yarn.lock
apps/static/assets/.temp

18 changes: 18 additions & 0 deletions Dockerfile
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"]

1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn core.wsgi --log-file=-
Empty file added apps/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions apps/authentication/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""
8 changes: 8 additions & 0 deletions apps/authentication/admin.py
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.
11 changes: 11 additions & 0 deletions apps/authentication/config.py
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'
60 changes: 60 additions & 0 deletions apps/authentication/forms.py
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')
4 changes: 4 additions & 0 deletions apps/authentication/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""
8 changes: 8 additions & 0 deletions apps/authentication/models.py
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.
8 changes: 8 additions & 0 deletions apps/authentication/tests.py
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.
14 changes: 14 additions & 0 deletions apps/authentication/urls.py
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")
]
56 changes: 56 additions & 0 deletions apps/authentication/views.py
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})
7 changes: 7 additions & 0 deletions apps/config.py
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'
4 changes: 4 additions & 0 deletions apps/home/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""
8 changes: 8 additions & 0 deletions apps/home/admin.py
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.
11 changes: 11 additions & 0 deletions apps/home/config.py
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.home'
label = 'apps_home'
4 changes: 4 additions & 0 deletions apps/home/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""
10 changes: 10 additions & 0 deletions apps/home/models.py
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.

8 changes: 8 additions & 0 deletions apps/home/tests.py
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.
17 changes: 17 additions & 0 deletions apps/home/urls.py
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.home import views

urlpatterns = [

# The home page
path('', views.index, name='home'),

# Matches any html file
re_path(r'^.*\.*', views.pages, name='pages'),

]
44 changes: 44 additions & 0 deletions apps/home/views.py
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('home/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('home/' + load_template)
return HttpResponse(html_template.render(context, request))

except template.TemplateDoesNotExist:

html_template = loader.get_template('home/page-404.html')
return HttpResponse(html_template.render(context, request))

except:
html_template = loader.get_template('home/page-500.html')
return HttpResponse(html_template.render(context, request))
Loading

0 comments on commit 636a11b

Please sign in to comment.