2021-01-28 18:12:42 -07:00

24 lines
804 B
Python

from django.db import models
from accounts.models import Student
class Code(models.Model):
student = models.ForeignKey(Student, on_delete=models.CASCADE)
qr_code = models.ImageField(upload_to='qr_codes', blank=True)
def __str__(self):
return str(self.name)
class Period(models.Model):
student = models.ForeignKey(Student, on_delete=models.CASCADE)
clocked_in = models.DateTimeField(auto_now_add=True)
clocked_out = models.DateTimeField(blank=True, null=True)
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
def duration(self):
return round(self.clocked_out - self.clocked_in)
def __str__(self):
return f'{self.clocked_in}: {self.student.user.first_name} {self.student.user.last_name}'