2011-07-31 10:46:29 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
openslides.participant.models
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Models for the participant app.
|
|
|
|
|
|
|
|
:copyright: 2011 by the OpenSlides team, see AUTHORS.
|
|
|
|
:license: GNU GPL, see LICENSE for more details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from django.db import models
|
2011-09-05 09:08:00 +02:00
|
|
|
from django.db.models import Q
|
2011-07-31 10:46:29 +02:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
|
2011-09-03 17:17:29 +02:00
|
|
|
from participant.api import gen_password
|
|
|
|
|
2011-07-31 10:46:29 +02:00
|
|
|
class Profile(models.Model):
|
|
|
|
GENDER_CHOICES = (
|
|
|
|
('male', _('Male')),
|
|
|
|
('female', _('Female')),
|
|
|
|
)
|
|
|
|
TYPE_CHOICE = (
|
|
|
|
('delegate', _('Delegate')),
|
|
|
|
('observer', _('Observer')),
|
|
|
|
('staff', _('Staff')),
|
2011-09-07 22:46:47 +02:00
|
|
|
('guest', _('Guest')),
|
2011-07-31 10:46:29 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
user = models.OneToOneField(User, unique=True, editable=False)
|
2011-11-24 19:51:16 +01:00
|
|
|
gender = models.CharField(max_length=50, choices=GENDER_CHOICES, blank=True, verbose_name = _("Gender"))
|
2011-07-31 10:46:29 +02:00
|
|
|
group = models.CharField(max_length=100, null=True, blank=True, verbose_name = _("Group"))
|
2011-11-24 19:51:16 +01:00
|
|
|
type = models.CharField(max_length=100, choices=TYPE_CHOICE, blank=True, verbose_name = _("Typ"))
|
2011-07-31 10:46:29 +02:00
|
|
|
committee = models.CharField(max_length=100, null=True, blank=True, verbose_name = _("Committee"))
|
2012-04-02 07:38:55 +02:00
|
|
|
comment = models.CharField(max_length=255, null=True, blank=True, verbose_name = _("Comment"))
|
2011-09-03 17:17:29 +02:00
|
|
|
firstpassword = models.CharField(max_length=100, null=True, blank=True, verbose_name = _("First Password"))
|
|
|
|
|
|
|
|
|
|
|
|
def reset_password(self):
|
|
|
|
self.user.set_password(self.firstpassword)
|
2011-09-07 14:27:36 +02:00
|
|
|
self.user.save()
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
if self.group:
|
|
|
|
return "%s (%s)" % (self.user.get_full_name(), self.group)
|
|
|
|
return "%s" % self.user.get_full_name()
|
|
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
permissions = (
|
2011-09-04 12:21:58 +02:00
|
|
|
('can_see_participant', "Can see participant"),
|
|
|
|
('can_manage_participant', "Can manage participant"),
|
2011-07-31 10:46:29 +02:00
|
|
|
)
|