Merge branch 'qwann/views/shared' into 'master'

Qwann/views/shared

See merge request !7
This commit is contained in:
Martin Pepin 2017-04-26 21:37:32 +02:00
commit 01d8f2bb74
11 changed files with 80 additions and 60 deletions

View file

@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os
from django.core.urlresolvers import reverse_lazy
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -61,6 +62,9 @@ MIDDLEWARE_CLASSES = [
ROOT_URLCONF = 'evenementiel.urls'
LOGIN_REDIRECT_URL = reverse_lazy('shared:home')
LOGOUT_REDIRECT_URL = reverse_lazy('shared:home')
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',

View file

@ -9,6 +9,7 @@ urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^event/', include('event.urls')),
url(r'^user/', include('user.urls')),
url(r'^', include('shared.urls')),
]
if settings.DEBUG:

View file

@ -16,9 +16,44 @@
{% endif %}
<hr/>
{% block sidenav %}
{% if not user.is_authenticated %}
<li>
<a href="{% url "user:login" %}">
<i class="fa fa-sign-in"></i>
<span>Se connecter</span>
</a>
</li>
<li>
<a href="{% url "user:create_user" %}">
<i class="fa fa-user"></i>
<span>Créer un compte</span>
</a>
</li>
<li>
<a href="{% url "user:password_reset" %}">
<i class="fa fa-question"></i>
<span>Mot de passe oublié</span>
</a>
</li>
{% endif %}
{% if user.is_authenticated %}
<li>
<a href="{% url "user:password_change" %}">
<i class="fa fa-unlock-alt"></i>
<span>Changer de mot de passe</span>
</a>
</li>
<li>
<a href="{% url "user:logout"%}">
<i class="fa fa-sign-out"></i>
<span>Se déconnecter</span>
</a>
</li>
{% endif %}
{% endblock %}
{% endblock %}
{% block real_content %}

View file

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% block page_title %}Acceuil{% endblock %}
{% block content %}
<h2>Bonjours, je suis une maison</h2>
{% lorem 3 p %}
<h2>Looool</h2>
{% lorem 3 p %}
{% endblock %}

7
shared/urls.py Normal file
View file

@ -0,0 +1,7 @@
from django.conf.urls import url
from .views import Home
app_name = 'shared'
urlpatterns = [
url(r'$', Home.as_view(), name='home'),
]

View file

@ -1,3 +1,5 @@
from django.shortcuts import render
from django.views.generic import TemplateView
# Create your views here.
class Home(TemplateView):
template_name = "home.html"

View file

@ -1,3 +1,2 @@
from django.db import models
from django.contrib.auth.models import User

View file

@ -1,38 +0,0 @@
{% extends "base.html" %}
{% block sidenav %}
{% if not user.is_authenticated %}
<li>
<a href="{% url "user:login" %}">
<i class="fa fa-sign-in"></i>
<span>Se connecter</span>
</a>
</li>
<li>
<a href="{% url "user:create_user" %}">
<i class="fa fa-user"></i>
<span>Créer un compte</span>
</a>
</li>
<li>
<a href="{% url "user:password_reset" %}">
<i class="fa fa-question"></i>
<span>Mot de passe oublié</span>
</a>
</li>
{% endif %}
{% if user.is_authenticated %}
<li>
<a href="{% url "user:password_change" %}">
<i class="fa fa-unlock-alt"></i>
<span>Changer de mot de passe</span>
</a>
</li>
<li>
<a href="{% url "user:logout"%}">
<i class="fa fa-sign-out"></i>
<span>Se déconnecter</span>
</a>
</li>
{% endif %}
{% endblock %}

View file

@ -1,4 +1,4 @@
{% extends "user/base_user.html" %}
{% extends "base.html" %}
{% load widget_tweaks %}
{% load bootstrap %}

View file

@ -1,7 +1,7 @@
from django.conf.urls import url
from django.contrib.auth import views as auth_views
from django.core.urlresolvers import reverse_lazy
from event.views import Index # TODO : mettre le vrai home
from shared.views import Home
from user.views import CreateUser
app_name = 'user'
@ -22,16 +22,12 @@ urlpatterns = [
# LOGOUT
url('^logout/$',
auth_views.logout,
# TODO : mettre le vrai home
{'next_page': reverse_lazy('event:index'),
},
name='logout',),
# PASSWORD_CHANGE
url('^password_change/$',
auth_views.password_change,
{'template_name': 'user/change_pass.html',
# TODO : mettre le vrai home
'post_change_redirect': reverse_lazy('event:index'),
'post_change_redirect': reverse_lazy('shared:home'),
'extra_context': {
'page_title': 'Changement de mot de passe',
'button': 'Modifier',
@ -54,15 +50,17 @@ urlpatterns = [
name='password_reset'),
# PASS RESET DONE
url('^password_reset/done/$',
# TODO : mettre le vrai home
Index.as_view(),
Home.as_view(),
name='password_reset_done'),
# PASS RESET CONFIRM
url('^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
url('^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/'
'(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
auth_views.password_reset_confirm,
{
'template_name': 'user/user_form.html',
'post_reset_redirect': reverse_lazy('user:password_reset_complete'),
'post_reset_redirect': reverse_lazy(
'user:password_reset_complete'
),
'extra_context': {
'page_title': 'Changer de mot de passe',
'button': 'Changer'
@ -71,7 +69,6 @@ urlpatterns = [
name='password_reset_confirm'),
# PASS RESET COMPLETE
url('^reset/done/$',
# TODO : mettre le vrai home
Index.as_view(),
Home.as_view(),
name='password_reset_complete'),
]

View file

@ -3,13 +3,15 @@ from django.views.generic.edit import CreateView
from django.contrib.messages.views import SuccessMessageMixin
from django.core.urlresolvers import reverse_lazy
class CreateUser(SuccessMessageMixin, CreateView):
template_name = 'user/user_form.html'
form_class = CreateUserForm
success_url = reverse_lazy('erkan:index')
template_name = 'user/user_form.html'
form_class = CreateUserForm
success_url = reverse_lazy('shared:home')
success_message = "Votre compte utilisateur a été correctement créé !"
def get_context_data(self, **kwargs):
ctx = super(CreateUser, self).get_context_data(**kwargs)
ctx['button'] = 'Créer'
ctx = super().get_context_data(**kwargs)
ctx['button'] = 'Créer'
ctx['page_title'] = "Création d'utilisateur"
return ctx