Append a default class for the person-api.
Also fixed the assignment-ballot-paper for group-persons
This commit is contained in:
parent
f99fdc6981
commit
3e1938941f
@ -430,7 +430,7 @@ class AssignmentPDF(PDFView):
|
|||||||
for candidate, poll_list in vote_results.iteritems():
|
for candidate, poll_list in vote_results.iteritems():
|
||||||
row = []
|
row = []
|
||||||
|
|
||||||
candidate_string = candidate.user.get_full_name()
|
candidate_string = candidate.clean_name
|
||||||
if candidate in elected_candidates:
|
if candidate in elected_candidates:
|
||||||
candidate_string = "* " + candidate_string
|
candidate_string = "* " + candidate_string
|
||||||
if candidate.category:
|
if candidate.category:
|
||||||
@ -565,7 +565,7 @@ class AssignmentPollPDF(PDFView):
|
|||||||
if self.poll.yesnoabstain:
|
if self.poll.yesnoabstain:
|
||||||
for option in options:
|
for option in options:
|
||||||
candidate = option.candidate
|
candidate = option.candidate
|
||||||
cell.append(Paragraph(candidate.user.get_full_name(),
|
cell.append(Paragraph(candidate.clean_name,
|
||||||
stylesheet['Ballot_option_name']))
|
stylesheet['Ballot_option_name']))
|
||||||
if candidate.name_suffix:
|
if candidate.name_suffix:
|
||||||
cell.append(Paragraph("(%s)" % candidate.name_suffix,
|
cell.append(Paragraph("(%s)" % candidate.name_suffix,
|
||||||
@ -591,9 +591,9 @@ class AssignmentPollPDF(PDFView):
|
|||||||
else:
|
else:
|
||||||
for option in options:
|
for option in options:
|
||||||
candidate = option.candidate
|
candidate = option.candidate
|
||||||
cell.append(Paragraph(circle + candidate.user.get_full_name(),
|
cell.append(Paragraph(circle + candidate.clean_name,
|
||||||
stylesheet['Ballot_option_name']))
|
stylesheet['Ballot_option_name']))
|
||||||
if candidate.category:
|
if candidate.name_suffix:
|
||||||
cell.append(Paragraph("(%s)" % candidate.category,
|
cell.append(Paragraph("(%s)" % candidate.category,
|
||||||
stylesheet['Ballot_option_group_right']))
|
stylesheet['Ballot_option_group_right']))
|
||||||
else:
|
else:
|
||||||
|
@ -16,14 +16,14 @@ from django.db.models import signals
|
|||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils.translation import ugettext_lazy as _, ugettext_noop
|
from django.utils.translation import ugettext_lazy as _, ugettext_noop
|
||||||
|
|
||||||
from openslides.utils.person import PersonMixin
|
from openslides.utils.person import PersonMixin, Person
|
||||||
from openslides.utils.person.signals import receive_persons
|
from openslides.utils.person.signals import receive_persons
|
||||||
|
|
||||||
from openslides.config.models import config
|
from openslides.config.models import config
|
||||||
from openslides.config.signals import default_config_value
|
from openslides.config.signals import default_config_value
|
||||||
|
|
||||||
|
|
||||||
class User(DjangoUser, PersonMixin):
|
class User(DjangoUser, PersonMixin, Person):
|
||||||
person_prefix = 'user'
|
person_prefix = 'user'
|
||||||
GENDER_CHOICES = (
|
GENDER_CHOICES = (
|
||||||
('male', _('Male')),
|
('male', _('Male')),
|
||||||
@ -56,6 +56,10 @@ class User(DjangoUser, PersonMixin):
|
|||||||
max_length=100, null=True, blank=True,
|
max_length=100, null=True, blank=True,
|
||||||
verbose_name=_("Default password"))
|
verbose_name=_("Default password"))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def clean_name(self):
|
||||||
|
return self.get_full_name() or self.username
|
||||||
|
|
||||||
def get_name_suffix(self):
|
def get_name_suffix(self):
|
||||||
return self.category
|
return self.category
|
||||||
|
|
||||||
@ -88,10 +92,9 @@ class User(DjangoUser, PersonMixin):
|
|||||||
return ('user_delete', [str(self.id)])
|
return ('user_delete', [str(self.id)])
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
name = self.get_full_name() or self.username
|
|
||||||
if self.name_suffix:
|
if self.name_suffix:
|
||||||
return u"%s (%s)" % (name, self.name_suffix)
|
return u"%s (%s)" % (self.clean_name, self.name_suffix)
|
||||||
return u"%s" % name
|
return u"%s" % self.clean_name
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
# Rename permissions
|
# Rename permissions
|
||||||
@ -103,7 +106,7 @@ class User(DjangoUser, PersonMixin):
|
|||||||
ordering = ('last_name',)
|
ordering = ('last_name',)
|
||||||
|
|
||||||
|
|
||||||
class Group(DjangoGroup, PersonMixin):
|
class Group(DjangoGroup, PersonMixin, Person):
|
||||||
person_prefix = 'group'
|
person_prefix = 'group'
|
||||||
|
|
||||||
django_group = models.OneToOneField(DjangoGroup, editable=False, parent_link=True)
|
django_group = models.OneToOneField(DjangoGroup, editable=False, parent_link=True)
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from openslides.utils.person.signals import receive_persons
|
from openslides.utils.person.signals import receive_persons
|
||||||
from openslides.utils.person.api import generate_person_id, get_person, Persons
|
from openslides.utils.person.api import (generate_person_id, get_person,
|
||||||
|
Person, Persons)
|
||||||
from openslides.utils.person.forms import PersonFormField, MultiplePersonFormField
|
from openslides.utils.person.forms import PersonFormField, MultiplePersonFormField
|
||||||
from openslides.utils.person.models import PersonField, PersonMixin
|
from openslides.utils.person.models import PersonField, PersonMixin
|
||||||
|
|
||||||
|
@ -13,6 +13,37 @@
|
|||||||
from openslides.utils.person.signals import receive_persons
|
from openslides.utils.person.signals import receive_persons
|
||||||
|
|
||||||
|
|
||||||
|
class Person(object):
|
||||||
|
"""
|
||||||
|
Meta-class for all person objects
|
||||||
|
"""
|
||||||
|
def person_id(self):
|
||||||
|
"""
|
||||||
|
Return an id for representation of ths person. Has to be unique.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('Any person object needs a person_id')
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
"""
|
||||||
|
Return a string for this person.
|
||||||
|
"""
|
||||||
|
return str(self.person_id)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def clean_name(self):
|
||||||
|
"""
|
||||||
|
Return the name of this person without a suffix
|
||||||
|
"""
|
||||||
|
return unicode(self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name_suffix(self):
|
||||||
|
"""
|
||||||
|
Return a suffix for the person-name.
|
||||||
|
"""
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
class Persons(object):
|
class Persons(object):
|
||||||
"""
|
"""
|
||||||
A Storage for a multiplicity of different Person-Objects.
|
A Storage for a multiplicity of different Person-Objects.
|
||||||
|
Loading…
Reference in New Issue
Block a user