diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e99e36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc \ No newline at end of file diff --git a/.streamlit/config.toml b/.streamlit/config.toml deleted file mode 100644 index eb5c79d..0000000 --- a/.streamlit/config.toml +++ /dev/null @@ -1,2 +0,0 @@ -[server] -port = 8501 \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 6e9d812..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "python.analysis.extraPaths": [ - "./config", - "./components" - ] -} \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index ce455a4..0000000 Binary files a/README.md and /dev/null differ diff --git a/components/__init__.py b/accounts/__init__.py similarity index 100% rename from components/__init__.py rename to accounts/__init__.py diff --git a/accounts/admin.py b/accounts/admin.py new file mode 100644 index 0000000..7347b1e --- /dev/null +++ b/accounts/admin.py @@ -0,0 +1,9 @@ +from django.contrib import admin +from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin +from django.utils.translation import gettext_lazy as _ + +from .models import UserInfo + + +# Register your models here. +admin.site.register(UserInfo) diff --git a/accounts/apps.py b/accounts/apps.py new file mode 100644 index 0000000..3e3c765 --- /dev/null +++ b/accounts/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AccountsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'accounts' diff --git a/accounts/forms.py b/accounts/forms.py new file mode 100644 index 0000000..a798b45 --- /dev/null +++ b/accounts/forms.py @@ -0,0 +1,94 @@ +from django import forms +from django.forms import EmailInput +from django.contrib.auth.forms import AuthenticationForm, UsernameField, UserCreationForm +from django.contrib.auth import password_validation +from django.contrib.auth.models import User, Group +import datetime +from django.utils.translation import gettext_lazy as _ + +class LoginForm(AuthenticationForm): + username = UsernameField( + label="", + widget=forms.TextInput(attrs={ + "autofocus": True, + "placeholder": "Nome de usuário"})) + password = forms.CharField( + label="", + strip=False, + widget=forms.PasswordInput(attrs={ + "autocomplete": "Senha atual", + "placeholder": "Palavra-chave"}), + ) + +class CreateUserForm(UserCreationForm): + password1 = forms.CharField( + label="", + strip=False, + widget=forms.PasswordInput(attrs={ + "autocomplete": "Palavra-chave", + "placeholder": "Palavra-chave" + }), + help_text=password_validation.password_validators_help_text_html(), + ) + password2 = forms.CharField( + label="", + widget=forms.PasswordInput(attrs={ + "autocomplete": "new-password", + "placeholder": "Confirmar palavra-chave" + }), + strip=False, + help_text=_("Enter the same password as before, for verification."), + ) + + email = forms.EmailField( + required=True, + widget=EmailInput(attrs={'placeholder': "Endereço de email"}), + label="") + + gender_choices = [ + ('F', 'Feminino'), + ('M', 'Masculino'), + ('O', 'Outro'), + ] + gender = forms.ChoiceField(choices=gender_choices, widget=forms.RadioSelect()) + name = forms.CharField( + max_length=100, + label="Nome completo", + widget=forms.TextInput(attrs={"placeholder": "Digite seu nome",}) + ) + + crr_year = datetime.date.today().year + years = list(range(crr_year, crr_year-100, -1)) + birthday = forms.DateField(widget=forms.SelectDateWidget(years=years), label="Aniversário") + + size_choices = [ + ('P', 'Pequeno'), + ('M', 'Médio'), + ('G', 'Grande'), + ] + size = forms.ChoiceField(choices=size_choices, widget=forms.RadioSelect()) + + + style_choices = [ + ('BA', 'Básico'), + ('MO', 'Moderninho'), + ('EL', 'Elegante'), + ] + style = forms.ChoiceField(choices=style_choices, widget=forms.RadioSelect()) + + interests_choices = [ + ('roupas', 'Roupas'), + ('fitness', 'Fitness'), + ('beleza', 'Beleza'), + ('eletronicos', 'Eletrônicos'), + ('outros', 'Outros') + ] + interests = forms.MultipleChoiceField(choices=interests_choices, widget=forms.CheckboxSelectMultiple()) + class Meta: + model = User + fields = ("username","email") + field_classes = {"username": UsernameField} + widgets = { + "username": forms.TextInput(attrs={"placeholder": "Nome de usuário",}), + } + labels = {"username": "",} diff --git a/accounts/migrations/0001_initial.py b/accounts/migrations/0001_initial.py new file mode 100644 index 0000000..cdfae8b --- /dev/null +++ b/accounts/migrations/0001_initial.py @@ -0,0 +1,37 @@ +# Generated by Django 5.0.6 on 2024-06-18 22:58 + +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), + ] + + operations = [ + migrations.CreateModel( + name='UserInfo', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('birthday', models.DateField()), + ('genero', models.CharField(max_length=8)), + ('created_date', models.DateTimeField(auto_now_add=True)), + ('gender', models.CharField(choices=[('F', 'Feminino'), ('M', 'Masculino'), ('O', 'Outro')], max_length=1)), + ('size', models.CharField(choices=[('P', 'Pequeno'), ('M', 'Médio'), ('G', 'Grande')], max_length=1)), + ('style', models.CharField(choices=[('P', 'Pequeno'), ('M', 'Médio'), ('G', 'Grande')], max_length=2)), + ('roupas', models.IntegerField()), + ('fitness', models.IntegerField()), + ('beleza', models.IntegerField()), + ('eletronicos', models.IntegerField()), + ('outros', models.IntegerField()), + ('friends', models.ManyToManyField(blank=True, to='accounts.userinfo')), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='user_info', to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/accounts/migrations/0002_remove_userinfo_genero.py b/accounts/migrations/0002_remove_userinfo_genero.py new file mode 100644 index 0000000..922539f --- /dev/null +++ b/accounts/migrations/0002_remove_userinfo_genero.py @@ -0,0 +1,17 @@ +# Generated by Django 5.0.6 on 2024-06-19 02:07 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='userinfo', + name='genero', + ), + ] diff --git a/accounts/migrations/0003_alter_userinfo_style.py b/accounts/migrations/0003_alter_userinfo_style.py new file mode 100644 index 0000000..7a93f4a --- /dev/null +++ b/accounts/migrations/0003_alter_userinfo_style.py @@ -0,0 +1,21 @@ +# Generated by Django 5.0.6 on 2024-06-20 23:36 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("accounts", "0002_remove_userinfo_genero"), + ] + + operations = [ + migrations.AlterField( + model_name="userinfo", + name="style", + field=models.CharField( + choices=[("BA", "Básico"), ("MO", "Moderninho"), ("EL", "Elegante")], + max_length=2, + ), + ), + ] diff --git a/accounts/migrations/0004_userinfo_likes.py b/accounts/migrations/0004_userinfo_likes.py new file mode 100644 index 0000000..6d82459 --- /dev/null +++ b/accounts/migrations/0004_userinfo_likes.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.6 on 2024-06-22 20:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("accounts", "0003_alter_userinfo_style"), + ("gifts", "0006_remove_gift_likes"), + ] + + operations = [ + migrations.AddField( + model_name="userinfo", + name="likes", + field=models.ManyToManyField(blank=True, to="gifts.gift"), + ), + ] diff --git a/config/__init__.py b/accounts/migrations/__init__.py similarity index 100% rename from config/__init__.py rename to accounts/migrations/__init__.py diff --git a/accounts/models.py b/accounts/models.py new file mode 100644 index 0000000..d5b121b --- /dev/null +++ b/accounts/models.py @@ -0,0 +1,56 @@ +from django.db import models + +# Create your models here. +from django.db import models +from django.utils.translation import gettext_lazy as _ +from django.contrib.auth.models import User +from gifts.models import Gift + +class UserInfo(models.Model): + + user = models.OneToOneField( + User, on_delete=models.CASCADE, related_name="user_info") + name = models.CharField(max_length=100) + birthday = models.DateField() + created_date = models.DateTimeField(auto_now_add=True) + + gender_choices = [ + ('F', 'Feminino'), + ('M', 'Masculino'), + ('O', 'Outro'), + ] + gender = models.CharField( + max_length=1, + choices=gender_choices + ) + + size_choices = [ + ('P', 'Pequeno'), + ('M', 'Médio'), + ('G', 'Grande'), + ] + size = models.CharField( + max_length=1, + choices=size_choices + ) + + style_choices = [ + ('BA', 'Básico'), + ('MO', 'Moderninho'), + ('EL', 'Elegante'), + ] + style = models.CharField( + max_length=2, + choices=style_choices + ) + roupas = models.IntegerField() + fitness = models.IntegerField() + beleza = models.IntegerField() + eletronicos = models.IntegerField() + outros = models.IntegerField() + + friends = models.ManyToManyField("UserInfo", blank = True) + + likes = models.ManyToManyField(Gift, blank=True) + def __str__(self): + return self.user.username + str(' info') diff --git a/accounts/templates/accounts/create.html b/accounts/templates/accounts/create.html new file mode 100644 index 0000000..d8cdb1a --- /dev/null +++ b/accounts/templates/accounts/create.html @@ -0,0 +1,130 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %} +Home +{% endblock title %} + +{% block content %} +
+ +
+ +
+
+ {% csrf_token %} + {{ form.non_field_errors }} +
+

