snapshot: preserve current onboarding offboarding portal state
This commit is contained in:
@@ -16,6 +16,16 @@ from .models import EmployeeProfile, NotificationRule, NotificationTemplate, Off
|
||||
from .emailing import send_system_email
|
||||
from .services import upload_to_nextcloud
|
||||
from .services import get_email_test_redirect, is_email_test_mode
|
||||
from .forms import (
|
||||
ACCESS_CHOICES,
|
||||
DEVICE_CHOICES,
|
||||
HARDWARE_EXTRA_CHOICES,
|
||||
OnboardingRequestForm,
|
||||
RESOURCE_CHOICES,
|
||||
SOFTWARE_CHOICES,
|
||||
SOFTWARE_EXTRA_CHOICES,
|
||||
WORKSPACE_GROUP_CHOICES,
|
||||
)
|
||||
|
||||
|
||||
DEFAULT_NOTIFICATION_TEMPLATES = {
|
||||
@@ -179,6 +189,76 @@ def _split_multiline(text: str) -> list[str]:
|
||||
return [line.strip() for line in (text or '').split('\n') if line.strip()]
|
||||
|
||||
|
||||
def _chunk_choice_labels(choices: list[tuple[str, str]], chunk_size: int = 3) -> list[list[str]]:
|
||||
labels = [label for _, label in choices]
|
||||
return _chunk_list(labels, chunk_size=chunk_size)
|
||||
|
||||
|
||||
MANUAL_ONBOARDING_FIELD_SECTIONS = [
|
||||
(
|
||||
'Stammdaten',
|
||||
[
|
||||
'gender',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'job_title',
|
||||
'department',
|
||||
'work_email',
|
||||
'order_business_cards',
|
||||
'business_card_name',
|
||||
'business_card_title',
|
||||
'business_card_email',
|
||||
'business_card_phone',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Vertrag',
|
||||
[
|
||||
'contract_start',
|
||||
'employment_type',
|
||||
'employment_end_date',
|
||||
'handover_date',
|
||||
],
|
||||
),
|
||||
(
|
||||
'IT-Setup',
|
||||
[
|
||||
'group_mailboxes_required_choice',
|
||||
'group_mailboxes',
|
||||
'additional_hardware_needed_choice',
|
||||
'additional_hardware_other',
|
||||
'additional_software_needed_choice',
|
||||
'additional_software',
|
||||
'additional_access_needed_choice',
|
||||
'additional_access_text',
|
||||
'successor_required_choice',
|
||||
'successor_name',
|
||||
'inherit_phone_number_choice',
|
||||
'phone_number_choice',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Abschluss',
|
||||
[
|
||||
'additional_notes',
|
||||
'signature_image',
|
||||
'agreement_confirm',
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def _manual_onboarding_field_sections() -> list[dict]:
|
||||
fields = OnboardingRequestForm.base_fields
|
||||
sections = []
|
||||
for title, field_names in MANUAL_ONBOARDING_FIELD_SECTIONS:
|
||||
labels = [str(fields[name].label or name) for name in field_names if name in fields]
|
||||
if not labels:
|
||||
continue
|
||||
sections.append({'title': title, 'rows': _chunk_list(labels, chunk_size=2)})
|
||||
return sections
|
||||
|
||||
|
||||
def _resolve_workflow_emails() -> tuple[str, str, str, str, str]:
|
||||
config = WorkflowConfig.objects.order_by('id').first()
|
||||
it_email = (config.it_onboarding_email if config and config.it_onboarding_email else settings.IT_ONBOARDING_NOTIFICATION_EMAIL)
|
||||
@@ -448,10 +528,12 @@ def _generate_onboarding_pdf(request_obj: OnboardingRequest) -> Path:
|
||||
successor_name = (request_obj.successor_name or '').strip()
|
||||
additional_notes = (request_obj.additional_notes or '').strip()
|
||||
phone_number = (request_obj.phone_number or '').strip()
|
||||
display_name = f"{gender} {first_name} {last_name}".strip() if gender and gender != '-' else f"{first_name} {last_name}".strip()
|
||||
|
||||
context = {
|
||||
'VORNAME': first_name,
|
||||
'NACHNAME': last_name,
|
||||
'DISPLAY_NAME': display_name or request_obj.full_name,
|
||||
'ANREDE': gender,
|
||||
'BERUFSBEZEICHNUNG': request_obj.job_title or 'N/A',
|
||||
'ABTEILUNG': request_obj.department or 'N/A',
|
||||
@@ -539,6 +621,7 @@ def _generate_offboarding_pdf(request_obj: OffboardingRequest) -> Path:
|
||||
.order_by('-created_at')
|
||||
.first()
|
||||
)
|
||||
has_onboarding_data = latest_onboarding is not None
|
||||
onboarding_hardware = _split_multiline(latest_onboarding.needed_devices) if latest_onboarding else []
|
||||
selected_set = {item.lower() for item in onboarding_hardware}
|
||||
hardware_catalog = [
|
||||
@@ -568,8 +651,17 @@ def _generate_offboarding_pdf(request_obj: OffboardingRequest) -> Path:
|
||||
'NOTES': request_obj.notes or '-',
|
||||
'REQUESTED_BY': requester_email,
|
||||
'REQUESTED_BY_NAME': requester_name,
|
||||
'HAS_ONBOARDING_DATA': has_onboarding_data,
|
||||
'ONBOARDING_HARDWARE': onboarding_hardware,
|
||||
'HARDWARE_CHECKLIST': checklist,
|
||||
'MANUAL_FIELD_SECTIONS': _manual_onboarding_field_sections(),
|
||||
'MANUAL_DEVICES': _chunk_choice_labels(DEVICE_CHOICES),
|
||||
'MANUAL_SOFTWARE': _chunk_choice_labels(SOFTWARE_CHOICES),
|
||||
'MANUAL_ACCESSES': _chunk_choice_labels(ACCESS_CHOICES),
|
||||
'MANUAL_WORKSPACE_GROUPS': _chunk_choice_labels(WORKSPACE_GROUP_CHOICES),
|
||||
'MANUAL_RESOURCES': _chunk_choice_labels(RESOURCE_CHOICES),
|
||||
'MANUAL_EXTRA_HARDWARE': _chunk_choice_labels(HARDWARE_EXTRA_CHOICES),
|
||||
'MANUAL_EXTRA_SOFTWARE': _chunk_choice_labels(SOFTWARE_EXTRA_CHOICES),
|
||||
}
|
||||
|
||||
html = _render_html(template_path, context)
|
||||
|
||||
Reference in New Issue
Block a user