mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-30 08:32:26 +00:00
Add preferences dormitory choice on displayed room states
This commit is contained in:
parent
9eca19e176
commit
2d4c94243b
2 changed files with 7 additions and 4 deletions
|
@ -34,12 +34,13 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
from topologie.models import Dormitory
|
||||
|
||||
from .preferences.models import MultiopOption
|
||||
|
||||
class DormitoryForm(FormRevMixin, Form):
|
||||
"""Form used to select dormitories."""
|
||||
|
||||
dormitory = forms.ModelMultipleChoiceField(
|
||||
queryset=Dormitory.objects.all(),
|
||||
queryset=MultiopOption.get_cached_value("enabled_dorm").all(),
|
||||
label=_("Dormitory"),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False,
|
||||
|
|
|
@ -58,9 +58,9 @@ def display_rooms_connection(request, dormitory=None):
|
|||
dormitory: Dormitory, the dormitory used to filter rooms. If no
|
||||
dormitory is given, all rooms are displayed (default: None).
|
||||
"""
|
||||
room_list = Room.objects.select_related("building__dormitory").order_by(
|
||||
"building_dormitory", "port"
|
||||
)
|
||||
room_list = Room.objects.select_related("building__dormitory").filter(
|
||||
building__dormitory__in=MultiopOption.get_cached_value("enabled_dorm").all()
|
||||
).order_by("building_dormitory", "port")
|
||||
if dormitory:
|
||||
room_list = room_list.filter(building__dormitory=dormitory)
|
||||
room_list = SortTable.sort(
|
||||
|
@ -113,6 +113,7 @@ def aff_pending_connection(request):
|
|||
Room.objects.select_related("building__dormitory")
|
||||
.filter(port__isnull=True)
|
||||
.filter(adherent__in=all_has_access())
|
||||
.filter(building__dormitory__in=MultiopOption.get_cached_value("enabled_dorm").all())
|
||||
.order_by("building_dormitory", "port")
|
||||
)
|
||||
dormitory_form = DormitoryForm(request.POST or None)
|
||||
|
@ -150,6 +151,7 @@ def aff_pending_disconnection(request):
|
|||
Room.objects.select_related("building__dormitory")
|
||||
.filter(port__isnull=False)
|
||||
.exclude(Q(adherent__in=all_has_access()) | Q(adherent__in=all_adherent()))
|
||||
.filter(building__dormitory__in=MultiopOption.get_cached_value("enabled_dorm").all())
|
||||
.order_by("building_dormitory", "port")
|
||||
)
|
||||
dormitory_form = DormitoryForm(request.POST or None)
|
||||
|
|
Loading…
Reference in a new issue