From 3b61c46ea4ba7d5c86ab3130b4ab3bb380669214 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 20 Oct 2026 07:18:57 +0200 Subject: [PATCH] Refactor code structure for improved readability and maintainability; remove redundant code blocks and optimize function calls. --- app/anydesk/frontend/sessions.html | 17 +- app/contacts/frontend/contact_detail.html | 156 +++- app/core/case_visibility.py | 199 +++++ app/dashboard/backend/router.py | 10 +- app/economy/frontend/also_cloud.html | 54 +- app/jobs/check_reminders.py | 2 + app/models/schemas.py | 7 +- app/modules/also/backend/billing.py | 96 +++ app/modules/also/backend/service.py | 34 +- app/modules/bottom_bar/backend/service.py | 5 +- app/modules/calendar/backend/router.py | 61 +- app/modules/hardware/backend/intake.py | 284 +++++++ app/modules/hardware/backend/inventory.py | 127 ++++ app/modules/hardware/backend/router.py | 37 +- app/modules/hardware/frontend/views.py | 16 +- app/modules/hardware/templates/create.html | 88 ++- app/modules/hardware/templates/detail.html | 168 +++- app/modules/hardware/templates/edit.html | 17 +- app/modules/hardware/templates/index.html | 24 +- .../hardware/templates/inventory_specs.html | 53 ++ app/modules/orders/backend/router.py | 30 +- app/modules/orders/templates/detail.html | 6 +- app/modules/planner/backend/calendar.py | 583 ++++++++++++++ app/modules/planner/backend/capacity.py | 151 ++++ app/modules/planner/backend/checks.py | 37 + app/modules/planner/backend/configuration.py | 136 ++++ app/modules/planner/backend/router.py | 100 ++- app/modules/planner/backend/work.py | 534 +++++++++++++ app/modules/planner/frontend/views.py | 18 +- app/modules/planner/templates/absence.html | 15 + app/modules/planner/templates/index.html | 20 +- app/modules/planner/templates/work.html | 122 +++ app/modules/rentals/backend/router.py | 34 +- app/modules/sag/backend/router.py | 41 +- app/modules/sag/backend/visibility.py | 86 +++ app/modules/sag/frontend/views.py | 12 + app/modules/sag/templates/detail_v4.html | 214 +++++- app/modules/sag/templates/detail_v5.html | 6 +- app/products/backend/economic_pricing.py | 2 +- app/routers/anydesk.py | 31 +- app/services/anydesk.py | 4 + app/services/anydesk_links.py | 145 ++++ app/services/reminder_notification_service.py | 8 + app/shared/frontend/base.html | 10 +- app/subscriptions/backend/router.py | 40 +- docs/UNIFIED_PLANNING.md | 107 +++ fremtidige planer/README.md | 1 + ...so-cloud-marketplace-periodefakturering.md | 279 +++++++ main.py | 13 +- migrations/1070_unified_planning.sql | 166 ++++ migrations/1071_case_confidentiality.sql | 24 + migrations/1072_absence_reports.sql | 8 + migrations/249_anydesk_machine_links.sql | 10 + migrations/250_bmc_asset_category.sql | 5 + migrations/251_hardware_intake.sql | 11 + static/css/case-v5.css | 26 +- static/css/planning-dates.css | 19 + static/js/absence-report.js | 51 ++ static/js/case-planning-summary.js | 20 + static/js/case-privacy.js | 23 + static/js/case-slot-resize.js | 83 ++ static/js/case-v5.js | 83 +- static/js/case-week-calendar.js | 59 ++ static/js/hardware-intake.js | 197 +++++ static/js/planner.js | 17 +- static/js/planning-dates.js | 52 ++ static/js/planning-work.js | 412 ++++++++++ static/vendor/flatpickr/LICENSE.md | 21 + static/vendor/flatpickr/da.js | 71 ++ static/vendor/flatpickr/flatpickr.min.css | 13 + static/vendor/flatpickr/flatpickr.min.js | 2 + tests/js/case-slot-resize.test.cjs | 63 ++ tests/js/case-week-calendar.test.cjs | 42 + tests/test_absence_report_ui.js | 43 ++ tests/test_also_period_billing.py | 178 +++++ tests/test_anydesk_machine_links.py | 146 ++++ tests/test_anydesk_session_history.py | 81 ++ tests/test_bmc_asset_category.py | 79 ++ tests/test_contact_hardware_scope.py | 26 + tests/test_hardware_intake.py | 192 +++++ tests/test_hardware_intake_ui.js | 70 ++ tests/test_hardware_inventory.py | 116 +++ tests/test_planner_absence_ui.js | 33 + tests/test_planning_dates_ui.js | 23 + tests/test_planning_drag_ui.js | 111 +++ tests/test_quick_rent_case_picker.py | 28 + tests/test_quick_rent_case_picker_ui.js | 39 + tests/test_quick_rent_monthly.py | 31 + tests/test_subscription_change_creation.py | 37 + tests/test_subscription_direct_save.py | 35 + tests/test_subscription_simple_change.js | 30 + tests/test_subscription_tab_count.js | 19 + tests/test_unified_planning.py | 717 ++++++++++++++++++ 93 files changed, 7523 insertions(+), 229 deletions(-) create mode 100644 app/core/case_visibility.py create mode 100644 app/modules/also/backend/billing.py create mode 100644 app/modules/hardware/backend/intake.py create mode 100644 app/modules/hardware/backend/inventory.py create mode 100644 app/modules/hardware/templates/inventory_specs.html create mode 100644 app/modules/planner/backend/calendar.py create mode 100644 app/modules/planner/backend/capacity.py create mode 100644 app/modules/planner/backend/checks.py create mode 100644 app/modules/planner/backend/configuration.py create mode 100644 app/modules/planner/backend/work.py create mode 100644 app/modules/planner/templates/absence.html create mode 100644 app/modules/planner/templates/work.html create mode 100644 app/modules/sag/backend/visibility.py create mode 100644 app/services/anydesk_links.py create mode 100644 docs/UNIFIED_PLANNING.md create mode 100644 fremtidige planer/also-cloud-marketplace-periodefakturering.md create mode 100644 migrations/1070_unified_planning.sql create mode 100644 migrations/1071_case_confidentiality.sql create mode 100644 migrations/1072_absence_reports.sql create mode 100644 migrations/249_anydesk_machine_links.sql create mode 100644 migrations/250_bmc_asset_category.sql create mode 100644 migrations/251_hardware_intake.sql create mode 100644 static/css/planning-dates.css create mode 100644 static/js/absence-report.js create mode 100644 static/js/case-planning-summary.js create mode 100644 static/js/case-privacy.js create mode 100644 static/js/case-slot-resize.js create mode 100644 static/js/case-week-calendar.js create mode 100644 static/js/hardware-intake.js create mode 100644 static/js/planning-dates.js create mode 100644 static/js/planning-work.js create mode 100644 static/vendor/flatpickr/LICENSE.md create mode 100644 static/vendor/flatpickr/da.js create mode 100644 static/vendor/flatpickr/flatpickr.min.css create mode 100644 static/vendor/flatpickr/flatpickr.min.js create mode 100644 tests/js/case-slot-resize.test.cjs create mode 100644 tests/js/case-week-calendar.test.cjs create mode 100644 tests/test_absence_report_ui.js create mode 100644 tests/test_also_period_billing.py create mode 100644 tests/test_anydesk_machine_links.py create mode 100644 tests/test_anydesk_session_history.py create mode 100644 tests/test_bmc_asset_category.py create mode 100644 tests/test_contact_hardware_scope.py create mode 100644 tests/test_hardware_intake.py create mode 100644 tests/test_hardware_intake_ui.js create mode 100644 tests/test_hardware_inventory.py create mode 100644 tests/test_planner_absence_ui.js create mode 100644 tests/test_planning_dates_ui.js create mode 100644 tests/test_planning_drag_ui.js create mode 100644 tests/test_quick_rent_case_picker.py create mode 100644 tests/test_quick_rent_case_picker_ui.js create mode 100644 tests/test_quick_rent_monthly.py create mode 100644 tests/test_subscription_change_creation.py create mode 100644 tests/test_subscription_direct_save.py create mode 100644 tests/test_subscription_simple_change.js create mode 100644 tests/test_subscription_tab_count.js create mode 100644 tests/test_unified_planning.py diff --git a/app/anydesk/frontend/sessions.html b/app/anydesk/frontend/sessions.html index bc4c9ce..6d37094 100644 --- a/app/anydesk/frontend/sessions.html +++ b/app/anydesk/frontend/sessions.html @@ -477,6 +477,7 @@ +
AnyDesk-ID gemmes på kontaktpersonens hardware. Findes maskinen ikke, oprettes en PC under firmaet. Koblingen bruges også på tidligere uregistrerede sessioner. Sag og noter gælder kun denne session.
@@ -718,8 +719,8 @@ async function loadHardware() { async function loadCustomers() { try { - const data = await api('/api/v1/customers/?limit=500'); - customerList = data.customers || data || []; + const data = await api('/api/v1/customers/?limit=500&is_active=true'); + customerList = (data.customers || data || []).filter(customer => customer.is_active === true); } catch(e) { /* silent */ } } @@ -1036,8 +1037,8 @@ async function loadContactsForCustomer(customerId, selectedId) { sel.innerHTML = ''; try { const url = customerId - ? `/api/v1/contacts/?customer_id=${customerId}&limit=300` - : '/api/v1/contacts/?limit=300'; + ? `/api/v1/contacts/?customer_id=${customerId}&limit=100&is_active=true` + : '/api/v1/contacts/?limit=100&is_active=true'; const data = await api(url); currentContactList = data.contacts || data || []; filterContactOptions(); @@ -1138,13 +1139,17 @@ async function saveRegModal() { const params = new URLSearchParams(); if (hw) params.append('hardware_asset_id', hw); if (cust) params.append('customer_id', cust); + if (cust) params.append('remember_machine_link', 'true'); if (contact) params.append('contact_id', contact); if (sag) params.append('sag_id', sag); if (notes) params.append('notes', notes); try { - await api(`/api/v1/anydesk/sessions/${id}/link?${params}`, { method: 'PATCH' }); - toast('✅ Session registreret', 'success'); + const result = await api(`/api/v1/anydesk/sessions/${id}/link?${params}`, { method: 'PATCH' }); + toast(result.remembered + ? `✅ AnyDesk-ID gemt på hardware · ${result.linked_sessions || 0} andre sessioner opdateret` + : '✅ Session registreret', 'success'); + if (result.remembered) await loadHardware(); document.getElementById('drawer-backdrop').classList.remove('open'); document.getElementById('session-drawer').classList.remove('open'); await loadSessions(); diff --git a/app/contacts/frontend/contact_detail.html b/app/contacts/frontend/contact_detail.html index cc2ab5c..f892e20 100644 --- a/app/contacts/frontend/contact_detail.html +++ b/app/contacts/frontend/contact_detail.html @@ -878,6 +878,24 @@ + +