Seus dados básicos:

+
+ {{ form.username.errors }} + + {{ form.username }} +
+
+ {{ form.email.errors }} + + {{ form.email }} +
+
+ {{ form.password1.errors }} + + {{ form.password1 }} +
+
+ {{ form.password2.errors }} + + {{ form.password2 }} +
+ + +
+ +
+
+ {{ form.name.errors }} + + {{ form.name }} +
+
+ {{ form.bithday.errors }} + + {{ form.birthday }} +
+
+ {{ form.gender.errors }} + + {{ form.gender }} +
+ + +
+ +
+
+ {{ form.size.errors }} + + {{ form.size }} +
+ +
+ +
+
+ + + {{ form.interests }} + +
+ +
+ + +
+
+ {{ form.style.errors }} + + {{ form.style }} +
+ +
+ +
+ +

Seu cadastro foi feito com + sucesso!

+ +
+ Anterior + +
+
+ + +
+
+{% endblock content %} \ No newline at end of file diff --git a/accounts/templates/accounts/login.html b/accounts/templates/accounts/login.html new file mode 100644 index 0000000..9dcafa7 --- /dev/null +++ b/accounts/templates/accounts/login.html @@ -0,0 +1,31 @@ +{% extends 'base.html' %} +{% load static %} +{% block title %} Home +{% endblock title %} +{% block content %} +
+ +
+
+
+

Entre na sua conta:

+
+ {% csrf_token %} {{ form.as_div }} +
+

Ainda não tem uma conta? + + Cadastre-se + +
+ +

+
+
+
+ +

+
+
+{% endblock content %} diff --git a/utils/__init__.py b/accounts/templates/accounts/logout.html similarity index 100% rename from utils/__init__.py rename to accounts/templates/accounts/logout.html diff --git a/accounts/templates/change_pass/password_change_done.html b/accounts/templates/change_pass/password_change_done.html new file mode 100644 index 0000000..9d38f2b --- /dev/null +++ b/accounts/templates/change_pass/password_change_done.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %} +Home +{% endblock title %} + +{% block content %} +
+ + +

Sua senha foi alterada com sucesso

+
+ +{% endblock content %} diff --git a/accounts/templates/change_pass/password_change_form.html b/accounts/templates/change_pass/password_change_form.html new file mode 100644 index 0000000..53e561f --- /dev/null +++ b/accounts/templates/change_pass/password_change_form.html @@ -0,0 +1,26 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %} +Home +{% endblock title %} + +{% block content %} +
+
+ +
+
+ +

Deseja alterar sua senha?

+

Digite seu email e te enviaremos uma chave de redefinição.

+
+
+ {% csrf_token %} + {{ form.as_p }} +
+ +
+
+{% endblock content %} + diff --git a/accounts/templates/reset_pass/password_reset_complete.html b/accounts/templates/reset_pass/password_reset_complete.html new file mode 100644 index 0000000..8072da7 --- /dev/null +++ b/accounts/templates/reset_pass/password_reset_complete.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %} +Home +{% endblock title %} + +{% block content %} +
+ + +

Sua senha foi alterada com sucesso

+
+ +{% endblock content %} diff --git a/accounts/templates/reset_pass/password_reset_confirm.html b/accounts/templates/reset_pass/password_reset_confirm.html new file mode 100644 index 0000000..b4ccf22 --- /dev/null +++ b/accounts/templates/reset_pass/password_reset_confirm.html @@ -0,0 +1,27 @@ +{% extends 'base.html' %} +{% load static %} +{% block title %} Home +{% endblock title %} +{% block content %} +
+ +
+
+
+

Entre na sua conta:

+
+ {% csrf_token %} {{ form.as_div }} +
+ + Esqueci a senha + +
+ +
+
+
+
+{% endblock content %} diff --git a/accounts/templates/reset_pass/password_reset_done.html b/accounts/templates/reset_pass/password_reset_done.html new file mode 100644 index 0000000..9d38f2b --- /dev/null +++ b/accounts/templates/reset_pass/password_reset_done.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %} +Home +{% endblock title %} + +{% block content %} +
+ + +

Sua senha foi alterada com sucesso

+
+ +{% endblock content %} diff --git a/accounts/templates/reset_pass/password_reset_email.html b/accounts/templates/reset_pass/password_reset_email.html new file mode 100644 index 0000000..7c81876 --- /dev/null +++ b/accounts/templates/reset_pass/password_reset_email.html @@ -0,0 +1,3 @@ +Alguem solicitou uma mudança de senha para o email {{ email }}. Caso você que tenha solicitado, +siga o link abaixo para continuar a recuperação da senha +{{ protocol}}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} \ No newline at end of file diff --git a/accounts/templates/reset_pass/password_reset_form.html b/accounts/templates/reset_pass/password_reset_form.html new file mode 100644 index 0000000..6db8dcf --- /dev/null +++ b/accounts/templates/reset_pass/password_reset_form.html @@ -0,0 +1,26 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %} +Home +{% endblock title %} + +{% block content %} +
+
+ +
+
+ +

Esqueceu sua senha?

+

Digite seu email e te enviaremos uma chave de redefinição.

