22
33from django import forms
44
5- from .models import Refund , Proposal
5+ from .models import Proposal , Refund
66
77UUID_LAST_DIGITS = 12
88
99
1010class ProposalForm (forms .ModelForm ):
11-
1211 class Meta :
1312 model = Proposal
1413 fields = [
15- ' name' ,
16- ' surname' ,
17- ' email' ,
18- ' title' ,
19- ' description' ,
14+ " name" ,
15+ " surname" ,
16+ " email" ,
17+ " title" ,
18+ " description" ,
2019 ]
2120
2221 def __init__ (self , event , * args , ** kwargs ):
2322 super ().__init__ (* args , ** kwargs )
24- self .fields ["name" ].widget .attrs .update ({'id' : 'cfp-name' , 'size' : '20' ,
25- 'placeholder' : 'Tu nombre' })
26- self .fields ["surname" ].widget .attrs .update ({'id' : 'cfp-surname' , 'size' : '40' ,
27- 'placeholder' : 'Tus apellidos' })
28- self .fields ["email" ].widget .attrs .update ({
29- 'id' : 'cfp-email' ,
30- 'size' : '40' ,
31- 'placeholder' : 'Tu email'
32- })
33- self .fields ["title" ].widget .attrs .update ({
34- 'id' : 'cfp-title' ,
35- 'size' : '60' ,
36- 'placeholder' : 'El título de tu maravillosa charla' })
37- self .fields ["description" ].widget .attrs .update ({'id' : 'cfp-title' ,
38- 'cols' : '60' , 'rows' : '20' })
23+ self .fields ["name" ].widget .attrs .update (
24+ {
25+ "id" : "cfp-name" ,
26+ "size" : "20" ,
27+ "placeholder" : "Tu nombre" ,
28+ "class" : "input is-rounded" ,
29+ }
30+ )
31+ self .fields ["surname" ].widget .attrs .update (
32+ {
33+ "id" : "cfp-surname" ,
34+ "size" : "40" ,
35+ "placeholder" : "Tus apellidos" ,
36+ "class" : "input is-rounded" ,
37+ }
38+ )
39+ self .fields ["email" ].widget .attrs .update (
40+ {
41+ "id" : "cfp-email" ,
42+ "size" : "40" ,
43+ "placeholder" : "Tu email" ,
44+ "class" : "input is-rounded" ,
45+ }
46+ )
47+ self .fields ["title" ].widget .attrs .update (
48+ {
49+ "id" : "cfp-title" ,
50+ "size" : "60" ,
51+ "placeholder" : "El título de tu maravillosa charla" ,
52+ "class" : "input is-rounded" ,
53+ }
54+ )
55+ self .fields ["description" ].widget .attrs .update (
56+ {
57+ "id" : "cfp-title" ,
58+ "cols" : "60" ,
59+ "rows" : "20" ,
60+ "class" : "textarea" ,
61+ }
62+ )
3963 self .event = event
4064
4165 def save (self ):
@@ -46,51 +70,50 @@ def save(self):
4670
4771
4872class EmailForm (forms .Form ):
49- email = forms .EmailField (label = ' Tu email' , max_length = 192 )
73+ email = forms .EmailField (label = " Tu email" , max_length = 192 )
5074
5175
5276class WaitingListForm (forms .Form ):
53- email = forms .EmailField (label = ' Tu email' , max_length = 192 )
54- name = forms .CharField (label = ' Nombre' , max_length = 256 )
55- surname = forms .CharField (label = ' Apellidos' , max_length = 256 )
56- phone = forms .CharField (label = ' Teléfono' , max_length = 32 )
77+ email = forms .EmailField (label = " Tu email" , max_length = 192 )
78+ name = forms .CharField (label = " Nombre" , max_length = 256 )
79+ surname = forms .CharField (label = " Apellidos" , max_length = 256 )
80+ phone = forms .CharField (label = " Teléfono" , max_length = 32 )
5781
5882
5983class RefundForm (forms .Form ):
60- email = forms .EmailField (label = ' Tu email' , max_length = 192 )
84+ email = forms .EmailField (label = " Tu email" , max_length = 192 )
6185 uuid = forms .CharField ()
6286
6387 def __init__ (self , event , * args , ** kwargs ):
64- logging .error (' Llamada al metodo __init__ de RefundForm' )
88+ logging .error (" Llamada al metodo __init__ de RefundForm" )
6589 super ().__init__ (* args , ** kwargs )
6690 self .event = event
6791
6892 def clean_uuid (self ):
6993 email = self .cleaned_data ["email" ]
7094 uuid = self .cleaned_data ["uuid" ]
71- if uuid == ' tu puta madre' :
72- raise forms .ValidationError (' Cuida ese vocabulario' )
95+ if uuid == " tu puta madre" :
96+ raise forms .ValidationError (" Cuida ese vocabulario" )
7397
7498 if len (uuid ) < UUID_LAST_DIGITS :
7599 raise forms .ValidationError (
76- ' Necesito los últimos () letras o dígitos '
77- ' del código' .format (UUID_LAST_DIGITS )
78- )
100+ " Necesito los últimos () letras o dígitos "
101+ " del código" .format (UUID_LAST_DIGITS )
102+ )
79103 uuid = uuid [- UUID_LAST_DIGITS :]
80104 tickets = list (
81105 self .event .all_tickets ()
82106 .filter (customer_email = email )
83107 .filter (keycode__iendswith = uuid )
84- )
108+ )
85109 if len (tickets ) != 1 :
86110 raise forms .ValidationError (
87- ' El correo o las últimos {} letras o dígitos del'
88- ' codigo están mal.' .format (UUID_LAST_DIGITS )
89- )
111+ " El correo o las últimos {} letras o dígitos del"
112+ " codigo están mal." .format (UUID_LAST_DIGITS )
113+ )
90114 self .ticket = tickets [0 ]
91115 if Refund .exists (self .event , self .ticket ):
92116 raise forms .ValidationError (
93- 'Ya se ha solicitado una devolución del'
94- ' importe para ese ticket'
95- )
117+ "Ya se ha solicitado una devolución del" " importe para ese ticket"
118+ )
96119 return uuid
0 commit comments