Skip to content

Commit

Permalink
Merge pull request #180 from rackerlabs/issue-179
Browse files Browse the repository at this point in the history
Added logic for SiteSerializer when handling email_scan_alerts and em…
  • Loading branch information
derpadoo committed Feb 26, 2020
2 parents b3be7c3 + c9d65f9 commit 42c71b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion master/django_scantron/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.21"
__version__ = "1.22"
12 changes: 7 additions & 5 deletions master/django_scantron/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ def validate(self, attrs):
invalid_targets = ",".join(targets_dict["invalid_targets"])
raise serializers.ValidationError(f"Invalid excluded targets provided: {invalid_targets}")

# Email scan alerts and email addresses.
email_scan_alerts = attrs["email_scan_alerts"]
email_alert_address = attrs["email_alert_address"]
# Email scan alerts and email address.
if ("email_scan_alerts" in attrs) and ("email_alert_address" in attrs):

if email_scan_alerts and not email_alert_address:
raise serializers.ValidationError(f"Provide an email address if enabling 'Email scan alerts'")
email_scan_alerts = attrs["email_scan_alerts"]
email_alert_address = attrs["email_alert_address"]

if email_scan_alerts and not email_alert_address:
raise serializers.ValidationError(f"Provide an email address if enabling 'Email scan alerts'")

return attrs

Expand Down

0 comments on commit 42c71b8

Please sign in to comment.