mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-04 17:06:27 +00:00
Add some docstrings in multi_op/
This commit is contained in:
parent
b66a9230a0
commit
e52705edc3
4 changed files with 37 additions and 9 deletions
|
@ -36,7 +36,7 @@ from topologie.models import Dormitory
|
||||||
|
|
||||||
|
|
||||||
class DormitoryForm(FormRevMixin, Form):
|
class DormitoryForm(FormRevMixin, Form):
|
||||||
"""Select a dorm"""
|
"""Form used to select dormitories."""
|
||||||
|
|
||||||
dormitory = forms.ModelMultipleChoiceField(
|
dormitory = forms.ModelMultipleChoiceField(
|
||||||
queryset=Dormitory.objects.all(),
|
queryset=Dormitory.objects.all(),
|
||||||
|
|
|
@ -34,7 +34,7 @@ from .models import Preferences
|
||||||
|
|
||||||
|
|
||||||
class EditPreferencesForm(ModelForm):
|
class EditPreferencesForm(ModelForm):
|
||||||
""" Edit the ticket's settings"""
|
"""Form used to edit the settings of multi_op."""
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Preferences
|
model = Preferences
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
"""
|
"""
|
||||||
Fichier définissant les administration des models de preference
|
multi_op preferences model. The settings are used when managing dormitories
|
||||||
|
with multiple operators.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class Preferences(models.Model):
|
class Preferences(models.Model):
|
||||||
""" Definition of the app settings"""
|
"""Definition of the settings of multi_op."""
|
||||||
|
|
||||||
enabled_dorm = models.ManyToManyField(
|
enabled_dorm = models.ManyToManyField(
|
||||||
"topologie.Dormitory",
|
"topologie.Dormitory",
|
||||||
|
|
|
@ -53,7 +53,13 @@ from .preferences.forms import EditPreferencesForm
|
||||||
|
|
||||||
|
|
||||||
def display_rooms_connection(request, dormitory=None):
|
def display_rooms_connection(request, dormitory=None):
|
||||||
"""View to display global state of connection state"""
|
"""View used to display an overview of the rooms' connection state.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request: django request.
|
||||||
|
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(
|
room_list = Room.objects.select_related("building__dormitory").order_by(
|
||||||
"building_dormitory", "port"
|
"building_dormitory", "port"
|
||||||
)
|
)
|
||||||
|
@ -81,19 +87,30 @@ def display_rooms_connection(request, dormitory=None):
|
||||||
@login_required
|
@login_required
|
||||||
@can_view_all(Room)
|
@can_view_all(Room)
|
||||||
def aff_state_global(request):
|
def aff_state_global(request):
|
||||||
|
"""View used to display the connection state of all rooms."""
|
||||||
return display_rooms_connection(request)
|
return display_rooms_connection(request)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_view(Dormitory)
|
@can_view(Dormitory)
|
||||||
def aff_state_dormitory(request, dormitory, dormitoryid):
|
def aff_state_dormitory(request, dormitory, dormitoryid):
|
||||||
|
"""View used to display the connection state of the rooms in the given
|
||||||
|
dormitory.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request: django request.
|
||||||
|
dormitory: Dormitory, the dormitory used to filter rooms.
|
||||||
|
dormitoryid: int, the id of the dormitory.
|
||||||
|
"""
|
||||||
return display_rooms_connection(dormitory=dormitory)
|
return display_rooms_connection(dormitory=dormitory)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_view_all(Room)
|
@can_view_all(Room)
|
||||||
def aff_pending_connection(request):
|
def aff_pending_connection(request):
|
||||||
"""Aff pending Rooms to connect on our network"""
|
"""View used to display rooms pending connection to the organisation's
|
||||||
|
network.
|
||||||
|
"""
|
||||||
room_list = (
|
room_list = (
|
||||||
Room.objects.select_related("building__dormitory")
|
Room.objects.select_related("building__dormitory")
|
||||||
.filter(port__isnull=True)
|
.filter(port__isnull=True)
|
||||||
|
@ -128,7 +145,9 @@ def aff_pending_connection(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_view_all(Room)
|
@can_view_all(Room)
|
||||||
def aff_pending_disconnection(request):
|
def aff_pending_disconnection(request):
|
||||||
"""Aff pending Rooms to disconnect from our network"""
|
"""View used to display rooms pending disconnection from the organisation's
|
||||||
|
network.
|
||||||
|
"""
|
||||||
room_list = (
|
room_list = (
|
||||||
Room.objects.select_related("building__dormitory")
|
Room.objects.select_related("building__dormitory")
|
||||||
.filter(port__isnull=False)
|
.filter(port__isnull=False)
|
||||||
|
@ -163,7 +182,13 @@ def aff_pending_disconnection(request):
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Room)
|
@can_edit(Room)
|
||||||
def disconnect_room(request, room, roomid):
|
def disconnect_room(request, room, roomid):
|
||||||
"""Action of disconnecting a room"""
|
"""View used to disconnect a room.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request: django request.
|
||||||
|
room: Room, the room to be disconnected.
|
||||||
|
roomid: int, the id of the room.
|
||||||
|
"""
|
||||||
room.port_set.clear()
|
room.port_set.clear()
|
||||||
room.save()
|
room.save()
|
||||||
messages.success(request, _("The room %s was disconnected.") % room)
|
messages.success(request, _("The room %s was disconnected.") % room)
|
||||||
|
@ -171,5 +196,7 @@ def disconnect_room(request, room, roomid):
|
||||||
|
|
||||||
|
|
||||||
def navbar_user():
|
def navbar_user():
|
||||||
"""View to display the app in user's dropdown in the navbar"""
|
"""View used to display a link to manage operators in the navbar (in the
|
||||||
|
dropdown menu Topology).
|
||||||
|
"""
|
||||||
return ("topologie", render_to_string("multi_op/navbar.html"))
|
return ("topologie", render_to_string("multi_op/navbar.html"))
|
||||||
|
|
Loading…
Reference in a new issue