From fc398a60fc40538db49d86084045b1eaae87f0e5 Mon Sep 17 00:00:00 2001 From: Gabriel Falcao Date: Sun, 7 Oct 2007 23:58:58 -0300 Subject: [PATCH] - Agora existem views para mostrar dados de detalhes de palestras e palestrantes - Adicionado um controller - Adicionado um mega master hammer que a partir do html estatico de programacao da secao 8, retorna os tiulos das palestras. Isso sera usado para saber quais palestras foram aprovadas a partir da secao q foi escrita na mao. (Poe na conta de thor) --- controllers.py | 111 +++++++++++++++++++++++++++++++ templates/dados_palestra.html | 41 ++++++++++++ templates/dados_palestrante.html | 21 ++++++ templates/programacao.html | 23 +++++++ 4 files changed, 196 insertions(+) create mode 100644 controllers.py create mode 100644 templates/dados_palestra.html create mode 100644 templates/dados_palestrante.html create mode 100644 templates/programacao.html diff --git a/controllers.py b/controllers.py new file mode 100644 index 0000000..922a623 --- /dev/null +++ b/controllers.py @@ -0,0 +1,111 @@ +# -*- coding: utf-8; -*- +# Copyright (C) 2007 Gabriel Falcão +# +# 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. + +from django.http import HttpResponse, HttpResponseRedirect +from django.template import RequestContext +from django.shortcuts import render_to_response, get_object_or_404 +from django.conf import settings +from django.core.exceptions import ObjectDoesNotExist + +class MetaDict: + """ + Esta classe recebe um dicionario como parametro e adiciona cada + chave do dicionario em seu atributo, contendo o valor de cada item + """ + def __init__(self, dictionary): + if isinstance(dictionary, dict): + for key, value in dictionary.items(): + setattr(self, key, value) + else: + raise RuntimeError('MetaDict class only accepts a dictionary\ + as parameter') + def __iter__(self): + for value in self.__dict__.values(): + yield value + + def __getitem__(self,index): + try: + return self.__dict__[index] + except: + return False + + def __repr__(self): + return ", ".join(self.all()) + + def all(self): + return self.__dict__.keys() + + def first(self): + return self.__dict__[self.__dict__.keys()[0]] + + def last(self): + return self.__dict__[self.__dict__.keys()[-1]] + + def slice(self,index): + try: + return self.__dict__[self.__dict__.keys()[index]] + except: + return False + + def __contains__(self, item): + return item in self.__dict__.keys() or item in self.__dict__.values() + + def as_dict(self): + return self.__dict__ + + def __len__(self): + return len(self.__dict__.keys()) + +class empty: + + def __default__(self): + return [] + + def __getattr__(self,*a): + return self.__default__ + + def __repr__(self): + return self.__default__ + + def __nonzero__(self): + return 1 + +def get_object_or_list(obj,**kw): + try: + return obj(**kw) + except ObjectDoesNotExist: + return empty() + +def get_object_or_none(obj,**kw): + try: + return obj.objects.get(**kw) + except ObjectDoesNotExist: + return None + except AssertionError: + #hammer! hammer! hammer! + return empty()#obj.objects.filter(**kw)[0] + +def limpa_conversas(visitante, corretor): + conversas_vc = [] + if isinstance(visitante, Visitante): + conversas_vc.append(get_object_or_none(Conversa,visitante__id=\ + visitante.id)) + if isinstance(corretor, Corretor): + conversas_vc.append(get_object_or_none(Conversa,corretor__id=\ + corretor.id)) + [c.delete() for c in conversas_vc if c] diff --git a/templates/dados_palestra.html b/templates/dados_palestra.html new file mode 100644 index 0000000..38dd512 --- /dev/null +++ b/templates/dados_palestra.html @@ -0,0 +1,41 @@ +{% extends "base.html" %} +{% block content %} + +{% if dados_palestra %} + +

{{ dados_palestra.titulo }}

+{#dados_palestra.titulo#} +{#dados_palestra.evento#} +{#dados_palestra.tipo#} +{#dados_palestra.categoria#} +{#dados_palestra.palestrante#} +{#dados_palestra.descricao_curta#} +{#dados_palestra.descricao_longa#} +{#dados_palestra.recursos#} + +
+

Palestrante{{ dados_palestra.palestrante.all|pluralize }}

+
    + {% for p in dados_palestra.palestrante.all %} +
  • {{p.nome}}
  • + {% endfor %} +
+
+ {#

Categoria

#} + {#

{{dados_palestra.categoria.nome}}

#} + +

Descrição da palestra

+

{{dados_palestra.descricao_longa}}

+
+ +{% else %} +
+

Padre Quevedo 404

+
+
+ Palestra nón ecziste! +
+
+{% endif %} +Voltar +{% endblock %} diff --git a/templates/dados_palestrante.html b/templates/dados_palestrante.html new file mode 100644 index 0000000..d42402c --- /dev/null +++ b/templates/dados_palestrante.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} +{% block content %} + +

Editar {{ title }}

+ +{% if ok %} + +
+

Seus dados foram editados com sucesso!

+
+ +{% else %} + +
+ {{ form.as_p }} + +
+ +{% endif %} + +{% endblock %} diff --git a/templates/programacao.html b/templates/programacao.html new file mode 100644 index 0000000..9c99b4f --- /dev/null +++ b/templates/programacao.html @@ -0,0 +1,23 @@ +{% extends "base.html" %} +{% block content %} + +{% if aprovadas %} + + + +{% else %} +
+

Padre Quevedo 404

+
+
+ Usuario nón ecziste! +
+
+{% endif %} + +Voltar +{% endblock %} -- 2.20.1