[accueil.py] Création et migration de tout comme il faut

parent d6884a59
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# ACCUEIL.PY
#
# Copyright (C) 2010 Antoine Durand-Gasselin
# Author: Antoine Durand-Gasselin <adg@crans.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 3 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, see <http://www.gnu.org/licenses/>.
#
#
import django.shortcuts
import settings
from login import require_droits
from django.http import HttpResponse
@require_droits()
def view(request):
'''Affiche toutes les applications disponibles en fonction des
droits de la personne connectée.'''
dico = {"apps" : list(settings.INTRANET_APPS), "session": request.session }
return django.shortcuts.render_to_response("accueil.html", dico)
from django.db import models
# Create your models here.
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}
from django.conf.urls.defaults import patterns as patterns
urlpatterns = patterns('',
('^$', 'intranet.dummy.views.bonjour')
)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Create your views here.
import django.shortcuts
from login import require_droits
@require_droits()
def my_view(request):
def bonjour(request):
return django.shortcuts.render_to_response("bonjour.html", {"session" : request.session })
from django.db import models
# Create your models here.
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}
from django.conf.urls.defaults import patterns as patterns
urlpatterns = patterns('',
('^do_prises$', 'intranet.prises.views.do_prises'),
('^$', 'intranet.prises.views.view')
)
......@@ -25,12 +25,6 @@
from __future__ import with_statement
from django.conf.urls.defaults import patterns as patterns
urlpatterns = patterns('',
('^do_prises$', 'intranet.apps.prises.do_prises'),
('^$', 'intranet.apps.prises.view')
)
import re
import psycopg2, psycopg2.extensions
......@@ -43,7 +37,7 @@ class LoggingCursor(psycopg2.extensions.cursor):
"""Curseur avec ajout du logging"""
def execute(self, sql, args=None):
print self.mogrify(sql, args)
try:
psycopg2.extensions.cursor.execute(self, sql, args)
except Exception, exc:
......@@ -71,7 +65,7 @@ class CursorMaker(object):
# On a eu un souci, effectuons un peu de nettoyage...
self.cnx.rollback()
self.cur.close()
# On récupère la liste des batiments
with CursorMaker() as cur:
......
......@@ -82,9 +82,14 @@ TEMPLATE_DIRS = (
# Don't forget to use absolute paths, not relative paths.
)
INTRANET_APPS = (
{'name':'dummy', 'category':'Beta'},
{'name':'prises', 'category': 'Administration'},
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
)
) + tuple( 'intranet.%s' % app['name'] for app in INTRANET_APPS )
......@@ -16,7 +16,7 @@ body
a, a:hover, a:visited {color:blue;}
img {border:none;}
ul {display: inline; clear: both; list-style-type: none; padding: 0; margin: 10px; }
ul {list-style-type: none; padding: 0;}
/* ******************************************************************** */
/*
......@@ -102,6 +102,28 @@ li.fieldset {
- enumerations d'icônes
*/
span.fieldlegend {
position: relative;
top: -10px;
left: 10px;
padding: 1px 4px;
background: PaleGreen;
color: DarkGreen;
font-weight: bold;
}
span.pluginlegend {
color: DarkGreen;
display: block;
text-align: center;
}
ul.icones {
margin: 0px;
clear: both;
float: none;
}
ul.icones li {
display: block;
float: left;
......
{% extends "template.html" %}
{% block title%}Accueil{% endblock %}
{% block h1%} <h1>Bienvenue sur l'intranet du Cr@ns</h1> {% endblock %}
{% block content %}
<ul>
{% regroup apps by category as items %}
{% for category in items %}
<li class="fieldset">
<span class="fieldlegend"> {{ category.grouper }} </span>
<ul class="icones">
{% for item in category.list %}
<li>
<a href="/{{item.name}}/" alt="Aller vers {{item.name}}">
<img src="/static/img/{% if item.pic %}{{ item.pic }}{% else %}icone_{{ item.name }}{%endif%}.png" alt="icone {{ item.name }}">
<span class="pluginlegend"> {{ item.name}} </p> </a>
</li>
{% endfor %}
</ul>
<hr class="nofloat" style="visibility:hidden" />
</li>
{% endfor %}
</ul>
<hr class="nofloat" style="visibility:hidden" />
{% endblock %}
......@@ -7,6 +7,6 @@
<p>Voilà! les modifications ont été apportées&nbsp;:
{{ modifs }}
</p>
<p> Retourner à <a href="{% url intranet.apps.prises.view %}"> la sélection des prises</a>.</p>
<p> Retourner à <a href="{% url intranet.prises.views.view %}"> la sélection des prises</a>.</p>
{% endblock %}
......@@ -6,7 +6,7 @@
{% for bat in batiments %}
<li>
{% ifnotequal bat cur_bat %}
<a href="{% url apps.prises.view %}?bat={{bat}}"> Batiment {{ bat|upper }} </a>
<a href="{% url prises.views.view %}?bat={{bat}}"> Batiment {{ bat|upper }} </a>
{% endifnotequal %}
{% ifequal bat cur_bat %}
Batiment {{ bat|upper }}
......@@ -14,7 +14,7 @@
</li>
{% endfor %}
</ul>
<hr class="nofloat" style="visibility:hidden" />
{% if chbres_by_etage %}
<script type="text/javascript">
<!--
......@@ -42,11 +42,12 @@ function maj(chbre) {
//-->
</script>
<form name="chambres" action="{% url apps.prises.do_prises %}" method="post">
<form name="chambres" action="{% url prises.views.do_prises %}" method="post">
<ul>
{% for etage, chbres_e in chbres_by_etage %}
{% ifnotequal currentloop.first True %} <hr> {% endifnotequal %}
<li class="fieldset">
<span class="fieldlegend">{{ etage }}° étage</span>
<ul class="icones">
{% for bat, chbre, p_crans, p_crous, crans, crous, comm, status in chbres_e %}
<li style="cursor:pointer" id="item_{{ bat }}{{chbre }}"
......@@ -66,13 +67,13 @@ function maj(chbre) {
</li>
{% endfor %}
</ul>
<hr class="nofloat" style="visibility:hidden" />
<hr class="nofloat" style="visibility:hidden" />
</li>
{% endfor %}
</ul>
<hr class="nofloat" style="visibility:hidden" />
<input type="submit" value="Envoyer" class="nofloat"/>
</form>
{% else %}
<hr class="nofloat" style="visibility:hidden" />
{% endif %}
{% endblock %}
......@@ -3,9 +3,7 @@ import settings
urlpatterns = patterns('',
# Les pages existantes
('^$', 'intranet.apps.dummy.my_view'),
('^dummy', 'intranet.apps.dummy.my_view'),
(r'^prises/', include('intranet.apps.prises')),
('^$', 'intranet.accueil.view'),
# Pages de login
('^login', 'intranet.login.prompt_login'),
......@@ -14,5 +12,9 @@ urlpatterns = patterns('',
# Pour servir le static
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT + 'static/' })
)
{'document_root': settings.MEDIA_ROOT + 'static/' }),
# on rajoute toutes les plugins
*(('^%s/' % app['name'], include('intranet.'+app['name']+'.urls')) for app in settings.INTRANET_APPS))
# )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment