Compare commits
No commits in common. "a6474e07e858400c771b706de151de79ab555878" and "4a315b81633e593c465b501cd21c894420ed2e90" have entirely different histories.
a6474e07e8
...
4a315b8163
|
@ -1,6 +1,17 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import Project, HonoraryCertificate, Library, IFG, Travel
|
||||
# Register your models here.
|
||||
from .models import Project, HonoraryCertificate, Library, IFG #, ELitStip
|
||||
|
||||
# @admin.register(Project)
|
||||
# class ProjectAdmin(admin.ModelAdmin):
|
||||
# #fields = ('pid',)
|
||||
# readonly_fields = ('pid',)
|
||||
# # list_display =('pid',)
|
||||
# def __init__(self, *args, **kwargs):
|
||||
# super().__init__(*args, **kwargs)
|
||||
# self.fields = super().get_all_field_names() + 'pid'
|
||||
# return self
|
||||
|
||||
@admin.register(Project)
|
||||
class ProjectAdmin(admin.ModelAdmin):
|
||||
|
@ -10,5 +21,4 @@ admin.site.register([
|
|||
HonoraryCertificate,
|
||||
Library,
|
||||
IFG,
|
||||
Travel,
|
||||
])
|
||||
|
|
|
@ -3,7 +3,7 @@ from django.forms import ModelForm, DateField, ChoiceField, RadioSelect, Boolean
|
|||
from django.contrib.admin.widgets import AdminDateWidget
|
||||
from django.utils.html import format_html
|
||||
|
||||
from .models import Project, Volunteer, Extern, IFG, Library, TYPE_CHOICES, HonoraryCertificate, Travel
|
||||
from .models import Project, Volunteer, IFG, Library, TYPE_CHOICES, HonoraryCertificate
|
||||
from .settings import DATAPROTECTION, FOERDERRICHTLINIEN
|
||||
|
||||
|
||||
|
@ -13,11 +13,11 @@ class ProjectForm(ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = Project
|
||||
exclude = ('pid', 'granted', 'granted_date', 'realname', 'email', 'project_end_mail', 'survey_mail_send')
|
||||
exclude = ('pid', 'granted', 'granted_date', 'username', 'realname', 'email', 'project_end_mail', 'survey_mail_send')
|
||||
widgets = {'start': AdminDateWidget(),
|
||||
'end': AdminDateWidget(),}
|
||||
|
||||
class ExternForm(ModelForm):
|
||||
class VolunteerForm(ModelForm):
|
||||
|
||||
choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect,
|
||||
label='Was möchtest Du beantragen?')
|
||||
|
@ -27,7 +27,7 @@ class ExternForm(ModelForm):
|
|||
DATAPROTECTION, FOERDERRICHTLINIEN))
|
||||
|
||||
class Meta:
|
||||
model = Extern
|
||||
model = Volunteer
|
||||
exclude = ('granted', 'granted_date', 'survey_mail_send')
|
||||
|
||||
INTERN_CHOICES = [('PRO', 'Projektsteckbrief'),
|
||||
|
@ -42,11 +42,6 @@ class InternForm(ModelForm):
|
|||
model = Volunteer
|
||||
exclude = ('granted', 'granted_date', 'survey_mail_send')
|
||||
|
||||
class TravelForm(ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Travel
|
||||
exclude = ('granted', 'granted_date', 'survey_mail_send', 'realname', 'email',)
|
||||
|
||||
class LibraryForm(ModelForm):
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
# Generated by Django 3.1.1 on 2020-10-26 10:35
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('input', '0023_auto_20201022_1400'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Travel',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('realname', models.CharField(max_length=200, null=True)),
|
||||
('email', models.CharField(max_length=200, null=True)),
|
||||
('username', models.CharField(max_length=200, null=True)),
|
||||
('granted', models.BooleanField(null=True)),
|
||||
('granted_date', models.DateField(null=True)),
|
||||
('survey_mail_send', models.BooleanField(null=True)),
|
||||
('request_url', models.CharField(max_length=2000)),
|
||||
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='input.project')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -1,25 +0,0 @@
|
|||
# Generated by Django 3.1.1 on 2020-10-26 10:48
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('input', '0024_travel'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='honorarycertificate',
|
||||
name='username',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='project',
|
||||
name='username',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='travel',
|
||||
name='username',
|
||||
),
|
||||
]
|
|
@ -8,7 +8,7 @@ from .settings import ACCOUNTS
|
|||
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)
|
||||
username = models.CharField(max_length=200, null=True)
|
||||
|
||||
# the following Fields are not supposed to be edited by users
|
||||
granted = models.BooleanField(null=True)
|
||||
|
@ -54,29 +54,16 @@ class Project(Volunteer):
|
|||
return f"{self.pid} {self.name}"
|
||||
|
||||
|
||||
class Intern(Volunteer):
|
||||
'''abstrat base class for data entry from /intern (except Project)'''
|
||||
request_url = models.CharField(max_length=2000)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class HonoraryCertificate(Intern):
|
||||
class HonoraryCertificate(Volunteer):
|
||||
''' this class is also used for accreditations '''
|
||||
|
||||
# request_url = models.CharField(max_length=2000)
|
||||
request_url = models.CharField(max_length=2000)
|
||||
project = models.ForeignKey(Project, null = True, on_delete = models.SET_NULL)
|
||||
|
||||
def __str__(self):
|
||||
return "Certificate for " + self.realname
|
||||
|
||||
|
||||
class Travel(Intern):
|
||||
project = models.ForeignKey(Project, on_delete = models.CASCADE)
|
||||
|
||||
|
||||
|
||||
#abstract base class for Library and IFG
|
||||
class Grant(Extern):
|
||||
cost = models.CharField(max_length=10)
|
||||
|
|
|
@ -7,8 +7,8 @@ from django.conf import settings
|
|||
from django.template.loader import get_template
|
||||
from django.template import Context
|
||||
|
||||
from .forms import ProjectForm, ExternForm, LibraryForm, IFGForm,\
|
||||
HonoraryCertificateForm, InternForm, TravelForm
|
||||
from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm,\
|
||||
HonoraryCertificateForm, InternForm
|
||||
from .models import Project, TYPE_CHOICES, Library
|
||||
from .settings import URLPREFIX, IF_EMAIL
|
||||
|
||||
|
@ -62,9 +62,6 @@ class InternView(CookieWizardView):
|
|||
elif choice == 'PRO':
|
||||
print ('Projektsteckbrief erreicht!')
|
||||
form = ProjectForm(data)
|
||||
elif choice == 'TRAV':
|
||||
print('Reisekosten erreicht')
|
||||
form = TravelForm(data)
|
||||
else:
|
||||
raise RuntimeError(f'ERROR! UNKNOWN FORMTYPE {choice}')
|
||||
else:
|
||||
|
@ -72,7 +69,7 @@ class InternView(CookieWizardView):
|
|||
return form
|
||||
|
||||
def done(self, form_list, **kwargs):
|
||||
print('InternView.done() reached')
|
||||
print('ExternView.done() reached')
|
||||
# gather data from all forms
|
||||
data = {}
|
||||
for form in form_list:
|
||||
|
@ -85,7 +82,7 @@ class InternView(CookieWizardView):
|
|||
# this is ugly code. how can we copy this without explicit writing?
|
||||
# i found no way to access the ModelForm.Meta.exclude-tupel
|
||||
form.realname = data['realname']
|
||||
# form.username = data['username']
|
||||
form.username = data['username']
|
||||
form.email = data['email']
|
||||
form.save()
|
||||
|
||||
|
@ -96,7 +93,7 @@ class ExternView(CookieWizardView):
|
|||
'''This View is for Volunteers'''
|
||||
|
||||
template_name = "input/extern.html"
|
||||
form_list = [ExternForm, LibraryForm]
|
||||
form_list = [VolunteerForm, LibraryForm]
|
||||
|
||||
def get_form(self, step=None, data=None, files=None):
|
||||
'''this function determines which part of the multipart form is
|
||||
|
@ -135,7 +132,7 @@ class ExternView(CookieWizardView):
|
|||
# we have to copy the data from the first form here
|
||||
# this is a bit ugly code. how can we copy this without explicit writing?
|
||||
form.realname = data['realname']
|
||||
# form.username = data['username']
|
||||
form.username = data['username']
|
||||
form.email = data['email']
|
||||
# write type of form in some cases
|
||||
if data['choice'] in ('BIB', 'ELIT', 'SOFT'):
|
||||
|
|
Loading…
Reference in New Issue