Completed
Push — master ( 45f0c4...1295f2 )
by Vijay
9s
created

validate_assignme_action()   A

Complexity

Conditions 4

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
dl 0
loc 18
rs 9.2
c 0
b 0
f 0
1
# from wye.base.constants import WorkshopStatus
2
3
4
# # def validate_action_param(action_map):
5
# #     print("validate_action_param")
6
# #     def wrapper(func):
7
# #         def inner(self, user, **kwargs):
8
# #             response = {'status': False, 'msg': ''}
9
# #             pk = kwargs.get('pk')
10
# #             action = kwargs.get('action')
11
12
# #             # validate parameters
13
# #             if not (pk and action):
14
# #                 response['msg'] = 'Invalid request.'
15
# #                 return response
16
# #             # validate action
17
# #             if action not in action_map:
18
# #                 response['msg'] = 'Action not allowed.'
19
# #                 return response
20
# #             return func(self, user, **kwargs)
21
# #         return inner
22
# #     return wrapper
23
24
25
# def validate_assignme_action(func):
26
#     def inner(self, user, **kwargs):
27
#         # if workshop completed don't accept
28
#         # presenter.
29
#         if self.status == WorkshopStatus.HOLD:
30
#             return {
31
#                 'status': False,
32
#                 'msg': 'Not accepting presenter as \
33
#                 workshop is on hold.'
34
#             }
35
#         elif self.status == WorkshopStatus.COMPLETED:
36
#             return {
37
#                 'status': False,
38
#                 'msg': 'Sorry, but it would seem that this \
39
#                 workshop is already completed and hence \
40
#                 won\'t be able to accept a presenter.'}
41
#         return func(self, user, **kwargs)
42
#     return inner
43