Merge lp:~bellini666/stoq/boleto_corrections into lp:~stoq-dev/stoq/master

Proposed by Thiago Bellini
Status: Merged
Merged at revision: 4988
Proposed branch: lp:~bellini666/stoq/boleto_corrections
Merge into: lp:~stoq-dev/stoq/master
Diff against target: 216 lines (+49/-43)
2 files modified
stoqlib/gui/editors/accounteditor.py (+10/-5)
stoqlib/lib/boleto.py (+39/-38)
To merge this branch: bzr merge lp:~bellini666/stoq/boleto_corrections
Reviewer Review Type Date Requested Status
Ronaldo Maia Approve
Review via email: mp+91321@code.launchpad.net

Description of the change

Colocando strings para tradução. Algumas estavam mal escritas, é uma oportunidade para traduzir certo inclusive.

Arrumado a validação de campos custom no editor de contas do financial.

Remoção do 'len_convenio' do BB.

To post a comment you must log in.
Revision history for this message
Ronaldo Maia (romaia) wrote :

131 - u'Tamanho do numero maior que o permitido')
132 + _('Number length must be less than %s') % tamanho)

Lower em vez de less.

61 if len(list_sacado) > 3:
62 - raise BoletoException(u'Número de linhas do sacado maior que 3')
65 for line in list_sacado:
66 if len(line) > 80:
67 raise BoletoException(

Em vez de levantar os errors, trunca os valores: pega só list_sacado[:3] e para cada linha, só line[:80]

Dessa forma não vai dar erro se o nome do cliente for muito grande.

Aprovado com essas mudanças.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stoqlib/gui/editors/accounteditor.py'
2--- stoqlib/gui/editors/accounteditor.py 2012-01-25 11:33:24 +0000
3+++ stoqlib/gui/editors/accounteditor.py 2012-02-02 18:10:27 +0000
4@@ -261,10 +261,13 @@
5 entry = ProxyEntry()
6 entry.model_attribute = name
7 setattr(self, name, entry)
8+ # Set the model attr too so it can be validated
9+ setattr(self.bank_model, name, '')
10 entry.props.data_type = 'str'
11 entry.connect('validate', self._on_bank_option__validate,
12 bank_info, option)
13- self._add_widget("<i>%s</i>:" % (option, ), entry, options=True)
14+ self._add_widget("<i>%s</i>:" % (option.capitalize(), ),
15+ entry, options=True)
16 entry.show()
17 self._option_fields[option] = entry
18 attributes.append(entry.model_attribute)
19@@ -407,10 +410,12 @@
20 return ValidationError(str(e))
21
22 def _on_bank_option__validate(self, entry, value, bank_info, option):
23- try:
24- bank_info.validate_option(option, value)
25- except BoletoException, e:
26- return ValidationError(str(e))
27+ # Only validate if there's a value. Maybe it's not mandatory
28+ if value:
29+ try:
30+ bank_info.validate_option(option, value)
31+ except BoletoException, e:
32+ return ValidationError(str(e))
33 self.bank_model.set_option(option, value)
34
35 def _on_test_button__clicked(self, button):
36
37=== modified file 'stoqlib/lib/boleto.py'
38--- stoqlib/lib/boleto.py 2012-01-23 16:52:45 +0000
39+++ stoqlib/lib/boleto.py 2012-02-02 18:10:27 +0000
40@@ -64,7 +64,7 @@
41 setattr(self, internal_attr, '-'.join(val))
42
43 else:
44- raise BoletoException('Wrong value format')
45+ raise BoletoException(_('Wrong value format'))
46
47 return property(
48 lambda self: getattr(self, internal_attr),
49@@ -147,7 +147,7 @@
50 num = num.replace('X', str(dv), 1)
51 if len(num) != 44:
52 raise BoletoException(
53- 'Código com %d caracteres' % len(num))
54+ _('The barcode must have 44 caracteres, found %d') % len(num))
55 return num
56
57 @property
58@@ -243,11 +243,12 @@
59
60 def _sacado_set(self, list_sacado):
61 if len(list_sacado) > 3:
62- raise BoletoException(u'Número de linhas do sacado maior que 3')
63+ raise BoletoException(
64+ _('The drawee number of lines must be less than 3'))
65 for line in list_sacado:
66 if len(line) > 80:
67 raise BoletoException(
68- u'Linha de sacado possui mais que 80 caracteres')
69+ _('The drawee lines must have less than 80 characters'))
70 self._sacado = list_sacado
71 sacado = property(_sacado_get, _sacado_set)
72
73@@ -306,25 +307,20 @@
74 @classmethod
75 def validate_field(cls, field, dv_10=None, func=None):
76 if ' ' in field:
77- raise BoletoException(
78- u'Campo não pode ter espaços')
79+ raise BoletoException(_('The field cannot have spaces'))
80 if '.' in field or ',' in field:
81- raise BoletoException(
82- u'Campo não pode ter pontos ou virgulas')
83+ raise BoletoException(_('The field cannot have dots of commas'))
84 dv = None
85 if '-' in field:
86 if field.count('-') != 1:
87- raise BoletoException(
88- u'Só pode ter um hífen')
89+ raise BoletoException(_('More than one hyphen found'))
90 field, dv = field.split('-', 1)
91 if not dv:
92- raise BoletoException(
93- u'Digito verificador não pode ser vazio')
94+ raise BoletoException(_('Verifier digit cannot be empty'))
95 try:
96 int(field)
97 except ValueError:
98- raise BoletoException(
99- u'Conta precisa ser um número')
100+ raise BoletoException(_('Account needs to be a number'))
101
102 if dv and dv_10 is not None:
103 func = cls.validate_field_func
104@@ -343,19 +339,16 @@
105 elif (ret is not None and
106 str(ret) != dv.lower() and
107 ret < 10):
108- raise BoletoException(
109- u'Dígito verificador invalido')
110+ raise BoletoException(_('Invalid verifier digit'))
111 else:
112 try:
113 dv = int(dv)
114 except ValueError:
115 raise BoletoException(
116- u'Dígito verificador tem que ser um número ou %s' % (
117- dv_10))
118+ _('Verifier digit must be a number or %s') % dv_10)
119
120 if ret is not None and ret != dv:
121- raise BoletoException(
122- u'Dígito verificador invalido')
123+ raise BoletoException(_('Invalid verifier digit'))
124
125 @classmethod
126 def validate_option(cls, option, value):
127@@ -365,14 +358,14 @@
128 def formata_numero(numero, tamanho):
129 if len(numero) > tamanho:
130 raise BoletoException(
131- u'Tamanho do numero maior que o permitido')
132+ _('Number length must be less than %s') % tamanho)
133 return numero.zfill(tamanho)
134
135 @staticmethod
136 def formata_texto(texto, tamanho):
137 if len(texto) > tamanho:
138 raise BoletoException(
139- u'Tamanho do texto maior que o permitido')
140+ _('Text length must be less than %s') % tamanho)
141 return texto.ljust(tamanho)
142
143 @staticmethod
144@@ -568,11 +561,16 @@
145 try:
146 value = int(value)
147 except ValueError:
148- raise BoletoException("carteira tem que ser um número")
149+ # TRANSLATORS: Do not translate 'Carteira'
150+ raise BoletoException(_("Carteira must be a number"))
151 if 0 > value:
152- raise BoletoException("carteira tem que ser entre 0 e 99")
153+ raise BoletoException(
154+ # TRANSLATORS: Do not translate 'Carteira'
155+ _("Carteira must be a number between 0 and 99"))
156 if value > 99:
157- raise BoletoException("carteira tem que ser entre 0 e 99")
158+ raise BoletoException(
159+ # TRANSLATORS: Do not translate 'Carteira'
160+ _("Carteira must be a number between 0 and 99"))
161
162
163 @register_bank
164@@ -581,7 +579,6 @@
165 bank_number = 1
166 logo = 'logo_bb.gif'
167 options = {'convenio': BILL_OPTION_CUSTOM,
168- 'len_convenio': BILL_OPTION_CUSTOM,
169 'agencia': BILL_OPTION_BANK_BRANCH,
170 'conta': BILL_OPTION_BANK_BRANCH}
171
172@@ -592,10 +589,13 @@
173 if not 'carteira' in kwargs:
174 kwargs['carteira'] = '18'
175
176- self.len_convenio = 7
177- if 'len_convenio' in kwargs:
178- self.len_convenio = int(kwargs.pop('len_convenio'))
179- self.convenio = ''
180+ convenio = kwargs.pop('convenio', None)
181+ if convenio:
182+ self.len_convenio = len(convenio)
183+ self.convenio = convenio
184+ else:
185+ self.len_convenio = 7
186+ self.convenio = ''
187
188 self.format_nnumero = 1
189 if 'format_nnumero' in kwargs:
190@@ -674,17 +674,18 @@
191 def validate_option(cls, option, value):
192 if option == 'convenio':
193 if value == '':
194- raise BoletoException('Convenio não pode ser vazio')
195+ # TRANSLATORS: Do not translate 'Convenio'
196+ raise BoletoException(_('Convenio cannot be empty'))
197 try:
198 int(value)
199 except ValueError:
200- raise BoletoException(_("Must be a number"))
201- if len(value) > 8:
202- raise BoletoException(_("Cannot be longer than %d") % (8,))
203-
204- if option == 'len_convenio':
205- if value not in ['6', '7', '8']:
206- raise BoletoException('Tem que ser 6, 7 ou 8')
207+ # TRANSLATORS: Do not translate 'Convenio'
208+ raise BoletoException(_("Convenio must be a number"))
209+ if len(value) not in [6, 7, 8]:
210+ raise BoletoException(
211+ # TRANSLATORS: Do not translate 'Convenio'
212+ _("Convenio length must be 6, 7 or 8. Try filing it with "
213+ "'0's at the left."))
214
215
216 @register_bank

Subscribers

People subscribed via source and target branches