-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: form login criar conta validacoes
- Loading branch information
1 parent
0de47c1
commit 2392de9
Showing
12 changed files
with
412 additions
and
21 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django import forms | ||
from django.contrib.auth.forms import AuthenticationForm | ||
from django.contrib.auth.forms import UserCreationForm | ||
from .models import Usuario | ||
|
||
|
||
class FormHomepage(forms.Form): | ||
email = forms.EmailField(label=False) | ||
|
||
|
||
class CustomLoginForm(AuthenticationForm): | ||
username = forms.EmailField(required=True, widget=forms.TextInput( | ||
attrs={'placeholder': 'Email'})) | ||
|
||
def clean_username(self): | ||
username = self.cleaned_data.get('username') | ||
# Exemplo de validação simples de formato de email: | ||
if not username.endswith('@'): | ||
raise forms.ValidationError( | ||
'Este campo deve ser um email válido.') | ||
return username | ||
|
||
|
||
class CriarContaForm(UserCreationForm): | ||
# se o campo não for obrigatório dentro dos parenteses incluir (required=False) | ||
email = forms.EmailField() | ||
|
||
class Meta: # Quando se cria um UserCreationForm ele espera uma class Meta indicando qual o modelo ele ira se basear | ||
model = Usuario | ||
fields = ('username', 'email', 'password1', 'password2') | ||
|
||
def clean_email(self): | ||
email = self.cleaned_data.get('email') | ||
if Usuario.objects.filter(email=email).exists(): | ||
raise forms.ValidationError( | ||
'Já existe uma conta com este e-mail.' | ||
) | ||
return email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,103 @@ | ||
.content { | ||
padding-top: 4.68rem; | ||
@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: 40rem; | ||
background-color: rgb(0, 0, 0, 0.5); | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.form-criarconta { | ||
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.9rem; | ||
padding-top: 2rem; | ||
} | ||
|
||
.form-criarconta 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-criarconta button { | ||
height: 3rem; | ||
border-radius: 0.3rem; | ||
outline: none; | ||
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-criarconta button:hover { | ||
background-color: rgb(189, 8, 8); | ||
cursor: pointer; | ||
} | ||
|
||
.form-criarconta small { | ||
} | ||
|
||
.form-criarconta 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); | ||
} |
Oops, something went wrong.