You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.4 KiB

4 years ago
4 years ago
  1. from django.db import models
  2. class Volunteer(models.Model):
  3. realname = models.CharField(max_length=200, null=True)
  4. email = models.CharField(max_length=200, null=True)
  5. username = models.CharField(max_length=200, null=True)
  6. class Meta:
  7. abstract = True
  8. class Project(Volunteer):
  9. name = models.CharField(max_length=200)
  10. start = models.DateField('start date')
  11. pid = models.IntegerField(null=True, blank=True) # automaticly generated
  12. def save(self,*args,**kwargs):
  13. # is there a way to call super().save() only once?
  14. super().save(*args,*kwargs)
  15. self.pid = 10000 + self.pk
  16. super().save(*args,*kwargs)
  17. def __str__(self):
  18. return self.name
  19. class HonoraryCertificate(Volunteer):
  20. request_url = models.CharField(max_length=2000)
  21. number = models.IntegerField(null = True)
  22. def __str__(self):
  23. return "Certificate for " + self.realname
  24. #abstract class for Library, IFG, ...
  25. class Grant(Volunteer):
  26. cost = models.CharField(max_length=10)
  27. notes = models.CharField(max_length=500)
  28. class Meta:
  29. abstract = True
  30. # should be identical for ELitStip and Software?
  31. class Library(Grant):
  32. library = models.CharField(max_length=200)
  33. duration = models.CharField(max_length=100)
  34. def __str__(self):
  35. return self.library
  36. class IFG(Grant):
  37. url = models.CharField(max_length=2000)
  38. def __str__(self):
  39. return "IFG-Anfrage von " + self.realname