Skip to content
Snippets Groups Projects
Commit 56b55712 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when editing/adding appointment only locations and workers assigned to worker...

when editing/adding appointment only locations and workers assigned to worker location are visible, workers are sorted alphabitecally,
parent 54adf8d6
No related branches found
No related tags found
1 merge request!55Resolve "worker list should be in alphabetic order"
Pipeline #
......@@ -8,6 +8,7 @@ from django.utils.dates import MONTHS
from models import Subject, Worker, Appointment, Visit, AppointmentType, ContactAttempt, AppointmentTypeLink, \
Availability, Holiday
from models.constants import SUBJECT_TYPE_CHOICES, SCREENING_NUMBER_PREFIXES_FOR_TYPE
from views.notifications import get_filter_locations
"""
Possible redundancy, but if need arises, contents of forms can be easily customized
......@@ -227,6 +228,9 @@ class AppointmentEditForm(ModelForm):
queryset=AppointmentType.objects.all(),
initial=initial_appointment_types)
self.fields = fields
self.fields['worker_assigned'].queryset = Worker.objects.filter(
locations__in=get_filter_locations(self.user)).distinct().order_by('first_name', 'last_name')
self.fields['location'].queryset = get_filter_locations(self.user)
def clean_location(self):
location = self.cleaned_data['location']
......@@ -273,6 +277,9 @@ class AppointmentAddForm(ModelForm):
queryset=AppointmentType.objects.all(),
)
self.fields = fields
self.fields['worker_assigned'].queryset = Worker.objects.filter(
locations__in=get_filter_locations(self.user)).distinct().order_by('first_name', 'last_name')
self.fields['location'].queryset = get_filter_locations(self.user)
def clean_location(self):
location = self.cleaned_data['location']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment