pharmacies: вкладки в popup редактирования и точка на карте для координат.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-13 11:16:11 +03:00
parent 045171275e
commit 07b4c69d14
5 changed files with 308 additions and 19 deletions
+44
View File
@@ -469,6 +469,9 @@ class PharmacyCardVisibilityTests(TestCase):
self.assertContains(resp, 'id="pharmacy-edit-modal"')
self.assertContains(resp, 'name="source"')
self.assertContains(resp, 'Сохранить')
self.assertContains(resp, 'data-tab="address"')
self.assertContains(resp, 'id="pharmacy-picker-map"')
self.assertContains(resp, 'pharmacyModalTab')
def test_list_modal_save_returns_list(self):
from apps.locations.models import PharmacyCardVisibility
@@ -512,6 +515,47 @@ class PharmacyCardVisibilityTests(TestCase):
self.assertEqual(self.pharmacy.street, 'Модальна')
self.assertContains(resp, 'id="pharmacy-modal-root"')
def test_list_modal_save_map_coordinates(self):
from apps.locations.models import PharmacyCardVisibility
self._set_level('edit', PharmacyCardVisibility.Level.OWN_OR_STAFF)
self._grant_pharmacies_section(self.own)
self.client.force_login(self.own)
session = self.client.session
session['2fa_verified'] = True
session.save()
resp = self.client.post(
f'/pharmacies/{self.pharmacy.pk}/edit/',
{
'source': 'list',
'organization': self.pharmacy.organization_id,
'pharmacy_number': self.pharmacy.pharmacy_number,
'status': 'open',
'category': 'A',
'vat_category': '',
'working_hours': self.pharmacy.working_hours or '08:00-20:00',
'location_region': self.pharmacy.location_region_id,
'street': self.pharmacy.street or 'Тестова',
'house_number': self.pharmacy.house_number or '1',
'building': '',
'apartment': '',
'location': '46.581955,30.7891',
'phone': '',
'license_number': '',
'license_expiry_date': '',
'head_pharmacist': '',
'responsible_manager': '',
'curator': '',
'pharmacists_count': 2,
'comments': '',
},
HTTP_HX_REQUEST='true',
)
self.assertEqual(resp.status_code, 200)
self.pharmacy.refresh_from_db()
self.assertEqual(self.pharmacy.location, '46.581955,30.7891')
self.assertTrue(self.pharmacy.has_coordinates)
def test_pharmacies_excel_export(self):
self._grant_pharmacies_section(self.staff)
self.client.force_login(self.staff)
+15
View File
@@ -169,6 +169,7 @@ def pharmacy_update_view(request, pk):
pharmacy_modal=pharmacy,
pharmacy_edit_form=form,
pharmacy_form_error=form_error,
pharmacy_modal_tab=_pharmacy_modal_tab(form),
can_edit=True,
))
@@ -180,6 +181,20 @@ def pharmacy_update_view(request, pk):
return render_page(request, 'pharmacy-detail.html', context)
def _pharmacy_modal_tab(form) -> str:
names = set(getattr(form, 'errors', {}) or ())
if names & {
'location', 'street', 'house_number', 'building', 'apartment', 'location_region',
}:
return 'address'
if names & {
'license_number', 'license_expiry_date',
'head_pharmacist', 'responsible_manager', 'curator',
}:
return 'people'
return 'main'
def _pharmacy_for_portal(request, pk):
return get_object_or_404(
accessible_pharmacies(request.user).select_related(