Merge branch 'qwann/views/shared' into 'master'
Qwann/views/shared See merge request !7
This commit is contained in:
commit
01d8f2bb74
11 changed files with 80 additions and 60 deletions
|
@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/1.9/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from django.core.urlresolvers import reverse_lazy
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
@ -61,6 +62,9 @@ MIDDLEWARE_CLASSES = [
|
||||||
|
|
||||||
ROOT_URLCONF = 'evenementiel.urls'
|
ROOT_URLCONF = 'evenementiel.urls'
|
||||||
|
|
||||||
|
LOGIN_REDIRECT_URL = reverse_lazy('shared:home')
|
||||||
|
LOGOUT_REDIRECT_URL = reverse_lazy('shared:home')
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
|
|
@ -9,6 +9,7 @@ urlpatterns = [
|
||||||
url(r'^admin/', admin.site.urls),
|
url(r'^admin/', admin.site.urls),
|
||||||
url(r'^event/', include('event.urls')),
|
url(r'^event/', include('event.urls')),
|
||||||
url(r'^user/', include('user.urls')),
|
url(r'^user/', include('user.urls')),
|
||||||
|
url(r'^', include('shared.urls')),
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
|
|
@ -18,7 +18,42 @@
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
{% block sidenav %}
|
{% 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 %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block real_content %}
|
{% block real_content %}
|
||||||
|
|
11
shared/templates/home.html
Normal file
11
shared/templates/home.html
Normal 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
7
shared/urls.py
Normal 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'),
|
||||||
|
]
|
|
@ -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"
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
|
@ -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 %}
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "user/base_user.html" %}
|
{% extends "base.html" %}
|
||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
{% load bootstrap %}
|
{% load bootstrap %}
|
||||||
|
|
21
user/urls.py
21
user/urls.py
|
@ -1,7 +1,7 @@
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.contrib.auth import views as auth_views
|
from django.contrib.auth import views as auth_views
|
||||||
from django.core.urlresolvers import reverse_lazy
|
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
|
from user.views import CreateUser
|
||||||
|
|
||||||
app_name = 'user'
|
app_name = 'user'
|
||||||
|
@ -22,16 +22,12 @@ urlpatterns = [
|
||||||
# LOGOUT
|
# LOGOUT
|
||||||
url('^logout/$',
|
url('^logout/$',
|
||||||
auth_views.logout,
|
auth_views.logout,
|
||||||
# TODO : mettre le vrai home
|
|
||||||
{'next_page': reverse_lazy('event:index'),
|
|
||||||
},
|
|
||||||
name='logout',),
|
name='logout',),
|
||||||
# PASSWORD_CHANGE
|
# PASSWORD_CHANGE
|
||||||
url('^password_change/$',
|
url('^password_change/$',
|
||||||
auth_views.password_change,
|
auth_views.password_change,
|
||||||
{'template_name': 'user/change_pass.html',
|
{'template_name': 'user/change_pass.html',
|
||||||
# TODO : mettre le vrai home
|
'post_change_redirect': reverse_lazy('shared:home'),
|
||||||
'post_change_redirect': reverse_lazy('event:index'),
|
|
||||||
'extra_context': {
|
'extra_context': {
|
||||||
'page_title': 'Changement de mot de passe',
|
'page_title': 'Changement de mot de passe',
|
||||||
'button': 'Modifier',
|
'button': 'Modifier',
|
||||||
|
@ -54,15 +50,17 @@ urlpatterns = [
|
||||||
name='password_reset'),
|
name='password_reset'),
|
||||||
# PASS RESET DONE
|
# PASS RESET DONE
|
||||||
url('^password_reset/done/$',
|
url('^password_reset/done/$',
|
||||||
# TODO : mettre le vrai home
|
Home.as_view(),
|
||||||
Index.as_view(),
|
|
||||||
name='password_reset_done'),
|
name='password_reset_done'),
|
||||||
# PASS RESET CONFIRM
|
# 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,
|
auth_views.password_reset_confirm,
|
||||||
{
|
{
|
||||||
'template_name': 'user/user_form.html',
|
'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': {
|
'extra_context': {
|
||||||
'page_title': 'Changer de mot de passe',
|
'page_title': 'Changer de mot de passe',
|
||||||
'button': 'Changer'
|
'button': 'Changer'
|
||||||
|
@ -71,7 +69,6 @@ urlpatterns = [
|
||||||
name='password_reset_confirm'),
|
name='password_reset_confirm'),
|
||||||
# PASS RESET COMPLETE
|
# PASS RESET COMPLETE
|
||||||
url('^reset/done/$',
|
url('^reset/done/$',
|
||||||
# TODO : mettre le vrai home
|
Home.as_view(),
|
||||||
Index.as_view(),
|
|
||||||
name='password_reset_complete'),
|
name='password_reset_complete'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -3,13 +3,15 @@ from django.views.generic.edit import CreateView
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core.urlresolvers import reverse_lazy
|
||||||
|
|
||||||
|
|
||||||
class CreateUser(SuccessMessageMixin, CreateView):
|
class CreateUser(SuccessMessageMixin, CreateView):
|
||||||
template_name = 'user/user_form.html'
|
template_name = 'user/user_form.html'
|
||||||
form_class = CreateUserForm
|
form_class = CreateUserForm
|
||||||
success_url = reverse_lazy('erkan:index')
|
success_url = reverse_lazy('shared:home')
|
||||||
success_message = "Votre compte utilisateur a été correctement créé !"
|
success_message = "Votre compte utilisateur a été correctement créé !"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
ctx = super(CreateUser, self).get_context_data(**kwargs)
|
ctx = super().get_context_data(**kwargs)
|
||||||
ctx['button'] = 'Créer'
|
ctx['button'] = 'Créer'
|
||||||
ctx['page_title'] = "Création d'utilisateur"
|
ctx['page_title'] = "Création d'utilisateur"
|
||||||
return ctx
|
return ctx
|
||||||
|
|
Loading…
Add table
Reference in a new issue