1 # -*- mode: python; encoding: utf-8; -*-
3 # Copyright 2013 Thadeu Lima de Souza Cascardo <cascardo@cascardo.info>
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 class OcupacaoForm(baseui.OptionsForm):
24 def __init__(self, ocupacoes, contribuinte):
25 g = ocupacoes.groups()
29 o = map(lambda x: (x[0], x[3]), l)
30 baseui.OptionsForm.__init__(self, u"Ocupações", o, contribuinte.get_campo_contribuinte("ocupacaoPrincipal"))
31 self.ocupacoes = ocupacoes
32 self.contribuinte = contribuinte
33 def set_value(self, value):
34 baseui.OptionsForm.set_value(self, value)
35 self.contribuinte.set_campo_contribuinte("ocupacaoPrincipal", value)
37 class ContribuinteForm(baseui.StringForm):
38 def __init__(self, name, attr, contribuinte):
39 self.contribuinte = contribuinte
41 baseui.StringForm.__init__(self, name, self.contribuinte.get_campo_contribuinte(self.attr))
42 def set_value(self, value):
43 baseui.StringForm.set_value(self, value)
44 self.contribuinte.set_campo_contribuinte(self.attr, value)
46 def DadosPessoais(UI, contrib):
48 ocup = ocupacoes.Ocupacoes()
49 form.append(ContribuinteForm("Nome", "nome", contrib))
50 form.append(OcupacaoForm(ocup, contrib))
51 for i in contribuinte.contribuinte_attributes:
52 form.append(ContribuinteForm(i, i, contrib))
56 def menu(UI, contrib):
57 m = [ "Sair", "Dados Pessoais" ]
58 f = [ None, DadosPessoais ]
71 cpf = UI.get_string("Digite seu CPF: ")
73 contrib = contribuinte.Contribuinte(cpf)
74 ret = menu(UI, contrib)
75 except RuntimeError, e:
78 if __name__ == '__main__':
81 # vim:tabstop=4:expandtab:smartindent