- name = models.CharField(max_length=100)
- file = models.FileField(upload_to = 'wtem/attachment')
\ No newline at end of file
+ exercise_id = models.IntegerField()
+ 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