Skip to content

Commit

Permalink
Merge pull request #33975 from dimagi/mjr/create_dedupe_privilege
Browse files Browse the repository at this point in the history
Add dedupe domain privilege
  • Loading branch information
mjriley committed Jan 18, 2024
2 parents 8f3fff9 + 9e25684 commit d724c1c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions corehq/apps/accounting/bootstrap/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
privileges.REGEX_FIELD_VALIDATION,
privileges.EXPORT_OWNERSHIP,
privileges.CASE_LIST_EXPLORER,
privileges.CASE_DEDUPE,
]


Expand Down
46 changes: 46 additions & 0 deletions corehq/apps/accounting/migrations/0089_dedupe_priv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from django.core.management import call_command
from django.db import migrations

from corehq.privileges import CASE_DEDUPE
from corehq.util.django_migrations import skip_on_fresh_install



@skip_on_fresh_install
def _add_dedupe_to_pro_and_above(apps, schema_editor):
call_command('cchq_prbac_bootstrap')
call_command(
'cchq_prbac_grandfather_privs',
CASE_DEDUPE,
skip_edition='Paused,Community,Standard',
noinput=True,
)


def _reverse(apps, schema_editor):
call_command(
'cchq_prbac_revoke_privs',
CASE_DEDUPE,
skip_edition='Paused,Community,Standard',
delete_privs=False,
check_privs_exist=True,
noinput=True,
)

from corehq.apps.hqadmin.management.commands.cchq_prbac_bootstrap import Command
Command.OLD_PRIVILEGES.append(CASE_DEDUPE)
call_command('cchq_prbac_bootstrap')


class Migration(migrations.Migration):

dependencies = [
('accounting', '0088_add_new_softwareplan_visibility'),
]

operations = [
migrations.RunPython(
_add_dedupe_to_pro_and_above,
reverse_code=_reverse,
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ def ensure_roles(self, roles, dry_run=False):
Role(slug=privileges.CASE_COPY,
name='Allow Case Copy',
description='Allow case copy from one user to another'),
Role(slug=privileges.CASE_DEDUPE,
name='Deduplication Rules',
description='Support for finding duplicate cases'),
]

BOOTSTRAP_PLANS = [
Expand Down
4 changes: 4 additions & 0 deletions corehq/privileges.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@

CASE_COPY = 'case_copy'

CASE_DEDUPE = 'case_deduplicate'

MAX_PRIVILEGES = [
LOOKUP_TABLES,
API_ACCESS,
Expand Down Expand Up @@ -181,6 +183,7 @@
DATA_DICTIONARY,
CASE_LIST_EXPLORER,
CASE_COPY,
CASE_DEDUPE,
]

# These are special privileges related to their own rates in a SoftwarePlanVersion
Expand Down Expand Up @@ -258,4 +261,5 @@ def get_name_from_privilege(cls, privilege):
DATA_DICTIONARY: _("Project level data dictionary of cases"),
CASE_LIST_EXPLORER: _("Case List Explorer"),
CASE_COPY: _("Allow case copy from one user to another"),
CASE_DEDUPE: _("Deduplication Rules"),
}.get(privilege, privilege)
1 change: 1 addition & 0 deletions migrations.lock
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ accounting
0086_add_duplicate_invoice_id_to_invoice_model
0087_invoice_unique_constraints
0088_add_new_softwareplan_visibility
0089_dedupe_priv
admin
0001_initial
0002_logentry_remove_auto_add
Expand Down

0 comments on commit d724c1c

Please sign in to comment.