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