1 from django.conf import settings
2 from django.db import models
3 from django.utils.timezone import now
6 class Profile(models.Model):
7 user = models.OneToOneField(settings.AUTH_USER_MODEL, models.CASCADE)
8 presence = models.BooleanField()
9 approve_by_default = models.BooleanField()
12 verbose_name = verbose_name_plural = 'profil'
15 return self.user.username
18 class Presence(models.Model):
19 user = models.ForeignKey(settings.AUTH_USER_MODEL, models.CASCADE)
20 chunk = models.ForeignKey('documents.Chunk', models.SET_NULL, blank=True, null=True)
21 timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
22 active = models.BooleanField()
25 def report(cls, user, chunk, active):
26 if user.is_anonymous or not hasattr(user, 'profile') or not user.profile.presence: