login/logout logic (sort of)

This commit is contained in:
Thomas NOËL 2012-05-13 17:09:40 +02:00
parent a3bb887988
commit c7dbb75003
25 changed files with 132 additions and 27 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.pyc
polynum.db
polynum/static

View File

3
polynum/pages/models.py Normal file
View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

View File

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

7
polynum/pages/urls.py Normal file
View File

@ -0,0 +1,7 @@
from django.conf.urls import url, patterns
import views
urlpatterns = patterns('',
url(r'^/*$', views.homepage, name='homepage'),
)

5
polynum/pages/views.py Normal file
View File

@ -0,0 +1,5 @@
from django.shortcuts import render, redirect
def homepage(request):
return render(request, 'homepage.html')

View File

@ -8,7 +8,8 @@
{{ wizard.form.media }}
{% endblock %}
{% block body %}
{% block content %}
<div class="hero-unit">
<h2>Étape {{ wizard.steps.step1 }} sur {{ wizard.steps.count }}</h2>
@ -36,4 +37,6 @@
</form>
</div><!-- /hero-unit -->
{% endblock %}

View File

@ -1,6 +1,7 @@
from django.shortcuts import redirect
from django.contrib.formtools.wizard.views import NamedUrlSessionWizardView
from django.core.files.storage import FileSystemStorage
from django.contrib.auth.decorators import login_required
from forms import DocumentUploadForm, DocumentDetailsForm
@ -14,6 +15,7 @@ named_new_request_forms = (
class RequestWizardView(NamedUrlSessionWizardView):
template_name = 'new_request.html'
file_storage = FileSystemStorage(location = '/tmp/pdf/')
def done(self, form_list, **kwargs):
@ -32,7 +34,7 @@ class RequestWizardView(NamedUrlSessionWizardView):
return initial
new_request_wizard = RequestWizardView.as_view(named_new_request_forms,
new_request_wizard = login_required(RequestWizardView.as_view(named_new_request_forms,
url_name='new_request_step',
done_step_name='new_request_finished')
done_step_name='new_request_finished'))

View File

@ -1,5 +1,10 @@
# Django settings for polynum project.
import os.path
import django.conf.global_settings as DEFAULT_SETTINGS
PROJECT_ROOT = os.path.join(os.path.dirname(__file__), '.')
DEBUG = True
TEMPLATE_DEBUG = DEBUG
@ -48,18 +53,18 @@ USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
MEDIA_URL = '/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
@ -109,6 +114,7 @@ TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_ROOT, "templates"),
)
INSTALLED_APPS = (
@ -119,12 +125,13 @@ INSTALLED_APPS = (
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.formtools',
# 'django.contrib.admindocs',
'mptt',
'crispy_forms',
'polynum.pages',
'polynum.base',
'polynum.request',
'django.contrib.formtools',
)
# From http://django-crispy-forms.readthedocs.org/en/d-0/install.html
@ -158,3 +165,9 @@ LOGGING = {
},
}
}
try:
from local_settings import *
except:
pass

View File

@ -41,13 +41,14 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">PolyNum</a>
<div class="btn-group pull-right">
<a class="btn" href="/login">
<i class="icon-user"></i> Connexion
<!-- span class="caret"></span -->
</a>
</a>
<span class="brand">PolyNum</span>
<div class="btn-group pull-right">
{% if user.is_authenticated %}
<a class="btn" href="/accounts/logout"><i class="icon-user"></i> Déconnexion de «{{user}}»</a>
{% else %}
<a class="btn" href="/accounts/login"><i class="icon-user"></i> Connexion</a>
{% endif %}
</div>
<div class="nav-collapse pull-left">
<ul class="nav">
@ -74,24 +75,20 @@
<div class="well sidebar-nav">
{% block sidebar %}
<ul class="nav nav-list">
<li class="nav-header">Plouf plaf</li>
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="nav-header">Sidebar</li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="nav-header">PolyNum</li>
<li><a href="/request/new">Nouvelle demande</a></li>
<li><a href="/dashboard">Tableau de bord</a></li>
<li class="nav-header"></li>
<li><a href="/">Accueil</a></li>
<li><a href="/about">À propos</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
{% endblock %}
</div>
</div>
<div class="span9">
<div class="hero-unit">
{% block body %}{% endblock %}
</div>
{% block content %}{% endblock %}
</div>
</div>

View File

@ -0,0 +1,33 @@
{% extends "base.html" %}
{% block content %}
<div class="hero-unit">
<h1>PolyNum</h1>
<h2>Polycopiés numériques</h2>
</div>
<div class="row-fluid">
{% if user.is_authenticated %}
Bienvenue, {{ user }}
{% else %}
<div class="span4">
<h2>Demande</h2>
<p>Pour faire une demande de reprographie, cliquez sur
<a href="/request/new">nouvelle demande</a>.</p>
<p>Vous pouvez ensuite suivre l'état de vos demandes dans votre
<a href="/dashboard">tableau de bord</a>.</p>
</div>
<div class="span4">
<h2>Validation</h2>
<p>Consultez votre <a href="/dashboard">tableau de bord</a>.</p>
</div>
<div class="span4">
<h2>Reprographie</h2>
<p>Consultez votre <a href="/dashboard">tableau de bord</a>.</p>
</div>
{% endif %}
</div>
{% endblock %}

View File

@ -0,0 +1,26 @@
{% extends "base.html" %}
{% block content %}
<div class="hero-unit">
{% if form.errors %}
<p>Utilisateur inconnu, ou mauvais mot de passe... Recommancez.</p>
{% endif %}
<form method="post">
{% csrf_token %}
<table>
<tr>
<td>{{ form.username.label_tag }}</td> <td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td> <td>{{ form.password }}</td>
</tr>
</table>
<input type="submit" value="Connexion" />
<input type="hidden" name="next" value="{% if next %}{{ next }}{% else %}/{% endif %}">
</form>
</div>
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% block content %}
<div class="hero-unit">
<h1>Au revoir...</h1>
</form>
</div>
{% endblock %}

View File

@ -12,7 +12,11 @@ urlpatterns = patterns('',
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}, name='login'),
url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', {'template_name': 'logout.html'}, name='logout'),
url(r'^request/', include('polynum.request.urls')),
url(r'^', include('polynum.pages.urls')),
)