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-10-22 09:36:16 +00:00
|
|
|
|
2020-09-30 12:17:38 +00:00
|
|
|
class Volunteer(models.Model):
|
2020-09-30 10:15:58 +00:00
|
|
|
realname = models.CharField(max_length=200, null=True)
|
|
|
|
email = models.CharField(max_length=200, null=True)
|
|
|
|
username = models.CharField(max_length=200, null=True)
|
2020-10-20 07:35:04 +00:00
|
|
|
granted = models.BooleanField(null=True)
|
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
|
|
|
|
obj.save()
|
|
|
|
|
2020-09-30 10:15:58 +00:00
|
|
|
class Meta:
|
|
|
|
abstract = True
|
2020-09-30 09:04:47 +00:00
|
|
|
|
2020-10-22 09:36:16 +00:00
|
|
|
|
2020-09-30 12:17:38 +00:00
|
|
|
class Project(Volunteer):
|
2020-09-30 09:04:47 +00:00
|
|
|
name = models.CharField(max_length=200)
|
2020-10-21 11:53:39 +00:00
|
|
|
start = models.DateField('Startdatum', null=True)
|
|
|
|
end = models.DateField('Erwartetes Projektende', null=True)
|
|
|
|
account = models.CharField('Kostenstelle', max_length=5,
|
|
|
|
choices=ACCOUNTS.items(), null=True,)
|
2020-09-30 09:04:47 +00:00
|
|
|
|
2020-10-22 09:36:16 +00:00
|
|
|
# the following Fields are not supposed to be editet by users
|
|
|
|
pid = models.IntegerField(null=True, blank=True)
|
|
|
|
end_mail_send = models.BooleanField(null=True)
|
2020-10-06 13:15:05 +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 = 10000 + self.pk
|
|
|
|
super().save(*args,*kwargs)
|
2020-10-06 13:15:05 +00:00
|
|
|
|
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-09-30 11:31:19 +00:00
|
|
|
|
2020-10-22 09:36:16 +00:00
|
|
|
|
2020-09-30 12:17:38 +00:00
|
|
|
class HonoraryCertificate(Volunteer):
|
2020-10-07 07:55:32 +00:00
|
|
|
request_url = models.CharField(max_length=2000)
|
2020-10-21 07:22:53 +00:00
|
|
|
project = models.ForeignKey(Project, null = True, on_delete = models.SET_NULL)
|
2020-09-30 11:31:19 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Certificate for " + self.realname
|
2020-09-30 11:46:06 +00:00
|
|
|
|
2020-10-22 09:36:16 +00:00
|
|
|
|
|
|
|
#abstract base class for Library, IFG, ...
|
2020-09-30 12:17:38 +00:00
|
|
|
class Grant(Volunteer):
|
2020-09-30 11:46:06 +00:00
|
|
|
cost = models.CharField(max_length=10)
|
|
|
|
notes = models.CharField(max_length=500)
|
|
|
|
|
2020-09-30 12:17:38 +00:00
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
2020-10-20 07:35:04 +00:00
|
|
|
|
2020-10-21 11:27:05 +00:00
|
|
|
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
|
|
|
|
2020-10-22 09:36:16 +00:00
|
|
|
|
2020-10-20 07:35:04 +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
|
|
|
|
2020-10-19 09:56:10 +00:00
|
|
|
type = models.CharField(
|
|
|
|
max_length=4,
|
2020-10-21 11:27:05 +00:00
|
|
|
choices=TYPE_CHOICES.items(), #attention: actually only BIB, ELIT, SOFT should be used here
|
2020-10-19 09:56:10 +00:00
|
|
|
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
|
|
|
|
2020-10-22 09:36:16 +00:00
|
|
|
|
2020-09-30 12:17:38 +00:00
|
|
|
class IFG(Grant):
|
2020-10-19 09:56:10 +00:00
|
|
|
url = models.CharField(max_length=2000)
|
2020-09-30 12:17:38 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "IFG-Anfrage von " + self.realname
|