Skip to content

Commit a923f2c

Browse files
committed
Merge branch 'automate-mccabe-check' of github.com:WiSchLabs/ofm_helper into automate-mccabe-check
2 parents b523e00 + 5e5825d commit a923f2c

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

core/views/checklist_views.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from braces.views import CsrfExemptMixin, JsonRequestResponseMixin
1+
from braces.views import JSONResponseMixin
22
from django.contrib.auth.decorators import login_required
33
from django.utils.decorators import method_decorator
44
from django.views import View
@@ -7,7 +7,7 @@
77

88

99
@method_decorator(login_required, name='dispatch')
10-
class GetChecklistItemsView(CsrfExemptMixin, JsonRequestResponseMixin, View):
10+
class GetChecklistItemsView(JSONResponseMixin, View):
1111
def get(self, request, *args, **kwargs):
1212
checklist_items = ChecklistItem.objects.filter(checklist__user=request.user)
1313

@@ -17,7 +17,7 @@ def get(self, request, *args, **kwargs):
1717

1818

1919
@method_decorator(login_required, name='dispatch')
20-
class GetChecklistItemsForTodayView(CsrfExemptMixin, JsonRequestResponseMixin, View):
20+
class GetChecklistItemsForTodayView(JSONResponseMixin, View):
2121
def get(self, request, *args, **kwargs):
2222
current_matchday = Matchday.get_current()
2323
home_match_tomorrow = Match.objects.filter(
@@ -66,23 +66,8 @@ def get(self, request, *args, **kwargs):
6666
return self.render_json_response(checklist_items_json)
6767

6868

69-
def _get_checklist_item_in_json(checklist_item):
70-
checklist_item_json = dict()
71-
checklist_item_json['id'] = checklist_item.id
72-
checklist_item_json['name'] = checklist_item.name
73-
if checklist_item.to_be_checked_if_home_match_tomorrow:
74-
checklist_item_json['type_home_match'] = checklist_item.to_be_checked_if_home_match_tomorrow
75-
if checklist_item.to_be_checked_on_matchdays is not None:
76-
checklist_item_json['type_matchdays'] = checklist_item.to_be_checked_on_matchdays
77-
if checklist_item.to_be_checked_on_matchday_pattern is not None:
78-
checklist_item_json['type_matchday_pattern'] = checklist_item.to_be_checked_on_matchday_pattern
79-
checklist_item_json['checked'] = checklist_item.last_checked_on_matchday == Matchday.get_current()
80-
81-
return checklist_item_json
82-
83-
8469
@method_decorator(login_required, name='dispatch')
85-
class CreateChecklistItemView(CsrfExemptMixin, JsonRequestResponseMixin, View):
70+
class CreateChecklistItemView(JSONResponseMixin, View):
8671
def get(self, request, *args, **kwargs):
8772
checklist, _ = Checklist.objects.get_or_create(user=request.user)
8873
new_checklist_item = ChecklistItem.objects.create(checklist=checklist, name='Neuer Eintrag')
@@ -93,7 +78,7 @@ def get(self, request, *args, **kwargs):
9378

9479

9580
@method_decorator(login_required, name='dispatch')
96-
class UpdateChecklistPriorityView(CsrfExemptMixin, JsonRequestResponseMixin, View):
81+
class UpdateChecklistPriorityView(JSONResponseMixin, View):
9782
def post(self, request, *args, **kwargs):
9883
checklist_priority = request.POST.get('checklist_priority')
9984

@@ -107,7 +92,7 @@ def post(self, request, *args, **kwargs):
10792

10893

10994
@method_decorator(login_required, name='dispatch')
110-
class UpdateChecklistItemView(CsrfExemptMixin, JsonRequestResponseMixin, View):
95+
class UpdateChecklistItemView(JSONResponseMixin, View):
11196
def post(self, request, *args, **kwargs):
11297
checklist_item_id = request.POST.get('checklist_item_id')
11398
checklist_item_name = request.POST.get('checklist_item_name')
@@ -154,11 +139,26 @@ def _update_checklist_item_condition(checklist_item, checklist_item_matchdays, c
154139

155140

156141
@method_decorator(login_required, name='dispatch')
157-
class DeleteChecklistItemView(CsrfExemptMixin, JsonRequestResponseMixin, View):
142+
class DeleteChecklistItemView(JSONResponseMixin, View):
158143
def post(self, request, *args, **kwargs):
159144
checklist_item_id = request.POST.get('checklist_item_id')
160145
checklist_item = ChecklistItem.objects.get(checklist__user=request.user, id=checklist_item_id)
161146
if checklist_item:
162147
checklist_item.delete()
163148
return self.render_json_response({'success': True})
164149
return self.render_json_response({'success': False})
150+
151+
152+
def _get_checklist_item_in_json(checklist_item):
153+
checklist_item_json = dict()
154+
checklist_item_json['id'] = checklist_item.id
155+
checklist_item_json['name'] = checklist_item.name
156+
if checklist_item.to_be_checked_if_home_match_tomorrow:
157+
checklist_item_json['type_home_match'] = checklist_item.to_be_checked_if_home_match_tomorrow
158+
if checklist_item.to_be_checked_on_matchdays is not None:
159+
checklist_item_json['type_matchdays'] = checklist_item.to_be_checked_on_matchdays
160+
if checklist_item.to_be_checked_on_matchday_pattern is not None:
161+
checklist_item_json['type_matchday_pattern'] = checklist_item.to_be_checked_on_matchday_pattern
162+
checklist_item_json['checked'] = checklist_item.last_checked_on_matchday == Matchday.get_current()
163+
164+
return checklist_item_json

0 commit comments

Comments
 (0)