Skip to content

Commit

Permalink
bugs: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wendellast committed Jun 15, 2024
1 parent d6d1c12 commit 23a2dea
Show file tree
Hide file tree
Showing 18 changed files with 133 additions and 131 deletions.
30 changes: 15 additions & 15 deletions .env-example
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
DEBUGGG = "True"
DEBUGDB='True'

CLIENT_ID="Seu client-id"
SECRET="Sua secred-id"


EMAIL_HOST = 'Seu host'
EMAIL_POST = 'Seu post'
EMAIL_USE_TLS = True
EMAIL_HOST_USER = "seu email"
EMAIL_HOST_PASSWORD ='seu password app'

# Database settings
# Sqlite
Expand All @@ -8,17 +17,8 @@ DATABASE_NAME = "./db.sqlite3"

# Postgres
# DATABASE_ENGINE='django.db.backends.postgresql'
# DATABASE_NAME="railway"
DATABASE_USER = "Sue userdb"
DATABASE_PASSWORD = "senha do db"
DATABASE_HOST = "host-db"
DATABASE_PORT = "pordb"


client_id="seu client id"
secret="Sua secrect key"
EMAIL_HOST = 'seu provedor'
EMAIL_POST = "sua porta"
EMAIL_USE_TLS = True
EMAIL_HOST_USER ='seu email'
EMAIL_HOST_PASSWORD ='sua senha app'
# DATABASE_NAME="seu name database"
DATABASE_USER = "seu database use"
DATABASE_PASSWORD = "seu database passowrd"
DATABASE_HOST = "seu database host"
DATABASE_PORT = "seu database port"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ trash
*.sqlite3
media/
db.sqlite3
media
15 changes: 2 additions & 13 deletions bookguardian/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# Generated by Django 5.0.3 on 2024-05-14 20:38
# Generated by Django 5.0.6 on 2024-06-15 01:30

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
dependencies = []

operations = [
migrations.CreateModel(
Expand Down Expand Up @@ -61,13 +57,6 @@ class Migration(migrations.Migration):
),
("read", models.BooleanField(default=False)),
("created_at", models.DateField(auto_now_add=True)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
]

This file was deleted.

25 changes: 25 additions & 0 deletions bookguardian/migrations/0002_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.0.6 on 2024-06-15 01:30

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
("bookguardian", "0001_initial"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.AddField(
model_name="bookguardian",
name="user",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
]
32 changes: 0 additions & 32 deletions bookguardian/migrations/0003_alter_bookguardian_category.py

This file was deleted.

Binary file modified bookguardian/migrations/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
5 changes: 1 addition & 4 deletions bookguardian/templates/configPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ <h3 style="margin-top: 8rem;">Cor</h3>
</div>
<div class="configConainerRow" id="configNavBtn">
<button id="saveConfig">
Salvar
</button>
<button id="cancelConfig">
Cancelar
Voltar
</button>
</div>
{% endblock content %}
4 changes: 2 additions & 2 deletions bookguardian/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class HomeList(LoginRequiredMixin, ListView):
model = models.BookGuardian
template_name = "index.html"
context_object_name = "bookguardian"
login_url = '/login/' # Define a URL para redirecionar se o usuário não estiver logado
login_url = '/login/'

def get_queryset(self):
user = self.request.user
if user.is_authenticated:
queryset = models.BookGuardian.objects.filter(user=user)
else:
# Redireciona o usuário para outra página se não estiver autenticado

return reverse_lazy("bookguardian:ladinpage")
return queryset

Expand Down
Binary file modified db.sqlite3
Binary file not shown.
67 changes: 46 additions & 21 deletions setup/settings.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import os
from pathlib import Path
import dotenv
# Build paths inside the project like this: BASE_DIR / 'subdir'.

BASE_DIR = Path(__file__).resolve().parent.parent
dotenv.load_dotenv(dotenv.find_dotenv())

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-nxjvm_=1vo=io18_+vz1ott6uu2qm(=6f#!#aemnwtwwppt*@e"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False if os.getenv("DEBUGGG") == "False" else True
DEBUG = False if os.environ.get("DEBUGDB") == "False" else True

ALLOWED_HOSTS = ['web-production-2e20.up.railway.app', '127.0.0.1']

Expand All @@ -22,8 +20,7 @@
# Application definition

INSTALLED_APPS = [
# "unfold", #Theme1
"jazzmin", # Theme2
"jazzmin", # Theme
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
Expand All @@ -33,7 +30,8 @@
# My apps
"bookguardian",
"userauths",
"allauth",
#allauth
"allauth",
"allauth.account",
"allauth.socialaccount",
"allauth.socialaccount.providers.google",
Expand All @@ -59,15 +57,21 @@
SOCIALACCOUNT_PROVIDERS = {
"google": {
"APP": {
"client_id": os.getenv("client_id"),
"secret": os.getenv("secret"),
"client_id": os.environ.get("CLIENT_ID"),
"secret": os.environ.get("SECRET"),
"key": "",
}
}
},
"SCOPE": [
"profile",
"email",
],
"AUTH_PARAMS": {
"access_type": "online",
},
"OAUTH_PKCE_ENABLED": True,
},
}
LOGIN_URL = "userauths:sign-in"
LOGIN_REDIRECT_URL = "bookguardian:index"
LOGOUT_REDIRECT_URL = "bookguardian:index"


ROOT_URLCONF = "setup.urls"

Expand Down Expand Up @@ -97,8 +101,12 @@

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
"ENGINE": os.environ.get("DATABASE_ENGINE"),
"NAME": os.environ.get("DATABASE_NAME"),
"USER": os.environ.get("DATABASE_USER"),
"PASSWORD": os.environ.get("DATABASE_PASSWORD"),
"HOST": os.environ.get("DATABASE_HOST"),
"PORT": os.environ.get("DATABASE_PORT"),
}
}

