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.

211 lines
9.6 KiB

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