Merge branch 'master' of git://hammerboy.no-ip.org/eventmanager
authorwww-data <www-data@mail.holoscopio.com>
Thu, 27 Sep 2007 16:08:22 +0000 (13:08 -0300)
committerwww-data <www-data@mail.holoscopio.com>
Thu, 27 Sep 2007 16:08:22 +0000 (13:08 -0300)
__init__.py
eventos/models.py
forms.py
media/css/geral.css
templates/base.html
templates/editar_palestrante.html [deleted file]
templates/editar_usuario.html [new file with mode: 0644]
templates/inscricao.html
views.py

index fc9c155..ebf8a9b 100644 (file)
@@ -1,3 +1,22 @@
+"""
+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
index e698eab..eeae7a5 100644 (file)
@@ -96,10 +96,11 @@ class Participante(models.Model):
     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
@@ -166,7 +167,7 @@ class Trabalho(models.Model):
 
     class Admin:
         fields = (
-            (None, {'fields': ('titulo', 'evento', 'categoria',
+            (None, {'fields': ('titulo', 'evento', 'categoria', 'tipo',
                 'palestrante', 'descricao_curta', 'descricao_longa',
                 'recursos')}),
         )
index f89c3c7..1f10f13 100644 (file)
--- a/forms.py
+++ b/forms.py
@@ -142,6 +142,15 @@ class InscricaoBase(LoginBase):
 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',
index 2b4ca86..3561423 100644 (file)
@@ -117,7 +117,8 @@ div#patrocinio table {
     color: #666;\r
 }\r
 \r
-#cadastro p textarea {\r
+#cadastro p textarea,\r
+#cadastro p input[type=text] {\r
     width: 100%;\r
 }\r
 \r
@@ -149,3 +150,7 @@ div#patrocinio table {
 .errorlist {\r
     color: red;\r
 }\r
+\r
+#info-preco li {\r
+    padding: 3px; 0px 3px 0px;\r
+}\r
index 3d5ecd0..bcf58f1 100644 (file)
 
             <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>
diff --git a/templates/editar_palestrante.html b/templates/editar_palestrante.html
deleted file mode 100644 (file)
index b92c0ec..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-{% 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 %}
diff --git a/templates/editar_usuario.html b/templates/editar_usuario.html
new file mode 100644 (file)
index 0000000..d42402c
--- /dev/null
@@ -0,0 +1,21 @@
+{% 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 %}
index 41cc24b..271fad8 100644 (file)
@@ -3,6 +3,20 @@
 
 <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>
 
index 4208dfa..077786f 100644 (file)
--- a/views.py
+++ b/views.py
@@ -168,6 +168,7 @@ def inscricao_individual(request):
         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'])
@@ -209,6 +210,7 @@ def inscricao_caravana(request):
         p.telefone = cd['telefone']
         p.home_page = cd['home_page']
         p.comercial = False # yeah, always false!
+        p.cpf_cnpj = ''
         p.save()
 
         c = Caravana()
@@ -375,22 +377,24 @@ def editar_trabalho(request, codigo):
 
 @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