Merge branch 'Elarnon/pyflakes' into 'master'
Nettoyage de code Essentiellement, suppression d'import inutilisés. See merge request !33
This commit is contained in:
commit
c81cad77e5
14 changed files with 8 additions and 48 deletions
|
@ -1,7 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
from django.contrib.contenttypes.models import ContentType
|
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.db.models import Sum, Count
|
from django.db.models import Sum, Count
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.forms.models import BaseInlineFormSet
|
from django.forms.models import BaseInlineFormSet
|
||||||
from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution
|
from bda.models import Spectacle
|
||||||
|
|
||||||
class BaseBdaFormSet(BaseInlineFormSet):
|
class BaseBdaFormSet(BaseInlineFormSet):
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
|
|
@ -5,7 +5,6 @@ import calendar
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.db.models.signals import post_save
|
|
||||||
|
|
||||||
class Tirage(models.Model):
|
class Tirage(models.Model):
|
||||||
title = models.CharField("Titre", max_length=300)
|
title = models.CharField("Titre", max_length=300)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from django.conf.urls import include, url, patterns
|
from django.conf.urls import url, patterns
|
||||||
from bda import views
|
|
||||||
from bda.views import SpectacleListView
|
from bda.views import SpectacleListView
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
|
|
16
bda/views.py
16
bda/views.py
|
@ -2,11 +2,9 @@
|
||||||
|
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.http import Http404
|
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
from django.forms.models import inlineformset_factory
|
from django.forms.models import inlineformset_factory
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -19,7 +17,6 @@ from datetime import timedelta
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from gestioncof.decorators import cof_required, buro_required
|
from gestioncof.decorators import cof_required, buro_required
|
||||||
from gestioncof.shared import send_custom_mail
|
|
||||||
from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution, Tirage
|
from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution, Tirage
|
||||||
from bda.algorithm import Algorithm
|
from bda.algorithm import Algorithm
|
||||||
|
|
||||||
|
@ -120,7 +117,6 @@ def places_ics(request, tirage_id):
|
||||||
places_dict[place.spectacle] = place
|
places_dict[place.spectacle] = place
|
||||||
spectacles.append(place.spectacle)
|
spectacles.append(place.spectacle)
|
||||||
filtered_places.append(place)
|
filtered_places.append(place)
|
||||||
date = place.spectacle.date.date()
|
|
||||||
return render(request, "resume_places.ics",
|
return render(request, "resume_places.ics",
|
||||||
{"participant": participant,
|
{"participant": participant,
|
||||||
"places": filtered_places}, content_type="text/calendar")
|
"places": filtered_places}, content_type="text/calendar")
|
||||||
|
@ -264,18 +260,6 @@ def do_resell(request, form):
|
||||||
spectacle = form.cleaned_data["spectacle"]
|
spectacle = form.cleaned_data["spectacle"]
|
||||||
count = form.cleaned_data["count"]
|
count = form.cleaned_data["count"]
|
||||||
places = "2 places" if count == "2" else "une place"
|
places = "2 places" if count == "2" else "une place"
|
||||||
"""
|
|
||||||
send_custom_mail("bda-revente@lists.ens.fr",
|
|
||||||
"bda-revente",
|
|
||||||
{"places": places,
|
|
||||||
"spectacle": spectacle.title,
|
|
||||||
"date": spectacle.date_no_seconds(),
|
|
||||||
"lieu": spectacle.location,
|
|
||||||
"prix": spectacle.price,
|
|
||||||
"revendeur": request.user.get_full_name(),
|
|
||||||
"revendeur_mail": request.user.email},
|
|
||||||
from_email = request.user.email)
|
|
||||||
"""
|
|
||||||
mail = u"""Bonjour,
|
mail = u"""Bonjour,
|
||||||
|
|
||||||
Je souhaite revendre %s pour %s le %s (%s) à %.02f€.
|
Je souhaite revendre %s pour %s le %s (%s) à %.02f€.
|
||||||
|
|
|
@ -7,10 +7,7 @@ from django.contrib.auth.models import User
|
||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
import django.forms as forms
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.contrib.admin import SimpleListFilter
|
|
||||||
from django.db.models import Q
|
|
||||||
|
|
||||||
def add_link_field(target_model = '', field = '', link_text = unicode, desc_text = unicode):
|
def add_link_field(target_model = '', field = '', link_text = unicode, desc_text = unicode):
|
||||||
def add_link(cls):
|
def add_link(cls):
|
||||||
|
|
|
@ -2,7 +2,6 @@ import csv
|
||||||
from django.http import HttpResponse, HttpResponseForbidden
|
from django.http import HttpResponse, HttpResponseForbidden
|
||||||
from django.template.defaultfilters import slugify
|
from django.template.defaultfilters import slugify
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.contrib.auth.models import User
|
|
||||||
|
|
||||||
def export(qs, fields=None):
|
def export(qs, fields=None):
|
||||||
model = qs.model
|
model = qs.model
|
||||||
|
@ -40,16 +39,6 @@ def admin_list_export(request, model_name, app_label, queryset=None, fields=None
|
||||||
if not queryset:
|
if not queryset:
|
||||||
model = apps.get_model(app_label, model_name)
|
model = apps.get_model(app_label, model_name)
|
||||||
queryset = model.objects.all()
|
queryset = model.objects.all()
|
||||||
filters = dict()
|
|
||||||
"""
|
|
||||||
for key, value in request.GET.items():
|
|
||||||
if key not in ('ot', 'o'):
|
|
||||||
filters[str(key)] = str(value)
|
|
||||||
if len(filters):
|
|
||||||
queryset = queryset.filter(**filters)
|
|
||||||
"""
|
|
||||||
#qs2 = User.objects.filter(profile__eav__a_vot = True)
|
|
||||||
#queryset = queryset.filter(pk__in = qs2.values_list('id', flat = True))
|
|
||||||
queryset = queryset.filter(profile__is_cof = True)
|
queryset = queryset.filter(profile__is_cof = True)
|
||||||
if not fields:
|
if not fields:
|
||||||
if list_display and len(queryset.model._meta.admin.list_display) > 1:
|
if list_display and len(queryset.model._meta.admin.list_display) > 1:
|
||||||
|
|
|
@ -4,10 +4,11 @@ from django import forms
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.forms.widgets import RadioSelect, CheckboxSelectMultiple
|
from django.forms.widgets import RadioSelect, CheckboxSelectMultiple
|
||||||
|
from django.db.models import Max
|
||||||
|
|
||||||
from gestioncof.models import CofProfile, EventCommentValue
|
from gestioncof.models import CofProfile, EventCommentValue
|
||||||
from gestioncof.widgets import TriStateCheckbox
|
from gestioncof.widgets import TriStateCheckbox
|
||||||
from gestioncof.shared import lock_table, unlock_table, send_custom_mail
|
from gestioncof.shared import lock_table, unlock_table
|
||||||
|
|
||||||
class EventForm(forms.Form):
|
class EventForm(forms.Form):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -82,7 +83,6 @@ class SurveyStatusFilterForm(forms.Form):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
survey = kwargs.pop("survey")
|
survey = kwargs.pop("survey")
|
||||||
super(SurveyStatusFilterForm, self).__init__(*args, **kwargs)
|
super(SurveyStatusFilterForm, self).__init__(*args, **kwargs)
|
||||||
answers = {}
|
|
||||||
for question in survey.questions.all():
|
for question in survey.questions.all():
|
||||||
for answer in question.answers.all():
|
for answer in question.answers.all():
|
||||||
name = "question_%d_answer_%d" % (question.id, answer.id)
|
name = "question_%d_answer_%d" % (question.id, answer.id)
|
||||||
|
@ -242,7 +242,6 @@ class AdminEventForm(forms.Form):
|
||||||
kwargs["initial"] = {"status":"no"}
|
kwargs["initial"] = {"status":"no"}
|
||||||
super(AdminEventForm, self).__init__(*args, **kwargs)
|
super(AdminEventForm, self).__init__(*args, **kwargs)
|
||||||
choices = {}
|
choices = {}
|
||||||
comments = {}
|
|
||||||
for choice in current_choices:
|
for choice in current_choices:
|
||||||
if choice.event_option.id not in choices:
|
if choice.event_option.id not in choices:
|
||||||
choices[choice.event_option.id] = [choice.id]
|
choices[choice.event_option.id] = [choice.id]
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.db.models.signals import post_save
|
|
||||||
|
|
||||||
def choices_length (choices):
|
def choices_length (choices):
|
||||||
return reduce (lambda m, choice: max (m, len (choice[0])), choices, 0)
|
return reduce (lambda m, choice: max (m, len (choice[0])), choices, 0)
|
||||||
|
|
|
@ -15,7 +15,7 @@ from django.conf import settings
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db.models import Min
|
from django.db.models import Min
|
||||||
|
|
||||||
from gestioncof.models import CofProfile, Clipper
|
from gestioncof.models import CofProfile
|
||||||
from gestioncof.petits_cours_models import *
|
from gestioncof.petits_cours_models import *
|
||||||
from gestioncof.decorators import buro_required
|
from gestioncof.decorators import buro_required
|
||||||
from gestioncof.shared import lock_table, unlock_tables
|
from gestioncof.shared import lock_table, unlock_tables
|
||||||
|
|
|
@ -4,7 +4,7 @@ from django_cas_ng.backends import CASBackend
|
||||||
from django_cas_ng.utils import get_cas_client
|
from django_cas_ng.utils import get_cas_client
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.contrib.auth.models import User as DjangoUser
|
from django.contrib.auth.models import User as DjangoUser
|
||||||
from django.db import models, connection
|
from django.db import connection
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
from django.template import Template, Context
|
from django.template import Template, Context
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,7 @@ import unicodecsv
|
||||||
|
|
||||||
from django.shortcuts import redirect, get_object_or_404, render
|
from django.shortcuts import redirect, get_object_or_404, render
|
||||||
from django.http import Http404, HttpResponse
|
from django.http import Http404, HttpResponse
|
||||||
from django.core.urlresolvers import reverse
|
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db.models import Max
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -15,15 +13,13 @@ from gestioncof.models import Event, EventRegistration, EventOption, EventOption
|
||||||
from gestioncof.models import EventCommentField, EventCommentValue
|
from gestioncof.models import EventCommentField, EventCommentValue
|
||||||
from gestioncof.shared import send_custom_mail
|
from gestioncof.shared import send_custom_mail
|
||||||
from gestioncof.models import CofProfile, Clipper
|
from gestioncof.models import CofProfile, Clipper
|
||||||
from gestioncof.decorators import buro_required, cof_required
|
from gestioncof.decorators import buro_required
|
||||||
from gestioncof.forms import UserProfileForm, EventStatusFilterForm, \
|
from gestioncof.forms import UserProfileForm, EventStatusFilterForm, \
|
||||||
SurveyForm, SurveyStatusFilterForm, RegistrationUserForm, \
|
SurveyForm, SurveyStatusFilterForm, RegistrationUserForm, \
|
||||||
RegistrationProfileForm, AdminEventForm, EventForm
|
RegistrationProfileForm, AdminEventForm, EventForm
|
||||||
|
|
||||||
from bda.models import Tirage
|
from bda.models import Tirage
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def home(request):
|
def home(request):
|
||||||
data = {"surveys": Survey.objects.filter(old=False).all(),
|
data = {"surveys": Survey.objects.filter(old=False).all(),
|
||||||
|
|
|
@ -8,7 +8,7 @@ if __name__ == "__main__":
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cof.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cof.settings")
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
settings.DEBUG = True
|
settings.DEBUG = True
|
||||||
from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution
|
from bda.models import Spectacle, Participant, ChoixSpectacle
|
||||||
from bda.algorithm import Algorithm
|
from bda.algorithm import Algorithm
|
||||||
from django.db.models import Sum
|
from django.db.models import Sum
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
|
|
Loading…
Reference in a new issue