From: www-data Date: Wed, 26 Sep 2007 05:15:32 +0000 (-0300) Subject: Merge git://hammerboy.no-ip.org/eventmanager X-Git-Url: http://git.cascardo.info/?p=cascardo%2Feventmanager.git;a=commitdiff_plain;h=221f9b712a6b693ac9593b7997fa63263d3e3ae9;hp=c821835265246633aa6736de9640d692b8b335f2 Merge git://hammerboy.no-ip.org/eventmanager Conflicts: forms.py settings.py templates/editar_trabalho.html templates/inscricao.html templates/meus_trabalhos.html views.py --- diff --git a/decorators.py b/decorators.py index 079a484..6918158 100644 --- a/decorators.py +++ b/decorators.py @@ -17,7 +17,10 @@ License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + Changes: + * Lincoln de Sousa (22 Jul 2007) adding is_login_form here. + """ from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth import login @@ -40,10 +43,9 @@ def enable_login_form(func): request.session.delete_test_cookie() except KeyError: pass + return HttpResponseRedirect('/') else: - # TODO: Notify the user that data sent is wrong. - msg = _('User name and Password doesn\'t match') - request.error_message = msg + return HttpResponseRedirect('/?login_failed') request.session.set_test_cookie() return func(request, *args, **kwargs) diff --git a/eventos/models.py b/eventos/models.py index eda0771..ffc4ebc 100644 --- a/eventos/models.py +++ b/eventos/models.py @@ -85,6 +85,20 @@ class Palestrante(models.Model): class Participante(models.Model): nome = models.CharField(maxlength=100) + email = models.CharField(maxlength=100) + rg = models.CharField(maxlength=100) + home_page = models.CharField(maxlength=100, blank=True) + + telefone = models.CharField(maxlength=100, blank=True) + rua = models.CharField(maxlength=100) + numero = models.CharField(maxlength=10) + bairro = models.CharField(maxlength=100) + cidade = models.CharField(maxlength=100) + uf = models.CharField(maxlength=3) + cep = models.CharField(maxlength=8) + usuario = models.ForeignKey(User) + + refbanco = models.IntegerField() class Admin: pass @@ -93,6 +107,24 @@ class Participante(models.Model): return self.nome +class Caravana(models.Model): + coordenador = models.ForeignKey(Participante) + participantes = models.TextField() + + class Admin: + pass + + def __str__(self): + return str(self.coordenador) + + def parsed_participantes(self): + real_data = [] + for i in self.participantes.split('\n'): + if i.strip(): + nome, email = i.rsplit(' ', 1) + real_data.append({'nome': nome, 'email': email}) + return real_data + class CategoriaTrabalho(models.Model): nome = models.CharField(maxlength=100) diff --git a/forms.py b/forms.py index 8dc99df..f89c3c7 100644 --- a/forms.py +++ b/forms.py @@ -18,13 +18,33 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. """ from django import newforms as forms -from django.newforms.widgets import Textarea, PasswordInput +from django.newforms import ValidationError +from django.newforms.widgets import Textarea, PasswordInput, HiddenInput +from django.contrib.auth.models import User from eventmanager.eventos.models import \ TipoTrabalho, CategoriaTrabalho, Palestrante, STATE_CHOICES MKCHOICES = lambda K, xid=-1:[(x.id, str(x)) for x in K.objects.all() \ if xid != x.id] +class LoginBase(forms.Form): + nome_usuario = forms.CharField(max_length=100) + senha = forms.CharField(max_length=100, widget=PasswordInput()) + senha_2 = forms.CharField(max_length=100, widget=PasswordInput(), + label='Conferir Senha') + + def clean_nome_usuario(self): + try: + User.objects.get(username=self.cleaned_data['nome_usuario']) + raise ValidationError('Já existe um usuário com esse nome') + except User.DoesNotExist: + return self.cleaned_data['nome_usuario'] + + def clean_senha_2(self): + if self.cleaned_data['senha'] != self.cleaned_data['senha_2']: + raise ValidationError('A confirmação não confere com a senha') + return self.cleaned_data['senha_2'] + class SubmeterTrabalho(forms.Form): def __init__(self, request, *args, **kwargs): super(SubmeterTrabalho, self).__init__(*args, **kwargs) @@ -52,12 +72,8 @@ class SubmeterTrabalho(forms.Form): 'ex.: Computadores, softwares, etc. Máximo de 300 caracteres.') outros_palestrantes = forms.MultipleChoiceField(required=0) -class CadastroPalestrante(forms.Form): +class CadastroPalestrante(LoginBase): nome_completo = forms.CharField(max_length=100) - nome_usuario = forms.CharField(max_length=100) - senha = forms.CharField(max_length=100, widget=PasswordInput()) - senha_2 = forms.CharField(max_length=100, widget=PasswordInput(), - label='Conferir Senha') email = forms.CharField(max_length=100) telefone = forms.CharField(required=False) @@ -65,10 +81,10 @@ class CadastroPalestrante(forms.Form): instituicao = forms.CharField(max_length=100, label='Instituição') minicurriculo = forms.CharField(widget=Textarea(), max_length=250, label='Mini Currículo', - help_text='Este mini currículo será utilizado no material de divulgação' - 'e no site. Máximo de 250 caracteres.') + help_text='Este mini currículo será utilizado no material de divulgação ' + 'e no sítio. Máximo de 250 caracteres.') curriculo = forms.CharField(widget=Textarea(), max_length=6000, label='Currículo', - help_text='Este currículo será utilizado para avaliação do palestrante.' + help_text='Este currículo será utilizado para avaliação do palestrante. ' 'Máximo de 6000 caracteres.') rua = forms.CharField(max_length=100) numero = forms.CharField(max_length=10, label='Número') @@ -76,6 +92,11 @@ class CadastroPalestrante(forms.Form): cidade = forms.CharField(max_length=100) uf = forms.ChoiceField(choices=STATE_CHOICES) + def clean_celular(self): + if not self.cleaned_data['telefone'] and \ + not self.cleaned_data['celular']: + raise ValidationError('Algum número de precisa ser preenchido') + return self.cleaned_data['celular'] class EditarPalestrante(forms.Form): nome = forms.CharField(max_length=100, label='Nome completo') @@ -97,22 +118,63 @@ class EditarPalestrante(forms.Form): cidade = forms.CharField(max_length=100) uf = forms.ChoiceField(choices=STATE_CHOICES) - class EditarSenha(forms.Form): senha_atual = forms.CharField(max_length=100, widget=PasswordInput()) nova_senha = forms.CharField(max_length=100, widget=PasswordInput()) nova_senha_2 = forms.CharField(max_length=100, widget=PasswordInput(), label='Conferir Senha') - -class Inscricao(forms.Form): +class InscricaoBase(LoginBase): nome_completo = forms.CharField(max_length=100) - cpf = forms.CharField(max_length=100) - email = forms.CharField(max_length=100) + rg = forms.CharField(max_length=100) + email = forms.CharField(max_length=100) rua = forms.CharField(max_length=100) numero = forms.CharField(max_length=10, label='Número') bairro = forms.CharField(max_length=100) cidade = forms.CharField(max_length=100) uf = forms.ChoiceField(choices=STATE_CHOICES) - + cep = forms.CharField(max_length=8, help_text='Somente números') + telefone = forms.CharField(max_length=100) + home_page = forms.CharField(max_length=100, label='Página Pessoal', + required=False) + +class Inscricao(InscricaoBase): + inscricao_comercial = forms.BooleanField(required=False, + label='Inscrição Comercial') + +class InscricaoCaravana(InscricaoBase): + lista_nomes = forms.CharField(label='Lista de nomes', + widget=forms.Textarea(), help_text='Um participante por linha, ' + 'informando nome completo e email no seguine formato: ' + 'Nome Completo <email@server.domain>') + + def clean_lista_nomes(self): + nomes = self.cleaned_data['lista_nomes'] + if len([x for x in nomes.split('\n') if x]) < 10: + raise ValidationError('A caravana precisa de pelo menos 10 ' + 'participantes.') + return nomes + +class Boleto(forms.Form): + # Field names are in mixedCase because of bb's sistem request =/ + idConv = forms.CharField(max_length=6, initial='303366', + widget=HiddenInput()) + refTran = forms.CharField(max_length=17, + widget=HiddenInput()) + tpPagamento = forms.CharField(max_length=2, initial='21', + widget=HiddenInput()) + valor = forms.CharField(max_length=15, widget=HiddenInput()) + dtVenc = forms.CharField(max_length=8, widget=HiddenInput()) + urlRetorno = forms.CharField(max_length=60, initial='/inscricao', + widget=HiddenInput()) + urlInforma = forms.CharField(max_length=60, initial='/inscricao', + widget=HiddenInput()) + nome = forms.CharField(max_length=60, widget=HiddenInput()) + endereco = forms.CharField(max_length=60, widget=HiddenInput()) + cidade = forms.CharField(max_length=18, widget=HiddenInput()) + uf = forms.CharField(max_length=2, widget=HiddenInput()) + cep = forms.CharField(max_length=8, widget=HiddenInput()) + msgLoja = forms.CharField(max_length=480, + initial='Nao receber apos a data de vencimento', + widget=HiddenInput()) diff --git a/get_data.py b/get_data.py new file mode 100755 index 0000000..8782d62 --- /dev/null +++ b/get_data.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# -*- coding: utf-8; -*- +""" +Copyright (C) 2007 Lincoln de Sousa + +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. +""" +import sys +import os + +if '-h' in sys.argv or '--help' in sys.argv: + print 'Usage: %s\n' \ + 'Script used to extract data from Trabalho and ' \ + 'Palestrante entities.' % sys.argv[0] + sys.exit(0) + +# hackish django setup... +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) +os.environ['DJANGO_SETTINGS_MODULE'] = 'eventmanager.settings' + +from eventos.models import * + +for i in Trabalho.objects.all(): + for j in i.palestrante.all(): + print i.titulo + ':' + j.nome + ':' + j.email diff --git a/media/css/geral.css b/media/css/geral.css index 4860a03..2b4ca86 100644 --- a/media/css/geral.css +++ b/media/css/geral.css @@ -1,165 +1,151 @@ -body { - margin: 0px; - background-color: #fff; - font-family: verdana,arial,helvetica,sans-serif; -} - -h1.title { - color: #f00; - background: url(/site_media/imgs/logo.png) no-repeat; - width: 471px; - height: 150px; - overflow: hidden; -} - -h1.title a { - display: block; - padding-top: 190px; -} - -h2 { - padding: 0px 0px 0px 0px; - margin: 0px; - text-transform: uppercase; - color: #cc0000; -} - -label { - display: block; - width: 180px; - font-weight: bold; - font-style: normal; - color: #000; -} - -em { - color: #999; -} - -a { - color: #cc0000; - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -#headsection { - border: solid 1px #f7f7f7; - background: #e4e4e4; - padding: 0px 60px 0px 60px; -} - -#login-form { - position: absolute; - right: 60px; - top: 120px; -} - -#login-form label { - width: 80px !important; - float: left; -} - -#login-form input[type=text] { - width: 100px; -} - -#login-form input[type=password] { - width: 40px; -} - -#menu-palestrante { - position: absolute; - right: 60px; - top: 30px; -} - -#menu-palestrante ul { - padding-left: 15px; - margin: 0px; - list-style-type: square; -} - -#main-menu li { -} - -#menu { - list-style-type: none; - list-style-image: none; - padding: 0px; - margin: 0px; - background-color: #cc0000; - padding: 5px 60px 5px 60px; -} - -#menu li { - display: inline; - padding-right: 15px; -} - -#menu li a { - text-transform: uppercase; - text-decoration: none; - font-weight: bold; - color: white; -} - -#content { - padding: 0px; - margin: 20px 60px 0px 60px; -} - -#footer { - margin: 25px 60px 5px 60px; - padding-top: 10px; - border-top: solid 1px #c00; - text-align: center; -} - -#news { - list-style-type: none; - padding-left: 0px; - border: dotted 1px #d7d7d7; -} - -#news li { - padding: 4px; -} - -.even { - background-color: #f7e7fe; -} - -.errorlist { - padding: 0px; - margin: 0px; - color: red; - list-style-type: none; -} - -#cadastro input[type=text] { - width: 300px; -} - -#cadastro p { - display: block; - width: 450px; - font-style: italic; - font-size: small; - color: #666; -} - -#cadastro p textarea { - width: 100%; -} - -#id_minicurriculo, -#id_descricao_curta { - height: 60px; -} - -#id_recursos { - height: 150px; -} +* {margin:0; padding:0; border:0;} + +body { + font-family:"Lucida Grande","Lucida Sans Unicode",geneva,verdana,sans-serif; + font-size:12px; + color:#222; + line-height:1.65em; + background:url(/site_media/imgs/bg_top.png) repeat-x; +} + +a { + color: red; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +div#top h1 { + text-indent:-9999px; + width:355px; + height:134px; + background:url(/site_media/imgs/emsl07.jpg) no-repeat; + margin:34px 0 0 30px; +} + +div#top h2 { + text-indent:-9999px; + width:217px; + height:56px; + background:url(/site_media/imgs/el_data.gif) no-repeat; + margin-top:-142px; + margin-left:530px; +} + +div#top form { + width:748px; + text-align:right; + margin-top:15px; +} + +div#top input { border:1px solid #C00; width:85px; } +div#top label { color:white; padding-left:10px; } + +div#container {width:718px; padding:67px 30px 30px 30px; } + +ul#menu { + float:left; + width:180px; + list-style:none; + margin-bottom:35px; +} + +div#content { + padding-left:220px; +} + +h2, h3, h4 { font-weight:normal; } +div#content h2 { font-size:24px; margin-bottom:20px; margin-top:5px; } +div#content h3 { font-size:16px; color:#CC0D0D; margin-bottom:16px; margin-top:5px; } +div#content h4 { font-size:16px; color:#666; margin-bottom:13px; margin-top:5px; } + +div#content p {margin-bottom:15px;} + +div#content ul {list-style:circle inside;} + +div#footer { + background:url(/site_media/imgs/bg_footer.png) repeat-x #333; + clear:both; + height:145px; + padding:13px 30px 15px 30px; +} + +div#org {float:left;} + +div#patrocinio {padding-left:220px;} + +div#patrocinio h3 { + width:58px; + height:14px; + background:url(/site_media/imgs/tit_patrocinio.gif) no-repeat; + text-indent:-9999px; +} + +div#patrocinio table { + background:white; + margin-top:13px; +} + + +/* -- meu -- */ + +#cadastro input, +#cadastro textarea, +#cadastro select { + border: solid 1px #666; +} + +#cadastro input[type=text] { + width: 300px; +} + +#cadastro label { + display: block; + float: left; + width: 450px; + font-style: normal; + color: #000; +} + +#cadastro p { + display: block; + width: 450px; + font-style: italic; + font-size: small; + color: #666; +} + +#cadastro p textarea { + width: 100%; +} + +#id_minicurriculo, +#id_descricao_curta { + height: 60px; +} + +#id_recursos { + height: 150px; +} + +#menu-palestrante { + position: absolute; + top: 125px; + width: 250px !important; + margin-left: 498px; +} + +#menu-palestrante ul { + list-style-type: none; +} + +.login-failed { + background-color: red; + border: solid 1px white !important; +} + +.errorlist { + color: red; +} diff --git a/media/imgs/bg_footer.png b/media/imgs/bg_footer.png new file mode 100644 index 0000000..1b33a8c Binary files /dev/null and b/media/imgs/bg_footer.png differ diff --git a/media/imgs/bg_top.png b/media/imgs/bg_top.png new file mode 100644 index 0000000..474f0b8 Binary files /dev/null and b/media/imgs/bg_top.png differ diff --git a/media/imgs/bt_entrar.gif b/media/imgs/bt_entrar.gif new file mode 100644 index 0000000..0374604 Binary files /dev/null and b/media/imgs/bt_entrar.gif differ diff --git a/media/imgs/el_data.gif b/media/imgs/el_data.gif new file mode 100644 index 0000000..ea96afe Binary files /dev/null and b/media/imgs/el_data.gif differ diff --git a/media/imgs/el_footer.gif b/media/imgs/el_footer.gif new file mode 100644 index 0000000..dd9db61 Binary files /dev/null and b/media/imgs/el_footer.gif differ diff --git a/media/imgs/emsl07.jpg b/media/imgs/emsl07.jpg new file mode 100644 index 0000000..a7ac785 Binary files /dev/null and b/media/imgs/emsl07.jpg differ diff --git a/media/imgs/logo.svg b/media/imgs/logo.svg new file mode 100644 index 0000000..68e34d8 --- /dev/null +++ b/media/imgs/logo.svg @@ -0,0 +1,342 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media/imgs/menu_avaliacao.gif b/media/imgs/menu_avaliacao.gif new file mode 100644 index 0000000..abb8be5 Binary files /dev/null and b/media/imgs/menu_avaliacao.gif differ diff --git a/media/imgs/menu_chamada-de-trabalhos.gif b/media/imgs/menu_chamada-de-trabalhos.gif new file mode 100644 index 0000000..0860612 Binary files /dev/null and b/media/imgs/menu_chamada-de-trabalhos.gif differ diff --git a/media/imgs/menu_como-chegar.gif b/media/imgs/menu_como-chegar.gif new file mode 100644 index 0000000..0e15990 Binary files /dev/null and b/media/imgs/menu_como-chegar.gif differ diff --git a/media/imgs/menu_contato.gif b/media/imgs/menu_contato.gif new file mode 100644 index 0000000..f08d9c0 Binary files /dev/null and b/media/imgs/menu_contato.gif differ diff --git a/media/imgs/menu_home.gif b/media/imgs/menu_home.gif new file mode 100644 index 0000000..43b5f5a Binary files /dev/null and b/media/imgs/menu_home.gif differ diff --git a/media/imgs/menu_inscricao.gif b/media/imgs/menu_inscricao.gif new file mode 100644 index 0000000..9b19014 Binary files /dev/null and b/media/imgs/menu_inscricao.gif differ diff --git a/media/imgs/menu_localizacao.gif b/media/imgs/menu_localizacao.gif new file mode 100644 index 0000000..e7c7f6b Binary files /dev/null and b/media/imgs/menu_localizacao.gif differ diff --git a/media/imgs/menu_onde-comer.gif b/media/imgs/menu_onde-comer.gif new file mode 100644 index 0000000..3b125be Binary files /dev/null and b/media/imgs/menu_onde-comer.gif differ diff --git a/media/imgs/menu_onde-ficar.gif b/media/imgs/menu_onde-ficar.gif new file mode 100644 index 0000000..dbc5369 Binary files /dev/null and b/media/imgs/menu_onde-ficar.gif differ diff --git a/media/imgs/menu_programacao.gif b/media/imgs/menu_programacao.gif new file mode 100644 index 0000000..899097f Binary files /dev/null and b/media/imgs/menu_programacao.gif differ diff --git a/media/imgs/menu_retrospectiva.gif b/media/imgs/menu_retrospectiva.gif new file mode 100644 index 0000000..9e63f8b Binary files /dev/null and b/media/imgs/menu_retrospectiva.gif differ diff --git a/media/imgs/tit_patrocinio.gif b/media/imgs/tit_patrocinio.gif new file mode 100644 index 0000000..78d5052 Binary files /dev/null and b/media/imgs/tit_patrocinio.gif differ diff --git a/settings.py b/settings.py index b794cf6..baff74b 100644 --- a/settings.py +++ b/settings.py @@ -85,3 +85,6 @@ INSTALLED_APPS = ( 'eventmanager.eventos', 'eventmanager.conteudo', ) + +# código mínimo já utilizado em testes de geração de boletos. +MIN_REF_TRAN = 2 diff --git a/templates/base.html b/templates/base.html index 79f3eae..385cd71 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,71 +1,77 @@ - - + {% load i18n %} - Encontro Mineiro de Software Livre - + + + EMSL'07 — Encontro Mineiro de Software Livre -
-

