saxix / django-adminactions

Compare 0dc6a1a ... +0 ... 708e811

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 1 files from the diff.

@@ -24,14 +24,26 @@
Loading
24 24
    #  ('adminactions_export', 'adminactions_massupdate',
25 25
    #                        'adminactions_merge', 'adminactions_chart',
26 26
    #                        'adminactions_byrowsupdate')
27 -
    for model in apps.get_models():
27 +
    perm_suffix = 'adminactions_'
28 +
    existing_perms = set(
29 +
        Permission.objects.filter(codename__startswith=perm_suffix).values_list(
30 +
            'codename', 'content_type_id'
31 +
        )
32 +
    )
33 +
    models = list(apps.get_models())
34 +
    content_types = ContentType.objects.get_for_models(*models)
35 +
36 +
    new_permissions = []
37 +
    for model in models:
28 38
        for action in aa:
29 39
            opts = model._meta
30 -
            codename = get_permission_codename(action.base_permission, opts)
31 -
            label = 'Can {} {} (adminactions)'.format(action.base_permission.replace('adminactions_', ""),
40 +
            codename = get_permission_codename(action.base_permission, opts)[:100]
41 +
            ct = content_types[model]
42 +
            if (codename, ct.id) in existing_perms:
43 +
                continue
44 +
            label = 'Can {} {} (adminactions)'.format(action.base_permission.replace(perm_suffix, ""),
32 45
                                                      opts.verbose_name_raw)
33 -
            ct = ContentType.objects.get_for_model(model)
34 -
            params = dict(codename=codename,
35 -
                          content_type=ct,
36 -
                          defaults={'name': label[:50]})
37 -
            Permission.objects.get_or_create(**params)
46 +
            permission = Permission(codename=codename, content_type=ct, name=label[:255])
47 +
            new_permissions.append(permission)
48 +
49 +
    Permission.objects.bulk_create(new_permissions, ignore_conflicts=True)

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
src/adminactions 0.10% 84.84%
Project Totals (23 files) 84.84%
Loading