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.

71 lines
2.0 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. granted = models.BooleanField(null=True)
  7. class Meta:
  8. abstract = True
  9. class Project(Volunteer):
  10. name = models.CharField(max_length=200)
  11. start = models.DateField('start date')
  12. pid = models.IntegerField(null=True, blank=True) # automaticly generated
  13. def save(self,*args,**kwargs):
  14. # is there a way to call super().save() only once?
  15. super().save(*args,*kwargs)
  16. self.pid = 10000 + self.pk
  17. super().save(*args,*kwargs)
  18. def __str__(self):
  19. return self.name
  20. class HonoraryCertificate(Volunteer):
  21. request_url = models.CharField(max_length=2000)
  22. number = models.IntegerField(null = True)
  23. def __str__(self):
  24. return "Certificate for " + self.realname
  25. #abstract class for Library, IFG, ...
  26. class Grant(Volunteer):
  27. cost = models.CharField(max_length=10)
  28. notes = models.CharField(max_length=500)
  29. class Meta:
  30. abstract = True
  31. TYPE_CHOICES = [('BIB', 'Bibliotheksstipendium'),
  32. ('ELIT', 'eLiteraturstipendium'),
  33. ('SOFT', 'Softwarestipendium'),
  34. ('VIS', 'Visitenkarten'),
  35. ('LIST', 'Mailingliste'),
  36. ('MAIL', 'E-Mail-Adresse'),
  37. ('IFG', 'Kostenübernahme IFG-Anfrage'),
  38. ('LIT', 'Literaturstipendium'),]
  39. # same model is used for Library, ELitStip and Software!
  40. class Library(Grant):
  41. type = models.CharField(
  42. max_length=4,
  43. choices=TYPE_CHOICES, #attention: actually only BIB, ELIT, SOFT should be used here
  44. default='LIB',
  45. )
  46. library = models.CharField(max_length=200)
  47. duration = models.CharField(max_length=100)
  48. def __str__(self):
  49. return self.library
  50. class IFG(Grant):
  51. url = models.CharField(max_length=2000)
  52. def __str__(self):
  53. return "IFG-Anfrage von " + self.realname