Jusqu'à présent
This commit is contained in:
parent
0efdab977d
commit
0b934c51b1
93 changed files with 10455 additions and 0 deletions
BIN
gestion/.admin.py.swp
Normal file
BIN
gestion/.admin.py.swp
Normal file
Binary file not shown.
BIN
gestion/.models.py.swp
Normal file
BIN
gestion/.models.py.swp
Normal file
Binary file not shown.
0
gestion/__init__.py
Normal file
0
gestion/__init__.py
Normal file
BIN
gestion/__init__.pyc
Normal file
BIN
gestion/__init__.pyc
Normal file
Binary file not shown.
BIN
gestion/__pycache__/__init__.cpython-34.pyc
Normal file
BIN
gestion/__pycache__/__init__.cpython-34.pyc
Normal file
Binary file not shown.
BIN
gestion/__pycache__/admin.cpython-34.pyc
Normal file
BIN
gestion/__pycache__/admin.cpython-34.pyc
Normal file
Binary file not shown.
BIN
gestion/__pycache__/forms.cpython-34.pyc
Normal file
BIN
gestion/__pycache__/forms.cpython-34.pyc
Normal file
Binary file not shown.
BIN
gestion/__pycache__/models.cpython-34.pyc
Normal file
BIN
gestion/__pycache__/models.cpython-34.pyc
Normal file
Binary file not shown.
BIN
gestion/__pycache__/views.cpython-34.pyc
Normal file
BIN
gestion/__pycache__/views.cpython-34.pyc
Normal file
Binary file not shown.
35
gestion/admin.py
Normal file
35
gestion/admin.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
from django.contrib import admin
|
||||
from django.contrib.auth.models import User, Group
|
||||
from gestion.models import ErnestoUser
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
|
||||
class UserProfileInline(admin.StackedInline):
|
||||
model = ErnestoUser
|
||||
|
||||
def ProfileInfo(field, short_description, boolean=False):
|
||||
def getter(self):
|
||||
try:
|
||||
return getattr(self.profile, field)
|
||||
except ErnestoUser.DoesNotExist:
|
||||
return ""
|
||||
getter.short_description = short_description
|
||||
getter.boolean = boolean
|
||||
return getter
|
||||
|
||||
User.profile_phone = ProfileInfo("phone", "Telephone")
|
||||
User.profile_instru = ProfileInfo("instru", "Instrument joué")
|
||||
User.profile_is_ern = ProfileInfo("is_ernesto", "Ernestophoniste")
|
||||
User.profile_is_chef = ProfileInfo("is_chef", "Chef Fanfare")
|
||||
|
||||
class UserProfileAdmin(UserAdmin):
|
||||
list_display = ('username', 'first_name', 'last_name', 'email', 'profile_phone', 'profile_instru', 'profile_is_ern', 'profile_is_chef',)
|
||||
list_display_links = ('username', 'email', 'first_name', 'last_name',)
|
||||
list_filter = ('profile__instru',)
|
||||
ordering = ('username',)
|
||||
search_fields = ('username', 'first_name', 'last_name', 'profile__phone', 'profile__instru',)
|
||||
inlines = [ UserProfileInline, ]
|
||||
|
||||
admin.site.unregister(User)
|
||||
admin.site.unregister(Group)
|
||||
admin.site.register(User, UserProfileAdmin)
|
||||
# Register your models here.
|
BIN
gestion/admin.pyc
Normal file
BIN
gestion/admin.pyc
Normal file
Binary file not shown.
14
gestion/forms.py
Normal file
14
gestion/forms.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from django import forms
|
||||
from gestion.models import ErnestoUser
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
|
||||
class RegistrationFormUser(UserCreationForm):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('username', 'first_name', 'last_name', 'password1', 'password2', 'email',)
|
||||
|
||||
class InscriptionMembreForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = ErnestoUser
|
||||
fields = ("phone", "instru", )
|
31
gestion/migrations/0001_initial.py
Normal file
31
gestion/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ErnestoUser',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, serialize=False, primary_key=True, verbose_name='ID')),
|
||||
('is_ernesto', models.BooleanField(default=True, verbose_name="Membre de l'Ernestophone")),
|
||||
('is_chef', models.BooleanField(default=False, verbose_name='Chef Fanfare')),
|
||||
('phone', models.CharField(max_length=20, verbose_name='Telephone', blank=True)),
|
||||
('instru', models.CharField(max_length=40, verbose_name='Instrument joué', blank=True)),
|
||||
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Profil Ernestophoniste',
|
||||
'verbose_name_plural': 'Profils Ernestophonistes',
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
]
|
27
gestion/migrations/0002_auto_20150313_1739.py
Normal file
27
gestion/migrations/0002_auto_20150313_1739.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gestion', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='ernestouser',
|
||||
name='phone',
|
||||
field=models.CharField(max_length=20, blank=True, verbose_name='Téléphone'),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='ernestouser',
|
||||
name='user',
|
||||
field=models.OneToOneField(to=settings.AUTH_USER_MODEL, related_name='profile'),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
0
gestion/migrations/__init__.py
Normal file
0
gestion/migrations/__init__.py
Normal file
BIN
gestion/migrations/__pycache__/0001_initial.cpython-34.pyc
Normal file
BIN
gestion/migrations/__pycache__/0001_initial.cpython-34.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
gestion/migrations/__pycache__/__init__.cpython-34.pyc
Normal file
BIN
gestion/migrations/__pycache__/__init__.cpython-34.pyc
Normal file
Binary file not shown.
20
gestion/models.py
Normal file
20
gestion/models.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
class ErnestoUser(models.Model):
|
||||
user = models.OneToOneField(User, related_name = "profile")
|
||||
is_ernesto = models.BooleanField("Membre de l'Ernestophone", default=True)
|
||||
is_chef = models.BooleanField("Chef Fanfare", default=False)
|
||||
phone = models.CharField("Téléphone", max_length=20, blank=True)
|
||||
instru = models.CharField("Instrument joué", max_length=40, blank=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Profil Ernestophoniste"
|
||||
verbose_name_plural = "Profils Ernestophonistes"
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.user.username)
|
||||
|
||||
# Create your models here.
|
BIN
gestion/models.pyc
Normal file
BIN
gestion/models.pyc
Normal file
Binary file not shown.
3
gestion/tests.py
Normal file
3
gestion/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
43
gestion/views.py
Normal file
43
gestion/views.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
from django.shortcuts import render, redirect
|
||||
from django.contrib.auth.views import login as django_login_view
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.forms import AuthenticationForm
|
||||
|
||||
from gestion.forms import InscriptionMembreForm, RegistrationFormUser
|
||||
from gestion.models import ErnestoUser
|
||||
|
||||
def inscription_membre(request):
|
||||
if request.method == 'POST':
|
||||
requbis = request.POST.copy()
|
||||
user_form = RegistrationFormUser(requbis)
|
||||
comp_form = InscriptionMembreForm(requbis)
|
||||
|
||||
if user_form.is_valid() and comp_form.is_valid():
|
||||
pseudo = user_form.cleaned_data['username']
|
||||
member = user_form.save()
|
||||
(profile, _) = ErnestoUser.objects.get_or_create(user = member)
|
||||
comp_form = InscriptionMembreForm(requbis, instance = profile)
|
||||
comp_form.save()
|
||||
envoi = True
|
||||
return render(request, 'gestion/thanks.html', locals())
|
||||
else:
|
||||
comp_form = InscriptionMembreForm()
|
||||
user_form = RegistrationFormUser()
|
||||
return render(request, 'gestion/registration.html', locals())
|
||||
|
||||
def home(request):
|
||||
return render(request, 'gestion/home.html', {} )
|
||||
|
||||
def login(request):
|
||||
if request.method == "POST" and "username" in request.POST:
|
||||
try:
|
||||
user = User.objects.get(username = request.POST["username"])
|
||||
if not user.has_usable_password() or user.password in ("", "!"):
|
||||
return render(request, "error.html", {"error_type": "no_password"})
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
return django_login_view(request, template_name = 'login.html', )
|
||||
|
||||
|
||||
|
||||
# Create your views here.
|
Loading…
Add table
Add a link
Reference in a new issue