Encontro Mineiro de Software Livre

+
+

EMSL 2007 - Encontro Mineiro de Software Livre

+

18 a 20 de outubro de 2007 - DCC/UFLA - Lavras/MG

{% if user.is_authenticated %} - {% if user.palestrante_set.all %} - - {% endif %} + +

- {{ request.error_message }} + {% else %}
-
- - -
-
- - - - -
+ + + + + +
- {% endif %} + {% endif %}
- +
+ {% block content %}{% endblock %} +
- -{# vim: set ft=htmldjango: #} +{# vim:set ft=htmldjango: #} diff --git a/templates/cadastro.html b/templates/cadastro.html index 9027481..4b7ca0e 100644 --- a/templates/cadastro.html +++ b/templates/cadastro.html @@ -6,9 +6,11 @@ {% if ok %}
-

Cadastro efetuado com sucesso, você já foi autenticado.

+

Cadastro efetuado com sucesso!

-

Use o menu que apareceu para cadastrar uma palestra ou um minicurso

+

Foi enviado um email de confirmação para o endereço {{ email }}.

+

Siga as instruções do email para concluir o cadastro e prosseguir + com a submissão de trabalhos.

{% else %} diff --git a/templates/email-palestrante.html b/templates/email-palestrante.html new file mode 100644 index 0000000..3e5b91d --- /dev/null +++ b/templates/email-palestrante.html @@ -0,0 +1,10 @@ +Olá {{ fulano }}! + +Seu cadastro de palestrante para o Encontro Mineiro de Software Livre de 2007 +precisa ser confirmado, por favor siga o link abaixo, ou cole no seu navegador: + +{{ link }} + +Mais informações em http://emsl.minaslivre.org + +Caso você não tenha feito nenhum cadastro, por favor desconsidere este email. diff --git a/templates/inscricao.html b/templates/inscricao.html index 983ca11..41cc24b 100644 --- a/templates/inscricao.html +++ b/templates/inscricao.html @@ -1,24 +1,9 @@ {% extends "base.html" %} {% block content %} -

Inscrição do participante

+

Inscrição

-{% if ok %} - -
-

Cadastro efetuado com sucesso, você já foi autenticado.

-
- -{% else %} - -Esta seção ainda não está pronta, por favor volte mais tarde. - - -{% endif %} +

Inscrição Individual

+

Inscrição de Caravana

{% endblock %} diff --git a/templates/inscricao_caravana.html b/templates/inscricao_caravana.html new file mode 100644 index 0000000..38fd346 --- /dev/null +++ b/templates/inscricao_caravana.html @@ -0,0 +1,22 @@ +{% extends "base.html" %} +{% block content %} + +

Inscrição de Caravana

+ +{% if ok %} + +
+

Cadastro efetuado com sucesso.

+
+ +{% else %} + +
+ {{ form.as_p }} + + +
+ +{% endif %} + +{% endblock %} diff --git a/templates/inscricao_individual.html b/templates/inscricao_individual.html new file mode 100644 index 0000000..5a060a4 --- /dev/null +++ b/templates/inscricao_individual.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} +{% block content %} + +

