Skip to content

Commit

Permalink
Fixed missing validity checks in migrations (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
malinowskikam authored Aug 27, 2024
1 parent 93b2c54 commit e293805
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion msystems/migrations/0002_add_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def _get_role(role_name, role_model):
return role_model.objects.filter(name=role_name).first()
return role_model.objects.filter(name=role_name, validity_to__isnull=True).first()


def _create_role(role_name, role_model):
Expand Down
2 changes: 1 addition & 1 deletion msystems/migrations/0003_add_search_policyholders_perms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def add_rights(role_name, role_model, role_right_model):
role = role_model.objects.get(name=role_name)
role = role_model.objects.get(name=role_name, validity_to__isnull=True)
for right_id in POLICY_HOLDER_SEARCH_PERM:
if not role_right_model.objects.filter(validity_to__isnull=True, role=role, right_id=right_id).exists():
_add_right_for_role(role, right_id, role_right_model)
Expand Down
2 changes: 1 addition & 1 deletion msystems/migrations/0004_add_modal_right.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def add_rights(role_name, role_model, role_right_model):
role = role_model.objects.get(name=role_name)
role = role_model.objects.get(name=role_name, validity_to__isnull=True)
for right_id in POLICY_HOLDER_SEARCH_PERM:
if not role_right_model.objects.filter(validity_to__isnull=True, role=role, right_id=right_id).exists():
_add_right_for_role(role, right_id, role_right_model)
Expand Down
2 changes: 1 addition & 1 deletion msystems/migrations/0006_add_bill_query_rights.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def add_rights(role_name, role_model, role_right_model):
role = role_model.objects.get(name=role_name)
role = role_model.objects.get(name=role_name, validity_to__isnull=True)
for right_id in rolerights[role_name]:
if not role_right_model.objects.filter(validity_to__isnull=True, role=role, right_id=right_id).exists():
_add_right_for_role(role, right_id, role_right_model)
Expand Down
2 changes: 1 addition & 1 deletion msystems/migrations/0008_add_insuree_rights.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def add_rights(role_name, role_model, role_right_model):
role = role_model.objects.get(name=role_name)
role = role_model.objects.get(name=role_name, validity_to__isnull=True)
for right_id in rolerights[role_name]:
if not role_right_model.objects.filter(validity_to__isnull=True, role=role, right_id=right_id).exists():
_add_right_for_role(role, right_id, role_right_model)
Expand Down

0 comments on commit e293805

Please sign in to comment.