From 69b0b13ad310e338f3a27247b9aa8592bda98f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Thu, 14 Jul 2016 01:58:52 +0200 Subject: [PATCH] Nettoyage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PEP8 - Fichiers inutilisés --- Ernestophone/settings-example.py | 3 +- Ernestophone/urls.py | 20 +++++-- calendrier/admin.py | 3 - calendrier/calend.py | 16 +++--- calendrier/forms.py | 52 +++++++++++++----- calendrier/migrations/0001_initial.py | 23 ++++++-- .../migrations/0002_event_desc_users.py | 5 +- calendrier/models.py | 14 ++++- calendrier/templatetags/frenchmonth.py | 3 +- calendrier/templatetags/translate.py | 1 + calendrier/tests.py | 3 - calendrier/urls.py | 3 +- gestion/.admin.py.swp | Bin 12288 -> 0 bytes gestion/.models.py.swp | Bin 12288 -> 0 bytes gestion/admin.py | 21 ++++--- gestion/admin.pyc | Bin 2237 -> 0 bytes gestion/forms.py | 9 ++- gestion/migrations/0001_initial.py | 18 ++++-- gestion/migrations/0002_auto_20150413_1705.py | 6 +- gestion/migrations/0003_auto_20151014_1904.py | 9 ++- gestion/migrations/0004_ernestouser_mails.py | 3 +- gestion/models.py | 6 +- gestion/tests.py | 3 - gestion/views.py | 41 ++++++++------ pads/admin.py | 3 - pads/forms.py | 1 + pads/migrations/0001_initial.py | 3 +- pads/models.py | 4 +- pads/tests.py | 3 - pads/urls.py | 4 +- pads/views.py | 8 ++- partitions/admin.py | 3 - partitions/decorators.py | 1 + partitions/forms.py | 3 +- partitions/migrations/0001_initial.py | 3 +- partitions/migrations/0002_partitionset.py | 6 +- .../0004_remove_partition_morceau.py | 2 +- .../0006_partitionset_category_and_infos.py | 11 +++- partitions/models.py | 10 ++-- partitions/tests.py | 3 - partitions/urls.py | 15 +++-- propositions/admin.py | 3 - propositions/forms.py | 3 +- propositions/models.py | 14 +++-- propositions/templatetags/getresponse.py | 1 + propositions/tests.py | 3 - propositions/urls.py | 3 +- propositions/utils.py | 1 + propositions/views.py | 19 +++++-- 49 files changed, 247 insertions(+), 145 deletions(-) delete mode 100644 calendrier/admin.py delete mode 100644 calendrier/tests.py delete mode 100644 gestion/.admin.py.swp delete mode 100644 gestion/.models.py.swp delete mode 100644 gestion/admin.pyc delete mode 100644 gestion/tests.py delete mode 100644 pads/admin.py delete mode 100644 pads/tests.py delete mode 100644 partitions/admin.py delete mode 100644 partitions/tests.py delete mode 100644 propositions/admin.py delete mode 100644 propositions/tests.py diff --git a/Ernestophone/settings-example.py b/Ernestophone/settings-example.py index 481ec5d..cd61502 100644 --- a/Ernestophone/settings-example.py +++ b/Ernestophone/settings-example.py @@ -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" - diff --git a/Ernestophone/urls.py b/Ernestophone/urls.py index 1a47a08..487bd71 100644 --- a/Ernestophone/urls.py +++ b/Ernestophone/urls.py @@ -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[0-9A-Za-z]+)-(?P.+)/$', '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[0-9A-Za-z]+)-(?P.+)/$', + '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')), diff --git a/calendrier/admin.py b/calendrier/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/calendrier/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/calendrier/calend.py b/calendrier/calend.py index a061a4f..e91c321 100644 --- a/calendrier/calend.py +++ b/calendrier/calend.py @@ -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('' % ev.id) body.append(esc(ev.nom)) body.append('
') - return self.day_cell(cssclass, '
%d
%s' % (day, ''.join(body))) - return self.day_cell(cssclass, '
%d
' % day) + return self.day_cell(cssclass, + '
%d
%s' + % (day, ''.join(body))) + return self.day_cell(cssclass, + '
%d
' % 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 '%s' % (cssclass, body) - diff --git a/calendrier/forms.py b/calendrier/forms.py index b69e21d..c012310 100644 --- a/calendrier/forms.py +++ b/calendrier/forms.py @@ -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',) - diff --git a/calendrier/migrations/0001_initial.py b/calendrier/migrations/0001_initial.py index 0fa96ad..aebc813 100644 --- a/calendrier/migrations/0001_initial.py +++ b/calendrier/migrations/0001_initial.py @@ -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')), diff --git a/calendrier/migrations/0002_event_desc_users.py b/calendrier/migrations/0002_event_desc_users.py index 47eefb8..905f7ae 100644 --- a/calendrier/migrations/0002_event_desc_users.py +++ b/calendrier/migrations/0002_event_desc_users.py @@ -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, ), ] diff --git a/calendrier/models.py b/calendrier/models.py index 18d34c4..96eb583 100644 --- a/calendrier/models.py +++ b/calendrier/models.py @@ -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. diff --git a/calendrier/templatetags/frenchmonth.py b/calendrier/templatetags/frenchmonth.py index ffc4b6b..12b1324 100644 --- a/calendrier/templatetags/frenchmonth.py +++ b/calendrier/templatetags/frenchmonth.py @@ -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" diff --git a/calendrier/templatetags/translate.py b/calendrier/templatetags/translate.py index f9093fc..64416bc 100644 --- a/calendrier/templatetags/translate.py +++ b/calendrier/templatetags/translate.py @@ -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) diff --git a/calendrier/tests.py b/calendrier/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/calendrier/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/calendrier/urls.py b/calendrier/urls.py index 22a4723..606e5ee 100644 --- a/calendrier/urls.py +++ b/calendrier/urls.py @@ -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\d+)$', EventUpdate.as_view()), diff --git a/gestion/.admin.py.swp b/gestion/.admin.py.swp deleted file mode 100644 index 95ea2675bd20a3ede743ee9669650a145bda4416..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 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\d+)$', PadUpdate.as_view()), diff --git a/pads/views.py b/pads/views.py index 3b09eb1..d0f0344 100644 --- a/pads/views.py +++ b/pads/views.py @@ -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" diff --git a/partitions/admin.py b/partitions/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/partitions/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/partitions/decorators.py b/partitions/decorators.py index 3b0dcc2..50a7ea9 100644 --- a/partitions/decorators.py +++ b/partitions/decorators.py @@ -1,5 +1,6 @@ from django.contrib.auth.decorators import user_passes_test + def is_chef(user): try: profile = user.profile diff --git a/partitions/forms.py b/partitions/forms.py index f0b50ae..0fe9bb9 100644 --- a/partitions/forms.py +++ b/partitions/forms.py @@ -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) - diff --git a/partitions/migrations/0001_initial.py b/partitions/migrations/0001_initial.py index 1356b49..06abb6a 100644 --- a/partitions/migrations/0001_initial.py +++ b/partitions/migrations/0001_initial.py @@ -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/')), ], diff --git a/partitions/migrations/0002_partitionset.py b/partitions/migrations/0002_partitionset.py index 2325abc..e067289 100644 --- a/partitions/migrations/0002_partitionset.py +++ b/partitions/migrations/0002_partitionset.py @@ -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={ }, diff --git a/partitions/migrations/0004_remove_partition_morceau.py b/partitions/migrations/0004_remove_partition_morceau.py index 2124470..67cdc89 100644 --- a/partitions/migrations/0004_remove_partition_morceau.py +++ b/partitions/migrations/0004_remove_partition_morceau.py @@ -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): diff --git a/partitions/migrations/0006_partitionset_category_and_infos.py b/partitions/migrations/0006_partitionset_category_and_infos.py index 9e53a56..c5ff556 100644 --- a/partitions/migrations/0006_partitionset_category_and_infos.py +++ b/partitions/migrations/0006_partitionset_category_and_infos.py @@ -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, ), ] diff --git a/partitions/models.py b/partitions/models.py index 2f79474..33b07cf 100644 --- a/partitions/models.py +++ b/partitions/models.py @@ -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())) diff --git a/partitions/tests.py b/partitions/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/partitions/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/partitions/urls.py b/partitions/urls.py index bf5fe2a..6a7917b 100644 --- a/partitions/urls.py +++ b/partitions/urls.py @@ -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[^/]+)/(?P[^/]+)/?$', 'listepart'), url(r'^(?P[^/]+)/(?P[^/]+)/upload/?$', 'upload'), url(r'^(?P[^/]+)/(?P[^/]+)/delete/?$', 'delete_morc'), url(r'^(?P[^/]+)/(?P[^/]+)/conf/?$', 'conf_delete_morc'), - url(r'^(?P[^/]+)/(?P[^/]+)/see/(?P\d+)/?$', 'see'), - url(r'^(?P[^/]+)/(?P[^/]+)/(?P\d+)/$', 'download'), - url(r'^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)/delete/?$', 'delete'), - url(r'^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)/conf/?$', 'conf_delete'), + url(r'^(?P[^/]+)/(?P[^/]+)/see/(?P\d+)/?$', + 'see'), + url(r'^(?P[^/]+)/(?P[^/]+)/(?P\d+)/$', + 'download'), + url(r'^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)/delete/?$', + 'delete'), + url(r'^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)/conf/?$', + 'conf_delete'), url(r'^new/?$', 'ajouter_morceau'), ) diff --git a/propositions/admin.py b/propositions/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/propositions/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/propositions/forms.py b/propositions/forms.py index 1d6ef95..d3cff7c 100644 --- a/propositions/forms.py +++ b/propositions/forms.py @@ -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"}), - } + } diff --git a/propositions/models.py b/propositions/models.py index fedc48e..edfc240 100644 --- a/propositions/models.py +++ b/propositions/models.py @@ -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. - diff --git a/propositions/templatetags/getresponse.py b/propositions/templatetags/getresponse.py index 83378c3..941e016 100644 --- a/propositions/templatetags/getresponse.py +++ b/propositions/templatetags/getresponse.py @@ -3,6 +3,7 @@ from propositions.models import Reponses register = template.Library() + @register.inclusion_tag("propositions/reponse.html") def getresponse(user, prop): try: diff --git a/propositions/tests.py b/propositions/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/propositions/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/propositions/urls.py b/propositions/urls.py index 85282de..ae0aa70 100644 --- a/propositions/urls.py +++ b/propositions/urls.py @@ -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\d+)/oui/?$', 'repoui'), diff --git a/propositions/utils.py b/propositions/utils.py index c4d5797..fb81d5b 100644 --- a/propositions/utils.py +++ b/propositions/utils.py @@ -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)] diff --git a/propositions/views.py b/propositions/views.py index f27c51e..44a7055 100644 --- a/propositions/views.py +++ b/propositions/views.py @@ -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)