+
+
+ {% csrf_token %} + {{ form.as_p }} +
+ +
+
+{% endblock content %} + diff --git a/accounts/tests.py b/accounts/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/accounts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/accounts/urls.py b/accounts/urls.py new file mode 100644 index 0000000..3f389d4 --- /dev/null +++ b/accounts/urls.py @@ -0,0 +1,65 @@ +from django.urls import include, path +from django.contrib.auth import views as auth_views +from .views import UserCreateView +from .forms import LoginForm +from . import views + +urlpatterns = [ + # accounts templates + path( + 'login/', + auth_views.LoginView.as_view(template_name="accounts/login.html", + form_class=LoginForm), + name='login' + ), + path( + 'logout/', + auth_views.LogoutView.as_view(template_name="accounts/logout.html"), + name='logout' + ), + path( + 'new_account/', + UserCreateView.as_view(), + name='create_account' + ), + + # change_pass templates + path( + 'accounts/change_password/', + auth_views.PasswordChangeView.as_view( + template_name='change_pass/password_change_form.html'), + name='password_change' + ), + path( + 'accounts/password_changed/', + auth_views.PasswordChangeDoneView.as_view( + template_name='change_pass/password_change_done.html'), + name='password_change_done' + ), + + # reset_pass templates + path( + 'accounts/forget_password/', + auth_views.PasswordResetView.as_view( + template_name='reset_pass/password_reset_form.html'), + name='password_reset' + ), + path( + 'accounts/forget_password/email_sent', + auth_views.PasswordResetDoneView.as_view( + template_name='reset_pass/password_reset_done.html'), + name='password_reset_done' + ), + path( + 'accounts/confirm_password//', + auth_views.PasswordResetConfirmView.as_view( + template_name='reset_pass/password_reset_confirm.html'), + name='password_reset_confirm' + ), + path( + 'accounts/new_password/', + auth_views.PasswordResetView.as_view( + template_name='reset_pass/password_reset_complete.html'), + name='password_reset_complete' + ), +] diff --git a/accounts/views.py b/accounts/views.py new file mode 100644 index 0000000..8c83cef --- /dev/null +++ b/accounts/views.py @@ -0,0 +1,53 @@ +from django.shortcuts import render +from django.urls import reverse +from django.shortcuts import get_object_or_404, HttpResponseRedirect +from django.views.generic import CreateView +from django.contrib.auth.models import User, Group +from .models import UserInfo +from .forms import CreateUserForm + + +class UserCreateView(CreateView): + model = User + form_class = CreateUserForm + success_url = "/login" + template_name = "accounts/create.html" + + def form_valid(self, form): + new_user = form.save(commit=False) + new_user.email = form.cleaned_data["email"] + new_user.save() + form.save_m2m() + + interests = form.cleaned_data["interests"] + + points_dict = { + "roupas": 0, + "fitness": 0, + "beleza": 0, + "eletronicos": 0, + "outros": 0, + } + + for value in interests: + points_dict[value] = 100 + + user_info = UserInfo( + user=new_user, + name=form.cleaned_data["name"], + gender=form.cleaned_data["gender"], + birthday=form.cleaned_data["birthday"], + + size=form.cleaned_data["size"], + style=form.cleaned_data["style"], + roupas=points_dict["roupas"], + fitness=points_dict["fitness"], + beleza=points_dict["beleza"], + eletronicos=points_dict["eletronicos"], + outros=points_dict["outros"] + ) + + user_info.save() + + + return HttpResponseRedirect(reverse("login")) diff --git a/app.py b/app.py deleted file mode 100644 index f6869a2..0000000 --- a/app.py +++ /dev/null @@ -1,167 +0,0 @@ -import streamlit as st -import firebase_admin -from firebase_admin import credentials, auth -import pyrebase -from firebase_admin import firestore -import requests -import uuid -from google.oauth2 import id_token -from google.auth.transport import requests as google_requests -from utils.cookie_manager import CookieManager -from components.onboarding import needs_onboarding, show_onboarding -from config.general_config import firebaseConfig, get_auth_client, get_db, get_firebase, get_auth - -st.set_page_config(page_title="Gift App", page_icon="🎁") -cookie_manager = CookieManager() - -auth = get_auth() -db = get_db() -auth_client = get_auth_client() -firebase = get_firebase() - -def login_page(): - st.title("Login") - choice = st.selectbox("Login or Sign Up", ["Login", "Sign Up"]) - - email = st.text_input("Email") - password = st.text_input("Password", type="password") - - if choice == "Login": - if st.button("Login"): - try: - user = auth_client.sign_in_with_email_and_password(email, password) - st.success("Login successful.") - print(user) - user_token = user.get('idToken') - - cookie_manager.store_in_cookies('token', user_token) - cookie_manager.store_in_cookies('user_id', user.get('localId')) - cookie_manager.save() - - # st.session_state['user_id'] = user.get('localId') - - - st.experimental_rerun() - except Exception as e: - st.error(f"Login failed: {e}") - else: - if st.button("Sign Up"): - try: - user = auth_client.create_user_with_email_and_password(email, password) - st.success("Account created successfully.") - except Exception as e: - st.error(f"Sign Up failed: {e}") - - st.markdown("### Or login with Google") - if st.button("Login with Google"): - login_url = generate_google_login_url() - st.markdown(f"[Click here to login with Google]({login_url})") - -def generate_google_login_url(): - google_auth_endpoint = "https://accounts.google.com/o/oauth2/v2/auth" - redirect_uri = "http://localhost:8501" - client_id = "505194637297-dk7fl2c4m53sv1c663ha1ljhffo84rns.apps.googleusercontent.com" - - auth_url = f"{google_auth_endpoint}?response_type=code&client_id={client_id}&redirect_uri={redirect_uri}&scope=email%20profile&access_type=offline" - return auth_url - -def generate_uid(): - #generate valid uuid - return uuid.uuid4() - - - -def handle_google_auth_response(): - query_params = st.query_params - if "code" in query_params: - code = query_params["code"][0] - token_url = "https://oauth2.googleapis.com/token" - redirect_uri = "http://localhost:8501" - client_id = "505194637297-dk7fl2c4m53sv1c663ha1ljhffo84rns.apps.googleusercontent.com" - client_secret = "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" - - token_data = { - "code": code, - "client_id": client_id, - "client_secret": client_secret, - "redirect_uri": redirect_uri, - "grant_type": "authorization_code" - } - - token_response = requests.post(token_url, data=token_data) - token_info = token_response.json() - - if "id_token" in token_info: - id_token_value = token_info["id_token"] - try: - # Verify the Google ID token - request = google_requests.Request() - id_info = id_token.verify_oauth2_token(id_token_value, request, client_id) - - # Create a custom token for the user - custom_token = firebase_admin.auth.create_custom_token(id_info['sub']) - - # Sign in with the custom token - user = auth_client.sign_in_with_custom_token(custom_token.decode('utf-8')) - user_info = auth_client.get_account_info(user['idToken']) - user_id = user_info.get('users')[0].get('localId') - st.session_state['user_id'] = user_info.get('users')[0].get('localId') - cookie_manager.store_in_cookies('user_id', user_info.get('users')[0].get('localId')) - - - if cookie_manager.get_from_cookies('user_id') == user_info.get('users')[0].get('localId'): - if cookie_manager.get_from_cookies('token') == user['idToken']: - pass - else: - cookie_manager.store_in_cookies('token', user['idToken']) - else: - cookie_manager.store_in_cookies('user_id', user_id) - - cookie_manager.save() - - # Store the user email in session state - st.experimental_rerun() - except Exception as e: - st.error(f"Authentication failed: {e}") - else: - st.error("Failed to obtain token.") -# Main Page -def main_page(): - user_id = cookie_manager.get_from_cookies('user_id') - token = cookie_manager.get_from_cookies('token') - - if token: - try: - user = auth.verify_id_token(token) - st.title("Main Page") - if needs_onboarding(user_id): - show_onboarding(user_id) - else: - st.write("Welcome back! You have already completed the onboarding.") - except auth.InvalidIdTokenError: - st.error("Invalid or expired token. Please log in again.") - cookie_manager.delete_from_cookies('token') - cookie_manager.delete_from_cookies('user_id') - cookie_manager.save() - - - - if st.button("Logout"): - cookie_manager.delete_from_cookies('token') - cookie_manager.delete_from_cookies('user_id') - cookie_manager.save() - st.experimental_rerun() - else: - login_page() - handle_google_auth_response() - -# App -def main(): - - - # if 'user' not in st.session_state: - # st.session_state['user'] = None - main_page() - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/components/__pycache__/__init__.cpython-310.pyc b/components/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 5d0e3b6..0000000 Binary files a/components/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/components/__pycache__/onboarding.cpython-310.pyc b/components/__pycache__/onboarding.cpython-310.pyc deleted file mode 100644 index de3ab31..0000000 Binary files a/components/__pycache__/onboarding.cpython-310.pyc and /dev/null differ diff --git a/components/onboarding.py b/components/onboarding.py deleted file mode 100644 index bddba46..0000000 --- a/components/onboarding.py +++ /dev/null @@ -1,64 +0,0 @@ -from config.general_config import firebaseConfig, get_auth_client, get_db, get_firebase -import streamlit as st -auth = get_auth_client() -db = get_db() -auth_client = get_auth_client() -firebase = get_firebase() -# Function to check if a user is new -def is_new_user(user_id): - user_ref = db.collection('users').document(user_id) - user_doc = user_ref.get() - return not user_doc.exists - -def needs_onboarding(user_id): - user_ref = db.collection('users').document(user_id) - user_doc = user_ref.get() - if user_doc.exists: - user_data = user_doc.to_dict() - return not user_data.get('onboarded', False) - return True - -def show_onboarding(user_id): - onboarding_steps = [ - ("Antes de começarmos, queremos te conhecer melhor. Vamos começar?", None), - ("Qual o tamanho de roupa você usa?", ["PP", "P", "M", "G", "GG", "XG"]), - ("Qual o seu estilo?", ["casual", "streetware", "formal"]), - ("Quais seus principais interesses?", ["roupas", "skin care", "Eletronicos"]), - ("Quais tecidos você prefere?", ["algodao", "poliester", "cetim"]), - ("Seu perfil está pronto! Agora você pode indicar seus produtos preferidos.", None), - ] - - if 'current_step' not in st.session_state: - st.session_state.current_step = 0 - current_step = st.session_state.current_step - print('current_step', st.session_state.current_step, 'onboarding_steps', len(onboarding_steps), 'var current_step', current_step) - - step_message, options = onboarding_steps[current_step] - - st.write(step_message) - - # Display the appropriate input widget based on options - if options: - if current_step == 1: - selected_option = st.radio("Escolha o tamanho:", options) - elif current_step == 2: - selected_option = st.radio("Escolha o estilo:", options) - elif current_step == 3: - selected_option = st.multiselect("Escolha os interesses:", options) - elif current_step == 4: - selected_option = st.multiselect("Escolha os tecidos:", options) - else: - selected_option = None - - if st.button('Próximo'): - if options and not selected_option: - st.warning("Selecione ao menos uma opção para continuar.") - else: - if options: - field_name = ["size", "style", "interests", "fabrics"][current_step - 1] - db.collection('users').document(user_id).set({field_name: selected_option}, merge=True) - st.session_state.current_step += 1 - if st.session_state.current_step >= len(onboarding_steps): - db.collection('users').document(user_id).set({'onboarded': True}, merge=True) - st.session_state.current_step = 0 - st.experimental_rerun() \ No newline at end of file diff --git a/config/__pycache__/__init__.cpython-310.pyc b/config/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 382aa25..0000000 Binary files a/config/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/config/__pycache__/general_config.cpython-310.pyc b/config/__pycache__/general_config.cpython-310.pyc deleted file mode 100644 index 5abee55..0000000 Binary files a/config/__pycache__/general_config.cpython-310.pyc and /dev/null differ diff --git a/config/general_config.py b/config/general_config.py deleted file mode 100644 index c0bdd32..0000000 --- a/config/general_config.py +++ /dev/null @@ -1,36 +0,0 @@ -import firebase_admin -from firebase_admin import credentials, auth -import pyrebase -from firebase_admin import firestore - -firebaseConfig = { - "apiKey": "AIzaSyCBqbYP2izQkBYFJGvbl5OlG3LPOmfLZSI", - "authDomain": "thegift-ad01d.firebaseapp.com", - "databaseURL": "https://thegift-ad01d-default-rtdb.firebaseio.com", - "projectId": "thegift-ad01d", - "storageBucket": "thegift-ad01d.appspot.com", - "messagingSenderId": "267694872929", - "appId": "1:267694872929:web:cf914badd17f9bee36cd20", - "measurementId": "G-KTKJZ2BBP2" -} - -if not firebase_admin._apps: - cred = credentials.Certificate('./firebase/key.json') - fireabase = firebase_admin.initialize_app(cred) - -firebase = pyrebase.initialize_app(firebaseConfig) -auth_client = firebase.auth() - -db = firestore.client() - -def get_db(): - return db - -def get_auth_client(): - return auth_client - -def get_firebase(): - return firebase - -def get_auth() : - return auth \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..ca049ad Binary files /dev/null and b/db.sqlite3 differ diff --git a/firebase/key.json b/firebase/key.json deleted file mode 100644 index 4715b18..0000000 --- a/firebase/key.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "type": "service_account", - "project_id": "thegift-ad01d", - "private_key_id": "920ca4b431167b206efa446dc9e43f72a110627b", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDhiPCSpH6lIPVM\nNt532J0jA842IEU7qJtc6vo12i5CmDkxJCuUhvBLfit9AHOkfocCEtqdrRns4XEN\nVrkNNKHN8djof/SGsn5x/qiSEmoOrbPk57qs7i6BF1Zf8+oAoyGuHxAhgN8x1AK0\nFN5HpSNUOocQCE30vn8JQ8fZ7b6nzY1E6BzTHfafrxQwdRwKddtNL1lP1M4PSOFa\n1hIzLKOXyrjc28zQvhshZJJ41w8YIuShB2pceirnk973fiQcylsyslRgmqksDkrI\nP434Z9npOZdZE9wnrUTvTSw+5u2lwFjv/IYQV4X4CI2skva7ljQcqpaK1qPyb1Ro\n2YUqhDPnAgMBAAECggEAGCNbYsknOCN9uBv76xtsafsgyWCNIwmfIy6PpqQvekzS\nJi/HAvJUP92E6FqG206iwsvjc6e7VBkmy9+BwRI71Q+y1Y4doi2dZImgX2My0Fey\nnr0Bw5C0ZSLrHtbmBGPGmYeqkXi6VUS/IKibx6g6zpYlrsdswdUs7IAWy3zAqzMc\naz/eFy2vc/ir966b6a94xAqIBPgxZ1M/2jaFu1cyN7o04UVUTa1vdJBFoJ05z0Pa\nzF61H8vxUiZul8btNvUiDoBSLU6Ba6cIvGvKQ9Ik1MaRkDLav4FETeFFQlu0R/r7\nHkeV4A2wd6FdHCgIJyVpllR8B/PyIW/HfKQNYx9rwQKBgQD6vCHw0x28QOAvKR5Q\n7lfkzNlmCbSnMN+2ee0TZAwKNjfZI4z3s5oY4EiOqT7EffeSHIpaVA0xUfOK1fOQ\n0hY6fRWMXl1ecBHkxvP2E5EWom/Zthtju0AR9a/BdP42ua9okSGR2zmP1APe1ymn\nZzLqskfA9EQN+MMpCpINK00MwQKBgQDmRVcqDtCeQ7jxjwpPLXzubDb5S8ZkBRF8\n3yggQH9bWzhG5z6hhKhD2kgKz3j2Boli68tvbmpqcya0LD2PSZJZSCYGHFvjCGto\n7S8mG9NpYT8RbN2u4g7DNtMeRFEvCPNUabrvD/XNHjDg+Xc9nBKf7ibeKUss4PX9\nD9ahIR9ipwKBgBOJ448ztGZ+G7oxFxaxbBH9UJed/ADnUxeSKsJPEo0dKn72QT7w\nNPrpR14unCCNvGQba0CcuiZ0v2i7QW6woGDQbIRyug3o58wPIOW1IqJD6Dlr8nh0\nGAsOPTLzHfg/wgaBAL+v+K1XlTGhTLKp3RLi76p+nmsETpj9JOJ31FpBAoGAQrhC\nqjgCsGi09KDaftiSQ07tmswe3qotR/4s1TN681B5/OlR12DllEtx5lf5F2gLdLMX\njeDzSoa05y2OZK8PjXj/M3QSF7U/0fYvXB5h4j3AFV9y2BI97sg64aEv2K4COyor\ndMsuEFG4HeeKajqHlvldH6/dTVKdU8a8DJHZUy8CgYAxnW/bkyx4b51Eo2GtHDFo\nSeK443vShAT3nOIS9vQbgS4044En7mYKNSAjw1Vmr1z6izUArYgGZ1UWxdegro5X\nnS+d2hpk0aFjaAsET/0GxfelNERWlP7y1JR6Ylyb47V2Daqu7mwpxo7nQ5YdEdn8\nZm25txu0XKxFcs9aSxnKNQ==\n-----END PRIVATE KEY-----\n", - "client_email": "firebase-adminsdk-gemaz@thegift-ad01d.iam.gserviceaccount.com", - "client_id": "102509569346472270874", - "auth_uri": "https://accounts.google.com/o/oauth2/auth", - "token_uri": "https://oauth2.googleapis.com/token", - "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", - "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-gemaz%40thegift-ad01d.iam.gserviceaccount.com", - "universe_domain": "googleapis.com" - } - \ No newline at end of file diff --git a/gifts/__init__.py b/gifts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gifts/admin.py b/gifts/admin.py new file mode 100644 index 0000000..e07cda9 --- /dev/null +++ b/gifts/admin.py @@ -0,0 +1,9 @@ +from django.contrib import admin +from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin +from django.utils.translation import gettext_lazy as _ + +from .models import Gift + + +# Register your models here. +admin.site.register(Gift) diff --git a/gifts/apps.py b/gifts/apps.py new file mode 100644 index 0000000..00135f1 --- /dev/null +++ b/gifts/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class GiftsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'gifts' diff --git a/gifts/forms.py b/gifts/forms.py new file mode 100644 index 0000000..e69de29 diff --git a/gifts/migrations/0001_initial.py b/gifts/migrations/0001_initial.py new file mode 100644 index 0000000..e070d2f --- /dev/null +++ b/gifts/migrations/0001_initial.py @@ -0,0 +1,22 @@ +# Generated by Django 5.0.6 on 2024-06-19 02:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Gift', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=52)), + ('loja', models.CharField(max_length=300)), + ], + ), + ] diff --git a/gifts/migrations/0002_gift_img.py b/gifts/migrations/0002_gift_img.py new file mode 100644 index 0000000..d97bf13 --- /dev/null +++ b/gifts/migrations/0002_gift_img.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.6 on 2024-06-19 21:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("gifts", "0001_initial"), + ] + + operations = [ + migrations.AddField( + model_name="gift", + name="img", + field=models.CharField(default="aa", max_length=300), + preserve_default=False, + ), + ] diff --git a/gifts/migrations/0003_gift_likes.py b/gifts/migrations/0003_gift_likes.py new file mode 100644 index 0000000..4620ab3 --- /dev/null +++ b/gifts/migrations/0003_gift_likes.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.6 on 2024-06-20 00:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("accounts", "0002_remove_userinfo_genero"), + ("gifts", "0002_gift_img"), + ] + + operations = [ + migrations.AddField( + model_name="gift", + name="likes", + field=models.ManyToManyField(to="accounts.userinfo"), + ), + ] diff --git a/gifts/migrations/0004_alter_gift_likes.py b/gifts/migrations/0004_alter_gift_likes.py new file mode 100644 index 0000000..7db9568 --- /dev/null +++ b/gifts/migrations/0004_alter_gift_likes.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.6 on 2024-06-20 17:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("accounts", "0002_remove_userinfo_genero"), + ("gifts", "0003_gift_likes"), + ] + + operations = [ + migrations.AlterField( + model_name="gift", + name="likes", + field=models.ManyToManyField(blank=True, to="accounts.userinfo"), + ), + ] diff --git a/gifts/migrations/0005_gift_cat.py b/gifts/migrations/0005_gift_cat.py new file mode 100644 index 0000000..120f0f7 --- /dev/null +++ b/gifts/migrations/0005_gift_cat.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.6 on 2024-06-20 18:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("gifts", "0004_alter_gift_likes"), + ] + + operations = [ + migrations.AddField( + model_name="gift", + name="cat", + field=models.CharField(default="roupas", max_length=20), + preserve_default=False, + ), + ] diff --git a/gifts/migrations/0006_remove_gift_likes.py b/gifts/migrations/0006_remove_gift_likes.py new file mode 100644 index 0000000..de16a7c --- /dev/null +++ b/gifts/migrations/0006_remove_gift_likes.py @@ -0,0 +1,17 @@ +# Generated by Django 5.0.6 on 2024-06-22 20:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("gifts", "0005_gift_cat"), + ] + + operations = [ + migrations.RemoveField( + model_name="gift", + name="likes", + ), + ] diff --git a/gifts/migrations/__init__.py b/gifts/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gifts/models.py b/gifts/models.py new file mode 100644 index 0000000..f55d6bd --- /dev/null +++ b/gifts/models.py @@ -0,0 +1,10 @@ +from django.db import models +class Gift(models.Model): + name = models.CharField(max_length=52) + loja = models.CharField(max_length=300) + img = models.CharField(max_length=300) + cat = models.CharField(max_length=20) + + + def __str__(self): + return f'{self.name}' \ No newline at end of file diff --git a/gifts/templates/gifts/my_list.html b/gifts/templates/gifts/my_list.html new file mode 100644 index 0000000..1a1567f --- /dev/null +++ b/gifts/templates/gifts/my_list.html @@ -0,0 +1,28 @@ +{% extends 'base.html' %} +{% load static %} +{% block title %} Home +{% endblock title %} +{% block content %} + +
+ {% include 'staticpages/partials/menu_left.html' %} + {% include 'staticpages/partials/menu_right.html' %} + +
+ +
+ + {% include 'gifts/partials/gifts_cards.html' %} +
+{% endblock content %} diff --git a/gifts/templates/gifts/partials/gifts_cards.html b/gifts/templates/gifts/partials/gifts_cards.html new file mode 100644 index 0000000..cce79ca --- /dev/null +++ b/gifts/templates/gifts/partials/gifts_cards.html @@ -0,0 +1,17 @@ +
+ {% for gift in gifts_list %} + +
+
+ {{ gift.name }} +
+
+ +
{{ gift.name }}
+ + +
+
+
+ {% endfor %} +
\ No newline at end of file diff --git a/gifts/templates/gifts/people.html b/gifts/templates/gifts/people.html new file mode 100644 index 0000000..e127171 --- /dev/null +++ b/gifts/templates/gifts/people.html @@ -0,0 +1,62 @@ +{% extends 'base.html' %} +{% load static %} +{% block title %} Home +{% endblock title %} +{% block content %} + +
+ {% include 'staticpages/partials/menu_left.html' %} + {% include 'staticpages/partials/menu_right.html' %} + +
+
+ +
+ +
+ +
+ {% for people in people_list %} +
+
+
+ +
+
+

{{ people.name }}

+

@{{people.user }}

+ +
+ {% if people.roupas >= 100 %} +

Roupas

+ {% endif %} {% if people.fitness >= 100 %} +

Fitness

+ {% endif %} {% if people.beleza >= 100 %} +

Beleza

+ {% endif %} {% if people.eletronicos >= 100 %} +

Eletrônicos

+ {% endif %} {% if people.outros >= 100 %} +

Outros

+ {% endif %} +
+
+
+
+ +
+ + +
+ {% endfor %} +
+
+{% endblock content %} diff --git a/gifts/templates/gifts/profile.html b/gifts/templates/gifts/profile.html new file mode 100644 index 0000000..04689db --- /dev/null +++ b/gifts/templates/gifts/profile.html @@ -0,0 +1,38 @@ +{% extends 'base.html' %} + +{% load static %} + +{% block title %} +{{ people.name}} +{% endblock title%} +{% block content %} + +
+ {% include 'staticpages/partials/menu_left.html' %} + {% include 'staticpages/partials/menu_right.html' %} + + +
+ +
+
+ +

{{people.name}}

+

@{{people.user }}

+
+ {%if is_friend%} + Deixar de Seguir + {%else%} + Seguir + {%endif%} +
+
+
+ +
+ {% include 'gifts/partials/gifts_cards.html' %} + +
+{% endblock content %} diff --git a/gifts/templates/gifts/tinderbase.html b/gifts/templates/gifts/tinderbase.html new file mode 100644 index 0000000..32b392f --- /dev/null +++ b/gifts/templates/gifts/tinderbase.html @@ -0,0 +1,89 @@ + +{% extends 'base.html' %} +{% load static %} +{% block title %} Home +{% endblock title %} +{% block content %} + +
+ {% include 'staticpages/partials/menu_left.html' %} + {% include 'staticpages/partials/menu_right.html' %} + +
+ + +
+
+ {%if gifts_list%} + {% for gift in gifts_list%} + +
+
{{ gift.name }}
+
+ {{ gift.name }} +
+ Amei + + Gostei + Odiei +
+
+
+ + {% endfor %} +
+ +

Parece que não temos mais produtos para te mostrar agora...

+
+ {% else %} +
+ +

Parece que não temos mais produtos para te mostrar agora...

+
+ {%endif%} + +
+ +
+
+ {% csrf_token %} + +
+ + +{% endblock content %} + + diff --git a/gifts/tests.py b/gifts/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/gifts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/gifts/urls.py b/gifts/urls.py new file mode 100644 index 0000000..43c1dbd --- /dev/null +++ b/gifts/urls.py @@ -0,0 +1,13 @@ +from django.urls import path +from django.contrib.auth import views as auth_views +from . import views + +urlpatterns = [ + path('', views.tinder_base, name='home'), + path('explore', views.search_users, name='explore'), + path('explore//', views.detail_people, name='detail_people'), + path('friend_request/', views.friend_request, name='friend_request'), + path('my_gifts', views.my_gifts, name='my_gifts'), + path('friends', views.my_friends, name='friends'), + + ] \ No newline at end of file diff --git a/gifts/views.py b/gifts/views.py new file mode 100644 index 0000000..a95b660 --- /dev/null +++ b/gifts/views.py @@ -0,0 +1,163 @@ +from django.shortcuts import render, get_object_or_404 +from accounts.models import UserInfo +from gifts.models import Gift +import json +from django.http import HttpResponse, HttpResponseRedirect +from django.urls import reverse + +def friends_activity(request): + user_info = UserInfo.objects.get(user_id=request.user) + friends_list = user_info.friends.all() + peoples_list = [] + for people in friends_list: + name = people.name + id = people.user_id + #last_gift = people.likes.order_by('-id').first() + last_gift = people.likes.first() + if last_gift: + activity_dict = { + "name": name, + "person_id": id, + "last_gift":last_gift + } + + peoples_list.append(activity_dict) + + return peoples_list + +def my_friends(request): + activity = friends_activity(request) + context = {} + user_info = UserInfo.objects.get(user_id=request.user) + if request.GET.get("query", False): + search_term = request.GET["query"].lower() + people_list = user_info.friends.filter(name__icontains=search_term) + context = {"people_list": people_list, + "len_list": len(people_list), + "friends_activity": activity} + else: + people_list = user_info.friends.all() + context = {"people_list": people_list, + "len_list": len(people_list), + "friends_activity": activity} + + return render(request, "gifts/people.html", context) + +def my_gifts(request): + activity = friends_activity(request) + user_info = UserInfo.objects.get(user_id=request.user) + + my_gifts = user_info.likes.all() + + context = { + "gifts_list": my_gifts, + "friends_activity": activity + } + return render(request, "gifts/my_list.html", context) + + +def detail_people(request, people_id): + activity = friends_activity(request) + user_info = UserInfo.objects.get(user_id=request.user) + + friend_info = UserInfo.objects.get(user_id=people_id) + + + user_friends = user_info.friends.all() + user_gifts = friend_info.likes.all() + gifts_list = Gift.objects.filter(pk__in=user_gifts.values_list('pk', flat=True)) + + if friend_info in user_friends: + friends = True + else: + friends = False + + context = { + "is_friend": friends, + "people": friend_info, + "friends_activity": activity, + "gifts_list": gifts_list + } + return render(request, "gifts/profile.html", context) + +def friend_request(request, people_id): + + user_info = UserInfo.objects.get(user_id=request.user) + + friend_info = UserInfo.objects.get(user_id=people_id) + + + user_friends = user_info.friends.all() + + if friend_info in user_friends: + user_info.friends.remove(friend_info) + else: + user_info.friends.add(friend_info) + + user_info.save() + return HttpResponseRedirect( + reverse('detail_people', args=(people_id, ))) + + +def search_users(request): + context = {} + activity = friends_activity(request) + if request.GET.get("query", False): + search_term = request.GET["query"].lower() + people_list = UserInfo.objects.filter(name__icontains=search_term) + context = {"people_list": people_list, + "len_list": len(people_list), + "friends_activity": activity} + else: + people_list = UserInfo.objects.all() + context = {"people_list": people_list, + "len_list": len(people_list), + "friends_activity": activity} + + return render(request, "gifts/people.html", context) + + +def tinder_base(request): + activity = friends_activity(request) + if request.method == "POST": + + points = json.loads(request.POST.get("points_counter")) + + print(type(points)) + user_info = UserInfo.objects.get(user_id=request.user) + print(user_info) + + user_info.roupas=user_info.roupas + int(points.get("roupas")) + user_info.fitness=user_info.fitness + int(points.get("fitness")) + user_info.beleza=user_info.beleza + int(points.get("beleza")) + user_info.eletronicos=user_info.eletronicos + int(points.get("eletronicos")) + user_info.outros=user_info.outros + int(points.get("outros")) + + for gift in points.get('liked_gifts'): + gift_obj = Gift.objects.get(pk = int(gift)) + user_info.likes.add(gift_obj) + user_info.save() + return HttpResponse("Form submitted successfully") + else: + + id_user = request.user + user_info = UserInfo.objects.get(user_id=request.user) + + my_gifts = user_info.likes.all() + gifts_list = Gift.objects.exclude(pk__in=my_gifts.values_list('pk', flat=True)) + points_dict = { + "roupas": 0, + "fitness": 0, + "beleza": 0, + "eletronicos": 0, + "outros": 0, + "liked_gifts": [] + } + context = { + "gifts_list": gifts_list, + "len_gifts_list": len(gifts_list), + "points_dict": json.dumps(points_dict), + "friends_activity": activity + } + + return render(request, "gifts/tinderbase.html", context) diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..7a0a8f2 --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'thegift.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/requirements.txt b/requirements.txt index a38d0ab..f4987b2 100644 Binary files a/requirements.txt and b/requirements.txt differ diff --git a/static/images/hands_mascot.svg b/static/images/hands_mascot.svg new file mode 100644 index 0000000..5b90038 --- /dev/null +++ b/static/images/hands_mascot.svg @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/hate_icon.svg b/static/images/hate_icon.svg new file mode 100644 index 0000000..a8eaaf0 --- /dev/null +++ b/static/images/hate_icon.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/static/images/jumping_mascot.svg b/static/images/jumping_mascot.svg new file mode 100644 index 0000000..c7136ee --- /dev/null +++ b/static/images/jumping_mascot.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/like_icon.svg b/static/images/like_icon.svg new file mode 100644 index 0000000..a5e23b3 --- /dev/null +++ b/static/images/like_icon.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/static/images/logo.svg b/static/images/logo.svg new file mode 100644 index 0000000..76a3545 --- /dev/null +++ b/static/images/logo.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/static/images/logo_white.svg b/static/images/logo_white.svg new file mode 100644 index 0000000..83cf128 --- /dev/null +++ b/static/images/logo_white.svg @@ -0,0 +1,4 @@ + + + + diff --git a/static/images/love_icon.svg b/static/images/love_icon.svg new file mode 100644 index 0000000..ed93307 --- /dev/null +++ b/static/images/love_icon.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/love_small_icon.svg b/static/images/love_small_icon.svg new file mode 100644 index 0000000..6b23f23 --- /dev/null +++ b/static/images/love_small_icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/static/images/user_icon.svg b/static/images/user_icon.svg new file mode 100644 index 0000000..46966a1 --- /dev/null +++ b/static/images/user_icon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/static/script/script.js b/static/script/script.js new file mode 100644 index 0000000..db021ce --- /dev/null +++ b/static/script/script.js @@ -0,0 +1,81 @@ +$(function() { + $('.selectpicker').selectpicker(); + }); + +function toggleTab(e){ + var hrefVal = $(e).attr('href'); + $('.nav-tabs li').removeClass('active'); + $('.nav-tabs li[data-active="'+hrefVal+'"]').addClass('active'); +} +function getJsonData(inputString){ + let startIndex = inputString.indexOf('{'); + let endIndex = inputString.lastIndexOf('}'); + if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) { + // Extract the JSON string + let jsonString = inputString.substring(startIndex, endIndex + 1); + try { + // Parsing JSON string to JavaScript object + let parsedObject = JSON.parse(jsonString); + return parsedObject; + // Now you can use parsedObject[key] to access values + } catch (e) { + console.error('Error parsing JSON:', e); + } + } else { + console.error('No valid JSON object found in the input string.'); + } +} +function toggleTabTinder(element) { + try { + + // Get the current counter from the data attribute and increment it + const currentCounter = parseInt(element.getAttribute('data-counter'), 10); + const nextCounter = currentCounter + 1; + + // Get the current taste category and meaning + const type = element.getAttribute('data-type'); + const currElement = document.getElementById(`gift_idx_${currentCounter}`); + const cat = currElement.getAttribute('category'); + + var inputPoints = document.getElementById('points_counter'); + + var points = getJsonData(inputPoints.value); + + if (type === 'love') + { + points[cat] = points[cat] + 2 + const giftId = currElement.getAttribute('data-id'); + console.log(giftId) + points['liked_gifts'].push(giftId) + } + else if (type=='like') + { + points[cat] = points[cat] + 1 + } + else if (type=='hate') + { + points[cat] = points[cat] - 1 + } + + + console.log(points) + + inputPoints.value = JSON.stringify(points); + + // Get all elements with class 'tindercard' and remove 'in active' from them + const cards = document.querySelectorAll('.tindercard'); + cards.forEach(card => card.classList.remove('in', 'active')); + + // Add 'in active' to the clicked element's corresponding div + const nextElementId = `gift_idx_${nextCounter}`; + const nextElement = document.getElementById(nextElementId); + if (nextElement) { + nextElement.classList.add('in', 'active'); + } else { + const nextElement = document.getElementById('no_products'); + nextElement.classList.add('in', 'active'); + } + } catch (error) { + console.error('An error occurred in toggleTabTinder:', error); + } +} \ No newline at end of file diff --git a/static/style/style.css b/static/style/style.css new file mode 100644 index 0000000..e658c8d --- /dev/null +++ b/static/style/style.css @@ -0,0 +1,259 @@ +body { + background-color: #E8E9EB; + font-family: "Roboto", sans-serif; +} + +.container { + margin-right: 300px; + margin-left: 300px; + width: 800px; +} + +.pink-btn { + background-color: #B27092; + color: #E8E9EB; + width: 200px; +} + +.purple-btn { + background-color: #5F0A87; + color: #E8E9EB; + width: 200px; +} + +.purple-outline-btn { + border: 2px solid #5F0A87; + color: #2F004F; + width: 200px; +} + +.p-inside-box { + color: #B27092; +} + +.pink-link { + color: #B27092; +} + +.purple-link { + color: #2F004F; +} + +.form-holder { + padding: 10px; +} + +.form-group input { + width: 100%; + height: 50px; + margin-bottom: 10px; + box-shadow: 1px 1px #B27092; + border: 1px solid #B27092; +} + +.form-group input:hover, .form-group input:focus { + outline: 2px solid #B27092; +} + +.form-group label { + font-weight: 100; + width: 100%; + display: block; + font-size: 20px; +} + +.form-group select { + height: 40px; + margin: 0px 10px 10px 0px; + box-shadow: 1px 1px #B27092; + border: 1px solid #B27092; + background-color: #FFF; +} + +.form-group input[type=radio] { + width: 20px; + height: 20px; + box-shadow: none; +} + +.btn { + margin-bottom: 5px; +} + +.navbar-collapse { + height: 560px; +} + +.creation-form input { + width: 600px; + height: 50px; + margin-bottom: 10px; + box-shadow: 1px 1px #B27092; + border: 2px solid #B27092; + border-radius: 20px; +} + +.creation-form input[type=radio] { + width: 20px; + height: 20px; + box-shadow: none; +} + +.creation-form input[type=checkbox] { + width: 20px; + height: 20px; + box-shadow: none; +} + +.creation-form select { + width: 100%; + height: 50px; + margin-bottom: 10px; + box-shadow: 1px 1px #B27092; + border: 2px solid #B27092; + border-radius: 20px; +} + +.search_title { + color: #B27092; +} + +.img_search { + width: 300px; +} + +.circle-singleline { + width: 100px; + height: 100px; + margin-left: 35%; + border-radius: 50%; + line-height: 100px; + background: #2F004F; + color: #E8E9EB; +} + +.btn_side { + width: 50px; + margin-top: 20px; +} + +.circle-inline { + width: 50px; + height: 50px; + border-radius: 50%; + line-height: 50px; + background: #2F004F; + color: #E8E9EB; +} + +.card { + background-color: #5F0A87; + border-radius: 10px; + margin-bottom: 10px; +} + +.border_title { + margin: 0px !important; + width: 100%; + background-color: #2F004F; + color: #E8E9EB; + font-size: larger; + padding-left: 10px; +} + +.tindercard { + width: 500px; + height: 600px; +} + +.tindercard-img { + height: 400px; + overflow: hidden; +} + +.sidebar { + background-color: #2F004F; + color: #E8E9EB; + position: fixed; + z-index: 1; + height: 100%; + top: 0; + left: 0; + width: 300px; + display: flex; + justify-content: flex-start; + padding-top: 20px; + align-items: center; + flex-direction: column; +} + +.sidebar_right { + background-color: #2F004F; + color: #E8E9EB; + float: right; + position: fixed; + z-index: 1; + height: 100%; + top: 0; + right: 0; + width: 300px; + display: flex; + justify-content: flex-start; + padding-top: 20px; + align-items: center; + flex-direction: column; +} + +.purple_badge { + background-color: #5F0A87; +} + +.card_people { + background-color: #d7d8da; +} + +.follow-btn { + height: 30px; + margin: 10px; + width: 80px; +} + +.profile-header { + height: 300px; + color: #E8E9EB; + background-color: #C37FE2; + margin-bottom: 20px; + padding: 10px; + width: 100%; +} + +.white-link { + color: #E8E9EB; + font-size: 20px; + margin: 10px; +} + +.giftcard-img { + width: 200px; + height: 250px; + overflow: hidden; + border-radius: 4%; +} + +.giftcard { + width: 200px; + height: 300px; + color: #E8E9EB; + margin-right: 10px; + margin-bottom: 10px; +} + +.giftcard-list { + display: flex; + flex-wrap: wrap; +} + +.container_create { + display: flex; + justify-content: center; +}/*# sourceMappingURL=style.css.map */ \ No newline at end of file diff --git a/static/style/style.css.map b/static/style/style.css.map new file mode 100644 index 0000000..33883c2 --- /dev/null +++ b/static/style/style.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["style.scss","style.css"],"names":[],"mappings":"AASA;EACI,yBAVgB;EAWhB,iCAAA;ACRJ;;ADWA;EACI,mBAAA;EACA,kBAAA;EACA,YAAA;ACRJ;;ADYA;EACI,yBAfG;EAgBH,cAvBgB;EAwBhB,YAAA;ACTJ;;ADYA;EACI,yBAvBK;EAwBL,cA7BgB;EA8BhB,YAAA;ACTJ;;ADWA;EACI,yBAAA;EACA,cA9BU;EA+BV,YAAA;ACRJ;;ADYA;EACI,cAjCG;ACwBP;;ADYA;EACI,cArCG;AC4BP;;ADWA;EACI,cA3CU;ACmCd;;ADWA;EACI,aAAA;ACRJ;;ADWA;EACI,WAAA;EACA,YAAA;EACA,mBAAA;EACA,2BAAA;EACA,yBAAA;ACRJ;;ADWA;EACI,0BAAA;ACRJ;;ADWA;EACI,gBAAA;EACA,WAAA;EACA,cAAA;EACA,eAAA;ACRJ;;ADWA;EACI,YAAA;EACA,yBAAA;EACA,2BAAA;EACA,yBAAA;EACA,sBAAA;ACRJ;;ADWA;EACI,WAAA;EACA,YAAA;EACA,gBAAA;ACRJ;;ADYA;EACI,kBAAA;ACTJ;;ADYA;EACI,aAAA;ACTJ;;ADYA;EACI,YAAA;EACA,YAAA;EACA,mBAAA;EACA,2BAAA;EACA,yBAAA;EACA,mBAAA;ACTJ;;ADWA;EACI,WAAA;EACA,YAAA;EACA,gBAAA;ACRJ;;ADWA;EACI,WAAA;EACA,YAAA;EACA,gBAAA;ACRJ;;ADWA;EACI,WAAA;EACA,YAAA;EACA,mBAAA;EACA,2BAAA;EACA,yBAAA;EACA,mBAAA;ACRJ;;ADYA;EACI,cAxHG;AC+GP;;ADWA;EACI,YAAA;ACRJ;;ADUA;EACM,YAAA;EACA,aAAA;EACA,gBAAA;EACA,kBAAA;EACA,kBAAA;EACA,mBAtIQ;EAuIR,cA3Ic;ACoIpB;;ADUA;EACI,WAAA;EACA,gBAAA;ACPJ;;ADUA;EACI,WAAA;EACA,YAAA;EACA,kBAAA;EACA,iBAAA;EACA,mBApJU;EAqJV,cAzJgB;ACkJpB;;ADUA;EACI,yBAxJK;EAyJL,mBAAA;EACA,mBAAA;ACPJ;;ADUA;EACI,sBAAA;EACA,WAAA;EACA,yBAjKU;EAkKV,cAtKgB;EAuKhB,iBAAA;EACA,kBAAA;ACPJ;;ADWA;EACI,YAAA;EACA,aAAA;ACRJ;;ADWA;EACI,aAAA;EACA,gBAAA;ACRJ;;ADUA;EACI,yBAlLU;EAmLV,cAvLgB;EAwLhB,eAAA;EACA,UAAA;EACA,YAAA;EACA,MAAA;EACA,OAAA;EACA,YAAA;EAEA,aAAA;EACA,2BAAA;EACA,iBAAA;EACA,mBAAA;EACA,sBAAA;ACRJ;;ADWA;EACI,yBAnMU;EAoMV,cAxMgB;EAyMhB,YAAA;EACA,eAAA;EACA,UAAA;EACA,YAAA;EACA,MAAA;EACA,QAAA;EACA,YAAA;EAEA,aAAA;EACA,2BAAA;EACA,iBAAA;EACA,mBAAA;EACA,sBAAA;ACTJ;;ADaA;EACI,yBArNK;AC2MT;;ADaA;EACI,yBA7NU;ACmNd;;ADaA;EACI,YAAA;EACA,YAAA;EACA,WAAA;ACVJ;;ADaA;EACI,aAAA;EACA,cAzOgB;EA0OhB,yBApOW;EAqOX,mBAAA;EACA,aAAA;EACA,WAAA;ACVJ;;ADaA;EACI,cAjPgB;EAkPhB,eAAA;EACA,YAAA;ACVJ;;ADaA;EACI,YAAA;EACA,aAAA;EACA,gBAAA;EACA,iBAAA;ACVJ;;ADYA;EACI,YAAA;EACA,aAAA;EACA,cA/PgB;EAiQhB,kBAAA;EACA,mBAAA;ACVJ;;ADaA;EACI,aAAA;EACA,eAAA;ACVJ;;ADaA;EACI,aAAA;EACA,uBAAA;ACVJ","file":"style.css"} \ No newline at end of file diff --git a/static/style/style.scss b/static/style/style.scss new file mode 100644 index 0000000..ab40dfe --- /dev/null +++ b/static/style/style.scss @@ -0,0 +1,270 @@ +$background-white : #E8E9EB; +$light-grey : #d7d8da; + +$black: #3D3B30; +$dark-purple: #2F004F; +$purple: #5F0A87; +$light-purple: #C37FE2; +$pink: #B27092; + +body{ + background-color: $background-white; + font-family: 'Roboto', sans-serif; +} + +.container{ + margin-right: 300px; + margin-left: 300px; + width: 800px; + +} + +.pink-btn{ + background-color: $pink; + color: $background-white; + width: 200px +} + +.purple-btn{ + background-color: $purple; + color: $background-white; + width: 200px +} +.purple-outline-btn{ + border: 2px solid $purple; + color: $dark-purple; + width: 200px +} + + +.p-inside-box{ + color: $pink; +} + +.pink-link{ + color: $pink; +} +.purple-link{ + color: $dark-purple; +} + +.form-holder{ + padding: 10px; +} + +.form-group input{ + width: 100%; + height: 50px; + margin-bottom: 10px; + box-shadow: 1px 1px $pink; + border: 1px solid $pink; +} + +.form-group input:hover, .form-group input:focus{ + outline: 2px solid $pink; +} + +.form-group label{ + font-weight: 100; + width: 100%; + display: block; + font-size: 20px; +} + +.form-group select{ + height: 40px; + margin: 0px 10px 10px 0px; + box-shadow: 1px 1px $pink; + border: 1px solid $pink; + background-color: #FFF; +} + +.form-group input[type="radio"]{ + width: 20px; + height: 20px; + box-shadow: none; +} + + +.btn{ + margin-bottom: 5px; +} + +.navbar-collapse{ + height: 560px +} + +.creation-form input{ + width: 600px; + height: 50px; + margin-bottom: 10px; + box-shadow: 1px 1px $pink; + border: 2px solid $pink; + border-radius: 20px; +} +.creation-form input[type="radio"]{ + width: 20px; + height: 20px; + box-shadow: none; +} + +.creation-form input[type="checkbox"]{ + width: 20px; + height: 20px; + box-shadow: none; +} + +.creation-form select{ + width: 100%; + height: 50px; + margin-bottom: 10px; + box-shadow: 1px 1px $pink; + border: 2px solid $pink; + border-radius: 20px; +} + + +.search_title{ + color: $pink; +} +.img_search{ + width: 300px; +} +.circle-singleline { + width: 100px; + height: 100px; + margin-left: 35%; + border-radius: 50%; + line-height: 100px; + background: $dark-purple; + color: $background-white; +} + +.btn_side{ + width: 50px; + margin-top: 20px; +} + +.circle-inline { + width: 50px; + height: 50px; + border-radius: 50%; + line-height: 50px; + background: $dark-purple; + color: $background-white; +} + +.card{ + background-color: $purple; + border-radius: 10px; + margin-bottom: 10px; +} + +.border_title{ + margin: 0px !important; + width: 100%; + background-color: $dark-purple; + color: $background-white; + font-size: larger; + padding-left: 10px; + +} + +.tindercard{ + width:500px; + height: 600px; +} + +.tindercard-img{ + height: 400px; + overflow: hidden; +} +.sidebar{ + background-color: $dark-purple; + color: $background-white; + position: fixed; + z-index: 1; + height: 100%; + top: 0; + left: 0; + width: 300px; + + display: flex; + justify-content: flex-start; + padding-top: 20px; + align-items: center; + flex-direction: column; +} + +.sidebar_right{ + background-color: $dark-purple; + color: $background-white; + float: right; + position: fixed; + z-index: 1; + height: 100%; + top: 0; + right: 0; + width: 300px; + + display: flex; + justify-content: flex-start; + padding-top: 20px; + align-items: center; + flex-direction: column; +} + + +.purple_badge{ + background-color: $purple; +} + +.card_people{ + background-color: $light-grey; +} + +.follow-btn{ + height: 30px; + margin:10px; + width: 80px; +} + +.profile-header{ + height: 300px; + color: $background-white; + background-color: $light-purple; + margin-bottom: 20px; + padding: 10px; + width: 100%; +} + +.white-link{ + color: $background-white; + font-size: 20px; + margin: 10px; +} + +.giftcard-img{ + width: 200px; + height: 250px; + overflow: hidden; + border-radius: 4%; +} +.giftcard{ + width: 200px; + height: 300px; + color: $background-white; + + margin-right: 10px; + margin-bottom: 10px; + +} +.giftcard-list{ + display: flex; + flex-wrap: wrap; +} + +.container_create{ + display: flex; + justify-content: center; +} \ No newline at end of file diff --git a/staticpages/__init__.py b/staticpages/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/staticpages/admin.py b/staticpages/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/staticpages/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/staticpages/apps.py b/staticpages/apps.py new file mode 100644 index 0000000..6d252f4 --- /dev/null +++ b/staticpages/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class StaticpagesConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'staticpages' diff --git a/staticpages/migrations/__init__.py b/staticpages/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/staticpages/models.py b/staticpages/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/staticpages/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/staticpages/templates/staticpages/index.html b/staticpages/templates/staticpages/index.html new file mode 100644 index 0000000..533129c --- /dev/null +++ b/staticpages/templates/staticpages/index.html @@ -0,0 +1,27 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %} +Home +{% endblock title %} + +{% block content %} +
+ +

Descubra o que seus amigos mais desejam e receba sugestões de produtos

+

Com o The Gift, você pode descobrir os presentes sugeridos para seus amigos, + além de receber sugestões de produtos de acordo com as sua preferências

+
+ +
+ + + Cadastre-se Já! + +

Já possui cadastro? Entre aqui

+ + + +
+{% endblock content %} + diff --git a/staticpages/templates/staticpages/partials/menu_left.html b/staticpages/templates/staticpages/partials/menu_left.html new file mode 100644 index 0000000..2bd5887 --- /dev/null +++ b/staticpages/templates/staticpages/partials/menu_left.html @@ -0,0 +1,15 @@ +{% load static %} + \ No newline at end of file diff --git a/staticpages/templates/staticpages/partials/menu_right.html b/staticpages/templates/staticpages/partials/menu_right.html new file mode 100644 index 0000000..dc8a34d --- /dev/null +++ b/staticpages/templates/staticpages/partials/menu_right.html @@ -0,0 +1,22 @@ +{% load static %} + \ No newline at end of file diff --git a/staticpages/tests.py b/staticpages/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/staticpages/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/staticpages/urls.py b/staticpages/urls.py new file mode 100644 index 0000000..88a9cac --- /dev/null +++ b/staticpages/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index'), +] diff --git a/staticpages/views.py b/staticpages/views.py new file mode 100644 index 0000000..6c6774e --- /dev/null +++ b/staticpages/views.py @@ -0,0 +1,6 @@ +from django.shortcuts import render + +def index(request): + context = {} + return render(request, 'staticpages/index.html', context) + diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..b56c30e --- /dev/null +++ b/templates/base.html @@ -0,0 +1,43 @@ +{% load static %} + + + + + + + + + + {% block title %}{% endblock %} + + + + + + + + + + + + + + + + {% block extrastyles %}{% endblock %} + + +
+ {% block content %} + {% endblock content %} +
+ + + + diff --git a/thegift/__init__.py b/thegift/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/thegift/asgi.py b/thegift/asgi.py new file mode 100644 index 0000000..3ba694a --- /dev/null +++ b/thegift/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for thegift 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/5.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'thegift.settings') + +application = get_asgi_application() diff --git a/thegift/settings.py b/thegift/settings.py new file mode 100644 index 0000000..b85c862 --- /dev/null +++ b/thegift/settings.py @@ -0,0 +1,139 @@ +""" +Django settings for thegift project. + +Generated by 'django-admin startproject' using Django 5.0.6. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.0/ref/settings/ +""" +import django_heroku +import os +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# 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-r#_=--@zk1ae0z9@pn(4^603il-y0mqwu#0kh^p-1!ad#52_tm' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'staticpages.apps.StaticpagesConfig', + 'accounts.apps.AccountsConfig', + 'gifts.apps.GiftsConfig' +] + +MIDDLEWARE = [ + 'whitenoise.middleware.WhiteNoiseMiddleware', + '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 = 'thegift.urls' + +TEMPLATES = [ + { + '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', + ], + }, + }, +] + +WSGI_APPLICATION = 'thegift.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.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', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.0/topics/i18n/ + +LANGUAGE_CODE = 'pt-BR' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.0/howto/static-files/ + +STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ] +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +LOGIN_URL = '/login' +LOGOUT_REDIRECT_URL = '/' +LOGIN_REDIRECT_URL = '/home' + + +CRISPY_TEMPLATE_PACK = 'bootstrap' + +django_heroku.settings(locals()) \ No newline at end of file diff --git a/thegift/urls.py b/thegift/urls.py new file mode 100644 index 0000000..58c7b0a --- /dev/null +++ b/thegift/urls.py @@ -0,0 +1,27 @@ +""" +URL configuration for thegift project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('staticpages.urls')), + + path('account/', include('accounts.urls')), + path('home/', include('gifts.urls')), + +] diff --git a/thegift/wsgi.py b/thegift/wsgi.py new file mode 100644 index 0000000..97f46c3 --- /dev/null +++ b/thegift/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for thegift 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/5.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'thegift.settings') + +application = get_wsgi_application() diff --git a/utils/__pycache__/__init__.cpython-310.pyc b/utils/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index db7078b..0000000 Binary files a/utils/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/utils/__pycache__/cookie_manager.cpython-310.pyc b/utils/__pycache__/cookie_manager.cpython-310.pyc deleted file mode 100644 index 879d041..0000000 Binary files a/utils/__pycache__/cookie_manager.cpython-310.pyc and /dev/null differ diff --git a/utils/cookie_manager.py b/utils/cookie_manager.py deleted file mode 100644 index d5ceb88..0000000 --- a/utils/cookie_manager.py +++ /dev/null @@ -1,23 +0,0 @@ -# Function to store the Firebase Auth token in cookies -import streamlit_cookies_manager - -class CookieManager: - def __init__(self): - self.cookies = streamlit_cookies_manager.CookieManager() - - def store_in_cookies(self, key, value): - if key in self.cookies: - del self.cookies[key] - self.cookies[key] = value - # self.cookies.save() - - def get_from_cookies(self, key): - return self.cookies.get(key) - - def delete_from_cookies(self, key): - if key in self.cookies: - del self.cookies[key] - # self.cookies.save() - - def save(self): - self.cookies.save()