mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Add preferences dormitory choice on displayed room states
This commit is contained in:
parent
6235bcbe53
commit
7c9db55d79
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 topologie.models import Dormitory
|
||||||
|
|
||||||
|
from .preferences.models import MultiopOption
|
||||||
|
|
||||||
class DormitoryForm(FormRevMixin, Form):
|
class DormitoryForm(FormRevMixin, Form):
|
||||||
"""Form used to select dormitories."""
|
"""Form used to select dormitories."""
|
||||||
|
|
||||||
dormitory = forms.ModelMultipleChoiceField(
|
dormitory = forms.ModelMultipleChoiceField(
|
||||||
queryset=Dormitory.objects.all(),
|
queryset=MultiopOption.get_cached_value("enabled_dorm").all(),
|
||||||
label=_("Dormitory"),
|
label=_("Dormitory"),
|
||||||
widget=forms.CheckboxSelectMultiple,
|
widget=forms.CheckboxSelectMultiple,
|
||||||
required=False,
|
required=False,
|
||||||
|
|
|
@ -58,9 +58,9 @@ def display_rooms_connection(request, dormitory=None):
|
||||||
dormitory: Dormitory, the dormitory used to filter rooms. If no
|
dormitory: Dormitory, the dormitory used to filter rooms. If no
|
||||||
dormitory is given, all rooms are displayed (default: None).
|
dormitory is given, all rooms are displayed (default: None).
|
||||||
"""
|
"""
|
||||||
room_list = Room.objects.select_related("building__dormitory").order_by(
|
room_list = Room.objects.select_related("building__dormitory").filter(
|
||||||
"building_dormitory", "port"
|
building__dormitory__in=MultiopOption.get_cached_value("enabled_dorm").all()
|
||||||
)
|
).order_by("building_dormitory", "port")
|
||||||
if dormitory:
|
if dormitory:
|
||||||
room_list = room_list.filter(building__dormitory=dormitory)
|
room_list = room_list.filter(building__dormitory=dormitory)
|
||||||
room_list = SortTable.sort(
|
room_list = SortTable.sort(
|
||||||
|
@ -113,6 +113,7 @@ def aff_pending_connection(request):
|
||||||
Room.objects.select_related("building__dormitory")
|
Room.objects.select_related("building__dormitory")
|
||||||
.filter(port__isnull=True)
|
.filter(port__isnull=True)
|
||||||
.filter(adherent__in=all_has_access())
|
.filter(adherent__in=all_has_access())
|
||||||
|
.filter(building__dormitory__in=MultiopOption.get_cached_value("enabled_dorm").all())
|
||||||
.order_by("building_dormitory", "port")
|
.order_by("building_dormitory", "port")
|
||||||
)
|
)
|
||||||
dormitory_form = DormitoryForm(request.POST or None)
|
dormitory_form = DormitoryForm(request.POST or None)
|
||||||
|
@ -150,6 +151,7 @@ def aff_pending_disconnection(request):
|
||||||
Room.objects.select_related("building__dormitory")
|
Room.objects.select_related("building__dormitory")
|
||||||
.filter(port__isnull=False)
|
.filter(port__isnull=False)
|
||||||
.exclude(Q(adherent__in=all_has_access()) | Q(adherent__in=all_adherent()))
|
.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")
|
.order_by("building_dormitory", "port")
|
||||||
)
|
)
|
||||||
dormitory_form = DormitoryForm(request.POST or None)
|
dormitory_form = DormitoryForm(request.POST or None)
|
||||||
|
|
Loading…
Reference in a new issue