Completed
Pull Request — master (#227)
by Piotr
03:43
created

ActivationEmail   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 100 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A set_context_data() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
from django.contrib.auth.tokens import default_token_generator
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.contrib.auth.tokens'
Loading history...
2
3
from templated_mail.mail import BaseEmailMessage
0 ignored issues
show
introduced by
Unable to import 'templated_mail.mail'
Loading history...
4
5
from djoser import utils
6
from djoser.conf import settings
7
8
9 View Code Duplication
class ActivationEmail(BaseEmailMessage):
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...
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10
    template_name = 'email/activation.html'
11
12
    def set_context_data(self):
0 ignored issues
show
Coding Style introduced by
This method 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...
13
        super(ActivationEmail, self).set_context_data()
14
15
        user = self.context.get('user')
16
        self.context['uid'] = utils.encode_uid(user.pk)
17
        self.context['token'] = default_token_generator.make_token(user)
18
        self.context['url'] = settings.ACTIVATION_URL.format(**self.context)
19
20
21
class ConfirmationEmail(BaseEmailMessage):
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...
22
    template_name = 'email/confirmation.html'
23
24
25 View Code Duplication
class PasswordResetEmail(BaseEmailMessage):
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...
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
26
    template_name = 'email/password_reset.html'
27
28
    def set_context_data(self):
0 ignored issues
show
Coding Style introduced by
This method 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...
29
        super(PasswordResetEmail, self).set_context_data()
30
31
        user = self.context.get('user')
32
        self.context['uid'] = utils.encode_uid(user.pk)
33
        self.context['token'] = default_token_generator.make_token(user)
34
        self.context['url'] = settings.ACTIVATION_URL.format(**self.context)
35