mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
Support 202009 (#841)
* Add EmailMultiAlternatives import * Add strip_tags import * Add settings imports and new email test * Add email increment to ixf and tests * IX-F Importer: suggested update when it should be add + remove #832 * Take email increment out of if-else * Add max and min speed settings * Change validation check for models * new speed validation * Add basic user command * Add pdb cleanup users tool * Add pretty printing for speed * Add users as a subparser * add translation override to signals * Add parser as parent of subparser * refactor and change test * Move override to cover single variable * Add tooltip option for individual checkboxes * address 'fix me' issue with field_help helper func * Add zipcode validator and black format * Make website required input but zipcode dependent on country * Add net POC requirement to Netixlan serializer * Website is now blank=False ie required in all forms * refine error message * Require email is not blank and add test * Change error message * add website and zipcode test, edit zipcode error message * change placement of tooltip * add question mark * Add comment * Add runtime error logging for ixp member import * add uncaught error test * delete two unused methods * Rename test file and add different tests * Add missing email imports (reproduces changes in hot_fix_gh_831) * add resend methods * Add missing email imports (reproduces changes in hot_fix_gh_831) * Add pytest-mock to pipfile * Add resend email mechanism * Add email resending * remove failing assertion * fix for ticket_aged_proposals * Wrap resending emails in conditional for commit * Add resend email tests * fix mail_Debug bug * Figure out production mailing and resending settings * Add stale info field * default IXF_RESEND_FAILED_EMAILS to False fix issue with sent being set even if email was not sent fix issue with output stating resending of emails even if it wasnt * IX-F Preview - shows the consolidated delete operation when it shouldn't (#824) * black format (v 19.10) * black formatting * black formatting * pipfile relock * make changes from #825 play nice with changes from #833 * black to pipenv dev packages Co-authored-by: Elliot Frank <elliot@20c.com> Co-authored-by: Stefan Pratter <stefan@20c.com>
This commit is contained in:
@@ -50,6 +50,7 @@ from peeringdb_server.validators import (
|
||||
validate_prefix_overlap,
|
||||
validate_phonenumber,
|
||||
validate_irr_as_set,
|
||||
validate_zipcode,
|
||||
)
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@@ -1064,7 +1065,7 @@ class FacilitySerializer(ModelSerializer):
|
||||
website = serializers.URLField()
|
||||
address1 = serializers.CharField()
|
||||
city = serializers.CharField()
|
||||
zipcode = serializers.CharField()
|
||||
zipcode = serializers.CharField(required=False, allow_blank=True, default="")
|
||||
|
||||
tech_phone = serializers.CharField(required=False, allow_blank=True, default="")
|
||||
sales_phone = serializers.CharField(required=False, allow_blank=True, default="")
|
||||
@@ -1185,6 +1186,11 @@ class FacilitySerializer(ModelSerializer):
|
||||
except ValidationError as exc:
|
||||
raise serializers.ValidationError({"sales_phone": exc.message})
|
||||
|
||||
try:
|
||||
data["zipcode"] = validate_zipcode(data["zipcode"], data["country"])
|
||||
except ValidationError as exc:
|
||||
raise serializers.ValidationError({"zipcode": exc.message})
|
||||
|
||||
return data
|
||||
|
||||
|
||||
@@ -1462,9 +1468,35 @@ class NetworkIXLanSerializer(ModelSerializer):
|
||||
pass
|
||||
return super().run_validation(data=data)
|
||||
|
||||
def validate(self, data):
|
||||
netixlan = NetworkIXLan(**data)
|
||||
def _validate_network_contact(self, data):
|
||||
"""
|
||||
Per github ticket #826, we only allow a Netixlan to be added
|
||||
if there is a network contact that the AC can get in touch
|
||||
with to resolve issues.
|
||||
"""
|
||||
network = data["network"]
|
||||
|
||||
poc = (
|
||||
network.poc_set_active.filter(
|
||||
role__in=["Technical", "NOC", "Policy"], visible__in=["Users", "Public"]
|
||||
)
|
||||
.exclude(email="")
|
||||
.count()
|
||||
)
|
||||
|
||||
if poc == 0:
|
||||
raise serializers.ValidationError(
|
||||
_(
|
||||
"Network must have a Technical, NOC, or Policy point of contact "
|
||||
"with valid email before adding exchange point."
|
||||
)
|
||||
)
|
||||
|
||||
def validate(self, data):
|
||||
|
||||
self._validate_network_contact(data)
|
||||
|
||||
netixlan = NetworkIXLan(**data)
|
||||
try:
|
||||
netixlan.validate_ipaddr4()
|
||||
except ValidationError as exc:
|
||||
@@ -1475,6 +1507,11 @@ class NetworkIXLanSerializer(ModelSerializer):
|
||||
except ValidationError as exc:
|
||||
raise serializers.ValidationError({"ipaddr6": exc.message})
|
||||
|
||||
try:
|
||||
netixlan.validate_speed()
|
||||
except ValidationError as exc:
|
||||
raise serializers.ValidationError({"speed": exc.message})
|
||||
|
||||
# when validating an existing netixlan that has a mismatching
|
||||
# asn value raise a validation error stating that it needs
|
||||
# to be moved
|
||||
|
||||
Reference in New Issue
Block a user