+"""
+Copyright (C) 2007 Lincoln de Sousa <lincoln@archlinux-br.org>
+Copyright (C) 2007 Douglas Andrade <douglas@archlinux-br.org>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with this program; if not, write to the
+Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+"""
def initialize():
from eventos.models import Evento
from datetime import datetime
cidade = models.CharField(maxlength=100)
uf = models.CharField(maxlength=3)
cep = models.CharField(maxlength=8)
- usuario = models.ForeignKey(User)
+ cpf_cnpj = models.CharField(maxlength=20, blank=True)
comercial = models.BooleanField(default=False)
- refbanco = models.IntegerField()
+ usuario = models.ForeignKey(User)
+ refbanco = models.IntegerField(editable=False)
class Admin:
pass
class Admin:
fields = (
- (None, {'fields': ('titulo', 'evento', 'categoria',
+ (None, {'fields': ('titulo', 'evento', 'categoria', 'tipo',
'palestrante', 'descricao_curta', 'descricao_longa',
'recursos')}),
)
class Inscricao(InscricaoBase):
inscricao_comercial = forms.BooleanField(required=False,
label='Inscrição Comercial')
+ cpf_cnpj = forms.CharField(max_length=20, required=False, label='CPF/CNPJ',
+ help_text='Somente necessário para a inscrição comercial')
+
+ def clean_cpf_cnpj(self):
+ cpf_cnpj = self.cleaned_data['cpf_cnpj']
+ if self.cleaned_data['inscricao_comercial'] and not cpf_cnpj:
+ raise ValidationError('Você escolheu a inscrição comercial, '
+ 'portanto este campo se torna obrigatório')
+ return cpf_cnpj
class InscricaoCaravana(InscricaoBase):
lista_nomes = forms.CharField(label='Lista de nomes',
color: #666;\r
}\r
\r
-#cadastro p textarea {\r
+#cadastro p textarea,\r
+#cadastro p input[type=text] {\r
width: 100%;\r
}\r
\r
.errorlist {\r
color: red;\r
}\r
+\r
+#info-preco li {\r
+ padding: 3px; 0px 3px 0px;\r
+}\r
<form id="menu-palestrante">
<ul>
+ <li><a href="/meus_dados">Editar dados de usuário</a></li>
+
{% if user.palestrante_set.all %}
<li><a href="/submeter_trabalho">Submeter Trabalho</a></li>
<li><a href="/meus_trabalhos">Trabalhos inscritos</a></li>
- <li><a href="/meus_dados">Editar dados de usuário</a></li>
{% else %}
- <li><a href="/boleto">Emitir boleto</a></li>
+
+ {% if user.participante_set.all %}
+ <li><a href="/boleto">Emitir boleto</a></li>
+ {% endif %}
+
{% endif %}
<li><a href="/logout">Sair ({{ user }})</a></li>
+++ /dev/null
-{% extends "base.html" %}
-{% block content %}
-
-<h2>Editar Palestrante</h2>
-
-{% if ok %}
-
-<div class="confirmation">
- <p>Seus dados foram editados com sucesso!</p>
-</div>
-
-{% else %}
-
-<form id="cadastro" method="post" action=".">
- {{ form.as_p }}
- <input type="submit" value="Salvar" />
-</form>
-
-{% endif %}
-
-{% endblock %}
--- /dev/null
+{% extends "base.html" %}
+{% block content %}
+
+<h2>Editar {{ title }}</h2>
+
+{% if ok %}
+
+<div class="confirmation">
+ <p>Seus dados foram editados com sucesso!</p>
+</div>
+
+{% else %}
+
+<form id="cadastro" method="post" action=".">
+ {{ form.as_p }}
+ <input type="submit" value="Salvar" />
+</form>
+
+{% endif %}
+
+{% endblock %}
<h2>Inscrição</h2>
+<h3>Informações</h3>
+<ul id="info-preco">
+ <li><strong>Inscrição individual</strong> até o dia 12/10/2007 R$ 35,00
+ e no local R$50,00</li>
+
+ <li><strong>Inscrição individual comercial</strong> até o dia
+ 12/10/2007 e no local R$ 80,00</li>
+
+ <li><strong>Inscrição de caravanas</strong> até o dia 09/10/2007: R$ 25,00
+ por pessoa (mínimo de 10 pessoas por caravana)</li>
+</ul>
+
+<br />
+
<h3><a href="/inscricao_individual">Inscrição Individual</a></h3>
<h3><a href="/inscricao_caravana">Inscrição de Caravana</a></h3>
p.telefone = cd['telefone']
p.home_page = cd['home_page']
p.comercial = cd['inscricao_comercial']
+ p.cpf_cnpj = cd['cpf_cnpj']
p.save()
u = authenticate(username=cd['nome_usuario'], password=cd['senha'])
p.telefone = cd['telefone']
p.home_page = cd['home_page']
p.comercial = False # yeah, always false!
+ p.cpf_cnpj = ''
p.save()
c = Caravana()
@login_required
def meus_dados(request):
- form = EditarPalestrante(request.POST or None)
- palestrante = request.user.palestrante_set.get()
- ok = False
+ try:
+ entity = request.user.palestrante_set.get()
+ except Palestrante.DoesNotExist:
+ entity = request.user.participante_set.get()
+
+ FormKlass = form_for_instance(entity)
- for name, field in form.fields.items():
- field.initial = getattr(palestrante, name)
+ # ugly hammer to hide some fields...
+ del FormKlass.base_fields['usuario']
+ ok = False
+ form = FormKlass(request.POST or None)
if request.POST and form.is_valid():
- cd = form.cleaned_data
- for name, field in form.fields.items():
- setattr(palestrante, name, cd[name])
- palestrante.save()
+ form.save()
ok = True
- c = {'form': form, 'ok': ok}
- return build_response(request, 'editar_palestrante.html', c)
+ c = {'form': form, 'ok': ok, 'title': entity.__class__.__name__}
+ return build_response(request, 'editar_usuario.html', c)
@enable_login_form