From a188d48c89a348775b51e45e78a8d7bb7470e1c7 Mon Sep 17 00:00:00 2001 From: Joshua Rubingh Date: Wed, 27 May 2020 09:44:51 +0200 Subject: [PATCH] Update documentation --- doc/index.rst | 1 + doc/views.rst | 6 +++++ polyclinic_scheduling/apps/schedule/models.py | 2 ++ polyclinic_scheduling/apps/schedule/urls.py | 2 -- polyclinic_scheduling/apps/schedule/views.py | 26 ++++++++++++++++++- 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 doc/views.rst diff --git a/doc/index.rst b/doc/index.rst index ead6368..dcccd10 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -15,6 +15,7 @@ Here you can read more information about the Poliklinieken Planning Tool. install models + views Indices and tables ================== diff --git a/doc/views.rst b/doc/views.rst new file mode 100644 index 0000000..d23e4e2 --- /dev/null +++ b/doc/views.rst @@ -0,0 +1,6 @@ +====== +Vieuws +====== + +.. automodule:: apps.schedule.views + :members: diff --git a/polyclinic_scheduling/apps/schedule/models.py b/polyclinic_scheduling/apps/schedule/models.py index 16c414b..1a45627 100644 --- a/polyclinic_scheduling/apps/schedule/models.py +++ b/polyclinic_scheduling/apps/schedule/models.py @@ -23,6 +23,8 @@ class Schedule(MetaDataModel): The email address where the results should be sent to. Max length is 100 characters. status : ScheduleStatus The status of the schedule. + planning_source : JSON + The complete schedule stored in JSON data object. """ class Meta: diff --git a/polyclinic_scheduling/apps/schedule/urls.py b/polyclinic_scheduling/apps/schedule/urls.py index 6e7970a..3157ab4 100644 --- a/polyclinic_scheduling/apps/schedule/urls.py +++ b/polyclinic_scheduling/apps/schedule/urls.py @@ -6,7 +6,5 @@ app_name = 'schedule' urlpatterns = [ path('', views.ScheduleListView.as_view(), name='list'), path('new', views.new_or_update_schedule, name='new'), - #path('', views.ScheduleDetailView.as_view(), name='detail'), path('/clone', views.new_or_update_schedule, name='clone'), - ] \ No newline at end of file diff --git a/polyclinic_scheduling/apps/schedule/views.py b/polyclinic_scheduling/apps/schedule/views.py index 563e6f3..848429a 100644 --- a/polyclinic_scheduling/apps/schedule/views.py +++ b/polyclinic_scheduling/apps/schedule/views.py @@ -12,6 +12,13 @@ import json # Create your views here. class ScheduleListView(LoginRequiredMixin,ListView): + """ + This view will give a list of all entered schedules. The list is filtered on the logged in employee. + + Only the schedules owned by the logged in user are shown. + + The results are shown with 10 items per page. A pager will be shown when there are more then 10 schedules + """ model = Schedule paginate_by = 10 @@ -21,12 +28,29 @@ class ScheduleListView(LoginRequiredMixin,ListView): @login_required def new_or_update_schedule(request, schedule_id = None): + """ + This view will create or update an existing schedule. At the moment there is not a real update, but a clone functionality. + So every schedule that is updated will be stored as a new schedule. + + Only schedules owned by the logged in user can be loaded here and can be cloned. + + The data of the form is stored as a JSON object in a single database field for more flexibility. + + Arguments: + request HttpRequest -- This is the HTTP request from the Django framework. This will hold the current logged in user info. + + Keyword Arguments: + schedule_id Schedule -- This is the schedule to be edited. When none, a new schedule will be created (default: {None}) + + Returns: + A view with an empty form to create a new schedule or a prefilled form for cloning. + """ template_name = 'schedule/schedule_new.html' schedule = None if schedule_id is not None: try: - schedule = Schedule.objects.get(pk=schedule_id) + schedule = Schedule.objects.get(pk=schedule_id,employee=request.user.employee) except Schedule.DoesNotExist: pass