Skip to content

Commit

Permalink
adiciona template method gof
Browse files Browse the repository at this point in the history
Co-authored-by: WillAllmeida <will.allmeida@gmail.com>
Co-authored-by: aquiles23 <jjoseaquiless@gmail.com>
Co-authored-by: jpmota2208 <jpmota.unb@gmail.com>
Co-authored-by: igorveludo <velvet.guimaraes@gmail.com>
Co-authored-by: byronkamal <byronkamal@hotmail.com>
  • Loading branch information
6 people committed May 27, 2019
1 parent 51841af commit d7a1ec6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/usuario/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
from django import forms
from django.contrib.auth.models import User
from usuario.models import Usuario
from django.contrib.auth.forms import UserCreationForm, UserChangeForm

class UsuarioChangeForm(UserCreationForm):

password1 = forms.CharField(widget=forms.PasswordInput())
password2 = forms.CharField(widget=forms.PasswordInput())
username = forms.CharField()
email = forms.CharField(
error_messages={'required': 'Este campo é obrigatório! Preencha este campo com a marca do produto.'},
widget=forms.TextInput(
attrs={
'class' : 'form-control',
'placeholder' : 'Email',
}
)
)

name = forms.CharField(
error_messages={'required': 'Este campo é obrigatório! Preencha este campo com a descrição do produto.'},
widget=forms.TextInput(
attrs={
'class' : 'form-control',
'placeholder' : 'Nome',
}
)
)

class Meta():
model = User
fields = ('username','email','name','password', 'password2')

def __init__(self, *args, **kwargs):
super(CustomUserCreationForm, self).__init__(*args, **kwargs)
self.fields['password1'].label = "Senha"
self.fields['password2'].label = "Confirmar Senha"
self.fields['name'].label = "Nome"

def save(self, commit=True):
instance = super(CustomUserCreationForm, self).save(commit=False)
if commit:
instance.save()
return instance

class UsuarioForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
Expand Down

0 comments on commit d7a1ec6

Please sign in to comment.