-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ensure valid task_name before create a Routine
- Loading branch information
1 parent
885d036
commit b41110d
Showing
4 changed files
with
23 additions
and
2 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.core.exceptions import ValidationError | ||
from django.db.models.signals import pre_save | ||
from django.dispatch import receiver | ||
|
||
from django_cloud_tasks import models, exceptions | ||
|
||
|
||
@receiver(pre_save, sender=models.Routine) | ||
def ensure_valid_task_name(sender, instance, **kwargs): | ||
try: | ||
instance.task | ||
except exceptions.TaskNotFound: | ||
raise ValidationError(f"The task {instance.task_name} was not found. Make sure {instance.task_name} is properly set.") |
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