Completed
Pull Request — master (#51)
by Paolo
06:48
created

common.decorators   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A ajax_required() 0 11 2
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
"""
4
Created on Mon Mar 18 12:21:07 2019
5
6
@author: Paolo Cozzi <[email protected]>
7
"""
8
9
from django.http import HttpResponseBadRequest
10
11
12
def ajax_required(f):
13
    def wrap(request, *args, **kwargs):
14
        if not request.is_ajax():
15
            return HttpResponseBadRequest()
16
17
        return f(request, *args, **kwargs)
18
19
    wrap.__doc__ = f.__doc__
20
    wrap.__name__ = f.__name__
21
22
    return wrap
23