- Agora existem views para mostrar dados de detalhes de palestras e palestrantes
authorGabriel Falcao <root@gabrielfalcao.com>
Mon, 8 Oct 2007 02:58:58 +0000 (23:58 -0300)
committerGabriel Falcao <root@gabrielfalcao.com>
Mon, 8 Oct 2007 02:58:58 +0000 (23:58 -0300)
- 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 [new file with mode: 0644]
templates/dados_palestra.html [new file with mode: 0644]
templates/dados_palestrante.html [new file with mode: 0644]
templates/programacao.html [new file with mode: 0644]

diff --git a/controllers.py b/controllers.py
new file mode 100644 (file)
index 0000000..922a623
--- /dev/null
@@ -0,0 +1,111 @@
+# -*- coding: utf-8; -*-
+# Copyright (C) 2007 Gabriel Falcão <root@gabrielfalcao.com>
+#
+# 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 (file)
index 0000000..38dd512
--- /dev/null
@@ -0,0 +1,41 @@
+{% extends "base.html" %}
+{% block content %}
+
+{% if dados_palestra %}
+
+<h2>{{ dados_palestra.titulo }}</h2>
+{#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#}
+
+<div class="content">
+        <h4>Palestrante{{ dados_palestra.palestrante.all|pluralize }}</h4>
+        <ul>
+        {% for p in dados_palestra.palestrante.all %}
+            <li>{{p.nome}}</li>
+        {% endfor %}
+        </ul>
+    <br />
+    {#<h4>Categoria</h4>#}
+    {#<p>{{dados_palestra.categoria.nome}}</p>#}
+
+    <h4>Descrição da palestra</h4>
+    <p>{{dados_palestra.descricao_longa}}</p>
+</div>
+
+{% else %}
+<div id="404" style="text-align:center">
+    <h2>Padre Quevedo 404</h2>
+    <br />
+    <div style="color:#FF0000;">
+        Palestra nón ecziste!
+    </div>
+</div>
+{% endif %}
+<a href="javascript:;" onclick="history.back ();">Voltar</a>
+{% endblock %}
diff --git a/templates/dados_palestrante.html b/templates/dados_palestrante.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 %}
diff --git a/templates/programacao.html b/templates/programacao.html
new file mode 100644 (file)
index 0000000..9c99b4f
--- /dev/null
@@ -0,0 +1,23 @@
+{% extends "base.html" %}
+{% block content %}
+
+{% if aprovadas %}
+
+<!--<h2>{{ dados_usuario.nome }}</h2>-->
+<ul>
+    {% for p in aprovadas %}
+    <li>{{p.titulo}}</li>
+    {% endfor %}
+</ul>
+{% else %}
+<div id="404" style="text-align:center">
+    <h2>Padre Quevedo 404</h2>
+    <br />
+    <div style="color:#FF0000;">
+        Usuario nón ecziste!
+    </div>
+</div>
+{% endif %}
+
+<a href="javascript:;" onclick="history.back ();">Voltar</a>
+{% endblock %}