-
Notifications
You must be signed in to change notification settings - Fork 2
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
Support "Add new instrument name"; Initialize "Upload image"; #164
base: develop
Are you sure you want to change the base?
Conversation
- remove "instrument-detail" page - add two buttons on each instrument card: "Upload new images" & "View on wikidata" - initialize image upload modal UI Refs: #150
- remove "instrument-detail" page - add two buttons on each instrument card: "Upload new images" & "View on wikidata" - initialize image upload modal UI Refs: #150
- add new instrument name, source, description, and alias by a modal; - optionally publish to wikidata; Refs: #163
Refs: #163
web-app/django/VIM/apps/instruments/templates/instruments/includes/stdView.html
Outdated
Show resolved
Hide resolved
- remove "alias" field from "InstrumentName" model; - move "publish_name" to a separate .py file - use "csrf_protect" decorator for "publish_name" - extract the common code in "mansonryView.html" and "stdView.html" Refs: #163
@@ -15,7 +15,7 @@ class Command(BaseCommand): | |||
|
|||
NOTE: For now, this script only imports instrument names in English and French. It | |||
also only imports a set of previously-curated instruments that have images available. | |||
This list of instruments is stored in startup_data/vim_instruments_with_images-15sept.csv | |||
This list of instruments is stored in startup_data/all_instruments_with_16aug_2024.csv |
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.
No longer the right file name. You could probably just take out this comment and make the file name a command-line argument or a constant.
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'm overall confused by the authentication process for wikidata? You are hardcoding a username and password in this view?
Here's the first documentation I find on authentication with wikidata's API: https://www.wikidata.org/wiki/Wikidata:REST_API/Authentication. Not saying it's necessarily the way to go but I'm wondering where this version came from?
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 previously referred to the documentation on logging in here: https://www.mediawiki.org/wiki/API:Login#Python
Let me take a closer look.
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 using OAuth is essential, as recommended in the link you provided, to avoid hardcoding credentials. I’ve registered for OAuth and am currently awaiting approval. Based on feedback from last Saturday's project meeting, we also need to offer users a choice between using UMIL’s public account or authorizing their own Wikidata account. I'll create a new issue for this requirement. This pull request can be on hold until the user authentication issue is resolved.
For "add instrument name" feature, current commits only support using user's own wikidata account to add names. When developing, in order to test if the wikidata callback URL works properly, I config locally to make sure I can get the response from the callback URL(the callback URL is fixed to "vim.simssa.ca/oauth/callback" and can't be changed). So in this case if we push the code, the OAuth workflow will only work in the production server. Some important URLs and confidentials related to wikidata should be stored in ".env"( |
When this is merged, information about these configurations should be recorded somewhere so future developers can know what to do when something breaks and they have to fix this :) Probably in this repo's wiki... |
Yes, of course. I'll write a documentation about this. |
@@ -17,7 +17,7 @@ | |||
<div class="col-xl-3"> | |||
<div class="px-3 pt-3 me-1 mb-3 sidebar-container"> | |||
<div class="info-block p-2 mb-3 notranslate"> | |||
{% if active_language.en_label == "french" %} | |||
{% if active_language.en_label == "French" %} |
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.
Similar to #178, I think we need to rethink this hardcoding in the template.
href="?language={{ language.en_label }}">{{ language.autonym|title }}</a> | ||
</li> | ||
{% comment %} Here only English and French are shown {% endcomment %} | ||
{% if language.en_label == "English" or language.en_label == "French" %} |
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.
Why only English and French?
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.
It's because the options of other languages all have 500 server issues...So I temporarily only keep the English and French options.
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 just deleted this restriction locally and got no 500 errors.
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.
Yes, I didn't get 500 errors locally, but there is a 500 errors in production.
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 would suspect that if showing more languages than french and english is causing 500 errors in production but not locally then either we have already fixed the problem somewhere else and that change has just not propagated to production yet or there is some root cause in the production configuration that we need to uncover. In either case, I think this change will obscure more than it helps.
id="publishToWikidataCheckbox" | ||
name="publish_to_wikidata" /> | ||
<label class="form-check-label" for="publishToWikidataCheckbox"> | ||
Do you want to publish also to Wikidata? |
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.
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.
Okay I'll change this checkbox.
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.
Perhaps we don't need this checkbox? All edits should be published directly to wikidata by all means, as UMIL actually doesn't display any detail information of each instrument, right? If this is the case, I can just remove this checkbox.
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.
if (result.exists) { | ||
languageInput.classList.add('is-invalid'); | ||
languageInput.classList.remove('is-valid'); | ||
languageFeedbackInvalid.textContent = `This instrument already has a name in ${languageLabel} (${languageCode}): ${result.name}`; | ||
allValid = false; | ||
} else { | ||
languageInput.classList.add('is-valid'); | ||
languageInput.classList.remove('is-invalid'); | ||
languageFeedbackValid.textContent = `This instrument does not have a name in ${languageLabel} (${languageCode}) yet. You can add a new name.`; |
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 don't think we want to do this...people should be able to add names in languages where a name already exists.
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.
So if a name already exists in wikidata, we will overwrite it? Or we should automatically add names in alias?
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.
So if a name already exists in wikidata, we will overwrite it?
I don't think we want to do that.
Or we should automatically add names in alias?
Maybe? That would make sense to me if we are collecting a new name for an instrument in an already existing language.
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.
OK. So I'll publish it as an alias if a name already exists.
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.
We probably do want to think through what happens if the name provided is already an alias. Since there is no way to see aliases in the current VIM frontend (and even if there was, we probably can't assume people are necessarily paying close attention to it), we might want to check for duplication before we publish...I'm not sure whether Wikidata does this kind of check on its end.
When I am trying to add a new name and click "Do you want to publish to Wikidata?", a button pops up that says "Authorize". Am I supposed to click that? What happens if I click "Publish" before I click "Authorize" (when I just did it, it didn't prompt me to go through the authorization process...). I'm not sure people will know that they're supposed to click the Authorize button first. It seems to me that if they need to some authorization to publish, we should guide them through that workflow. |
I just went through the Upload instrument image workflow, and I got no obvious errors, but I can't see the image, nor do I see any confirmation that it worked...what happened? |
multiple /> | ||
</div> | ||
<div id="previewImages" class="row g-2"></div> | ||
<button type="submit" class="btn btn-primary modal-btn">Upload</button> |
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.
How is this submission handled? Right now it looks like it is the default? So a get request is made to the /instruments/
endpoint... but that view doesn't do anything with that?
The image uploading module is still incomplete, with only the UI currently implemented. I'll temporarily comment out the image uploading button until this is complete. |
If you want to publish names to wikidata, yes, you should click "authorize" button. You can't go through the authorization process because this process requires Also, even if you get these information in ".env", you still can't get the callback information locally because wikidata can only send information to "vim.simssa.ca/oauth/callback"... I don't know if there is a better way that you can go through the whole process... |
I think it would make sense to walk people through this process. I feel like the most common approach on websites I visit is that if I try to do something that requires authentication, it will direct me to the authentication process and then back to what I was doing before (for example, I try to buy something online and it asks me to log-in before sending me back to the checkout process, or if I visit my mcgill outlook inbox online after I have been logged out it sends me to the log-in page). |
Resolves: #150
Resolves: #160
Resolves: #161
Resolves: #163
Resolves: #165