+ file = models.FileField(upload_to = 'wtem/attachment')
+
+
+class Assignment(models.Model):
+ user = models.ForeignKey(User, unique = True)
+ exercises = JSONField()
+
+ def clean(self):
+ if not isinstance(self.exercises, list):
+ raise ValidationError(_('Assigned exercises must be declared in a list format'))
+ for exercise in self.exercises:
+ if not isinstance(exercise, int) or exercise < 1:
+ raise ValidationError(_('Invalid exercise id: %s' % exercise))
+
+ def __unicode__(self):
+ return self.user.username + ': ' + ','.join(map(str,self.exercises))
\ No newline at end of file