forked from beba/foerderbarometer
70 lines
2.0 KiB
Python
70 lines
2.0 KiB
Python
from django.db import models
|
|
|
|
|
|
class Volunteer(models.Model):
|
|
realname = models.CharField(max_length=200, null=True)
|
|
email = models.CharField(max_length=200, null=True)
|
|
username = models.CharField(max_length=200, null=True)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
class Project(Volunteer):
|
|
name = models.CharField(max_length=200)
|
|
start = models.DateField('start date')
|
|
|
|
pid = models.IntegerField(null=True, blank=True) # automaticly generated
|
|
|
|
def save(self,*args,**kwargs):
|
|
# is there a way to call super().save() only once?
|
|
super().save(*args,*kwargs)
|
|
self.pid = 10000 + self.pk
|
|
super().save(*args,*kwargs)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
class HonoraryCertificate(Volunteer):
|
|
request_url = models.CharField(max_length=2000)
|
|
number = models.IntegerField(null = True)
|
|
|
|
def __str__(self):
|
|
return "Certificate for " + self.realname
|
|
|
|
#abstract class for Library, IFG, ...
|
|
class Grant(Volunteer):
|
|
cost = models.CharField(max_length=10)
|
|
notes = models.CharField(max_length=500)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
# same model is used for Library, ELitStip and Software!
|
|
TYPE_CHOICES = [('BIB', 'Bibliotheksstipendium'),
|
|
('ELIT', 'eLiteraturstipendium'),
|
|
('SOFT', 'Softwarestipendium'),
|
|
('VIS', 'Visitenkarten'),
|
|
('LIST', 'Mailingliste'),
|
|
('MAIL', 'E-Mail-Adresse'),
|
|
('IFG', 'Kostenübernahme IFG-Anfrage'),
|
|
('LIT', 'Literaturstipendium'),]
|
|
|
|
class Library(Grant):
|
|
|
|
type = models.CharField(
|
|
max_length=4,
|
|
choices=TYPE_CHOICES, #attention: actually only BIB, ELIT, SOFT should be used here
|
|
default='LIB',
|
|
)
|
|
library = models.CharField(max_length=200)
|
|
duration = models.CharField(max_length=100)
|
|
|
|
def __str__(self):
|
|
return self.library
|
|
|
|
class IFG(Grant):
|
|
url = models.CharField(max_length=2000)
|
|
|
|
def __str__(self):
|
|
return "IFG-Anfrage von " + self.realname
|