Commit b5bc7ba2 authored by Bonnegent's avatar Bonnegent
Browse files

user auto registration

parent a53399fb
......@@ -27,6 +27,8 @@ DEBUG = True
ALLOWED_HOSTS = []
# User registration
ACCOUNT_ACTIVATION_DAYS = 7
# Application definition
......@@ -42,6 +44,7 @@ INSTALLED_APPS = [
'tournois',
'hijack_admin',
'django_extensions',
'registration',
]
MIDDLEWARE = [
......@@ -115,9 +118,9 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = 'fr-fr'
TIME_ZONE = 'UTC'
TIME_ZONE = 'Europe/Paris'
USE_I18N = True
......
"""conf URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import include
from django.conf.urls import url
from django.contrib import admin
from tournois import views
# pour les fichiers static
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^$', views.home, name='home'),
# user registration
# url(r'^accounts/', include('registration.backends.model_activation.urls')),
url(r'^accounts/', include('registration.backends.simple.urls')),
# default auth
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'^admin/', admin.site.urls),
url(r'^', include('tournois.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL,
document_root=settings.STATIC_ROOT)
......@@ -7,3 +7,4 @@ django-hijack-admin
Sphinx
sphinx-bootstrap-theme
django_extensions
django-registration
......@@ -9,11 +9,13 @@ babel==2.5.1 # via sphinx
certifi==2017.11.5 # via requests
chardet==3.0.4 # via requests
click==6.7 # via pip-tools
confusable-homoglyphs==2.0.2 # via django-registration
django-compat==1.0.15
django-documentation==1.1
django-extensions==1.9.9
django-hijack-admin==2.1.6
django-hijack==2.1.6
django-registration==2.3
django==2.0.1
docutils==0.14 # via sphinx
first==2.0.1 # via pip-tools
......
This diff is collapsed.
{% extends "tournois/home.html" %}
{% block title %}Connexion{% endblock %}
{% block content %}
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
{% if next %}
{% if user.is_authenticated %}
<p>Your account doesn't have access to this page. To proceed,
please login with an account that has access.</p>
{% else %}
<p>Please login to see this page.</p>
{% endif %}
{% endif %}
<form method="post" action="{% url 'login' %}">
{% 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>
<tr>
<td colspan=2>
<button class="btn btn-success btn-block" type="submit" value="login"/>
connexion</button>
</td>
</tr>
</table>
<input type="hidden" name="next" value="{{ next }}" />
</form>
{# Assumes you setup the password_reset view in your URLconf #}
<p><a href="{% url 'password_reset' %}">Lost password?</a></p>
{% endblock %}
{% extends "tournois/home.html" %}
{% block title %}Déconnexion réussi{% endblock %}
{% block content %}
<h1>Déconnexion réussi</h1>
<p>Vous êtes maintenant déconnecté.</p>
{% endblock %}
{% extends "tournois/home.html" %}
{% block title %}Connexion{% endblock %}
{% block content %}
<form method="post" action="">
{% csrf_token %}
<table>
{{form.as_table}}
<tr>
<td colspan=2>
<button class="btn btn-success btn-block" type="submit"/>
Création du compte</button>
</td>
</tr>
</table>
</form>
{% endblock %}
......@@ -46,19 +46,24 @@
<span class="sr-only">Toggle navigation</span>
<span class="glyphicon glyphicon glyphicon-collapse-down"></span>
</button>
<a class="navbar-brand" href="{% url 'home' %}">Tournois en cours</a>
<a class="navbar-brand" href="{% url 'home' %}">Terminés</a>
<a class="navbar-brand" href="{% url 'tournois_closed' %}">Tournois en cours</a>
<a class="navbar-brand" href="{% url 'tournois_closed' %}">Terminés</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
{% if user.is_staff %}
<li><a href="/admin/">Administration</a></li>
<li><a href="{% url 'admin:index' %}">Administration</a></li>
{% endif %}
</ul>
<ul class="nav navbar-nav pull-right">
<li><a href="{% url 'home' %}">
{% if user.is_authenticated %}
<li><a href="{% url 'auth_logout' %}">{{user}}
<span class="glyphicon glyphicon-remove-circle"></span>
</a></li>
{% else %}
<li><a href="{% url 'auth_login' %}">Connexion</a></li>
<li><a href="{% url 'registration_register' %}">Créer</a></li>
{% endif %}
</ul>
</div>
</div>
......
{% extends "tournois/home.html" %}
{% load staticfiles %}
{% block title %}Liste des parefeux{% endblock %}
{% block content %}
<div class="list-group">
{% for tournoi in tournoi_list %}
<a href="#" class="list-group-item list-group-item-action flex-column align-items-start active">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">{{tournoi}}</h5>
<small>XX participants</small>
</div>
<p class="mb-1">nas sed diam eget risus varius blandit.</p>
<small>Donec id elit non mi porta.</small>
</a>
{% empty %}
<a href="#" class="list-group-item list-group-item-action flex-column align-items-start">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">Actuellement ancun tournoi</h5>
</div>
</a>
{% endfor %}
{% if user.is_staff %}
<a href="#" class="list-group-item list-group-item-action flex-column align-items-start">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">Créer un tournoi</h5>
</div>
</a>
</div>
{% endif %}
{% endblock %}
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from . import views
urlpatterns = [
url(r'^$', views.TournoiCloseView.as_view(), name='tournois_closed'),
]
from django.shortcuts import render
from django.views import generic
from tournois.models import Tournoi
def home(request):
return render(request, 'tournois/home.html')
class TournoiCloseView(generic.ListView):
model = Tournoi
Supports Markdown
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