Beispiel #1
0
class CosinnusTodoConf(AppConf):
    
    prefix = 'COSINNUS_TODO'
    
    DEFAULT_TODOLIST_TITLE = p_('Name of the default todo list for each group/project', 'General')
    
    DEFAULT_TODOLIST_SLUG = 'general'
Beispiel #2
0
class EventAttendance(models.Model):
    """ Model for attendance choices of a User for an Event.
        The choices do not include a "no choice selected" state on purpose,
        as a user not having made a choice is modeled by a missing instance
        of ``EventAttendance`` for that user and event.
     """

    ATTENDANCE_NOT_GOING = 0
    ATTENDANCE_MAYBE_GOING = 1
    ATTENDANCE_GOING = 2

    ATTENDANCE_STATES = (
        (ATTENDANCE_NOT_GOING, p_('cosinnus_event_attendance', 'not going')),
        (ATTENDANCE_MAYBE_GOING, p_('cosinnus membership status',
                                    'maybe going')),
        (ATTENDANCE_GOING, p_('cosinnus membership status', 'going')),
    )

    event = models.ForeignKey(Event,
                              related_name='attendances',
                              on_delete=models.CASCADE)
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             related_name='cosinnus_event_attendances',
                             on_delete=models.CASCADE)
    state = models.PositiveSmallIntegerField(choices=ATTENDANCE_STATES,
                                             db_index=True,
                                             default=ATTENDANCE_NOT_GOING)
    date = models.DateTimeField(auto_now_add=True, editable=False)

    class Meta:
        unique_together = (
            'event',
            'user',
        )

    def __str__(self):
        return "Event Attendance <user: %(user)s, event: %(event)s, status: %(status)d>" % {
            'user': self.user.email,
            'event': self.event.slug,
            'status': self.status,
        }
Beispiel #3
0
class User(AbstractUser):
    """a customable user model
    """

    mobile_phone = models.CharField(p_('User model', 'cell phone num'),
                                    max_length=32,
                                    default='')
    token = models.CharField(max_length=300, unique=True)

    objects = UserManager()

    def save(self, *args, **kwargs):
        if not self.token:
            for _ in range(100):
                token = uuid.uuid4().hex
                if not type(self).objects.filter(token=token).exists():
                    self.token = token
                    break

        return super().save(*args, **kwargs)
Beispiel #4
0
from tinymce.models import HTMLField

from cosinnus.conf import settings
from cosinnus.utils.functions import unique_aware_slugify

#: Role defining a user has requested to be added to a group
MEMBERSHIP_PENDING = 0

#: Role defining a user is a member but not an admin of a group
MEMBERSHIP_MEMBER = 1

#: Role defining a user is an admin of a group
MEMBERSHIP_ADMIN = 2

MEMBERSHIP_STATUSES = (
    (MEMBERSHIP_PENDING, p_('cosinnus membership status', 'pending')),
    (MEMBERSHIP_MEMBER, p_('cosinnus membership status', 'member')),
    (MEMBERSHIP_ADMIN, p_('cosinnus membership status', 'admin')),
)

#: A user is a member of a group if either is an explicit member or admin
MEMBER_STATUS = (
    MEMBERSHIP_MEMBER,
    MEMBERSHIP_ADMIN,
)

_GROUPS_SLUG_CACHE_KEY = 'cosinnus/core/groups/slugs'
_GROUPS_PK_CACHE_KEY = 'cosinnus/core/groups/pks'
_GROUP_CACHE_KEY = 'cosinnus/core/group/%s'

_MEMBERSHIP_ADMINS_KEY = 'cosinnus/core/membership/admins/%d'