Passed
Push — master ( 430569...2d5fe0 )
by Swen
02:14
created

LocalizedFieldsAdminMixin.__init__()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
1
from django.contrib.admin import ModelAdmin
0 ignored issues
show
Configuration introduced by
The import django.contrib.admin could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
2
3
from . import widgets
4
from .fields import LocalizedField
5
6
7
FORMFIELD_FOR_LOCALIZED_FIELDS_DEFAULTS = {
8
    LocalizedField: {'widget': widgets.AdminLocalizedFieldWidget},
9
}
10
11
12
class LocalizedFieldsAdminMixin(ModelAdmin):
13
    """Mixin for making the fancy widgets work in Django Admin."""
14
15
    class Media:
16
        css = {
17
            'all': (
18
                'localized_fields/localized-fields-admin.css',
19
            )
20
        }
21
22
        js = (
23
            'localized_fields/localized-fields-admin.js',
24
        )
25
26
    def __init__(self, *args, **kwargs):
27
        """Initializes a new instance of :see:LocalizedFieldsAdminMixin."""
28
29
        super(LocalizedFieldsAdminMixin, self).__init__(*args, **kwargs)
30
        overrides = FORMFIELD_FOR_LOCALIZED_FIELDS_DEFAULTS.copy()
31
        overrides.update(self.formfield_overrides)
0 ignored issues
show
Bug introduced by
The member formfield_overrides does not seem to be defined here; its definition is on line 32.
Loading history...
32
        self.formfield_overrides = overrides
33