-
Notifications
You must be signed in to change notification settings - Fork 27
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
Clean instagram input #2400
base: master
Are you sure you want to change the base?
Clean instagram input #2400
Conversation
b63527b
to
09eb443
Compare
09eb443
to
e45a70b
Compare
I think the regexs might need some work here. First off, we have I think there's also Can you use url parse (as we've done elsewhere) to match the domain to one of This is the first pass. Then for usernames, we need to take the path part of the parsed value. I found this regex for validating usernames: https://blog.jstassen.com/2016/03/code-regex-for-instagram-username-and-hashtags/ |
I've added a fixup commit with these suggested changes and made it clear to the user that a URL not a username is expected on the form. |
The regex is looking good now. If the idea is to store the username only, then we shouldn't make the change to call the field "Instagram URL". As things stand, someone will enter a URL and it will be replaced with a username. But if they enter a username (or edit a profile with just a username in the field), it will fail validation due to the field not containing one of the valid domains. We would also need to update WCIVF and all previous values in this field to only expect the username. It might be better to standardise the URL with a username, rather than changing it from being a URL |
24ff4b1
to
8487472
Compare
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.
Couple of inline comments.
I think we're going to need to think about validating all existing data in this field somehow. If we deploy this code as-is, some profiles might not be saveable because the value in this field isn't valid. Users can just remove it, but we should clean this up before that happens.
The quickest thing to do, I imagine, is to run the regex over a CSV export with the instagram URL added. We can then see if there are any profiles with bad values and manually clean them up.
We'll want to do the same for LinkedIn URLs (as per the other open PR), so I expect running one report for both makes sense.
ynr/apps/people/models.py
Outdated
@@ -169,6 +169,8 @@ def get_value_html(self): | |||
|
|||
if self.value_type == "twitter_username": | |||
url = format_html("https://twitter.com/{}", self.value) | |||
if self.value_type == "instagram_url": | |||
url = format_html("https://instagram.com/{}", self.value) |
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.
Same with the www.
here
ynr/apps/people/models.py
Outdated
@@ -169,6 +169,8 @@ def get_value_html(self): | |||
|
|||
if self.value_type == "twitter_username": | |||
url = format_html("https://twitter.com/{}", self.value) | |||
if self.value_type == "instagram_url": | |||
url = format_html("https://www.instagram.com/{}", self.value) |
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.
Maybe I'm reading this wrong, but isn't clean_instagram_url
returning a full URL? In that case, the url here should just be self.value
?
8f883ca
to
bd0b93d
Compare
We have 4,227 instances of an instagram |
bd0b93d
to
033a9ea
Compare
- Audit all person identifiers and their validation - Check the domain and the username for valid entries
033a9ea
to
3352275
Compare
This work cleans instagram entries to the Person Identifier form so that the result is a username with the value of the instagram url. I've also updated the
people/README.md
to list and describe the input and output of all the person identifiers. Finally, I've included a management command to reformat existing usernames to urls.