Expand All @@ -119,8 +127,20 @@
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]

AUTH_USER_MODEL = "userauths.User"

SOCIALACCOUNT_PIPELINE = (
"allauth.socialaccount.pipeline.social_login",
"userauths.pipeline.link_to_existing_user",
"allauth.socialaccount.pipeline.social_user",
"allauth.socialaccount.pipeline.associate_user",
"allauth.socialaccount.pipeline.load_extra_data",
"allauth.socialaccount.pipeline.user.create_user",
"allauth.socialaccount.pipeline.save_social_token",
"allauth.socialaccount.pipeline.social_account",
"allauth.socialaccount.pipeline.sync_user_profile",
)
# Internationalization
# https://docs.djangoproject.com/en/5.0/topics/i18n/

Expand All @@ -132,6 +152,11 @@

USE_TZ = True

LOGIN_URL = "userauths:sign-in"
LOGIN_REDIRECT_URL = "/index"
LOGOUT_REDIRECT_URL = "/"

SITE_ID = 1

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/
Expand All @@ -154,8 +179,8 @@
# EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
# else:
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = os.getenv("EMAIL_HOST")
EMAIL_POST = os.getenv("EMAIL_POST")
EMAIL_USE_TLS = os.getenv("EMAIL_USE_TLS")
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
EMAIL_HOST = os.environ.get("EMAIL_HOST")
EMAIL_POST = os.environ.get("EMAIL_POST")
EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS")
EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD")
11 changes: 10 additions & 1 deletion setup/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.urls import include, path
from allauth.socialaccount.providers.google.urls import (
urlpatterns as google_urlpatterns,
)


social_urlpatterns = [
path("", include(google_urlpatterns)),
]


urlpatterns = [
path("admin/", admin.site.urls),
path("", include("bookguardian.urls")),
path("user/", include("userauths.urls")),
path('accounts/', include('allauth.urls')),
path("accounts/", include(social_urlpatterns)),
path(
"password_reset/", auth_views.PasswordResetView.as_view(), name="password_reset"
),
Expand Down
3 changes: 3 additions & 0 deletions userauths/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ class UserRegisterForm(UserCreationForm):
class Meta:
model = User
fields = ["username", "email", "password1", "password2"]

def clean_username(self):
return self.cleaned_data["username"].lower()
2 changes: 1 addition & 1 deletion userauths/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.0.3 on 2024-05-14 20:30
# Generated by Django 5.0.6 on 2024-06-15 01:30

import django.contrib.auth.models
import django.utils.timezone
Expand Down
2 changes: 1 addition & 1 deletion userauths/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class User(AbstractUser):
username = models.CharField(max_length=100)
username = models.CharField(max_length=100, unique=False)
email = models.EmailField(unique=True)
is_staff = models.BooleanField(default=False)
is_superuser = models.BooleanField(default=False)
Expand Down
Loading

0 comments on commit 23a2dea

Please sign in to comment.