Travel model and form added
This commit is contained in:
		
							parent
							
								
									4a315b8163
								
							
						
					
					
						commit
						5a014d4696
					
				| 
						 | 
					@ -1,17 +1,6 @@
 | 
				
			||||||
from django.contrib import admin
 | 
					from django.contrib import admin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Register your models here.
 | 
					from .models import Project, HonoraryCertificate, Library, IFG, Travel
 | 
				
			||||||
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)
 | 
					@admin.register(Project)
 | 
				
			||||||
class ProjectAdmin(admin.ModelAdmin):
 | 
					class ProjectAdmin(admin.ModelAdmin):
 | 
				
			||||||
| 
						 | 
					@ -21,4 +10,5 @@ admin.site.register([
 | 
				
			||||||
                     HonoraryCertificate,
 | 
					                     HonoraryCertificate,
 | 
				
			||||||
                     Library,
 | 
					                     Library,
 | 
				
			||||||
                     IFG,
 | 
					                     IFG,
 | 
				
			||||||
 | 
					                     Travel,
 | 
				
			||||||
                     ])
 | 
					                     ])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@ from django.forms import ModelForm, DateField, ChoiceField, RadioSelect, Boolean
 | 
				
			||||||
from django.contrib.admin.widgets import AdminDateWidget
 | 
					from django.contrib.admin.widgets import AdminDateWidget
 | 
				
			||||||
from django.utils.html import format_html
 | 
					from django.utils.html import format_html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .models import Project, Volunteer, IFG, Library, TYPE_CHOICES, HonoraryCertificate
 | 
					from .models import Project, Volunteer, IFG, Library, TYPE_CHOICES, HonoraryCertificate, Travel
 | 
				
			||||||
from .settings import DATAPROTECTION, FOERDERRICHTLINIEN
 | 
					from .settings import DATAPROTECTION, FOERDERRICHTLINIEN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,6 +42,11 @@ class InternForm(ModelForm):
 | 
				
			||||||
        model = Volunteer
 | 
					        model = Volunteer
 | 
				
			||||||
        exclude = ('granted', 'granted_date', 'survey_mail_send')
 | 
					        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):
 | 
					class LibraryForm(ModelForm):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,31 @@
 | 
				
			||||||
 | 
					# 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,
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
| 
						 | 
					@ -54,16 +54,29 @@ class Project(Volunteer):
 | 
				
			||||||
        return f"{self.pid} {self.name}"
 | 
					        return f"{self.pid} {self.name}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class HonoraryCertificate(Volunteer):
 | 
					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):
 | 
				
			||||||
    ''' this class is also used for accreditations '''
 | 
					    ''' 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)
 | 
					    project = models.ForeignKey(Project, null = True, on_delete = models.SET_NULL)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
        return "Certificate for " + self.realname
 | 
					        return "Certificate for " + self.realname
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Travel(Intern):
 | 
				
			||||||
 | 
					    project = models.ForeignKey(Project, on_delete = models.CASCADE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#abstract base class for Library and IFG
 | 
					#abstract base class for Library and IFG
 | 
				
			||||||
class Grant(Extern):
 | 
					class Grant(Extern):
 | 
				
			||||||
    cost = models.CharField(max_length=10)
 | 
					    cost = models.CharField(max_length=10)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@ from django.template.loader import get_template
 | 
				
			||||||
from django.template import Context
 | 
					from django.template import Context
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm,\
 | 
					from .forms import ProjectForm, VolunteerForm, LibraryForm, IFGForm,\
 | 
				
			||||||
                   HonoraryCertificateForm, InternForm
 | 
					                   HonoraryCertificateForm, InternForm, TravelForm
 | 
				
			||||||
from .models import Project, TYPE_CHOICES, Library
 | 
					from .models import Project, TYPE_CHOICES, Library
 | 
				
			||||||
from .settings import URLPREFIX, IF_EMAIL
 | 
					from .settings import URLPREFIX, IF_EMAIL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,6 +62,9 @@ class InternView(CookieWizardView):
 | 
				
			||||||
            elif choice == 'PRO':
 | 
					            elif choice == 'PRO':
 | 
				
			||||||
                print ('Projektsteckbrief erreicht!')
 | 
					                print ('Projektsteckbrief erreicht!')
 | 
				
			||||||
                form = ProjectForm(data)
 | 
					                form = ProjectForm(data)
 | 
				
			||||||
 | 
					            elif choice == 'TRAV':
 | 
				
			||||||
 | 
					                print('Reisekosten erreicht')
 | 
				
			||||||
 | 
					                form = TravelForm(data)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                raise RuntimeError(f'ERROR! UNKNOWN FORMTYPE {choice}')
 | 
					                raise RuntimeError(f'ERROR! UNKNOWN FORMTYPE {choice}')
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue