-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrated open-source UI template into Django project
- Added an open-source template to improve UI aesthetics, allowing us to focus on the programming aspects. - Modified hardcoded text elements in the template and linked them to Python dictionaries. This serves as a placeholder for future database integration for user information."
- Loading branch information
1 parent
847ccea
commit dab67f6
Showing
194 changed files
with
69,669 additions
and
69 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,15 @@ | ||
[flake8] | ||
# it's not a bug that we aren't using all of hacking, ignore: | ||
# F812: list comprehension redefines ... | ||
# H101: Use TODO(NAME) | ||
# H202: assertRaises Exception too broad | ||
# H233: Python 3.x incompatible use of print operator | ||
# H301: one import per line | ||
# H306: imports not in alphabetical order (time, os) | ||
# H401: docstring should not start with a space | ||
# H403: multi line docstrings should end on a new line | ||
# H404: multi line docstring should start without a leading new line | ||
# H405: multi line docstring summary not separated with an empty line | ||
# H501: Do not use self.__dict__ for string formatting | ||
ignore = F812,H101,H202,H233,H301,H306,H401,H403,H404,H405,H501 | ||
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,migrations,venv |
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
""" | ||
ASGI config for PathMate project. | ||
ASGI config for eventcalendar 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.2/howto/deployment/asgi/ | ||
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PathMate.settings') | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "eventcalendar.settings") | ||
|
||
application = get_asgi_application() |
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 @@ | ||
from django.contrib.auth.decorators import login_required | ||
from django.http import HttpResponse | ||
|
||
#@login_required | ||
def user_data(request): | ||
# you can replicate the logic you use in GetUserDataView here | ||
context = { | ||
'user_name': 'Not Logged In', | ||
'user_designation': '' | ||
} | ||
if request.user.is_authenticated: | ||
context = { | ||
'user_name': 'Miguel Martinez', | ||
'user_designation': 'Game Programmer' | ||
} | ||
|
||
return context |
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,13 @@ | ||
from django.contrib.sessions.models import Session | ||
from django.utils import timezone | ||
from django.contrib.auth.models import User | ||
|
||
|
||
def get_current_user(): | ||
active_sessions = Session.objects.filter(expire_date__gte=timezone.now()) | ||
user_id_list = [] | ||
for session in active_sessions: | ||
data = session.get_decoded() | ||
user_id_list.append(data.get("_auth_user_id", None)) | ||
user = User.objects.get(id=user_id_list[0]) | ||
return user |
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 |
---|---|---|
@@ -1,123 +1,147 @@ | ||
""" | ||
Django settings for PathMate project. | ||
Generated by 'django-admin startproject' using Django 4.2.5. | ||
Generated by 'django-admin startproject' using Django 3.0.8. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/4.2/topics/settings/ | ||
https://docs.djangoproject.com/en/3.0/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/4.2/ref/settings/ | ||
https://docs.djangoproject.com/en/3.0/ref/settings/ | ||
""" | ||
|
||
from pathlib import Path | ||
import os | ||
|
||
# Build paths inside the project like this: BASE_DIR / 'subdir'. | ||
BASE_DIR = Path(__file__).resolve().parent.parent | ||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ | ||
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = 'django-insecure-%5=2k4$_y=u^vqh_)6p#3=r+#o6k)$v#)q283tu_xiope#1%s&' | ||
SECRET_KEY = "i8e1s3!_(fjsiv%1pn3sb3o=s)!p*nzwh1$gp5-l&%nb!d=y_s" | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = True | ||
#DEBUG = False | ||
DEFAULT_AUTO_FIELD='django.db.models.AutoField' | ||
|
||
ALLOWED_HOSTS = [] | ||
ALLOWED_HOSTS = ["*"] | ||
|
||
|
||
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
"django.contrib.admin", | ||
"django.contrib.auth", | ||
"django.contrib.contenttypes", | ||
"django.contrib.sessions", | ||
"django.contrib.messages", | ||
"django.contrib.staticfiles", | ||
"calendarapp.apps.CalendarappConfig", | ||
"accounts.apps.AccountsConfig", | ||
] | ||
|
||
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', | ||
"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 = 'PathMate.urls' | ||
ROOT_URLCONF = "PathMate.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', | ||
], | ||
"BACKEND": "django.template.backends.django.DjangoTemplates", | ||
"DIRS": [os.path.join(BASE_DIR, "templates")], | ||
"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", | ||
"PathMate.context_processors.user_data", | ||
] | ||
}, | ||
}, | ||
} | ||
] | ||
|
||
WSGI_APPLICATION = 'PathMate.wsgi.application' | ||
WSGI_APPLICATION = "PathMate.wsgi.application" | ||
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases | ||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases | ||
|
||
DATABASES = { | ||
"default": { | ||
"ENGINE": "django.db.backends.sqlite3", | ||
"NAME": os.path.join(BASE_DIR, "db.sqlite3"), | ||
} | ||
} | ||
|
||
""" | ||
##CONECTAR CON POSTGRES | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': BASE_DIR / 'db.sqlite3', | ||
'ENGINE': 'django.db.backends.postgresql_psycopg2', | ||
'NAME': 'proyectoHadaMadrina', | ||
'USER': 'postgres', | ||
'PASSWORD': 'postgres', | ||
'HOST': '127.0.0.1', | ||
'DATABASE_PORT': '5432', | ||
} | ||
} | ||
""" | ||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators | ||
# https://docs.djangoproject.com/en/3.0/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', | ||
"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"}, | ||
] | ||
|
||
AUTH_USER_MODEL = "accounts.User" | ||
|
||
# Internationalization | ||
# https://docs.djangoproject.com/en/4.2/topics/i18n/ | ||
# https://docs.djangoproject.com/en/3.0/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
LANGUAGE_CODE = "en-us" | ||
|
||
TIME_ZONE = 'UTC' | ||
TIME_ZONE = "UTC" | ||
|
||
USE_I18N = True | ||
|
||
USE_TZ = True | ||
USE_L10N = True | ||
|
||
USE_TZ = False | ||
|
||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/4.2/howto/static-files/ | ||
# https://docs.djangoproject.com/en/3.0/howto/static-files/ | ||
""" | ||
STATIC_URL = "/static/" | ||
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] | ||
""" | ||
|
||
STATIC_URL = 'static/' | ||
|
||
# Default primary key field type | ||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field | ||
STATIC_URL = '/static/' | ||
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),) | ||
#STATIC_ROOT=os.path.join(BASE_DIR, 'static/') | ||
|
||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' | ||
# | ||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') # 'data' is my media folder | ||
MEDIA_URL = '/media/' |
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
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,21 @@ | ||
from django.views.generic import View | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.shortcuts import render | ||
|
||
from calendarapp.models import Event | ||
|
||
|
||
class DashboardView(LoginRequiredMixin, View): | ||
login_url = "accounts:signin" | ||
template_name = "calendarapp/dashboard.html" | ||
|
||
def get(self, request, *args, **kwargs): | ||
events = Event.objects.get_all_events(user=request.user) | ||
running_events = Event.objects.get_running_events(user=request.user) | ||
latest_events = Event.objects.filter(user=request.user).order_by("-id")[:10] | ||
context = { | ||
"total_event": events.count(), | ||
"running_events": running_events, | ||
"latest_events": latest_events, | ||
} | ||
return render(request, self.template_name, context) |
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
""" | ||
WSGI config for PathMate project. | ||
WSGI config for eventcalendar 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.2/howto/deployment/wsgi/ | ||
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PathMate.settings') | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "eventcalendar.settings") | ||
|
||
application = get_wsgi_application() |
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,21 @@ | ||
# Security Policy | ||
|
||
## Supported Versions | ||
|
||
Use this section to tell people about which versions of your project are | ||
currently being supported with security updates. | ||
|
||
| Version | Supported | | ||
| ------- | ------------------ | | ||
| 5.1.x | :white_check_mark: | | ||
| 5.0.x | :x: | | ||
| 4.0.x | :white_check_mark: | | ||
| < 4.0 | :x: | | ||
|
||
## Reporting a Vulnerability | ||
|
||
Use this section to tell people how to report a vulnerability. | ||
|
||
Tell them where to go, how often they can expect to get an update on a | ||
reported vulnerability, what to expect if the vulnerability is accepted or | ||
declined, etc. |
Empty 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,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AccountsConfig(AppConfig): | ||
name = "accounts" |
Oops, something went wrong.