1
0
Fork 0
foerderbarometer/input/models.py

198 lines
7.4 KiB
Python
Raw Normal View History

2020-10-22 14:02:59 +00:00
from datetime import date
2020-09-21 12:27:16 +00:00
from django.db import models
2020-10-21 11:00:44 +00:00
from .settings import ACCOUNTS
2020-09-22 10:21:05 +00:00
2020-09-30 12:17:38 +00:00
class Volunteer(models.Model):
2020-11-02 09:58:20 +00:00
realname = models.CharField(max_length=200, null=True, verbose_name="Name / Hauptansprechperson")
email = models.CharField(max_length=200, null=True, verbose_name='E-Mail-Adresse')
2020-10-22 14:02:59 +00:00
# the following Fields are not supposed to be edited by users
granted = models.BooleanField(null=True)
2020-10-22 14:02:59 +00:00
granted_date = models.DateField(null=True)
2020-11-02 10:56:07 +00:00
survey_mail_send = models.BooleanField(default=False, verbose_name='Keine Umfragemail schicken')
2020-09-22 10:21:05 +00:00
2020-10-20 10:00:59 +00:00
@classmethod
def set_granted(cl, key, b):
obj = cl.objects.get(pk=key)
obj.granted = b
2020-10-22 14:02:59 +00:00
obj.granted_date = date.today()
2020-10-20 10:00:59 +00:00
obj.save()
2020-09-30 10:15:58 +00:00
class Meta:
abstract = True
2020-09-30 09:04:47 +00:00
class Extern(Volunteer):
''' abstract basis class for all data entered by extern volunteers '''
username = models.CharField(max_length=200, null=True)
2020-10-29 14:05:11 +00:00
# the following Fields are not supposed to be edited by users
service_id = models.CharField(max_length=15, null=True, blank=True)
def save(self,*args,**kwargs):
# is there a way to call super().save() only once?
super().save(*args,*kwargs)
self.service_id = type(self).__name__ + str(self.pk)
super().save(*args,*kwargs)
class Meta:
abstract = True
2020-09-30 12:17:38 +00:00
class Project(Volunteer):
2020-11-02 09:58:20 +00:00
name = models.CharField(max_length=200, verbose_name='Name des Projekts')
description = models.CharField(max_length=500, verbose_name="Kurzbeschreibung", null=True)
start = models.DateField('Startdatum', null=True, blank= True)
end = models.DateField('Erwartetes Projektende', null=True)
2020-11-02 09:58:20 +00:00
otrs = models.CharField(max_length=300, null=True, verbose_name='OTRS-Link')
plan = models.CharField(max_length=2000, null=True, blank=True, verbose_name="Link zum Förderplan")
page = models.CharField(max_length=2000, null=True, blank=True, verbose_name="Link zur Projektseite")
urls = models.CharField(max_length=2000, null=True, blank=True, verbose_name="Weitere Links")
group = models.CharField(max_length=2000, null=True, blank=True, verbose_name="Mitorganisierende")
location = models.CharField(max_length=2000, null=True, blank=True, verbose_name="Ort/Adresse/Location")
participants_estimated = models.IntegerField(blank=True, null=True, verbose_name='Teilnehmende angefragt')
participants_real = models.IntegerField(blank=True, null=True, verbose_name='Teilnehmende ausgezählt')
2020-11-02 10:56:07 +00:00
insurance = models.BooleanField(default=False, verbose_name='Haftpflichtversicherung')
insurance_technic = models.BooleanField(default=False, verbose_name='Technikversicherung Ausland')
support = models.CharField(max_length=300, blank=True, null=True, verbose_name='Betreuungsperson und Vertretung')
cost = models.IntegerField(blank=True, null=True)
account = models.CharField('Kostenstelle', max_length=5,
choices=ACCOUNTS.items(), null=True,)
2020-11-02 10:56:07 +00:00
granted_from = models.CharField(max_length=100,null=True,verbose_name='Bewilligt von')
notes = models.CharField(max_length=1000,null=True,blank=True,verbose_name='Anmerkungen')
2020-09-30 09:04:47 +00:00
2020-10-22 14:02:59 +00:00
# the following Fields are not supposed to be edited by users
pid = models.CharField(max_length=15, null=True, blank=True)
end_mail_send = models.BooleanField(null=True)
status = models.CharField(max_length=3,choices=(('RUN', 'läuft'),('END','beendet')),default='RUN')
persons = models.IntegerField(default=1)
2020-11-02 10:56:07 +00:00
def save(self,*args,**kwargs):
2020-10-07 07:55:32 +00:00
# is there a way to call super().save() only once?
super().save(*args,*kwargs)
self.pid = self.account + str(self.pk)
2020-10-07 07:55:32 +00:00
super().save(*args,*kwargs)
2020-09-30 09:04:47 +00:00
def __str__(self):
2020-10-21 11:00:44 +00:00
return f"{self.pid} {self.name}"
2020-10-26 10:38:56 +00:00
class Intern(Volunteer):
'''abstrat base class for data entry from /intern (except Project)'''
2020-10-07 07:55:32 +00:00
request_url = models.CharField(max_length=2000)
2020-10-26 10:38:56 +00:00
class Meta:
abstract = True
class HonoraryCertificate(Intern):
''' this class is also used for accreditations '''
# request_url = models.CharField(max_length=2000)
project = models.ForeignKey(Project, null=True, blank=True, on_delete=models.SET_NULL)
def __str__(self):
return "Certificate for " + self.realname
2020-09-30 11:46:06 +00:00
2020-10-26 10:38:56 +00:00
class Travel(Intern):
project = models.ForeignKey(Project, on_delete=models.CASCADE)
2020-10-26 10:38:56 +00:00
#abstract base class for Library and IFG
class Grant(Extern):
2020-09-30 11:46:06 +00:00
cost = models.CharField(max_length=10)
notes = models.CharField(max_length=500, blank=True)
2020-09-30 11:46:06 +00:00
2020-09-30 12:17:38 +00:00
class Meta:
abstract = True
TYPE_CHOICES = {'BIB': 'Bibliotheksstipendium',
'ELIT': 'eLiteraturstipendium',
'SOFT': 'Softwarestipendium',
'VIS': 'Visitenkarten',
'LIST': 'Mailingliste',
'MAIL': 'E-Mail-Adresse',
'IFG': 'Kostenübernahme IFG-Anfrage',
'LIT': 'Literaturstipendium',}
2020-10-19 12:37:51 +00:00
# same model is used for Library, ELitStip and Software!
2020-09-30 12:17:38 +00:00
class Library(Grant):
2020-10-19 11:54:57 +00:00
type = models.CharField(
max_length=4,
choices=TYPE_CHOICES.items(), #attention: actually only BIB, ELIT, SOFT should be used here
default='LIB',
)
2020-09-30 12:17:38 +00:00
library = models.CharField(max_length=200)
duration = models.CharField(max_length=100)
2020-09-30 11:46:06 +00:00
def __str__(self):
return self.library
2020-09-30 12:17:38 +00:00
class Literature(Grant):
info = models.CharField(max_length=500)
source = models.CharField(max_length=200)
2020-09-30 12:17:38 +00:00
class IFG(Grant):
url = models.CharField(max_length=2000)
2020-09-30 12:17:38 +00:00
def __str__(self):
return "IFG-Anfrage von " + self.realname
2020-10-27 10:00:58 +00:00
DOMAIN_CHOICES = {'PEDIA': '@wikipedia.de',
'BOOKS': '@wikibooks.de',
'QUOTE': '@wikiquote.de',
'SOURCE': '@wikisource.de',
'VERSITY': '@wikiversity.de',}
class Domain(Extern):
domain = models.CharField(max_length=10,
choices=DOMAIN_CHOICES.items(),
default='PEDIA')
class Meta:
abstract = True
MAIL_CHOICES = {'REALNAME': 'Vorname.Nachname',
'USERNAME': 'Username',
'OTHER': 'Sonstiges:'}
class Email(Domain):
address = models.CharField(max_length=50,
2020-10-27 10:00:58 +00:00
choices=MAIL_CHOICES.items(),
default='USERNAME', verbose_name='Adressbestandteil')
2020-10-27 10:00:58 +00:00
other = models.CharField(max_length=50,blank=True,null=True)
class List(Domain):
address = models.CharField(max_length=50, default='NO_ADDRESS')
PROJECT_CHOICE = {'PEDIA': 'Wikipedia',
'SOURCE': 'Wikisource',
'BOOKS': 'Wikibooks',
'QUOTE': 'Wikiquote',
'VERSITY': 'Wikiversity',
'VOYAGE': 'Wikivoyage',
'DATA': 'Wikidata',
'NEWS': 'Wikinews',
'COMMONS': 'Wikimedia Commons'}
BC_VARIANT = {'PIC': 'Mit Bild',
'NOPIC': 'Ohne Bild'}
class BusinessCard(Extern):
project = models.CharField(max_length=20, choices=PROJECT_CHOICE.items(),
default='PEDIA', verbose_name='Wikimedia Projekt')
2020-10-27 14:50:46 +00:00
data = models.CharField(max_length=1000, verbose_name='Persönliche Daten', default='')
variant = models.CharField(max_length=5, choices=BC_VARIANT.items(),
default='NOPIC', verbose_name='Variante')
sent_to = models.CharField(max_length=1000, verbose_name='Sendungsadresse',
2020-10-27 14:50:46 +00:00
default='')