Page MenuHomePhabricator

Prefill nationality of author and country of origin of work at the country page
Open, Needs TriagePublic

Description

Context: Paulina shows a page for each country, which lists the copyright terms and shows statistics. This page also shows the authors and works search box, which behaves in the same way as at the main page.

Feature: At the country page, prefill the Nationality field and the Country of origin field, so that the defauld behavior is to filter only works and authors from the selected country.
The "Advanced filters" section should be displayed by default, so that the prefilled country is visible for the user.

imagen.png (852×991 px, 108 KB)

Event Timeline

I’d like to take this issue. The task seems to involve prefilling the Nationality and Country of origin filters when viewing a country’s page, and showing the “Advanced filters” section by default I’ll look into how those filters are currently handled on the main page and adjust the country page logic accordingly.

@AnbaNguyen I've assigned this task to you, since Sandijigs has already other task assigned. Thanks!

This comment was removed by AnbaNguyen.
AnbaNguyen changed the task status from Open to In Progress.Oct 9 2025, 2:29 PM
Pepe_piton changed the task status from In Progress to Open.Oct 10 2025, 6:59 PM

Excellent work, @AnbaNguyen I tried your code and it works perfect. It was a clever strategy to create the parameter 'prefill_country_qid'!

By the way, as a curiosity, country.wikidata_item_id and country_data are interchangeable.

The only very minor detail that I detected is that, in the author's "Nationality" filter, the prefill leaves trailing spaces. That can be solved just by moving line 141 up to line 140. I suppose you moved it down not to make the line too long, but in this special case, the new line has that minor effect of generating spaces in the html.

Anyway, I think you did a great job with the task!

@Pepe_piton : hi Jorge! thank you for reviewing! I've pushed a new commit to fix the trailing space issue.

hey @Pepe_piton @Nat_WDU
i made a merge request related this issue:-https://gitlab.wikimedia.org/toolforge-repos/paulina/-/merge_requests/89
changes made:-

  • Added JS to auto-select country
  • Displays matched country in input field
  • Keeps selected option synced with dropdown

Please check my work and share feedback so I can improve.

Hi everyone !

I've just sent a Merge Request for this task.

I've used two approaches:

  1. Jinja templating and if/else statement to prefill the work country of origin
  2. JavaScript to create a new function called prefillNationalityFilter.

Looking forward to your feedback and comments @Nat_WDU and @Pepe_piton

Hello @Nat_WDU @Pepe_piton

My approach keeps changes minimal, modified app.py to pass the country QID to the template, and added JavaScript in country.html to handle the prefilling and auto-expand advanced filters. I'd appreciate your review and any feedback on my implementation approach.

https://gitlab.wikimedia.org/toolforge-repos/paulina/-/merge_requests/122

Thank you

@Oluwatumininu.m Good work! The feature works well. The only minor detail is that when the user switches between Author and Work, the country dropdowns have different styles (one with yellow background and the other with white background). As for app.py, the two new variables you created are interchangeable with each other.

@AnbaNguyen Great. Now it's perfect! I really liked your approach: it's super straightforward and readable.

@shreya-bhagat Thanks for the contribution! You proposed a similar approach to AnbaNguyen's. I like it because it's simple, and it works perfectly.

@Dipanshu1223 What I like most of your contribution is that you touched the country template, and not the layout template. This is quite intuitive for a feature that is implemented in the country page. I found, however, that the feature is missing two things: 1) The advanced search should appear displayed by default (the open attribute would have to be added to details), and 2) when switching to the work search, the "Country of origin" field does not appear prefilled.

I'll continue reviewing tasks in the coming days. Cheers!

Thanks for the feedback. @Pepe_piton
I’ve addressed the two issues you pointed out:

  • Added JavaScript to prefill the 'Country of origin' field on the Work Search page.
  • Set the advanced search to display open by default.

Here’s the link to the updated changes: https://gitlab.wikimedia.org/toolforge-repos/paulina/-/merge_requests/89
Please check my work and share feedback so I can improve.

@Oluwatumininu.m Good work! The feature works well. The only minor detail is that when the user switches between Author and Work, the country dropdowns have different styles (one with yellow background and the other with white background). As for app.py, the two new variables you created are interchangeable with each other.

My bad!
Thank you so very much for the feedback!

I have fixed the styling inconsistency. I have taken out the redundant variable in the app.py also.
Thank you again.

@Aradhya05 Nice work! It works really well. I also liked that you used code like request.args.get('nationality', country_qid) so that, when the URL parameters for countries are present, it also prefills the country filters. Actually, Paulina still needs some polish to make all the search filters persistent, and this can be a good approach.

@Afanyulionel Your solution works very well too! And it is straightforward. The only thing I didn't understand was whether there is a need to create the country_name_for_search variable in app.py when the country_name variable already exists, which contains the same information. But that's just a side note.

@Miiswom Good work. Simple and effective. As with Dipanshu, I like your idea of focusing on the country.html template. I think since you are working on that template, which only loads when the URL includes the string /country/, there is no need to add the conditional if(location.href.includes("/country/Q"))

@Blegodwin Your contribution works very well too. Very easy to read and straightforward. Congrats!

@Dipanshu1223 It works perfect now.

@Oluwatumininu.m Now I can see the styles well.

@Aradhya05 Nice work! It works really well. I also liked that you used code like request.args.get('nationality', country_qid) so that, when the URL parameters for countries are present, it also prefills the country filters. Actually, Paulina still needs some polish to make all the search filters persistent, and this can be a good approach.

@Afanyulionel Your solution works very well too! And it is straightforward. The only thing I didn't understand was whether there is a need to create the country_name_for_search variable in app.py when the country_name variable already exists, which contains the same information. But that's just a side note.

@Miiswom Good work. Simple and effective. As with Dipanshu, I like your idea of focusing on the country.html template. I think since you are working on that template, which only loads when the URL includes the string /country/, there is no need to add the conditional if(location.href.includes("/country/Q"))

@Blegodwin Your contribution works very well too. Very easy to read and straightforward. Congrats!

@Dipanshu1223 It works perfect now.

@Oluwatumininu.m Now I can see the styles well.

Alright, understood @Pepe_piton . Well noted. I will keep that in mind and resuse existing variables. Thanks for the feedback