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.

64 lines
1.7 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. # same model is used for Library, ELitStip and Software!
  31. TYPE_CHOICES = [('BIB', 'Bibliotheksstipendium'),
  32. ('ELIT', 'eLiteraturstipendium'),
  33. ('SOFT', 'Softwarestipendium')]
  34. class Library(Grant):
  35. type = models.CharField(
  36. max_length=4,
  37. choices=TYPE_CHOICES,
  38. default='LIB',
  39. )
  40. library = models.CharField(max_length=200)
  41. duration = models.CharField(max_length=100)
  42. def __str__(self):
  43. return self.library
  44. class IFG(Grant):
  45. url = models.CharField(max_length=2000)
  46. def __str__(self):
  47. return "IFG-Anfrage von " + self.realname