GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PermissionLogic   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 40
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_full_permission_string() 0 11 2
B has_perm() 0 24 1
1
# coding=utf-8
2
3
4
class PermissionLogic(object):
5
    """
6
    Abstract permission logic class
7
    """
8
    def get_full_permission_string(self, perm):
9
        """
10
        Return full permission string (app_label.perm_model)
11
        """
12
        if not getattr(self, 'model', None):
13
            raise AttributeError("You need to use `add_permission_logic` to "
14
                                 "register the instance to the model class "
15
                                 "before calling this method.")
16
        app_label = self.model._meta.app_label
17
        model_name = self.model._meta.object_name.lower()
18
        return "%s.%s_%s" % (app_label, perm, model_name)
19
20
    def has_perm(self, user_obj, perm, obj=None):
21
        """
22
        Check if user have permission (of object)
23
24
        Parameters
25
        ----------
26
        user_obj : django user model instance
27
            A django user model instance which be checked
28
        perm : string
29
            `app_label.codename` formatted permission string
30
        obj : None or django model instance
31
            None or django model instance for object permission
32
33
        Returns
34
        -------
35
        boolean
36
            Whether the specified user have specified permission (of specified
37
            object).
38
39
        .. note::
40
            Sub class must override this method.
41
        """
42
        raise NotImplementedError(
43
                "'%s' does not override `has_perm(user_obj, perm, obj=None)` "
44
                "method. Sub class of `PermissionLogic` must override this "
45
                "method.")
46