Inscrição Individual

+ +{% if ok %} + +
+

Cadastro efetuado com sucesso.

+
+ +{% else %} + +
+ {{ form.as_p }} + +
+ +{% endif %} + +{% endblock %} diff --git a/templates/meus_trabalhos.html b/templates/meus_trabalhos.html index 14bc58e..465c1ba 100644 --- a/templates/meus_trabalhos.html +++ b/templates/meus_trabalhos.html @@ -5,9 +5,9 @@ {# o if abaixo eh para o caso de algum trabalho ter sido editado e redirecionado #} {% if editado_sucesso %} -
-

O trabalho "{{ editado_sucesso}}" for editado com sucesso!

-
+
+

O trabalho "{{ editado_sucesso }}" for editado com sucesso!

+
{% endif %} {% if trabalhos %} diff --git a/urls.py b/urls.py index cf93987..1ebcff7 100644 --- a/urls.py +++ b/urls.py @@ -28,7 +28,12 @@ urlpatterns = patterns('', (r'^admin/', include('django.contrib.admin.urls')), (r'^logout/', 'django.contrib.auth.views.logout', {'next_page': '/'}), + (r'^inscricao/', views.inscricao), + (r'^inscricao_individual/', views.inscricao_individual), + (r'^inscricao_caravana/', views.inscricao_caravana), + (r'^boleto/', views.inscricao_boleto), + (r'^submeter_trabalho/', views.submeter_trabalho), (r'^cadastro_palestrante/', views.cadastro_palestrante), (r'^meus_trabalhos/', views.meus_trabalhos), diff --git a/views.py b/views.py index 58e9a37..36ddaca 100644 --- a/views.py +++ b/views.py @@ -18,18 +18,25 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. """ from django.shortcuts import render_to_response, get_object_or_404 -from django.template import RequestContext, Context +from django.template import RequestContext, Context, loader from django.contrib.auth.decorators import login_required, user_passes_test from django.contrib.auth.models import Group, User -from django.contrib.auth.forms import AuthenticationForm -from django.contrib.auth import login +from django.contrib.auth import authenticate, login +from django.newforms import form_for_instance +from django.core.mail import EmailMessage from django.db import transaction +from django.http import get_host +from django.conf import settings from eventmanager.decorators import enable_login_form -from eventmanager.forms import * from eventmanager.conteudo.models import Noticia, Menu, Secao from eventmanager.eventos.models import * -from django.newforms import form_for_instance +from eventmanager.forms import * + +from datetime import datetime +import sha + +FROM_EMAIL = 'Emsl 2007 ' def build_response(request, template, extra={}): """ @@ -48,8 +55,10 @@ def build_response(request, template, extra={}): news = Noticia.objects.order_by('-data_criacao') menus = Menu.objects.all() index_sections = Secao.objects.filter(index=True) + login_failed = 'login_failed' in request.GET c = {'news': news, 'menu': menus, - 'index_sections': index_sections} + 'index_sections': index_sections, + 'login_failed': login_failed} c.update(extra) return render_to_response(template, Context(c), context_instance=RequestContext(request)) @@ -65,76 +74,207 @@ def index(request): def cadastro_palestrante(request): form = CadastroPalestrante(request.POST or None) ok = False + c = {'form': form} if request.POST and form.is_valid(): cd = form.cleaned_data badattr = form.errors - wrong = False - if not cd['telefone'] and not cd['celular']: - badattr['telefone_comercial'] = ['Algum número de telefone ' - 'precisa ser informado'] - wrong = True - - # don't save duplicated users... + group = Group.objects.get_or_create(name='palestrantes')[0] + + user = User(username=cd['nome_usuario'], email=cd['email']) + user.set_password(cd['senha']) + user.is_active = False + user.save() + user.groups.add(group) + + p = Palestrante() + p.usuario = user + + p.nome = cd['nome_completo'] + p.email = cd['email'] + p.telefone = cd['telefone'] + p.celular = cd['celular'] + p.instituicao = cd['instituicao'] + p.rua = cd['rua'] + p.numero = cd['numero'] + p.bairro = cd['bairro'] + p.cidade = cd['cidade'] + p.uf = cd['uf'] + p.minicurriculo = cd['minicurriculo'] + p.curriculo = cd['curriculo'] + p.save() + + for i in cd.get('area_interesse', []): + p.area_interesse.add(i) + + pid = p.id + md5_email = sha.new(cd['email']).hexdigest() + email = '%s <%s>' % (cd['nome_completo'], cd['email']) + link = '%s/verificar?c=%s&c1=%s' % (get_host(request), + pid, md5_email) + t = loader.get_template('email-palestrante.html') + ec = Context(dict(fulano=['nome_usuario'], link=link)) + + # to be shown in template... + c.update({'email': email}) try: - User.objects.get(username=cd['nome_usuario']) - badattr['nome_usuario'] = ['Este nome de usuário já existe!'] - wrong = True + # XXX: maybe is not a good so prety put things hardcoded =( + m = EmailMessage('Encontro Mineiro de Software Livre', + t.render(ec), FROM_EMAIL, [email]) + m.send() + except Exception: + badattr['email'] = \ + ['Desculpe mas não pude enviar o email de confirmação'] transaction.rollback() - except User.DoesNotExist: - pass - - if cd['senha'] != cd['senha_2']: - badattr['senha_2'] = ['A senha não confere'] - wrong = True - transaction.rollback() - - if not wrong: - group = Group.objects.get_or_create(name='palestrantes')[0] - - user = User(username=cd['nome_usuario'], email=cd['email']) - user.set_password(cd['senha']) - user.save() - user.groups.add(group) - - p = Palestrante() - p.usuario = user - - p.nome = cd['nome_completo'] - p.email = cd['email'] - p.telefone = cd['telefone'] - p.celular = cd['celular'] - p.instituicao = cd['instituicao'] - p.rua = cd['rua'] - p.numero = cd['numero'] - p.bairro = cd['bairro'] - p.cidade = cd['cidade'] - p.uf = cd['uf'] - p.minicurriculo = cd['minicurriculo'] - p.curriculo = cd['curriculo'] - p.save() - - for i in cd.get('area_interesse', []): - p.area_interesse.add(i) - - fakepost = request.POST.copy() - fakepost['username'] = cd['nome_usuario'] - fakepost['password'] = cd['senha'] - - manipulator = AuthenticationForm(request) - errors = manipulator.get_validation_errors(fakepost) - got_user = manipulator.get_user() - login(request, got_user) - transaction.commit() + else: ok = True - c = {'form': form, 'ok': ok} + c.update({'ok': ok}) + transaction.commit() + return build_response(request, 'cadastro.html', c) @enable_login_form def inscricao(request): + return build_response(request, 'inscricao.html') + + +@enable_login_form +@transaction.commit_manually +def inscricao_individual(request): form = Inscricao(request.POST or None) - return build_response(request, 'inscricao.html', {'form': form}) + ok = False + if request.POST and form.is_valid(): + cd = form.cleaned_data + + group = Group.objects.get_or_create(name='participantes')[0] + + user = User(username=cd['nome_usuario'], email=cd['email']) + user.set_password(cd['senha']) + user.is_active = False + user.save() + user.groups.add(group) + p = Participante() + p.usuario = user + p.nome = cd['nome_completo'] + p.rg = cd['rg'] + p.email = cd['email'] + p.rua = cd['rua'] + p.numero = cd['numero'] + p.bairro = cd['bairro'] + p.cidade = cd['cidade'] + p.uf = cd['uf'] + p.cep = cd['cep'] + p.refbanco = 0 + p.telefone = cd['telefone'] + p.home_page = cd['home_page'] + p.save() + + u = authenticate(username=cd['nome_usuario'], password=cd['senha']) + login(request, u) + transaction.commit() + ok = True + + c = {'form': form, 'ok': ok} + return build_response(request, 'inscricao_individual.html', c) + + +@enable_login_form +@transaction.commit_manually +def inscricao_caravana(request): + form = InscricaoCaravana(request.POST or None) + ok = False + if request.POST and form.is_valid(): + cd = form.cleaned_data + group = Group.objects.get_or_create(name='participantes')[0] + + user = User(username=cd['nome_usuario'], email=cd['email']) + user.set_password(cd['senha']) + user.is_active = False + user.save() + user.groups.add(group) + + p = Participante() + p.usuario = user + p.nome = cd['nome_completo'] + p.rg = cd['rg'] + p.email = cd['email'] + p.rua = cd['rua'] + p.numero = cd['numero'] + p.bairro = cd['bairro'] + p.cidade = cd['cidade'] + p.uf = cd['uf'] + p.cep = cd['cep'] + p.refbanco = 0 + p.telefone = cd['telefone'] + p.home_page = cd['home_page'] + p.save() + + c = Caravana() + c.coordenador = p + c.participantes = cd['lista_nomes'] + c.save() + + ok = True + u = authenticate(username=cd['nome_usuario'], password=cd['senha']) + login(request, u) + transaction.commit() + + c = {'form': form, 'ok': ok} + return build_response(request, 'inscricao_caravana.html', c) + + +@enable_login_form +def inscricao_boleto(request): + # dynamic values of the form + now = datetime.now() + today = datetime.date(now) + first_date = datetime.date(datetime(2007, 10, 12)) + c = {} + + p = request.user.participante_set.get() + ca = p.caravana_set.all() and p.caravana_set.get() + + initial = {} + + if p.refbanco == 0: + # o número refran deve ser gerado a cada novo boleto e deve ser único, + # mesmo para os testes + refs = [x.refbanco for x in Participante.objects.all()] + new_ref = len(refs) + while new_ref in refs or new_ref <= settings.MIN_REF_TRAN: + new_ref += 1 + + # este dado precisa ser persistente para que possa ser comparado logo acima + p.refbanco = new_ref + p.save() + else: + new_ref = p.refbanco + + initial['refTran'] = '1458197%s' % str(new_ref).zfill(10) + if today < first_date: + initial['valor'] = '3500' + initial['dtVenc'] = '12102007' + + # caso seja uma caravana... + if ca and len(ca.parsed_participantes()) >= 10: + # sim, o valor aqui é 25 -- Desconto + initial['valor'] = '%s00' % (len(ca.parsed_participantes()) * 25) + c.update({'caravana': 1}) + else: + initial['valor'] = '5000' + initial['dtVenc'] = '17102007' + + initial['nome'] = p.nome + initial['endereco'] = '%s, %s - %s' % (p.rua, p.numero, p.bairro) + initial['cidade'] = p.cidade + initial['uf'] = p.uf + initial['cep'] = p.cep + + form = Boleto(request.POST or None, initial=initial) + c.update({'form': form}) + c.update(initial) + return build_response(request, 'inscricao_boleto.html', c) @login_required @@ -152,7 +292,7 @@ def submeter_trabalho(request): t.descricao_curta = cd['descricao_curta'] t.descricao_longa = cd['descricao_longa'] t.recursos = cd['recursos'] - t.evento = Evento.objects.get(pk=1) # let the hammer play arround! + t.evento = Evento.objects.get(pk=1) # XXX: let the hammer play arround! t.save() logged_in = request.user.palestrante_set.get() @@ -204,6 +344,31 @@ def editar_trabalho(request,codigo): c = {'formulario':form} return build_response(request, 'editar_trabalho.html', c) +@login_required +@user_passes_test(lambda u:u.palestrante_set.count() == 1, login_url='/') +def editar_trabalho(request, codigo): + try: + p = Palestrante.objects.get(usuario=request.user) + except Palestrante.DoesNotExist: + # não palestrante... + c = {'palestrante': 0} + return build_response(request, 'meus_trabalhos.html', c) + + trabalho = get_object_or_404(Trabalho, id=codigo, palestrante=p) + Formulario = form_for_instance(trabalho) + + form = Formulario(request.POST or None) + if request.POST and form.is_valid(): + form.save() + t = Trabalho.objects.filter(palestrante=p) + c = {'trabalhos': t, 'palestrante': 1} + c['editado_sucesso'] = trabalho.titulo + return build_response(request, 'meus_trabalhos.html', c) + + c = {'formulario': form} + return build_response(request, 'editar_trabalho.html', c) + + @login_required def meus_dados(request): form = EditarPalestrante(request.POST or None)