Nettoyage
- PEP8 - Fichiers inutilisés
This commit is contained in:
parent
f39ec8633d
commit
69b0b13ad3
49 changed files with 247 additions and 145 deletions
|
@ -96,7 +96,7 @@ STATICFILES_DIRS = (
|
|||
os.path.join(BASE_DIR, 'media/partitions'),
|
||||
)
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
TEMPLATE_DIRS = (
|
||||
os.path.join(BASE_DIR, 'templates/gestion/'),
|
||||
os.path.join(BASE_DIR, 'templates/'),
|
||||
)
|
||||
|
@ -104,4 +104,3 @@ TEMPLATE_DIRS = (
|
|||
AUTH_PROFILE_MODEL = 'gestion.ErnestoUser'
|
||||
|
||||
LOGIN_URL = "/login"
|
||||
|
||||
|
|
|
@ -3,20 +3,28 @@ from django.contrib import admin
|
|||
from django.conf.urls.static import static
|
||||
from django.conf import settings
|
||||
|
||||
urlpatterns = patterns('',
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
# Examples:
|
||||
url(r'^$', 'gestion.views.home', name='home'),
|
||||
# url(r'^blog/', include('blog.urls')),
|
||||
|
||||
url(r'^login/?$', 'gestion.views.login', ),
|
||||
url(r'^logout/?$', 'django.contrib.auth.views.logout', {'next_page': '/'}, ),
|
||||
url(r'^logout/?$', 'django.contrib.auth.views.logout', {'next_page': '/'}),
|
||||
url(r'^registration/?$', 'gestion.views.inscription_membre'),
|
||||
url(r'^change/?', 'gestion.views.change_membre'),
|
||||
url(r'^password/?', 'gestion.views.change_password'),
|
||||
url(r'^user/password/reset/$', 'django.contrib.auth.views.password_reset', {'post_reset_redirect': '/user/password/reset/done/'}, name="password_reset"),
|
||||
url(r'^user/password/reset/done/$', 'django.contrib.auth.views.password_reset_done'),
|
||||
url(r'^user/password/reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', {'post_reset_redirect': '/user/password/done/'}, name="password_reset_confirm"),
|
||||
url(r'^user/password/done/$', 'django.contrib.auth.views.password_reset_complete'),
|
||||
url(r'^user/password/reset/$', 'django.contrib.auth.views.password_reset',
|
||||
{'post_reset_redirect': '/user/password/reset/done/'},
|
||||
name="password_reset"),
|
||||
url(r'^user/password/reset/done/$',
|
||||
'django.contrib.auth.views.password_reset_done'),
|
||||
url(r'^user/password/reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
|
||||
'django.contrib.auth.views.password_reset_confirm',
|
||||
{'post_reset_redirect': '/user/password/done/'},
|
||||
name="password_reset_confirm"),
|
||||
url(r'^user/password/done/$',
|
||||
'django.contrib.auth.views.password_reset_complete'),
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
url(r'^partitions/', include('partitions.urls')),
|
||||
url(r'^pads/', include('pads.urls')),
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,8 +1,8 @@
|
|||
from django.utils.html import conditional_escape as esc
|
||||
from itertools import groupby
|
||||
from django.utils.safestring import mark_safe
|
||||
from calendar import HTMLCalendar, monthrange
|
||||
from datetime import *
|
||||
from calendar import HTMLCalendar
|
||||
from datetime import date
|
||||
|
||||
|
||||
class EventCalendar(HTMLCalendar):
|
||||
|
||||
|
@ -22,8 +22,11 @@ class EventCalendar(HTMLCalendar):
|
|||
body.append('<a href="/calendar/%s">' % ev.id)
|
||||
body.append(esc(ev.nom))
|
||||
body.append('</a><br/>')
|
||||
return self.day_cell(cssclass, '<div class="dayNumber">%d</div> %s' % (day, ''.join(body)))
|
||||
return self.day_cell(cssclass, '<div class="dayNumber">%d</div>' % day)
|
||||
return self.day_cell(cssclass,
|
||||
'<div class="dayNumber">%d</div> %s'
|
||||
% (day, ''.join(body)))
|
||||
return self.day_cell(cssclass,
|
||||
'<div class="dayNumber">%d</div>' % day)
|
||||
return self.day_cell('noday', ' ')
|
||||
|
||||
def formatmonth(self, year, month):
|
||||
|
@ -31,11 +34,10 @@ class EventCalendar(HTMLCalendar):
|
|||
return super(EventCalendar, self).formatmonth(year, month)
|
||||
|
||||
def group_by_day(self, pEvents):
|
||||
field = lambda ev: ev.date.day
|
||||
def field(ev): ev.date.day
|
||||
return dict(
|
||||
[(dat, list(items)) for dat, items in groupby(pEvents, field)]
|
||||
)
|
||||
|
||||
def day_cell(self, cssclass, body):
|
||||
return '<td class="%s">%s</td>' % (cssclass, body)
|
||||
|
||||
|
|
|
@ -2,42 +2,65 @@ from django import forms
|
|||
from calendrier.models import Event, Participants
|
||||
from gestion.models import ErnestoUser
|
||||
|
||||
|
||||
class ModifEventForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Event
|
||||
exclude = ['slug']
|
||||
widgets = {
|
||||
'description': forms.Textarea(attrs={"placeholder":"facultatif, balises html supportées"}),
|
||||
'date': forms.TextInput(attrs={"placeholder": 'jj/mm/aaaa'}),
|
||||
'debut': forms.TextInput(attrs={"placeholder": 'hh:mm'}),
|
||||
'fin': forms.TextInput(attrs={"placeholder": 'hh:mm facultatif'})
|
||||
'description': forms.Textarea(attrs={
|
||||
"placeholder": "facultatif, balises html supportées"}),
|
||||
'date': forms.TextInput(attrs={"placeholder": 'jj/mm/aaaa'}),
|
||||
'debut': forms.TextInput(attrs={"placeholder": 'hh:mm'}),
|
||||
'fin': forms.TextInput(attrs={"placeholder": 'hh:mm facultatif'})
|
||||
}
|
||||
|
||||
|
||||
class SendMail(forms.Form):
|
||||
message = forms.CharField(max_length=2000, widget=forms.Textarea(attrs={"placeholder":"Remplir ici pour remplacer le mail automatique"}), required=False)
|
||||
message = forms.CharField(
|
||||
max_length=2000,
|
||||
widget=forms.Textarea(
|
||||
attrs={"placeholder":
|
||||
"Remplir ici pour remplacer le mail automatique"}),
|
||||
required=False)
|
||||
|
||||
|
||||
class EventForm(forms.ModelForm):
|
||||
sendmail = forms.BooleanField(initial=False, label="Envoyer l'invitation à la liste fanfare", required=False)
|
||||
message = forms.CharField(max_length=2000, widget=forms.Textarea(attrs={"placeholder":"Remplir ici pour remplacer le mail automatique"}), required=False)
|
||||
sendmail = forms.BooleanField(
|
||||
initial=False,
|
||||
label="Envoyer l'invitation à la liste fanfare",
|
||||
required=False)
|
||||
message = forms.CharField(
|
||||
max_length=2000,
|
||||
widget=forms.Textarea(
|
||||
attrs={"placeholder":
|
||||
"Remplir ici pour remplacer le mail automatique"}),
|
||||
required=False)
|
||||
|
||||
class Meta:
|
||||
model = Event
|
||||
exclude = ['slug']
|
||||
widgets = {
|
||||
'nomcourt': forms.TextInput(attrs={"placeholder": '9 caractères max'}),
|
||||
'description': forms.Textarea(attrs={"placeholder":"facultatif, balises html supportées"}),
|
||||
'date': forms.TextInput(attrs={"placeholder": 'jj/mm/aaaa'}),
|
||||
'debut': forms.TextInput(attrs={"placeholder": 'hh:mm'}),
|
||||
'fin': forms.TextInput(attrs={"placeholder": 'hh:mm facultatif'})
|
||||
'nomcourt': forms.TextInput(
|
||||
attrs={"placeholder": '9 caractères max'}),
|
||||
'description': forms.Textarea(
|
||||
attrs={"placeholder": "facultatif, balises html supportées"}),
|
||||
'date': forms.TextInput(attrs={"placeholder": 'jj/mm/aaaa'}),
|
||||
'debut': forms.TextInput(attrs={"placeholder": 'hh:mm'}),
|
||||
'fin': forms.TextInput(attrs={"placeholder": 'hh:mm facultatif'})
|
||||
}
|
||||
|
||||
|
||||
|
||||
class ParticipantsForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Participants
|
||||
fields = ('reponse', 'details')
|
||||
widgets = {
|
||||
'details': forms.Textarea(attrs={"placeholder": "50 caractères max"}),
|
||||
'details': forms.Textarea(
|
||||
attrs={"placeholder": "50 caractères max"}),
|
||||
}
|
||||
|
||||
|
||||
class ChangeDoodleName(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ChangeDoodleName, self).__init__(*args, **kwargs)
|
||||
|
@ -52,4 +75,3 @@ class ChangeDoodleName(forms.ModelForm):
|
|||
class Meta:
|
||||
model = ErnestoUser
|
||||
fields = ('doodlename',)
|
||||
|
||||
|
|
|
@ -14,16 +14,21 @@ class Migration(migrations.Migration):
|
|||
migrations.CreateModel(
|
||||
name='Event',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)),
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False,
|
||||
primary_key=True, auto_created=True)),
|
||||
('nom', models.CharField(max_length=100)),
|
||||
('nomcourt', models.CharField(verbose_name='Nom court', max_length=9)),
|
||||
('nomcourt', models.CharField(verbose_name='Nom court',
|
||||
max_length=9)),
|
||||
('date', models.DateField()),
|
||||
('debut', models.TimeField()),
|
||||
('fin', models.TimeField(blank=True, null=True)),
|
||||
('slug', models.CharField(max_length=7, editable=False, unique=True)),
|
||||
('slug', models.CharField(max_length=7, editable=False,
|
||||
unique=True)),
|
||||
('lieu', models.CharField(max_length=200)),
|
||||
('description', models.TextField(blank=True)),
|
||||
('calendrier', models.BooleanField(verbose_name='Afficher dans le calendrier pour tous', default=False)),
|
||||
('calendrier', models.BooleanField(
|
||||
verbose_name='Afficher dans le calendrier pour tous',
|
||||
default=False)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Événement',
|
||||
|
@ -33,8 +38,14 @@ class Migration(migrations.Migration):
|
|||
migrations.CreateModel(
|
||||
name='Participants',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, primary_key=True, auto_created=True)),
|
||||
('reponse', models.CharField(verbose_name='Réponse', choices=[('oui', 'Oui'), ('non', 'Non'), ('pe', 'Peut-être')], default='non', max_length=20)),
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False,
|
||||
primary_key=True, auto_created=True)),
|
||||
('reponse', models.CharField(verbose_name='Réponse',
|
||||
choices=[
|
||||
('oui', 'Oui'),
|
||||
('non', 'Non'),
|
||||
('pe', 'Peut-être')],
|
||||
default='non', max_length=20)),
|
||||
('details', models.CharField(blank=True, max_length=50)),
|
||||
('event', models.ForeignKey(to='calendrier.Event')),
|
||||
('participant', models.ForeignKey(to='gestion.ErnestoUser')),
|
||||
|
|
|
@ -14,7 +14,10 @@ class Migration(migrations.Migration):
|
|||
migrations.AddField(
|
||||
model_name='event',
|
||||
name='desc_users',
|
||||
field=models.TextField(null=True, verbose_name='Infos (visible seulement des fanfaron-ne-s)', blank=True),
|
||||
field=models.TextField(
|
||||
null=True,
|
||||
verbose_name='Infos (visible seulement des fanfaron-ne-s)',
|
||||
blank=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
||||
|
|
|
@ -7,6 +7,7 @@ ANSWERS = (
|
|||
('pe', 'Peut-être'),
|
||||
)
|
||||
|
||||
|
||||
class Event(models.Model):
|
||||
nom = models.CharField(max_length=100)
|
||||
nomcourt = models.CharField(max_length=9, verbose_name="Nom court")
|
||||
|
@ -16,8 +17,13 @@ class Event(models.Model):
|
|||
slug = models.CharField(max_length=7, editable=False, unique=True)
|
||||
lieu = models.CharField(max_length=200)
|
||||
description = models.TextField(blank=True)
|
||||
desc_users = models.TextField(blank=True, verbose_name="Infos (visible seulement des fanfaron-ne-s)", null=True)
|
||||
calendrier = models.BooleanField(default=False, verbose_name="Afficher dans le calendrier pour tous")
|
||||
desc_users = models.TextField(
|
||||
blank=True,
|
||||
verbose_name="Infos (visible seulement des fanfaron-ne-s)",
|
||||
null=True)
|
||||
calendrier = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name="Afficher dans le calendrier pour tous")
|
||||
|
||||
def __str__(self):
|
||||
return self.nom
|
||||
|
@ -25,10 +31,12 @@ class Event(models.Model):
|
|||
class Meta:
|
||||
verbose_name = "Événement"
|
||||
|
||||
|
||||
class Participants(models.Model):
|
||||
event = models.ForeignKey(Event)
|
||||
participant = models.ForeignKey(ErnestoUser)
|
||||
reponse = models.CharField("Réponse", max_length = 20, default = "non", choices = ANSWERS)
|
||||
reponse = models.CharField("Réponse", max_length=20, default="non",
|
||||
choices=ANSWERS)
|
||||
details = models.CharField(max_length=50, blank=True)
|
||||
|
||||
# Create your models here.
|
||||
|
|
|
@ -2,6 +2,7 @@ from django import template
|
|||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def frenchmonth(tex):
|
||||
rep = tex
|
||||
|
@ -21,7 +22,7 @@ def frenchmonth(tex):
|
|||
rep = "Juillet"
|
||||
if tex == "August":
|
||||
rep = "Août"
|
||||
if tex == "September":
|
||||
if tex == "September":
|
||||
rep = "Septembre"
|
||||
if tex == "October":
|
||||
rep = "Octobre"
|
||||
|
|
|
@ -3,6 +3,7 @@ from django.utils.safestring import mark_safe
|
|||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def translate(tex):
|
||||
tex = tex.replace("January", "Janvier", 1)
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -1,7 +1,8 @@
|
|||
from django.conf.urls import patterns, url
|
||||
from calendrier.views import EventUpdate, EventDelete
|
||||
|
||||
urlpatterns = patterns('calendrier.views',
|
||||
urlpatterns = patterns(
|
||||
'calendrier.views',
|
||||
url(r'^new$', 'create_event'),
|
||||
url(r'^$', 'home'),
|
||||
url(r'^edition/(?P<pk>\d+)$', EventUpdate.as_view()),
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -4,9 +4,11 @@ from gestion.models import ErnestoUser
|
|||
from django.contrib.auth.admin import UserAdmin
|
||||
from calendrier.models import Event
|
||||
|
||||
|
||||
class UserProfileInline(admin.StackedInline):
|
||||
model = ErnestoUser
|
||||
|
||||
|
||||
|
||||
def ProfileInfo(field, short_description, boolean=False):
|
||||
def getter(self):
|
||||
try:
|
||||
|
@ -23,16 +25,21 @@ User.profile_is_ern = ProfileInfo("is_ernesto", "Ernestophoniste")
|
|||
User.profile_is_chef = ProfileInfo("is_chef", "Chef Fanfare")
|
||||
User.profile_get_mails = ProfileInfo("mails", "Recevoir les mails")
|
||||
|
||||
|
||||
class UserProfileAdmin(UserAdmin):
|
||||
list_display = ('username', 'first_name', 'last_name', 'email', 'profile_phone', 'profile_instru', 'profile_is_ern', 'profile_is_chef',)
|
||||
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, ]
|
||||
fieldsets = (('Général', { 'fields': ('username', 'password', 'first_name', 'last_name', ) }),
|
||||
('Permissions', {'fields': ('is_active', 'is_staff', 'is_superuser' )})
|
||||
)
|
||||
search_fields = ('username', 'first_name', 'last_name', 'profile__phone',
|
||||
'profile__instru',)
|
||||
inlines = [UserProfileInline, ]
|
||||
fieldsets = (('Général', {'fields': ('username', 'password', 'first_name',
|
||||
'last_name', )}),
|
||||
('Permissions', {'fields': ('is_active', 'is_staff',
|
||||
'is_superuser')}))
|
||||
|
||||
|
||||
admin.site.unregister(User)
|
||||
|
|
Binary file not shown.
|
@ -1,19 +1,24 @@
|
|||
from django import forms
|
||||
from gestion.models import ErnestoUser
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
|
||||
|
||||
class RegistrationFormUser(UserCreationForm):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('username', 'first_name', 'last_name', 'password1', 'password2', 'email',)
|
||||
fields = ('username', 'first_name', 'last_name', 'password1',
|
||||
'password2', 'email',)
|
||||
|
||||
|
||||
class InscriptionMembreForm(forms.ModelForm):
|
||||
validation = forms.CharField(max_length=100, widget=forms.PasswordInput)
|
||||
|
||||
class Meta:
|
||||
model = ErnestoUser
|
||||
fields = ("phone", "instru", )
|
||||
|
||||
|
||||
class ChangeMembreForm(forms.ModelForm):
|
||||
first_name = forms.CharField(max_length=30, required=False)
|
||||
last_name = forms.CharField(max_length=50, required=False)
|
||||
|
|
|
@ -15,11 +15,19 @@ class Migration(migrations.Migration):
|
|||
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)),
|
||||
('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={
|
||||
|
|
|
@ -15,11 +15,13 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='ernestouser',
|
||||
name='phone',
|
||||
field=models.CharField(max_length=20, blank=True, verbose_name='Téléphone'),
|
||||
field=models.CharField(max_length=20, blank=True,
|
||||
verbose_name='Téléphone'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='ernestouser',
|
||||
name='user',
|
||||
field=models.OneToOneField(to=settings.AUTH_USER_MODEL, related_name='profile'),
|
||||
field=models.OneToOneField(to=settings.AUTH_USER_MODEL,
|
||||
related_name='profile'),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -13,18 +13,21 @@ class Migration(migrations.Migration):
|
|||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='ernestouser',
|
||||
options={'verbose_name_plural': 'Profil Ernestophoniste', 'verbose_name': 'Profil Ernestophoniste'},
|
||||
options={'verbose_name_plural': 'Profil Ernestophoniste',
|
||||
'verbose_name': 'Profil Ernestophoniste'},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='ernestouser',
|
||||
name='doodlename',
|
||||
field=models.CharField(max_length=30, default='afafa', blank=True, verbose_name='Nom pour le doodle'),
|
||||
field=models.CharField(max_length=30, default='afafa', blank=True,
|
||||
verbose_name='Nom pour le doodle'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='ernestouser',
|
||||
name='slug',
|
||||
field=models.CharField(max_length=7, default='fafafa', editable=False, unique=True),
|
||||
field=models.CharField(max_length=7, default='fafafa',
|
||||
editable=False, unique=True),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
|
|
|
@ -14,7 +14,8 @@ class Migration(migrations.Migration):
|
|||
migrations.AddField(
|
||||
model_name='ernestouser',
|
||||
name='mails',
|
||||
field=models.BooleanField(default=True, verbose_name='Recevoir les mails'),
|
||||
field=models.BooleanField(default=True,
|
||||
verbose_name='Recevoir les mails'),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
||||
|
|
|
@ -3,14 +3,16 @@
|
|||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class ErnestoUser(models.Model):
|
||||
user = models.OneToOneField(User, related_name = "profile")
|
||||
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)
|
||||
slug = models.CharField(max_length=7, editable=False, unique=True)
|
||||
doodlename = models.CharField("Nom pour le doodle", max_length=30, blank=True)
|
||||
doodlename = models.CharField("Nom pour le doodle", max_length=30,
|
||||
blank=True)
|
||||
mails = models.BooleanField("Recevoir les mails", default=True)
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -1,21 +1,19 @@
|
|||
from django.shortcuts import render, redirect
|
||||
from django.shortcuts import render
|
||||
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, PasswordChangeForm
|
||||
from django.contrib.auth.forms import PasswordChangeForm
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from datetime import datetime
|
||||
|
||||
from datetime import *
|
||||
import smtplib
|
||||
|
||||
from gestion.forms import InscriptionMembreForm, RegistrationFormUser, ChangeMembreForm
|
||||
from gestion.forms import InscriptionMembreForm, RegistrationFormUser, \
|
||||
ChangeMembreForm
|
||||
from gestion.models import ErnestoUser
|
||||
from propositions.utils import generer
|
||||
|
||||
from calendrier.views import calendar
|
||||
|
||||
|
||||
def inscription_membre(request):
|
||||
if request.method == 'POST':
|
||||
requbis = request.POST.copy()
|
||||
|
@ -33,12 +31,13 @@ def inscription_membre(request):
|
|||
try:
|
||||
ErnestoUser.objects.get(slug=code)
|
||||
except:
|
||||
temp=False
|
||||
temp = False
|
||||
member.save()
|
||||
(profile, _) = ErnestoUser.objects.get_or_create(user = member, slug=code)
|
||||
comp_form = InscriptionMembreForm(requbis, instance = profile)
|
||||
(profile, _) = ErnestoUser.objects.get_or_create(user=member,
|
||||
slug=code)
|
||||
comp_form = InscriptionMembreForm(requbis, instance=profile)
|
||||
obj = comp_form.save(commit=False)
|
||||
obj.slug=code
|
||||
obj.slug = code
|
||||
obj.save()
|
||||
envoi = True
|
||||
return render(request, 'gestion/thanks.html', locals())
|
||||
|
@ -47,6 +46,7 @@ def inscription_membre(request):
|
|||
user_form = RegistrationFormUser()
|
||||
return render(request, 'gestion/registration.html', locals())
|
||||
|
||||
|
||||
@login_required
|
||||
def change_password(request):
|
||||
if request.method == 'POST':
|
||||
|
@ -59,34 +59,39 @@ def change_password(request):
|
|||
form = PasswordChangeForm(request.user)
|
||||
return render(request, 'gestion/changepasswd.html', locals())
|
||||
|
||||
|
||||
@login_required
|
||||
def change_membre(request):
|
||||
if request.method == 'POST':
|
||||
requbis=request.POST.copy()
|
||||
form = ChangeMembreForm(requbis, instance = request.user)
|
||||
requbis = request.POST.copy()
|
||||
form = ChangeMembreForm(requbis, instance=request.user)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
success=True
|
||||
success = True
|
||||
else:
|
||||
form = ChangeMembreForm(instance=request.user)
|
||||
return render(request, 'gestion/change.html', locals())
|
||||
|
||||
|
||||
def home(request):
|
||||
lToday = datetime.now()
|
||||
return calendar(request, lToday.year, lToday.month)
|
||||
|
||||
|
||||
def login(request):
|
||||
if request.method == "POST" and "username" in request.POST:
|
||||
try:
|
||||
user = User.objects.get(username = request.POST["username"])
|
||||
user = User.objects.get(username=request.POST["username"])
|
||||
if not user.is_active:
|
||||
error = "Votre compte n'est pas actif"
|
||||
return render(request, "gestion/login.html", locals())
|
||||
if not user.has_usable_password() or user.password in ("", "!"):
|
||||
return render(request, "error.html", {"error_type": "no_password"})
|
||||
return render(request, "error.html",
|
||||
{"error_type": "no_password"})
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
return django_login_view(request, template_name = 'login.html', )
|
||||
return django_login_view(request, template_name='login.html')
|
||||
|
||||
|
||||
@login_required
|
||||
def divers(request):
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,6 +1,7 @@
|
|||
from django import forms
|
||||
from pads.models import Pad
|
||||
|
||||
|
||||
class PadForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Pad
|
||||
|
|
|
@ -13,7 +13,8 @@ class Migration(migrations.Migration):
|
|||
migrations.CreateModel(
|
||||
name='Pad',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)),
|
||||
('id', models.AutoField(verbose_name='ID', primary_key=True,
|
||||
auto_created=True, serialize=False)),
|
||||
('nom', models.CharField(max_length=100)),
|
||||
('url', models.URLField()),
|
||||
('date', models.DateField(verbose_name='Créé le')),
|
||||
|
|
|
@ -4,11 +4,11 @@ from django.db import models
|
|||
class Pad(models.Model):
|
||||
nom = models.CharField(max_length=100)
|
||||
url = models.URLField()
|
||||
date = models.DateField(verbose_name="Créé le")
|
||||
date = models.DateField(verbose_name="Créé le")
|
||||
|
||||
def __str__(self):
|
||||
return self.nom
|
||||
|
||||
class Meta:
|
||||
verbose_name="Pad"
|
||||
verbose_name = "Pad"
|
||||
# Create your models here.
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -1,7 +1,9 @@
|
|||
from django.conf.urls import patterns, url
|
||||
from pads.views import PadUpdate, PadDelete
|
||||
|
||||
urlpatterns = patterns('pads.views',
|
||||
|
||||
urlpatterns = patterns(
|
||||
'pads.views',
|
||||
url(r'^$', 'liste_pads'),
|
||||
url(r'^ajouter$', 'add_pad'),
|
||||
url(r'^edition/(?P<pk>\d+)$', PadUpdate.as_view()),
|
||||
|
|
|
@ -10,11 +10,13 @@ from pads.forms import PadForm
|
|||
|
||||
from partitions.decorators import chef_required
|
||||
|
||||
|
||||
@login_required
|
||||
def liste_pads(request):
|
||||
pads = Pad.objects.all().order_by("-date")
|
||||
return render(request, "pads/liste.html", locals())
|
||||
|
||||
|
||||
@chef_required
|
||||
def add_pad(request):
|
||||
if request.method == "POST":
|
||||
|
@ -28,15 +30,17 @@ def add_pad(request):
|
|||
form = PadForm()
|
||||
return render(request, "pads/create.html", locals())
|
||||
|
||||
|
||||
class PadUpdate(UpdateView):
|
||||
model = Pad
|
||||
template_name="pads/update.html"
|
||||
success_url=reverse_lazy(liste_pads)
|
||||
template_name = "pads/update.html"
|
||||
success_url = reverse_lazy(liste_pads)
|
||||
|
||||
@method_decorator(chef_required)
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(PadUpdate, self).dispatch(*args, **kwargs)
|
||||
|
||||
|
||||
class PadDelete(DeleteView):
|
||||
model = Pad
|
||||
template_name = "pads/delete.html"
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,5 +1,6 @@
|
|||
from django.contrib.auth.decorators import user_passes_test
|
||||
|
||||
|
||||
def is_chef(user):
|
||||
try:
|
||||
profile = user.profile
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from django import forms
|
||||
|
||||
|
||||
class UploadFileForm(forms.Form):
|
||||
title = forms.CharField(max_length=50)
|
||||
file = forms.FileField()
|
||||
|
||||
|
||||
class UploadMorceauForm(forms.Form):
|
||||
titre = forms.CharField(max_length=100)
|
||||
auteur = forms.CharField(max_length=100)
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ class Migration(migrations.Migration):
|
|||
migrations.CreateModel(
|
||||
name='Partition',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, serialize=False, primary_key=True, verbose_name='ID')),
|
||||
('id', models.AutoField(auto_created=True, serialize=False,
|
||||
primary_key=True, verbose_name='ID')),
|
||||
('nom', models.CharField(max_length=100)),
|
||||
('part', models.FileField(upload_to='partitions/')),
|
||||
],
|
||||
|
|
|
@ -14,10 +14,12 @@ class Migration(migrations.Migration):
|
|||
migrations.CreateModel(
|
||||
name='PartitionSet',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)),
|
||||
('id', models.AutoField(primary_key=True, verbose_name='ID',
|
||||
auto_created=True, serialize=False)),
|
||||
('nom', models.CharField(max_length=100)),
|
||||
('auteur', models.CharField(max_length=100)),
|
||||
('pupitres', models.ManyToManyField(to='partitions.Partition')),
|
||||
('pupitres', models.ManyToManyField(
|
||||
to='partitions.Partition')),
|
||||
],
|
||||
options={
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
|
@ -14,13 +14,20 @@ class Migration(migrations.Migration):
|
|||
migrations.AddField(
|
||||
model_name='partitionset',
|
||||
name='category',
|
||||
field=models.CharField(choices=[('active', 'Actif'), ('incoming', 'À venir'), ('old', 'Archive')], max_length=8, verbose_name='Types de partitions', default='incoming'),
|
||||
field=models.CharField(choices=[
|
||||
('active', 'Actif'),
|
||||
('incoming', 'À venir'),
|
||||
('old', 'Archive')],
|
||||
max_length=8,
|
||||
verbose_name='Types de partitions',
|
||||
default='incoming'),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='partitionset',
|
||||
name='infos',
|
||||
field=models.TextField(null=True, blank=True, verbose_name='Infos utiles'),
|
||||
field=models.TextField(null=True, blank=True,
|
||||
verbose_name='Infos utiles'),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
||||
|
|
|
@ -9,6 +9,7 @@ PARTITION_TYPES = (
|
|||
("old", "Archive"),
|
||||
)
|
||||
|
||||
|
||||
class Partition(models.Model):
|
||||
nom = models.CharField(max_length=100)
|
||||
part = models.FileField(upload_to="partitions/")
|
||||
|
@ -18,17 +19,18 @@ class Partition(models.Model):
|
|||
return self.nom
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
os.remove(os.path.join(Ernestophone.settings.MEDIA_ROOT, self.part.name))
|
||||
os.remove(os.path.join(Ernestophone.settings.MEDIA_ROOT,
|
||||
self.part.name))
|
||||
super(Partition, self).delete(*args, **kwargs)
|
||||
|
||||
|
||||
class PartitionSet(models.Model):
|
||||
nom = models.CharField(max_length=100)
|
||||
auteur = models.CharField(max_length=100)
|
||||
category = models.CharField('Types de partitions', max_length=8,
|
||||
choices=PARTITION_TYPES, default="incoming")
|
||||
choices=PARTITION_TYPES, default="incoming")
|
||||
infos = models.TextField("Infos utiles", null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return("%s - %s [%s]" % (self.nom, self.auteur,
|
||||
self.get_category_display()))
|
||||
|
||||
self.get_category_display()))
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -1,14 +1,19 @@
|
|||
from django.conf.urls import patterns, url
|
||||
|
||||
urlpatterns = patterns('partitions.views',
|
||||
urlpatterns = patterns(
|
||||
'partitions.views',
|
||||
url(r'^$', 'liste'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/?$', 'listepart'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/upload/?$', 'upload'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/delete/?$', 'delete_morc'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/conf/?$', 'conf_delete_morc'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/see/(?P<partition_id>\d+)/?$', 'see'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/(?P<partition_id>\d+)/$', 'download'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/(?P<id>[^/]+)/delete/?$', 'delete'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/(?P<id>[^/]+)/conf/?$', 'conf_delete'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/see/(?P<partition_id>\d+)/?$',
|
||||
'see'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/(?P<partition_id>\d+)/$',
|
||||
'download'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/(?P<id>[^/]+)/delete/?$',
|
||||
'delete'),
|
||||
url(r'^(?P<nom>[^/]+)/(?P<auteur>[^/]+)/(?P<id>[^/]+)/conf/?$',
|
||||
'conf_delete'),
|
||||
url(r'^new/?$', 'ajouter_morceau'),
|
||||
)
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,6 +1,7 @@
|
|||
from django import forms
|
||||
from propositions.models import Prop
|
||||
|
||||
|
||||
class PropForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Prop
|
||||
|
@ -9,4 +10,4 @@ class PropForm(forms.ModelForm):
|
|||
'lien': forms.TextInput(attrs={"placeholder": "facultatif"}),
|
||||
'nom': forms.TextInput(attrs={"placeholder": "Nom du morceau"}),
|
||||
'artiste': forms.TextInput(attrs={"placeholder": "facultatif"}),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,10 @@ REP = (
|
|||
('non', 'Non'),
|
||||
)
|
||||
|
||||
|
||||
class Prop(models.Model):
|
||||
nom = models.CharField(max_length=100)
|
||||
artiste = models.CharField(blank=True, max_length=100)
|
||||
nom = models.CharField(max_length=100)
|
||||
artiste = models.CharField(blank=True, max_length=100)
|
||||
user = models.ForeignKey(ErnestoUser, verbose_name="Proposé par")
|
||||
lien = models.URLField(blank=True)
|
||||
nboui = models.IntegerField(default=0, verbose_name="oui")
|
||||
|
@ -18,12 +19,13 @@ class Prop(models.Model):
|
|||
return self.nom
|
||||
|
||||
class Meta:
|
||||
verbose_name="Proposition"
|
||||
|
||||
verbose_name = "Proposition"
|
||||
|
||||
|
||||
class Reponses(models.Model):
|
||||
prop = models.ForeignKey(Prop)
|
||||
part = models.ForeignKey(ErnestoUser)
|
||||
reponse = models.CharField("Réponse", max_length=20, blank=True, choices=REP)
|
||||
reponse = models.CharField("Réponse", max_length=20, blank=True,
|
||||
choices=REP)
|
||||
|
||||
# Create your models here.
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ from propositions.models import Reponses
|
|||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.inclusion_tag("propositions/reponse.html")
|
||||
def getresponse(user, prop):
|
||||
try:
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -1,7 +1,8 @@
|
|||
from django.conf.urls import patterns, url
|
||||
from propositions.views import PropDelete
|
||||
|
||||
urlpatterns = patterns('propositions.views',
|
||||
urlpatterns = patterns(
|
||||
'propositions.views',
|
||||
url(r'^$', 'liste'),
|
||||
url(r'^new/?$', 'create_prop'),
|
||||
url(r'^(?P<id>\d+)/oui/?$', 'repoui'),
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import string
|
||||
import random
|
||||
|
||||
|
||||
def generer(*args):
|
||||
caracteres = string.ascii_letters + string.digits
|
||||
aleatoire = [random.choice(caracteres) for _ in range(6)]
|
||||
|
|
|
@ -9,6 +9,7 @@ from propositions.forms import PropForm
|
|||
from propositions.models import Prop
|
||||
from propositions.models import Reponses
|
||||
|
||||
|
||||
@login_required
|
||||
def create_prop(request):
|
||||
if request.method == "POST":
|
||||
|
@ -24,12 +25,14 @@ def create_prop(request):
|
|||
form = PropForm()
|
||||
return render(request, "propositions/create.html", locals())
|
||||
|
||||
|
||||
@login_required
|
||||
def liste(request):
|
||||
props = Prop.objects.all().order_by('-nboui', 'nbnon', 'nom')
|
||||
n = len(props)
|
||||
return render(request, 'propositions/liste.html', locals())
|
||||
|
||||
|
||||
|
||||
@login_required
|
||||
def repoui(request, id):
|
||||
prop = Prop.objects.get(id=id)
|
||||
|
@ -39,7 +42,7 @@ def repoui(request, id):
|
|||
if p.reponse == "oui":
|
||||
prop.nboui -= 1
|
||||
else:
|
||||
prop.nbnon-=1
|
||||
prop.nbnon -= 1
|
||||
p.delete()
|
||||
except Reponses.DoesNotExist:
|
||||
pass
|
||||
|
@ -50,26 +53,29 @@ def repoui(request, id):
|
|||
rep.save()
|
||||
prop.nboui += 1
|
||||
prop.save()
|
||||
return redirect('propositions.views.liste')
|
||||
return redirect('propositions.views.liste')
|
||||
|
||||
|
||||
class PropDelete(DeleteView):
|
||||
model = Prop
|
||||
template_name= "propositions/delete.html"
|
||||
template_name = "propositions/delete.html"
|
||||
success_url = reverse_lazy(liste)
|
||||
|
||||
@method_decorator(login_required)
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(PropDelete, self).dispatch(*args, **kwargs)
|
||||
return super(PropDelete, self).dispatch(*args, **kwargs)
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
success_url = self.get_success_url()
|
||||
if not ((self.object.user == self.request.user.profile) or self.request.user.profile.is_chef):
|
||||
if not ((self.object.user == self.request.user.profile)
|
||||
or self.request.user.profile.is_chef):
|
||||
return redirect('propositions.views.liste')
|
||||
else:
|
||||
self.object.delete()
|
||||
return HttpResponseRedirect(success_url)
|
||||
|
||||
|
||||
@login_required
|
||||
def test(request, pk):
|
||||
error = "Connard"
|
||||
|
@ -77,6 +83,7 @@ def test(request, pk):
|
|||
return redirect(PropDelete.as_view())
|
||||
return render(request, "propositions/liste.html", locals())
|
||||
|
||||
|
||||
@login_required
|
||||
def repnon(request, id):
|
||||
prop = Prop.objects.get(id=id)
|
||||
|
|
Loading…
Reference in a new issue