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()
11 class Presence(models.Model):
12 user = models.ForeignKey(settings.AUTH_USER_MODEL, models.CASCADE)
13 chunk = models.ForeignKey('documents.Chunk', models.SET_NULL, blank=True, null=True)
14 timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
15 active = models.BooleanField()
18 def report(cls, user, chunk, active):
19 if user.is_anonymous or not hasattr(user, 'profile') or not user.profile.presence: