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.

209 lines
8.6 KiB

4 years ago
4 years ago
  1. from datetime import date
  2. from django.db import models
  3. from .settings import ACCOUNTS
  4. class Volunteer(models.Model):
  5. realname = models.CharField(max_length=200, null=True, verbose_name="Name / Hauptansprechperson")
  6. email = models.CharField(max_length=200, null=True, verbose_name='E-Mail-Adresse')
  7. # the following Fields are not supposed to be edited by users
  8. granted = models.BooleanField(null=True)
  9. granted_date = models.DateField(null=True)
  10. survey_mail_send = models.BooleanField(default=False, verbose_name='Keine Umfragemail schicken')
  11. @classmethod
  12. def set_granted(cl, key, b):
  13. obj = cl.objects.get(pk=key)
  14. obj.granted = b
  15. obj.granted_date = date.today()
  16. obj.save()
  17. class Meta:
  18. abstract = True
  19. class Extern(Volunteer):
  20. ''' abstract basis class for all data entered by extern volunteers '''
  21. username = models.CharField(max_length=200, null=True, verbose_name='Benutzer_innenname')
  22. # the following Fields are not supposed to be edited by users
  23. service_id = models.CharField(max_length=15, null=True, blank=True)
  24. def save(self,*args,**kwargs):
  25. # is there a way to call super().save() only once?
  26. super().save(*args,*kwargs)
  27. self.service_id = type(self).__name__ + str(self.pk)
  28. super().save(*args,*kwargs)
  29. class Meta:
  30. abstract = True
  31. class Project(Volunteer):
  32. name = models.CharField(max_length=200, verbose_name='Name des Projekts')
  33. description = models.CharField(max_length=500, verbose_name="Kurzbeschreibung", null=True)
  34. start = models.DateField('Startdatum', null=True, blank= True)
  35. end = models.DateField('Erwartetes Projektende', null=True)
  36. otrs = models.CharField(max_length=300, null=True, verbose_name='OTRS-Link')
  37. plan = models.CharField(max_length=2000, null=True, blank=True, verbose_name="Link zum Förderplan")
  38. page = models.CharField(max_length=2000, null=True, blank=True, verbose_name="Link zur Projektseite")
  39. urls = models.CharField(max_length=2000, null=True, blank=True, verbose_name="Weitere Links")
  40. group = models.CharField(max_length=2000, null=True, blank=True, verbose_name="Mitorganisierende")
  41. location = models.CharField(max_length=2000, null=True, blank=True, verbose_name="Ort/Adresse/Location")
  42. participants_estimated = models.IntegerField(blank=True, null=True, verbose_name='Teilnehmende angefragt')
  43. participants_real = models.IntegerField(blank=True, null=True, verbose_name='Teilnehmende ausgezählt')
  44. insurance = models.BooleanField(default=False, verbose_name='Haftpflichtversicherung')
  45. insurance_technic = models.BooleanField(default=False, verbose_name='Technikversicherung Ausland')
  46. support = models.CharField(max_length=300, blank=True, null=True, verbose_name='Betreuungsperson und Vertretung')
  47. cost = models.IntegerField(blank=True, null=True)
  48. account = models.CharField('Kostenstelle', max_length=5,
  49. choices=ACCOUNTS.items(), null=True,)
  50. granted_from = models.CharField(max_length=100,null=True,verbose_name='Bewilligt von')
  51. notes = models.CharField(max_length=1000,null=True,blank=True,verbose_name='Anmerkungen')
  52. # the following Fields are not supposed to be edited by users
  53. pid = models.CharField(max_length=15, null=True, blank=True)
  54. end_mail_send = models.BooleanField(null=True)
  55. status = models.CharField(max_length=3,choices=(('RUN', 'läuft'),('END','beendet')),default='RUN')
  56. persons = models.IntegerField(default=1)
  57. def save(self,*args,**kwargs):
  58. # is there a way to call super().save() only once?
  59. super().save(*args,*kwargs)
  60. self.pid = self.account + str(self.pk)
  61. super().save(*args,*kwargs)
  62. def __str__(self):
  63. return f"{self.pid} {self.name}"
  64. class Intern(Volunteer):
  65. '''abstrat base class for data entry from /intern (except Project)'''
  66. request_url = models.CharField(max_length=2000, verbose_name='Antrag (URL)')
  67. class Meta:
  68. abstract = True
  69. class HonoraryCertificate(Intern):
  70. ''' this class is also used for accreditations '''
  71. project = models.ForeignKey(Project, null=True, blank=True, on_delete=models.SET_NULL)
  72. def __str__(self):
  73. return "Certificate for " + self.realname
  74. TRANSPORT_CHOICES = {'BAHN': 'Bahn',
  75. 'NONE': 'Keine Fahrtkosten',
  76. 'OTHER': 'Sonstiges (mit Begründung)'}
  77. PAYEDBY_CHOICES = {'WMDE': 'WMDE',
  78. 'REQU': 'Antragstellender Mensch'}
  79. class Travel(Intern):
  80. project = models.ForeignKey(Project, on_delete=models.CASCADE)
  81. transport = models.CharField(max_length=5, choices=TRANSPORT_CHOICES.items(), default='BAHN')
  82. other_transport = models.CharField(max_length=200, null=True, blank=True, verbose_name='Sonstige Transportmittel (mit Begründung)')
  83. travelcost = models.CharField(max_length=10, default="0", verbose_name="Fahrtkosten")
  84. checkin = models.DateField(blank=True, null=True, verbose_name='Check In')
  85. checkout = models.DateField(blank=True, null=True, verbose_name='Check Out')
  86. payed_for_hotel_by = models.CharField(max_length=4, choices=PAYEDBY_CHOICES.items(), blank=True, null=True, verbose_name='Kostenauslage Hotel durch')
  87. payed_for_travel_by = models.CharField(max_length=4, choices=PAYEDBY_CHOICES.items(), blank=True, null=True, verbose_name='Kostenauslage Fahrt durch')
  88. notes = models.CharField(max_length=500, blank=True)
  89. #abstract base class for Library and IFG
  90. class Grant(Extern):
  91. cost = models.CharField(max_length=10, verbose_name='Kosten')
  92. notes = models.CharField(max_length=500, blank=True, verbose_name='Anmerkungen')
  93. class Meta:
  94. abstract = True
  95. TYPE_CHOICES = {'BIB': 'Bibliotheksstipendium',
  96. 'ELIT': 'eLiteraturstipendium',
  97. 'SOFT': 'Softwarestipendium',
  98. 'VIS': 'Visitenkarten',
  99. 'LIST': 'Mailingliste',
  100. 'MAIL': 'E-Mail-Adresse',
  101. 'IFG': 'Kostenübernahme IFG-Anfrage',
  102. 'LIT': 'Literaturstipendium',}
  103. # same model is used for Library, ELitStip and Software!
  104. class Library(Grant):
  105. type = models.CharField(
  106. max_length=4,
  107. choices=TYPE_CHOICES.items(), #attention: actually only BIB, ELIT, SOFT should be used here
  108. default='LIB',
  109. )
  110. library = models.CharField(max_length=200)
  111. duration = models.CharField(max_length=100, verbose_name="Dauer")
  112. def __str__(self):
  113. return self.library
  114. class Literature(Grant):
  115. info = models.CharField(max_length=500, verbose_name='Informationen zum Werk')
  116. source = models.CharField(max_length=200, verbose_name='Bezugsquelle')
  117. class IFG(Grant):
  118. url = models.CharField(max_length=2000)
  119. def __str__(self):
  120. return "IFG-Anfrage von " + self.realname
  121. DOMAIN_CHOICES = {'PEDIA': '@wikipedia.de',
  122. 'BOOKS': '@wikibooks.de',
  123. 'QUOTE': '@wikiquote.de',
  124. 'SOURCE': '@wikisource.de',
  125. 'VERSITY': '@wikiversity.de',}
  126. class Domain(Extern):
  127. domain = models.CharField(max_length=10,
  128. choices=DOMAIN_CHOICES.items(),
  129. default='PEDIA')
  130. class Meta:
  131. abstract = True
  132. MAIL_CHOICES = {'REALNAME': 'Vorname.Nachname',
  133. 'USERNAME': 'Username',
  134. 'OTHER': 'Sonstiges:'}
  135. class Email(Domain):
  136. address = models.CharField(max_length=50,
  137. choices=MAIL_CHOICES.items(),
  138. default='USERNAME', verbose_name='Adressbestandteil')
  139. other = models.CharField(max_length=50,blank=True,null=True)
  140. class List(Domain):
  141. address = models.CharField(max_length=50, default='NO_ADDRESS')
  142. PROJECT_CHOICE = {'PEDIA': 'Wikipedia',
  143. 'SOURCE': 'Wikisource',
  144. 'BOOKS': 'Wikibooks',
  145. 'QUOTE': 'Wikiquote',
  146. 'VERSITY': 'Wikiversity',
  147. 'VOYAGE': 'Wikivoyage',
  148. 'DATA': 'Wikidata',
  149. 'NEWS': 'Wikinews',
  150. 'COMMONS': 'Wikimedia Commons'}
  151. BC_VARIANT = {'PIC': 'Mit Bild',
  152. 'NOPIC': 'Ohne Bild'}
  153. class BusinessCard(Extern):
  154. project = models.CharField(max_length=20, choices=PROJECT_CHOICE.items(),
  155. default='PEDIA', verbose_name='Wikimedia Projekt')
  156. data = models.CharField(max_length=1000, verbose_name='Persönliche Daten', default='')
  157. variant = models.CharField(max_length=5, choices=BC_VARIANT.items(),
  158. default='NOPIC', verbose_name='Variante')
  159. sent_to = models.CharField(max_length=1000, verbose_name='Sendungsadresse',
  160. default='')