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.

67 lines
1.9 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. ('VIS', 'Visitenkarten, Mailingliste oder E-Mail-Adresse'),
  35. ('IFG', 'Kostenübernahme IFG-Anfrage'),
  36. ('LIT', 'Literaturstipendium'),]
  37. class Library(Grant):
  38. type = models.CharField(
  39. max_length=4,
  40. choices=TYPE_CHOICES,
  41. default='LIB',
  42. )
  43. library = models.CharField(max_length=200)
  44. duration = models.CharField(max_length=100)
  45. def __str__(self):
  46. return self.library
  47. class IFG(Grant):
  48. url = models.CharField(max_length=2000)
  49. def __str__(self):
  50. return "IFG-Anfrage von " + self.realname