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

activation_email()   A

Complexity

Conditions 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
1
from djoser import utils
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...
2
from djoser.conf import settings
3
4
5
def activation_email(request, user, **kwargs):
6
    """
7
    Side effect of updating is_active field to False
8
    """
9
    user_email = utils.get_user_email(user)
10
    assert user_email is not None
11
    to = [user_email]
0 ignored issues
show
Coding Style Naming introduced by
The name to does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[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...
12
    context = {'user': user}
13
    context.update(kwargs)
14
    settings.EMAIL.activation(request, context).send(to)
15
16
    user.is_active = False
17
    user.save(update_fields=['is_active'])
18
19
20
def confirmation_email(request, user, **kwargs):
0 ignored issues
show
Coding Style introduced by
This function 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...
21
    user_email = utils.get_user_email(user)
22
    assert user_email is not None
23
    to = [user_email]
0 ignored issues
show
Coding Style Naming introduced by
The name to does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[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...
24
    context = {'user': user}
25
    context.update(kwargs)
26
    settings.EMAIL.confirmation(request, context).send(to)
27