Passed
Pull Request — master (#15)
by
unknown
02:34
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, LocalizedCharField, LocalizedTextField, \
5
    LocalizedFileField
6
7
8
9
FORMFIELD_FOR_LOCALIZED_FIELDS_DEFAULTS = {
10
    LocalizedField: {'widget': widgets.AdminLocalizedFieldWidget},
11
    LocalizedCharField: {'widget': widgets.AdminLocalizedCharFieldWidget},
12
    LocalizedTextField: {'widget': widgets.AdminLocalizedFieldWidget},
13
    LocalizedFileField: {'widget': widgets.AdminLocalizedFileFieldWidget},
14
}
15
16
17
class LocalizedFieldsAdminMixin(ModelAdmin):
18
    """Mixin for making the fancy widgets work in Django Admin."""
19
20
    class Media:
21
        css = {
22
            'all': (
23
                'localized_fields/localized-fields-admin.css',
24
            )
25
        }
26
27
        js = (
28
            'localized_fields/localized-fields-admin.js',
29
        )
30
31
    def __init__(self, *args, **kwargs):
32
        """Initializes a new instance of :see:LocalizedFieldsAdminMixin."""
33
34
        super(LocalizedFieldsAdminMixin, self).__init__(*args, **kwargs)
35
        overrides = FORMFIELD_FOR_LOCALIZED_FIELDS_DEFAULTS.copy()
36
        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 37.
Loading history...
37
        self.formfield_overrides = overrides
38