-
Notifications
You must be signed in to change notification settings - Fork 0
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
adding introduction to citing author and citing work #478
base: development
Are you sure you want to change the base?
Conversation
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.
When adding or updating an introduction on a citing_work or citing_author, if it includes a mention of a bibliography item, you get the following error:
File "/app/rard/utils/basemodel.py", line 319, in link_bibliography_mentions
for ant in antiquarians:
UnboundLocalError: local variable 'antiquarians' referenced before assignment
We can't really assign an antiquarian to a citing author or citing work, but we would like to link bibliography items in the same way. We'll have to expand the link_bibliography_mentions
method to handle this.
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 you look at the Antiquarian detail page, there's a htmx trigger on the bibliography item list which refreshes it when the introduction is updated. It just means you get to see the updated bibliography without having to refresh the page.
if self.ant_pk: | ||
context["antiquarian"] = Antiquarian.objects.get(id=self.ant_pk) |
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.
Repeated lines here. Was this supposed to do something different?
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.
May be a holdover from when I was going to try something and then either it needs to be updated or is no longer relevant
@@ -163,6 +163,7 @@ class BibliographySectionView(LoginRequiredMixin, PermissionRequiredMixin, ListV | |||
context_object_name = "bibliography_items" | |||
permission_required = ("research.view_bibliographyitem",) | |||
|
|||
# todo: update this to dynamically work with authors and ants |
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 needs doing doesn't it? You could use this approach to pass kwargs depending on the URL used to call the view:
https://docs.djangoproject.com/en/5.1/topics/http/urls/#views-extra-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.
Currently this view uses research/partials/antiquarian_bibliography_list.html
which includes a htmx process for refreshing the content that points to the antiquarian:bibliography url. You'll need to either switch to a different template depending on the related model in the view, or pass something in the context data that can be used to switch the url in the template.
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've bypassed the need for the antiquarian_bibliography_list
template with citing authors by including the equivalent in the detail template. My thinking was that htmx doesn't need a whole new template to update the content.
I think I've gotten confused somewhere along the way and am trying to blend two different strategies to this solution
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.
The problem is that updating the intro triggers the bibliography to refresh via this view, and the html content that gets swapped in has two problems:
- No bibliography items are returned because the view can't handle citing authors at the moment
- The template has
hx-get="{% url 'antiquarian:bibliography' pk=antiquarian.pk %}"
in it, but we need that to point to the citing_author:bibliography url if it's being rendered for the citing author detail page.
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.
To replicate the issue I'm talking about:
- Edit a citing author's introduction including a mention of a bibliography item
- Save the changes
- You should see the bibliography section at the bottom automatically update, but without any content
- Note the url in the #bib-list element at the bottom of the page
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.
Sorry, changes hadn't been pushed! Think these have been addressed in the latest one; I've used a get_templates
function so it points to the right one and put the citing author section in a new template
src/rard/research/urls.py
Outdated
path( | ||
"<pk>/bibliography/", | ||
views.BibliographySectionView.as_view(), | ||
name="bibliography", | ||
), |
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 using the passing extra options approach, I think this could work:
path( | |
"<pk>/bibliography/", | |
views.BibliographySectionView.as_view(), | |
name="bibliography", | |
), | |
path( | |
"<pk>/bibliography/", | |
views.BibliographySectionView.as_view(), | |
{"related_model":"citing_author"}, | |
name="bibliography", | |
), |
I've also just noticed that we don't have a shortcode for citing authors in mentions, so how do we mention them? Or is this just another thing to do for this PR |
I guess the researchers have just never needed to mention citing authors. Is there a reason we would want to add it? |
Perhaps not, I suppose the researchers can always request this in future |
Possible qol: when clicking the refresh, it should do a loader since typically on a CA it will already be updated and won't actually change |
closes #383