-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Validators level check in permission (#2345)
* Add current validators level while validators * Add changes in validate api * Add Global validator permission command * Permission set for the global validator on validate api * Change queryset value in group permission * Fix permission issue on validator check
- Loading branch information
Showing
4 changed files
with
138 additions
and
4 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
local_units/management/commands/make_global_validator_permission.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import logging | ||
|
||
from django.contrib.auth.models import Group, Permission | ||
from django.contrib.contenttypes.models import ContentType | ||
from django.core.management.base import BaseCommand | ||
|
||
from local_units.models import LocalUnit | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Create standard local unit global validator permission class and group" | ||
|
||
def handle(self, *args, **options): | ||
logger.info("Creating/Updating permissions/groups for local unit global validator") | ||
print("- Creating/Updating permissions/groups for local unit global validator") | ||
codename = "local_unit_global_validator" | ||
content_type = ContentType.objects.get_for_model(LocalUnit) | ||
permission, created = Permission.objects.get_or_create( | ||
codename=codename, | ||
name="Local Unit Global Validator", | ||
content_type=content_type, | ||
) | ||
|
||
# If it's a new permission, create a group for it | ||
group, created = Group.objects.get_or_create(name="Local Unit Global Validators") | ||
group.permissions.add(permission) | ||
logger.info("Local unit global validator permission and group created") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters