saxix / django-adminactions

@@ -250,7 +250,8 @@
Loading
250 250
                             updated=updated)
251 251
252 252
    opts = modeladmin.model._meta
253 -
    perm = "{0}.{1}".format(opts.app_label, get_permission_codename('adminactions_massupdate', opts))
253 +
    perm = "{0}.{1}".format(opts.app_label,
254 +
                            get_permission_codename(mass_update.base_permission, opts))
254 255
    if not request.user.has_perm(perm):
255 256
        messages.error(request, _('Sorry you do not have rights to execute this action'))
256 257
        return

@@ -21,7 +21,8 @@
Loading
21 21
    """
22 22
23 23
    opts = modeladmin.model._meta
24 -
    perm = "{0}.{1}".format(opts.app_label.lower(), get_permission_codename('adminactions_byrowsupdate', opts))
24 +
    perm = "{0}.{1}".format(opts.app_label.lower(),
25 +
                            get_permission_codename(byrows_update.base_permission, opts))
25 26
    if not request.user.has_perm(perm):
26 27
        messages.error(request, _('Sorry you do not have rights to execute this action'))
27 28
        return
@@ -40,6 +41,7 @@
Loading
40 41
41 42
    def formfield_callback(field, **kwargs):
42 43
        return modeladmin.formfield_for_dbfield(field, request=request, **kwargs)
44 +
43 45
    ActionForm = modelform_factory(
44 46
        modeladmin.model,
45 47
        form=GenericActionForm,
@@ -91,6 +93,7 @@
Loading
91 93
byrows_update.short_description = _("By rows update")
92 94
byrows_update.base_permission = 'adminactions_byrowsupdate'
93 95
96 +
94 97
def byrows_update_get_fields(modeladmin):
95 98
    """
96 99
        Get fields names to be shown of the model rows formset considering the

@@ -37,7 +37,8 @@
Loading
37 37
38 38
def graph_queryset(modeladmin, request, queryset):  # noqa
39 39
    opts = modeladmin.model._meta
40 -
    perm = "{0}.{1}".format(opts.app_label.lower(), get_permission_codename('adminactions_chart', opts))
40 +
    perm = "{0}.{1}".format(opts.app_label.lower(),
41 +
                            get_permission_codename(graph_queryset.base_permission, opts))
41 42
    if not request.user.has_perm(perm):
42 43
        messages.error(request, _('Sorry you do not have rights to execute this action'))
43 44
        return

@@ -83,7 +83,8 @@
Loading
83 83
    """
84 84
85 85
    opts = modeladmin.model._meta
86 -
    perm = "{0}.{1}".format(opts.app_label, get_permission_codename('adminactions_merge', opts))
86 +
    perm = "{0}.{1}".format(opts.app_label,
87 +
                            get_permission_codename(merge.base_permission, opts))
87 88
    if not request.user.has_perm(perm):
88 89
        messages.error(request, _('Sorry you do not have rights to execute this action'))
89 90
        return

@@ -18,7 +18,9 @@
Loading
18 18
def create_extra_permissions():
19 19
    from django.contrib.auth.models import Permission
20 20
    from django.contrib.contenttypes.models import ContentType
21 +
21 22
    from .actions import actions as aa
23 +
22 24
    #  ('adminactions_export', 'adminactions_massupdate',
23 25
    #                        'adminactions_merge', 'adminactions_chart',
24 26
    #                        'adminactions_byrowsupdate')

@@ -3,8 +3,10 @@
Loading
3 3
from django.core import serializers
4 4
from django.core.exceptions import ValidationError
5 5
from django.template.response import TemplateResponse
6 +
6 7
from .perms import get_permission_codename
7 8
9 +
8 10
class ImportFixtureForm(forms.Form):
9 11
    fixture_file = forms.FileField(required=False)
10 12
    fixture_content = forms.CharField(widget=forms.Textarea, required=False)

@@ -35,7 +35,8 @@
Loading
35 35
        export a queryset to csv file
36 36
    """
37 37
    opts = modeladmin.model._meta
38 -
    perm = "{0}.{1}".format(opts.app_label, get_permission_codename('adminactions_export', opts))
38 +
    perm = "{0}.{1}".format(opts.app_label,
39 +
                            get_permission_codename(base_export.base_permission, opts))
39 40
    if not request.user.has_perm(perm):
40 41
        messages.error(request, _('Sorry you do not have rights to execute this action'))
41 42
        return
@@ -118,6 +119,9 @@
Loading
118 119
    return render(request, template, ctx)
119 120
120 121
122 +
base_export.base_permission = 'adminactions_export'
123 +
124 +
121 125
def export_as_csv(modeladmin, request, queryset):
122 126
    return base_export(modeladmin, request, queryset,
123 127
                       impl=_export_as_csv,
@@ -151,6 +155,7 @@
Loading
151 155
export_as_xls.short_description = _("Export as XLS")
152 156
export_as_xls.base_permission = 'adminactions_export'
153 157
158 +
154 159
class FlatCollector:
155 160
    def __init__(self, using):
156 161
        self._visited = []
@@ -234,7 +239,8 @@
Loading
234 239
               'serializer': 'json',
235 240
               'indent': 4}
236 241
    opts = modeladmin.model._meta
237 -
    perm = "{0}.{1}".format(opts.app_label, get_permission_codename('adminactions_export', opts))
242 +
    perm = "{0}.{1}".format(opts.app_label,
243 +
                            get_permission_codename(export_as_fixture.base_permission, opts))
238 244
    if not request.user.has_perm(perm):
239 245
        messages.error(request, _('Sorry you do not have rights to execute this action'))
240 246
        return
@@ -310,13 +316,15 @@
Loading
310 316
export_as_fixture.short_description = _("Export as fixture")
311 317
export_as_fixture.base_permission = 'adminactions_export'
312 318
319 +
313 320
def export_delete_tree(modeladmin, request, queryset):  # noqa
314 321
    """
315 322
    Export as fixture selected queryset and all the records that belong to.
316 323
    That mean that dump what will be deleted if the queryset was deleted
317 324
    """
318 325
    opts = modeladmin.model._meta
319 -
    perm = "{0}.{1}".format(opts.app_label, get_permission_codename('adminactions_export', opts))
326 +
    perm = "{0}.{1}".format(opts.app_label,
327 +
                            get_permission_codename(export_delete_tree.base_permission, opts))
320 328
    if not request.user.has_perm(perm):
321 329
        messages.error(request, _('Sorry you do not have rights to execute this action'))
322 330
        return
Files Coverage
src/adminactions 84.75%
Project Totals (23 files) 84.75%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading