-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8d1ee1
commit b5d9dd7
Showing
6 changed files
with
74 additions
and
51 deletions.
There are no files selected for viewing
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,25 @@ | ||
#!/bin/bash | ||
|
||
# Exit immediately if a non-zero exit code is returned | ||
set -e | ||
|
||
QUEUE_NAME=${CELERY_WORKER_QUEUE:-celery} | ||
|
||
# Check if CELERY_WORKER_NAME is set | ||
if [ -z "$CELERY_WORKER_NAME" ]; then | ||
# If not set | ||
WORKER_NAME="${QUEUE_NAME}@${HOSTNAME}" | ||
else | ||
# If set and contains the '@' symbol | ||
if [[ "$CELERY_WORKER_NAME" != *"@"* ]]; then | ||
# If not, update CELERY_WORKER_NAME to celery@${CELERY_WORKER_NAME} | ||
WORKER_NAME="celery@${CELERY_WORKER_NAME}" | ||
else | ||
WORKER_NAME="${CELERY_WORKER_NAME}" | ||
fi | ||
fi | ||
|
||
echo "$WORKER_NAME" | ||
|
||
# Use CELERY_WORKER_NAME to set the --destination flag | ||
# celery --workdir src --app openarchiefbeheer.celery inspect --destination "$WORKER_NAME" active |
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 |
---|---|---|
@@ -1,26 +1,27 @@ | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from rest_framework.exceptions import ValidationError | ||
from rest_framework.request import Request | ||
|
||
from ..models import DestructionList | ||
|
||
|
||
class DestructionListChecksMixin: | ||
def get_destruction_list(self, request: Request) -> DestructionList: | ||
"""Check the permissions on a destruction list | ||
Used by APIView endpoints that create a resource related to a destruction list (for example a review/co-review) | ||
and need to check based on the rights of the user, the status and the assignees of the destruction list | ||
whether the action is allowed. | ||
""" | ||
|
||
def create(self, request, *args, **kwargs): | ||
try: | ||
return DestructionList.objects.get( | ||
destruction_list = DestructionList.objects.get( | ||
uuid=request.data.get("destruction_list") | ||
) | ||
except DestructionList.DoesNotExist: | ||
raise ValidationError( | ||
detail={"destruction_list": _("The destruction list does not exist.")} | ||
) | ||
|
||
def check_destruction_list_permissions(self, request: Request) -> None: | ||
destruction_list = self.get_destruction_list(request) | ||
self.check_object_permissions(self.request, destruction_list) | ||
|
||
def create(self, request, *args, **kwargs): | ||
self.check_destruction_list_permissions(request) | ||
return super().create(request, *args, **kwargs) |
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
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