stupa-pdf-api/src/pdf_field_mapping.py

146 lines
7.3 KiB
Python

#!/usr/bin/env python3
"""
PDF Field Mapping
This module provides a mapping of PDF fields to their corresponding keys in the application data.
"""
_PLACEHOLDER_VALUES: set = {None, "", "-", "JJJJ-MM", "/\\Fld@default "}
# --- COMMON fields (shared across variants) ---
TEXT_MAPPING_COMMON: dict = {
# --- Meta ---
'pa-id': {
'required': True,
'target-key': 'pa.meta.id',
'type': str,
},
'pa-key': {
'required': True,
'target-key': 'pa.meta.key',
'type': str,
},
# --- Applicant ---
'pa-applicant-type': {
'required': True,
'target-key': 'pa.applicant.type',
'type': 'enum',
'values': [('person', 'Person'), ('institution', 'Institution')]
},
'pa-institution-type': {
'required': True,
'target-key': 'pa.applicant.institution.type',
'type': 'enum',
'values': [
('-', '-'),
('stud-fs', 'Fachschaft'),
('stud-rf', 'STUPA-Referat'),
('stud-hg', 'Studentische Hochschulgruppe'),
('faculty', 'Fakultät'),
('hs-institution', 'Hochschuleinrichtung'),
]
},
'pa-institution': {'required': True, 'target-key': 'pa.applicant.institution.name', 'type': str},
'pa-first-name': {'required': True, 'target-key': 'pa.applicant.name.first'},
'pa-last-name': {'required': True, 'target-key': 'pa.applicant.name.last'},
'pa-email': {'required': True, 'target-key': 'pa.applicant.contact.email'},
'pa-phone': {'required': False, 'target-key': 'pa.applicant.contact.phone'},
'pa-course': {
'required': True,
'target-key': 'pa.applicant.course',
'type': 'enum',
'values': [('-', '-'), ('INF', 'INF'), ('ESB', 'ESB'), ('LS', 'LS'), ('TEC', 'TEC'), ('TEX', 'TEX'), ('NXT', 'NXT')]
},
'pa-role': {
'required': True,
'target-key': 'pa.applicant.role',
'type': 'enum',
'values': [
('-', '-'),
('Student', 'Student'),
('Professor', 'Professor'),
('Mitarbeiter', 'Mitarbeiter'),
('ASTA', 'ASTA'),
('Referatsleitung', 'Referatsleitung'),
('Fachschaftsvorstand', 'Fachschaftsvorstand'),
]
},
# --- Project core ---
'pa-project-name': {'required': True, 'target-key': 'pa.project.name', 'type': str},
'pa-start-date': {'required': True, 'target-key': 'pa.project.dates.start', 'type': str},
'pa-end-date': {'required': False, 'target-key': 'pa.project.dates.end', 'type': str},
'pa-participants': {'required': False, 'target-key': 'pa.project.participants', 'type': int},
'pa-project-description': {'required': True, 'target-key': 'pa.project.description', 'type': str},
# --- Participation (checkboxes) ---
'pa-participating-faculties-inf': {'required': False, 'target-key': 'pa.project.participation.faculties.inf', 'type': bool},
'pa-participating-faculties-esb': {'required': False, 'target-key': 'pa.project.participation.faculties.esb', 'type': bool},
'pa-participating-faculties-ls': {'required': False, 'target-key': 'pa.project.participation.faculties.ls', 'type': bool},
'pa-participating-faculties-tec': {'required': False, 'target-key': 'pa.project.participation.faculties.tec', 'type': bool},
'pa-participating-faculties-tex': {'required': False, 'target-key': 'pa.project.participation.faculties.tex', 'type': bool},
'pa-participating-faculties-nxt': {'required': False, 'target-key': 'pa.project.participation.faculties.nxt', 'type': bool},
'pa-participating-faculties-open': {'required': False, 'target-key': 'pa.project.participation.faculties.open', 'type': bool},
# --- Costs & totals ---
'pa-cost-{a;1:24}-name': {'required': True, 'target-key': 'pa.project.costs[{a}].name', 'type': str},
'pa-cost-{a;1:24}-amount-euro': {'required': True, 'target-key': 'pa.project.costs[{a}].amountEur', 'type': float},
'pa-requested-amount-euro-sum': {'required': True, 'target-key': 'pa.project.totals.requestedAmountEur', 'type': float},
# --- Attachments common ---
'pa-anh-vergleichsangebote': {'required': False, 'target-key': 'pa.attachments.comparativeOffers', 'type': bool},
# --- Misc ---
'warning-not-supported': {'required': False, 'target-key': 'warning.notSupported', 'type': str},
}
# --- QSM-specific fields (second variant) ---
TEXT_MAPPING_QSM = {
'pa-qsm-financing': {
'required': True,
'target-key': 'pa.project.financing.qsm.code',
'type': 'enum',
'values': [
('vwv-3-2-1-1', 'Finanzierung zusätzlicher Lehr- und Seminarangebote'),
('vwv-3-2-1-2', 'Fachspezifische Studienprojekte'),
('vwv-3-2-1-3', 'Hochschuldidaktische Fort- und Weiterbildungsmaßnahmen'),
('vwv-3-2-2-1', 'Verbesserung/Ausbau von Serviceeinrichtungen sowie Infrastruktur'),
('vwv-3-2-2-2', 'Lehr- und Lernmaterialien'),
('vwv-3-2-2-3', 'Durchführung von Exkursionen'),
('vwv-3-2-2-4', 'Finanzierung von infrastrukturellen Begleit- und Anpassungsmaßnahmen'),
('vwv-3-2-3-1', 'Verbesserung der Beratungsangebote für Studierende'),
('vwv-3-2-3-2', 'Studium Generale und fachübergreifende Lehrangebote'),
('vwv-3-2-3-3', 'Sonstige Maßnahmen im Interesse der Studierendenschaft'),
]
},
'pa-qsm-stellenfinanzierungen': {'required': False, 'target-key': 'pa.project.financing.qsm.flags.stellenfinanzierungen', 'type': bool},
'pa-qsm-studierende': {'required': False, 'target-key': 'pa.project.financing.qsm.flags.studierende', 'type': bool},
'pa-qsm-individuell': {'required': False, 'target-key': 'pa.project.financing.qsm.flags.individuell', 'type': bool},
'pa-qsm-exkursion-genehmigt': {'required': False, 'target-key': 'pa.project.financing.qsm.flags.exkursionGenehmigt', 'type': bool},
'pa-qsm-exkursion-bezuschusst': {'required': False, 'target-key': 'pa.project.financing.qsm.flags.exkursionBezuschusst', 'type': bool},
'pa-anh-fakultaet': {'required': False, 'target-key': 'pa.attachments.fakultaet', 'type': bool},
}
# --- VSM-specific fields (first variant; include for completeness) ---
TEXT_MAPPING_VSM = {
'pa-vsm-financing': {
'required': True,
'target-key': 'pa.project.financing.vsm.code',
'type': 'enum',
'values': [
('-', '-'),
('lhg-01', 'Hochschulpolitische, fachliche, soziale, wirtschaftliche und kulturelle Belange'),
('lhg-02', 'Mitwirkung an den Aufgaben der Hochschulen nach den §§ 2 bis 7'),
('lhg-03', 'Politische Bildung'),
('lhg-04', 'Förderung der Chancengleichheit und Abbau von Benachteiligungen'),
('lhg-05', 'Förderung der Integration ausländischer Studierender'),
('lhg-06', 'Förderung der sportlichen Aktivitäten'),
('lhg-07', 'Pflege der überregionalen Studierendenbeziehungen'),
]
},
'pa-vsm-aufgaben': {'required': False, 'target-key': 'pa.project.financing.vsm.flags.aufgaben', 'type': bool},
'pa-vsm-individuell': {'required': False, 'target-key': 'pa.project.financing.vsm.flags.individuell', 'type': bool},
}