Passed
Pull Request — master (#259)
by Piotr
01:33
created

OptionalSlashRouter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 4
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 3 1
1
from django.conf.urls import include, url
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
introduced by
Unable to import 'django.conf.urls'
Loading history...
2
from django.contrib.auth import get_user_model
0 ignored issues
show
introduced by
Unable to import 'django.contrib.auth'
Loading history...
3
4
from rest_framework.routers import DefaultRouter, Route
0 ignored issues
show
introduced by
Unable to import 'rest_framework.routers'
Loading history...
5
6
from djoser import views
7
8
User = get_user_model()
0 ignored issues
show
Coding Style Naming introduced by
The name User does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
9
10
11
class OptionalSlashRouter(DefaultRouter):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
12
    def __init__(self):
13
        super(OptionalSlashRouter, self).__init__()
14
        self.trailing_slash = '/?'
15
16
17
router = OptionalSlashRouter()
0 ignored issues
show
Coding Style Naming introduced by
The name router does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
18
router.routes.append(Route(
19
    url=r'^user{trailing_slash}$',
20
    mapping={
21
        'delete': 'remove',
22
        'get': 'me',
23
        'put': 'update',
24
    },
25
    name='{basename}-instance',
26
    initkwargs={'suffix': 'Instance'}
27
))
28
router.register(
29
    r'^user/{}'.format(User.USERNAME_FIELD),
30
    views.UsernameUpdateViewSet,
31
    base_name='username-update',
32
)
33
router.register(
34
    r'^user/password',
35
    views.PasswordUpdateViewSet,
36
    base_name='password-update',
37
)
38
router.register(
39
    r'^password/reset',
40
    views.PasswordResetViewSet,
41
    base_name='password-reset',
42
)
43
router.register(
44
    r'^password/reset/confirm',
45
    views.PasswordResetConfirmViewSet,
46
    base_name='password-reset-confirm',
47
)
48
router.register(
49
    r'^user',
50
    views.UserViewSet,
51
    base_name='user',
52
)
53
router.register(
54
    r'^users',
55
    views.UsersViewSet,
56
    base_name='users'
57
)
58
router.register(
59
    r'^users/activate',
60
    views.UserActivateViewSet,
61
    base_name='user-activate',
62
)
63
64
urlpatterns = [
0 ignored issues
show
Coding Style Naming introduced by
The name urlpatterns does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
65
    url(r'^', include(router.urls)),
66
]
67