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.

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