-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BITMAKER-2542 Allow setting DataPersistence field on Project/Spider m…
…odels (#150) --------- Co-authored-by: Raymond Negron <[email protected]> Co-authored-by: emegona <[email protected]>
- Loading branch information
1 parent
c6bcf35
commit d14d7b3
Showing
31 changed files
with
1,064 additions
and
394 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
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 |
---|---|---|
@@ -1,9 +1,36 @@ | ||
from rest_framework import serializers | ||
|
||
from core.models import Spider | ||
from core.models import DataStatus, Spider | ||
|
||
|
||
class SpiderSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Spider | ||
fields = ("sid", "name", "project") | ||
fields = ("sid", "name", "project", "data_status", "data_expiry_days") | ||
|
||
|
||
class SpiderUpdateSerializer(serializers.ModelSerializer): | ||
sid = serializers.UUIDField( | ||
read_only=True, help_text="A UUID identifying this spider." | ||
) | ||
data_status = serializers.ChoiceField( | ||
choices=DataStatus.HIGH_LEVEL_OPTIONS, | ||
required=False, | ||
help_text="New data status.", | ||
) | ||
data_expiry_days = serializers.IntegerField( | ||
required=False, | ||
help_text="New data expiry days.", | ||
) | ||
|
||
class Meta: | ||
model = Spider | ||
fields = ("sid", "name", "data_status", "data_expiry_days") | ||
|
||
def update(self, instance, validated_data): | ||
instance.data_status = validated_data.get("data_status", instance.data_status) | ||
instance.data_expiry_days = validated_data.get( | ||
"data_expiry_days", instance.data_expiry_days | ||
) | ||
instance.save() | ||
return instance |
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
Oops, something went wrong.