forked from DGNum/gestioCOF
drop py2 compat
This commit is contained in:
parent
95a8b484e0
commit
76dcaf7d51
4 changed files with 20 additions and 56 deletions
|
@ -1,9 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django import forms
|
||||
from django.contrib import admin
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
@ -18,13 +12,12 @@ from django.contrib.auth.admin import UserAdmin
|
|||
from django.core.urlresolvers import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.db.models import Q
|
||||
import django.utils.six as six
|
||||
|
||||
import autocomplete_light
|
||||
|
||||
|
||||
def add_link_field(target_model='', field='', link_text=six.text_type,
|
||||
desc_text=six.text_type):
|
||||
def add_link_field(target_model='', field='', link_text=str,
|
||||
desc_text=str):
|
||||
def add_link(cls):
|
||||
reverse_name = target_model or cls.model.__name__.lower()
|
||||
|
||||
|
@ -215,21 +208,19 @@ class UserProfileAdmin(UserAdmin):
|
|||
|
||||
|
||||
# FIXME: This is absolutely horrible.
|
||||
def user_unicode(self):
|
||||
def user_str(self):
|
||||
if self.first_name and self.last_name:
|
||||
return "%s %s (%s)" % (self.first_name, self.last_name, self.username)
|
||||
return "{} {} ({})".format(
|
||||
self.first_name, self.last_name, self.username
|
||||
)
|
||||
else:
|
||||
return self.username
|
||||
if six.PY2:
|
||||
User.__unicode__ = user_unicode
|
||||
else:
|
||||
User.__str__ = user_unicode
|
||||
User.__str__ = user_str
|
||||
|
||||
|
||||
class EventRegistrationAdmin(admin.ModelAdmin):
|
||||
form = autocomplete_light.modelform_factory(EventRegistration, exclude=[])
|
||||
list_display = ('__unicode__' if six.PY2 else '__str__', 'event', 'user',
|
||||
'paid')
|
||||
list_display = ('__str__', 'event', 'user', 'paid')
|
||||
list_filter = ('paid',)
|
||||
search_fields = ('user__username', 'user__first_name', 'user__last_name',
|
||||
'user__email', 'event__title')
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.contrib.auth.models import User
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.db import models
|
||||
from django.dispatch import receiver
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
import django.utils.six as six
|
||||
from django.db.models.signals import post_save, post_delete
|
||||
|
||||
from gestioncof.petits_cours_models import choices_length
|
||||
|
@ -35,7 +31,6 @@ TYPE_COMMENT_FIELD = (
|
|||
)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CofProfile(models.Model):
|
||||
user = models.OneToOneField(User, related_name="profile")
|
||||
login_clipper = models.CharField("Login clipper", max_length=8, blank=True)
|
||||
|
@ -72,7 +67,7 @@ class CofProfile(models.Model):
|
|||
verbose_name_plural = "Profils COF"
|
||||
|
||||
def __str__(self):
|
||||
return six.text_type(self.user.username)
|
||||
return self.user.username
|
||||
|
||||
|
||||
@receiver(post_save, sender=User)
|
||||
|
@ -86,7 +81,6 @@ def post_delete_user(sender, instance, *args, **kwargs):
|
|||
instance.user.delete()
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Club(models.Model):
|
||||
name = models.CharField("Nom", max_length=200, unique=True)
|
||||
description = models.TextField("Description", blank=True)
|
||||
|
@ -98,7 +92,6 @@ class Club(models.Model):
|
|||
return self.name
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Event(models.Model):
|
||||
title = models.CharField("Titre", max_length=200)
|
||||
location = models.CharField("Lieu", max_length=200)
|
||||
|
@ -115,10 +108,9 @@ class Event(models.Model):
|
|||
verbose_name = "Événement"
|
||||
|
||||
def __str__(self):
|
||||
return six.text_type(self.title)
|
||||
return self.title
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class EventCommentField(models.Model):
|
||||
event = models.ForeignKey(Event, related_name="commentfields")
|
||||
name = models.CharField("Champ", max_length=200)
|
||||
|
@ -130,10 +122,9 @@ class EventCommentField(models.Model):
|
|||
verbose_name = "Champ"
|
||||
|
||||
def __str__(self):
|
||||
return six.text_type(self.name)
|
||||
return self.name
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class EventCommentValue(models.Model):
|
||||
commentfield = models.ForeignKey(EventCommentField, related_name="values")
|
||||
registration = models.ForeignKey("EventRegistration",
|
||||
|
@ -144,7 +135,6 @@ class EventCommentValue(models.Model):
|
|||
return "Commentaire de %s" % self.commentfield
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class EventOption(models.Model):
|
||||
event = models.ForeignKey(Event, related_name="options")
|
||||
name = models.CharField("Option", max_length=200)
|
||||
|
@ -154,10 +144,9 @@ class EventOption(models.Model):
|
|||
verbose_name = "Option"
|
||||
|
||||
def __str__(self):
|
||||
return six.text_type(self.name)
|
||||
return self.name
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class EventOptionChoice(models.Model):
|
||||
event_option = models.ForeignKey(EventOption, related_name="choices")
|
||||
value = models.CharField("Valeur", max_length=200)
|
||||
|
@ -167,10 +156,9 @@ class EventOptionChoice(models.Model):
|
|||
verbose_name_plural = "Choix"
|
||||
|
||||
def __str__(self):
|
||||
return six.text_type(self.value)
|
||||
return self.value
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class EventRegistration(models.Model):
|
||||
user = models.ForeignKey(User)
|
||||
event = models.ForeignKey(Event)
|
||||
|
@ -184,11 +172,9 @@ class EventRegistration(models.Model):
|
|||
unique_together = ("user", "event")
|
||||
|
||||
def __str__(self):
|
||||
return "Inscription de %s à %s" % (six.text_type(self.user),
|
||||
six.text_type(self.event.title))
|
||||
return "Inscription de {} à {}".format(self.user, self.event.title)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Survey(models.Model):
|
||||
title = models.CharField("Titre", max_length=200)
|
||||
details = models.TextField("Détails", blank=True)
|
||||
|
@ -199,10 +185,9 @@ class Survey(models.Model):
|
|||
verbose_name = "Sondage"
|
||||
|
||||
def __str__(self):
|
||||
return six.text_type(self.title)
|
||||
return self.title
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SurveyQuestion(models.Model):
|
||||
survey = models.ForeignKey(Survey, related_name="questions")
|
||||
question = models.CharField("Question", max_length=200)
|
||||
|
@ -212,10 +197,9 @@ class SurveyQuestion(models.Model):
|
|||
verbose_name = "Question"
|
||||
|
||||
def __str__(self):
|
||||
return six.text_type(self.question)
|
||||
return self.question
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SurveyQuestionAnswer(models.Model):
|
||||
survey_question = models.ForeignKey(SurveyQuestion, related_name="answers")
|
||||
answer = models.CharField("Réponse", max_length=200)
|
||||
|
@ -224,10 +208,9 @@ class SurveyQuestionAnswer(models.Model):
|
|||
verbose_name = "Réponse"
|
||||
|
||||
def __str__(self):
|
||||
return six.text_type(self.answer)
|
||||
return self.answer
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SurveyAnswer(models.Model):
|
||||
user = models.ForeignKey(User)
|
||||
survey = models.ForeignKey(Survey)
|
||||
|
@ -244,7 +227,6 @@ class SurveyAnswer(models.Model):
|
|||
self.survey.title)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CalendarSubscription(models.Model):
|
||||
token = models.UUIDField()
|
||||
user = models.OneToOneField(User)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import unicodecsv
|
||||
import uuid
|
||||
from datetime import timedelta
|
||||
|
@ -14,7 +12,6 @@ from django.contrib.auth.models import User
|
|||
from django.contrib.sites.models import Site
|
||||
from django.utils import timezone
|
||||
from django.contrib import messages
|
||||
import django.utils.six as six
|
||||
|
||||
from gestioncof.models import Survey, SurveyAnswer, SurveyQuestion, \
|
||||
SurveyQuestionAnswer
|
||||
|
@ -575,7 +572,7 @@ def export_members(request):
|
|||
bits = [profile.num, user.username, user.first_name, user.last_name,
|
||||
user.email, profile.phone, profile.occupation,
|
||||
profile.departement, profile.type_cotiz]
|
||||
writer.writerow([six.text_type(bit) for bit in bits])
|
||||
writer.writerow([str(bit) for bit in bits])
|
||||
|
||||
return response
|
||||
|
||||
|
@ -594,7 +591,7 @@ def csv_export_mega(filename, qs):
|
|||
profile.phone, profile.num,
|
||||
profile.comments if profile.comments else "", comments]
|
||||
|
||||
writer.writerow([six.text_type(bit) for bit in bits])
|
||||
writer.writerow([str(bit) for bit in bits])
|
||||
|
||||
return response
|
||||
|
||||
|
@ -614,7 +611,7 @@ def export_mega_remarksonly(request):
|
|||
profile = user.profile
|
||||
bits = [user.username, user.first_name, user.last_name, user.email,
|
||||
profile.phone, profile.num, profile.comments, val.content]
|
||||
writer.writerow([six.text_type(bit) for bit in bits])
|
||||
writer.writerow([str(bit) for bit in bits])
|
||||
|
||||
return response
|
||||
|
||||
|
|
Loading…
Reference in a new issue