From e92f86a2988e73f85c4603a3a2169a4ca24776d5 Mon Sep 17 00:00:00 2001
From: Ekaropolus
Date: Fri, 16 May 2025 19:51:14 -0600
Subject: [PATCH] Accounts Framework added
---
.gitignore | 1 +
docker-compose.override.yml | 15 +
polisplexity/settings.py | 46 +-
polisplexity/urls.py | 5 +-
pxy_dashboard/templates/account/login.html | 1 +
.../account/account_inactive.html | 2 +-
.../pxy_dashboard/account/email.html | 2 +-
.../pxy_dashboard/account/email_confirm.html | 2 +-
.../pxy_dashboard/account/login.html | 15 +-
.../pxy_dashboard/account/logout.html | 2 +-
.../account/password_change.html | 2 +-
.../pxy_dashboard/account/password_reset.html | 2 +-
.../account/password_reset_done.html | 2 +-
.../account/password_reset_from_key.html | 2 +-
.../account/password_reset_from_key_done.html | 2 +-
.../pxy_dashboard/account/password_set.html | 2 +-
.../pxy_dashboard/account/signup.html | 2 +-
.../pxy_dashboard/account/signup_closed.html | 2 +-
.../account/verification_sent.html | 2 +-
.../account/verified_email_required.html | 2 +-
.../pxy_dashboard/partials/footer.html | 2 +-
.../pxy_dashboard/partials/head-css.html | 1 -
.../templates/socialaccount/login.html | 49 +
requirements.txt | 10 +
staticfiles/dashboard/css/app.main.css | 1395 +++++++++++++++++
templates/account/* | 1 +
templates/account/account_inactive.html | 1 +
templates/account/base.html | 1 +
templates/account/email.html | 1 +
templates/account/email_confirm.html | 1 +
templates/account/login.html | 1 +
templates/account/logout.html | 1 +
templates/account/password_change.html | 1 +
templates/account/password_reset.html | 1 +
templates/account/password_reset_done.html | 1 +
.../account/password_reset_from_key.html | 1 +
.../account/password_reset_from_key_done.html | 1 +
templates/account/password_set.html | 1 +
templates/account/signup.html | 1 +
templates/account/signup_closed.html | 1 +
templates/account/verification_sent.html | 1 +
.../account/verified_email_required.html | 1 +
42 files changed, 1563 insertions(+), 22 deletions(-)
create mode 100644 docker-compose.override.yml
create mode 120000 pxy_dashboard/templates/account/login.html
create mode 100644 pxy_dashboard/templates/socialaccount/login.html
create mode 100644 staticfiles/dashboard/css/app.main.css
create mode 120000 templates/account/*
create mode 120000 templates/account/account_inactive.html
create mode 120000 templates/account/base.html
create mode 120000 templates/account/email.html
create mode 120000 templates/account/email_confirm.html
create mode 120000 templates/account/login.html
create mode 120000 templates/account/logout.html
create mode 120000 templates/account/password_change.html
create mode 120000 templates/account/password_reset.html
create mode 120000 templates/account/password_reset_done.html
create mode 120000 templates/account/password_reset_from_key.html
create mode 120000 templates/account/password_reset_from_key_done.html
create mode 120000 templates/account/password_set.html
create mode 120000 templates/account/signup.html
create mode 120000 templates/account/signup_closed.html
create mode 120000 templates/account/verification_sent.html
create mode 120000 templates/account/verified_email_required.html
diff --git a/.gitignore b/.gitignore
index 4319204..7a51187 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,3 +27,4 @@ db.sqlite3
# System
.DS_Store
pxy_city_digital_twins/__backup__/
+Dockerfile.dev
diff --git a/docker-compose.override.yml b/docker-compose.override.yml
new file mode 100644
index 0000000..bacf022
--- /dev/null
+++ b/docker-compose.override.yml
@@ -0,0 +1,15 @@
+version: "3.8"
+
+services:
+ web:
+ build:
+ context: .
+ dockerfile: Dockerfile.dev
+ command: >
+ sh -c "python manage.py migrate &&
+ python manage.py runserver 0.0.0.0:8000"
+ ports:
+ - "8011:8000"
+ volumes:
+ - .:/app
+ - ./staticfiles:/app/staticfiles
diff --git a/polisplexity/settings.py b/polisplexity/settings.py
index 6505f1d..3ac8643 100644
--- a/polisplexity/settings.py
+++ b/polisplexity/settings.py
@@ -19,14 +19,22 @@ ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "").split(",")
# Application definition
INSTALLED_APPS = [
+ # Django built-in apps
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
+ "django.contrib.sites", # Required for allauth
- # App modules
+ # Allauth
+ "allauth",
+ "allauth.account",
+ "allauth.socialaccount",
+ "allauth.socialaccount.providers.github", # GitHub login only
+
+ # Your custom apps
"core",
"pxy_de",
"pxy_cr",
@@ -42,14 +50,34 @@ INSTALLED_APPS = [
"pxy_dashboard.apps",
"pxy_dashboard.components",
"pxy_dashboard.layouts",
+
+ # Third-party apps
+ "crispy_forms",
+ "crispy_bootstrap5",
+
]
+CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
+CRISPY_TEMPLATE_PACK = "bootstrap5"
+
+SITE_ID = 1
+
+AUTHENTICATION_BACKENDS = [
+ "django.contrib.auth.backends.ModelBackend", # default
+ "allauth.account.auth_backends.AuthenticationBackend", # allauth support
+]
+
+LOGIN_REDIRECT_URL = "/"
+ACCOUNT_LOGOUT_REDIRECT_URL = "/accounts/login/"
+
+
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
+ "allauth.account.middleware.AccountMiddleware", # ← Add this line
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
@@ -59,7 +87,10 @@ ROOT_URLCONF = "polisplexity.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
- "DIRS": [os.path.join(BASE_DIR, "templates")],
+ "DIRS": [
+ os.path.join(BASE_DIR, "templates"),
+ os.path.join(BASE_DIR, "pxy_dashboard", "templates"),
+ ],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
@@ -73,6 +104,8 @@ TEMPLATES = [
},
]
+
+
WSGI_APPLICATION = "polisplexity.wsgi.application"
# Database
@@ -132,3 +165,12 @@ CSRF_TRUSTED_ORIGINS = [
# Support for secure reverse proxy (e.g., Nginx or Hostinger HTTPS proxy)
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
+
+
+EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
+EMAIL_HOST = "smtp.hostinger.com"
+EMAIL_PORT = 465
+EMAIL_USE_SSL = True
+EMAIL_HOST_USER = "noreply@polisplexity.tech" # Cambia esto por tu correo real
+EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD") # Mejor usar .env
+DEFAULT_FROM_EMAIL = "Polisplexity "
diff --git a/polisplexity/urls.py b/polisplexity/urls.py
index 12eb325..db11adf 100644
--- a/polisplexity/urls.py
+++ b/polisplexity/urls.py
@@ -25,14 +25,15 @@ admin.site.index_title = "Welcome to Polisplexity City Technologies Portal"
urlpatterns = [
path("admin/", admin.site.urls),
+ path("accounts/", include("allauth.urls")), # ← Add this line
path('', include('pxy_dashboard.urls')),
path('core', include('core.urls')),
path('', include('pxy_city_digital_twins.urls')),
path('pxy_whatsapp/', include('pxy_whatsapp.urls')),
- path('bots/', include('pxy_bots.urls')), # Webhook URL: /bots/webhook//
+ path('bots/', include('pxy_bots.urls')),
path('pxy_meta_pages/', include('pxy_meta_pages.urls', namespace='pxy_meta_pages')),
-
]
+
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
\ No newline at end of file
diff --git a/pxy_dashboard/templates/account/login.html b/pxy_dashboard/templates/account/login.html
new file mode 120000
index 0000000..9482607
--- /dev/null
+++ b/pxy_dashboard/templates/account/login.html
@@ -0,0 +1 @@
+../pxy_dashboard/account/login.html
\ No newline at end of file
diff --git a/pxy_dashboard/templates/pxy_dashboard/account/account_inactive.html b/pxy_dashboard/templates/pxy_dashboard/account/account_inactive.html
index ca70623..a1f374f 100644
--- a/pxy_dashboard/templates/pxy_dashboard/account/account_inactive.html
+++ b/pxy_dashboard/templates/pxy_dashboard/account/account_inactive.html
@@ -1,4 +1,4 @@
-{% extends "account/base.html" %}
+{% extends "pxy_dashboard/account/base.html" %}
{% load i18n %}
diff --git a/pxy_dashboard/templates/pxy_dashboard/account/email.html b/pxy_dashboard/templates/pxy_dashboard/account/email.html
index 781b1cb..6dbabff 100644
--- a/pxy_dashboard/templates/pxy_dashboard/account/email.html
+++ b/pxy_dashboard/templates/pxy_dashboard/account/email.html
@@ -1,4 +1,4 @@
-{% extends "account/base.html" %}
+{% extends "pxy_dashboard/account/base.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
diff --git a/pxy_dashboard/templates/pxy_dashboard/account/email_confirm.html b/pxy_dashboard/templates/pxy_dashboard/account/email_confirm.html
index fcdb2cf..7f668b8 100644
--- a/pxy_dashboard/templates/pxy_dashboard/account/email_confirm.html
+++ b/pxy_dashboard/templates/pxy_dashboard/account/email_confirm.html
@@ -1,4 +1,4 @@
-{% extends "account/base.html" %}
+{% extends "pxy_dashboard/account/base.html" %}
{% load i18n %}
{% load account %}
diff --git a/pxy_dashboard/templates/pxy_dashboard/account/login.html b/pxy_dashboard/templates/pxy_dashboard/account/login.html
index 9a8373b..cbf417e 100644
--- a/pxy_dashboard/templates/pxy_dashboard/account/login.html
+++ b/pxy_dashboard/templates/pxy_dashboard/account/login.html
@@ -1,5 +1,6 @@
-{% extends "account/base.html" %}
-{% load static crispy_forms_tags %}
+{% extends "pxy_dashboard/account/base.html" %}
+{% load static crispy_forms_tags socialaccount %}
+
{% block title %}Log In{% endblock title %}
@@ -36,6 +37,16 @@
+{% load socialaccount %}
+
+{% if True %}
+
+{% endif %}
+