From 8f3740b885d1f5c5e74109db5a8cbbecb8134b53 Mon Sep 17 00:00:00 2001 From: Michele de Barros Santos Date: Tue, 3 Oct 2023 21:40:30 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20edi=C3=A7=C3=A3o=20perfil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db.sqlite3 | Bin 159744 -> 159744 bytes filme/forms.py | 2 +- filme/templates/editarperfil.html | 64 +++++++++++++++++- filme/urls.py | 6 +- filme/views.py | 11 +++- static/css/style_criarconta.css | 3 +- static/css/style_editarperfil.css | 105 +++++++++++++++++++++++++++++- static/css/style_login.css | 3 +- templates/navbar.html | 2 +- 9 files changed, 183 insertions(+), 13 deletions(-) diff --git a/db.sqlite3 b/db.sqlite3 index be10f5a722d9a8e09d46d22bc79d7c1fe695ce63..b50042d264bc9e3c0ea8f8d8a47979a501cd3bd6 100644 GIT binary patch delta 1072 zcmcK3yKmEA5CCvH1knJAQ?c+Ax}*iE zjKGwci2)WAsYq;ymH(g}Dt7(`NGskFDh%9qH=IttyW2htY##=mUcq;tU0ua@Uq5*M z`CRA`<_pfT;GBrhZ>+osp4-XdL2T!)7!a?_Vg%k=hAR{$AV#3sD9dpS&&)n#e3#E; z4NY(Mn#alP6M3Xtma^)zHYcm2&5H#T@dPhFIm4HJ(vXWzeWsCP^|+a-tgZy0uEt z)3xSmpYF+bDUyN_Kt{;p2_PpRE(%Bh5HO8$C~|h4z%TBG z@x8Fmzp{jf_OZ}@aBqR~Dme9}vX9Cl(2=97TMdhyY*J(Bj)t!40KGdjy7r)NG0|pf zT3BEO}@bA89f3LmNSsbRH@zXuO)P8 ztDi1ylvFY)iSm{zSJ!*CnUGXDrpLvN6dD!Tq9%DgPSny~ZrB!pZ4I2f;8xe}OIF0S zYIU#9%j$-rrckcpNY*Hq%w^hB(@;vbsd92s{zeSAqa{OHfMgUf5CQ7pP5ksR)6ipe z(4q&nV$dVk?De5-O}e92$DFwOi2iq`>0dhiFQ&|qldA|$JT4i@q=P1Mv)IiR^J!a8 z4r0)%FYLW`o>$`CSR|w89Pu}%ua}4bM0@vq{_qk`9ALx&aq#AR!S|Ao7r(Q9(s}uA qoyrEl3Akq$op9nKMtmgR&zHB~62kYV_+?`>g%H55oe~3op7aZwCq?G~ delta 556 zcmaixJ8#oa0EK<62sIGfsaT*zC`iqi$k%U2Lc+0=5+|vhN1ew&NSsGwCw3lA^H`cF z5;IJm*^rp3N@e30urZdQ;*UUDSP{#aKAj_dXMG!7-v-|w0{6o+8Mv2kKmK}zAP9O^&p?6y=>y$(HRkTYXEkAmhY4>cX&;sW!KyLbB879}k9nW6Zc*d8l{>-%>MD zDO(rD%#5*5dn19Wryy`lqh9g(hY(7=D?3Jt($0b|o7N}!WKN-r&f}Ba4ww6z2 zR`qtb%1V=Y>SRVH;MgJCy#$rcBk+ diff --git a/filme/forms.py b/filme/forms.py index 36d24dd..a26e17d 100644 --- a/filme/forms.py +++ b/filme/forms.py @@ -15,7 +15,7 @@ class CustomLoginForm(AuthenticationForm): def clean_username(self): username = self.cleaned_data.get('username') # Exemplo de validação simples de formato de email: - if not username.endswith('@'): + if '@' not in username: raise forms.ValidationError( 'Este campo deve ser um email válido.') return username diff --git a/filme/templates/editarperfil.html b/filme/templates/editarperfil.html index b0e6230..c9f8096 100644 --- a/filme/templates/editarperfil.html +++ b/filme/templates/editarperfil.html @@ -11,7 +11,69 @@ {% block content %}
-

Edição do Perfil

+
+
+
+ Edição de Perfil

{{ user.username }}

+
+ +
+ {% csrf_token %} + + {% if 'editarperfil' in request.path %} +
+ +
+
+ +
+
+ +
+ + {% else %} +
+ {% if form.old_password.errors %} + +
+ {% for erro in form.old_password.errors %} + {{ erro }} + {% endfor %} +
+ {% else %} + + {% endif %} +
+
+ + {{ form.new_password1.help_text }} +
+
+ {% if form.new_password2.errors %} + +
+ {% for erro in form.new_password2.errors %} + {{ erro }} + {% endfor %} +
+ {% else %} + + {% endif %} +
+ {% endif %} + + {% if 'editarperfil' in request.path %} + Quer mudar sua senha? + {% endif %} +
+ +
+
+ +
+
{% endblock %} diff --git a/filme/urls.py b/filme/urls.py index 7ca2578..bb0abe4 100644 --- a/filme/urls.py +++ b/filme/urls.py @@ -1,4 +1,4 @@ -from django.urls import path, include +from django.urls import path, reverse_lazy from .views import Homepage, HomeFilmes, DetalhesFilme, PesquisaFilme, EditarPerfil, CriarConta, CustomLoginView from django.contrib.auth import views as auth_view @@ -15,6 +15,8 @@ template_name='login.html'), name='login'), path('logout/', auth_view.LogoutView.as_view( template_name='logout.html'), name='logout'), - path('editarperfil/', EditarPerfil.as_view(), name='editarperfil'), + path('editarperfil/', EditarPerfil.as_view(), name='editarperfil'), + path('alterarsenha/', + auth_view.PasswordChangeView.as_view(template_name='editarperfil.html', success_url=reverse_lazy('filme:homefilmes')), name='alterarsenha'), path('criarconta/', CriarConta.as_view(), name='criarconta'), ] diff --git a/filme/views.py b/filme/views.py index 100ab1c..656ce32 100644 --- a/filme/views.py +++ b/filme/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render, redirect, reverse from .models import Filme, Usuario -from django.views.generic import TemplateView, ListView, DetailView, FormView +from django.views.generic import TemplateView, ListView, DetailView, FormView, UpdateView from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.views import LoginView from .forms import CustomLoginForm, CriarContaForm, FormHomepage @@ -76,8 +76,15 @@ def get_queryset(self): return None -class EditarPerfil(LoginRequiredMixin, TemplateView): +class EditarPerfil(LoginRequiredMixin, UpdateView): template_name = 'editarperfil.html' + model = Usuario + # Irá criar um form com os fields definidos na lista + fields = ['first_name', 'last_name', 'email'] + + # Assim que editar será redirecionado para homefilmes + def get_success_url(self): + return reverse('filme:homefilmes') class CriarConta(FormView): diff --git a/static/css/style_criarconta.css b/static/css/style_criarconta.css index 84d18eb..00d6ac6 100644 --- a/static/css/style_criarconta.css +++ b/static/css/style_criarconta.css @@ -27,7 +27,7 @@ .content-form { width: 30rem; - height: 40rem; + height: auto; background-color: rgb(0, 0, 0, 0.5); display: flex; flex-direction: column; @@ -91,7 +91,6 @@ } - .is-invalid { border: 1px solid rgb(255, 0, 0) !important; } diff --git a/static/css/style_editarperfil.css b/static/css/style_editarperfil.css index 837af4f..21822e3 100644 --- a/static/css/style_editarperfil.css +++ b/static/css/style_editarperfil.css @@ -1,4 +1,103 @@ -.content{ - padding-top: 4.68rem; - min-height: 100vh; +@import url("https://fonts.googleapis.com/css2?family=Montserrat&family=Roboto:wght@500&display=swap"); + +.header { + min-height: 100vh; + position: relative; /* Adicione uma posição relativa para que possamos posicionar o pseudo-elemento */ + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} + +.header::before { + content: ""; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-image: url("../images/background_netflix.jpg"); + background-repeat: no-repeat; + background-blend-mode: overlay; + background-size: cover; /* Ajuste para cobrir todo o cabeçalho */ + background-color: rgb(0, 0, 0, 0.7); + opacity: 0.7; /* Opacidade para a imagem de fundo */ + z-index: -1; /* Coloque o pseudo-elemento atrás do conteúdo */ +} + +.content-form { + width: 30rem; + height: auto; + background-color: rgb(0, 0, 0, 0.5); + display: flex; + flex-direction: column; +} + +.form-editarperfil { + display: flex; + flex-direction: column; + justify-content: center; + padding: 2rem 4rem; + gap: 1rem; +} + +.title-form { + font-family: "Montserrat", sans-serif; + color: rgb(255, 255, 255); + font: 2rem bold; + padding-left: 4.5rem; + padding-top: 2rem; +} + +.form-editarperfil input { + height: 3rem; + padding-left: 0.8rem; + border-radius: 0.3rem; + outline: none; + border: 1px rgb(204, 204, 204); + background-color: #313235; + color: hsl(0, 0%, 100%); +} + +.form-editarperfil button { + height: 3rem; + border-radius: 0.3rem; + outline: none; + margin: auto; + width: 90%; + background-color: rgb(255, 0, 0); + border: transparent; + color: hsl(0, 0%, 100%); + text-align: center; + font-weight: bold; + transition: background-color -3s ease; +} + +.form-editarperfil button:hover { + background-color: rgb(189, 8, 8); + cursor: pointer; +} + +.form-editarperfil small { + text-align: center; +} + +.form-editarperfil ul { + list-style-type: none; /* Retira o simbolo da lista */ +} + +.form-group { + display: flex; + flex-direction: column; + justify-content: center; +} + +.is-invalid { + border: 1px solid rgb(255, 0, 0) !important; +} + +.invalid-feedback { + outline: none; + font-size: 0.8rem; + color: rgb(255, 0, 0); } diff --git a/static/css/style_login.css b/static/css/style_login.css index 191e1bf..b696409 100644 --- a/static/css/style_login.css +++ b/static/css/style_login.css @@ -27,7 +27,7 @@ .content-form { width: 30rem; - height: 35rem; + height: auto; background-color: rgb(0, 0, 0, 0.5); display: flex; flex-direction: column; @@ -95,6 +95,7 @@ .inscrever p { text-decoration: underline; color: rgb(197, 82, 66); + padding-bottom: 2rem; } .is-invalid { diff --git a/templates/navbar.html b/templates/navbar.html index 8c696b6..49b8f84 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -24,7 +24,7 @@ {% endif %} {% if user.is_authenticated %} {% endif %}