-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate AWS IDs when users set their AWS IDs in the Edit Cloud Details information #2101
Conversation
Looks good to me, thanks Chrystinne. A couple of quick thoughts:
|
Actually I see we have |
This logic should go in the form class if not the model class. It doesn't belong in views.py. Probably the best thing would be to define it as a validator in the CloudInformation class. Try that and see if it works. If that doesn't work then define a |
physionet-django/user/models.py
Outdated
@@ -1218,8 +1218,7 @@ class CloudInformation(models.Model): | |||
on_delete=models.CASCADE) | |||
gcp_email = models.OneToOneField('user.AssociatedEmail', related_name='gcp_email', | |||
on_delete=models.SET_NULL, null=True) | |||
aws_id = models.CharField(max_length=60, null=True, blank=True, default=None) | |||
|
|||
aws_id = models.CharField(max_length=60, null=True, blank=True, default=None, validators=[validators.validate_aws_id]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you've lost the blank line before class Meta
? It needs to be added back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tompollard I accidentally did. Thanks for catching that!
ff3630e
to
1ce6f76
Compare
@bemoody Using a validator in the CloudInformation model class works. Thanks. |
physionet-django/user/views.py
Outdated
@@ -1,6 +1,7 @@ | |||
import logging | |||
import os | |||
import pdb | |||
import re |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this import is no longer needed.
Thanks @Chrystinne, looks good to me. My understanding is that validators won’t retroactively affect existing data, so there shouldn't be any problems with applying this on the live server. Please could you squash the commits before we merge? Perhaps one commit for the addition of the validator, and one for the migration? |
…e 12-digit numerical values.
…mation model. The modification includes the addition of the 'validate_aws_id' validator to ensure AWS ID validity at the model level.
2ced2df
to
4accd03
Compare
thanks! |
This pull request validates AWS IDs to ensure they match the 12-digit numerical values expected for AWS account IDs when users set their AWS IDs in the Edit Cloud Details information.