Skip to content
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

[#8661] Add 'Save Profile' button #5940

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

sevfurneaux
Copy link
Collaborator

Describe your changes
This PR adds the "Save Search Profile" button.

2025-01-14 16 59 58

Tasks

  • PR name contains story or task reference
  • Steps to recreate and test the changes
  • Documentation (docs and inline)
  • Tests (including n+1 and django_assert_num_queries where applicable)
  • Changelog

@sevfurneaux sevfurneaux self-assigned this Jan 15, 2025
@sevfurneaux
Copy link
Collaborator Author

@sevfurneaux sevfurneaux requested a review from vellip January 15, 2025 12:08
@sevfurneaux
Copy link
Collaborator Author

@goapunk @m4ra @vellip in regards to the name generation, this is currently happening in the frontend and is implemented in this PR. If a user selects any of the filters, then based on what filters/search query are available the names are created:

Example where districts filters are used
Screenshot 2025-01-15 at 12 15 37

Example where search query is used
Screenshot 2025-01-15 at 12 15 34

@sevfurneaux sevfurneaux force-pushed the sf-2025-add-save-profile-search-action branch 2 times, most recently from a3fa4d1 to 1a072c4 Compare January 15, 2025 13:33
@m4ra
Copy link
Contributor

m4ra commented Jan 15, 2025

@sevfurneaux the name is generated as SearchProfile 1 SearchProfile 2, etc and it's being developed in this PR #5928
It's best to let us know in our channels if you work on something that is not in the scope of the story.

@sevfurneaux
Copy link
Collaborator Author

sevfurneaux commented Jan 15, 2025

Thanks @m4ra. I actually implemented this due to it being noted in the #8661
[mB] Kiezradar frontend: "save search" button on Project Overview page
ticket:

If a search profile does not have a name, automatically generate a name based on the metadata of filters picked in the project overview page.

But presumably it wasn't updated prior to the ticket being created for the backend implementation.

Hopefully that won't happen again! 🤞

Ok, so shall I remove my implementation? Presumably you'll add the additional functionality beyond SearchProfile 1 and SearchProfile 2 so that it includes the metdata such as Projects in Charlottenburg as per the design? Unsure if that is noted in your ticket.

Screenshot 2025-01-15 at 13 40 36

@sevfurneaux sevfurneaux requested a review from m4ra January 15, 2025 13:49
@m4ra
Copy link
Contributor

m4ra commented Jan 15, 2025

@sevfurneaux That's getting more confusing now. No, we are not implementing naming based on metadata. @janeklqd can you please clarify whether we save the names as autogenerated with searchprofile 1.... etc or from the metadata. Adding here @goapunk since he has a PR open for the auto-naming in the backend.

Thanks @m4ra. I actually implemented this due to it being noted in the #8661
[mB] Kiezradar frontend: "save search" button on Project Overview page ticket:

If a search profile does not have a name, automatically generate a name based on the metadata of filters picked in the project overview page.

But presumably it wasn't updated prior to the ticket being created for the backend implementation.

Hopefully that won't happen again! 🤞

Ok, so shall I remove my implementation? Presumably you'll add the additional functionality beyond SearchProfile 1 and SearchProfile 2 so that it includes the metdata such as Projects in Charlottenburg as per the design? Unsure if that is noted in your ticket.

districts = AdministrativeDistrict.objects.all()
district_names_list = [district.name for district in districts]
district_names_list.append(str(city_wide))
return json.dumps(district_names_list)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@goapunk any idea if the district polygons are used anywhere outside the plans, anything to do with bplans? Since @sevfurneaux is removing these methods, would be good to double check with you as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sevfurneaux the map on the project list will not be highlighting the district borders any more? If that's the case I think removing this is fine

Copy link
Contributor

@m4ra m4ra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, only a check for the user that is not required, and waiting for Julien to confirm we are not in need of the district_polygons context.

@@ -119,6 +137,12 @@ def get_search_profile(self):
pass
return None

def get_search_profiles_count(self):
if self.request.user.is_authenticated:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK no need for this check, as the view is allowed only to registered users. Same in the get_search_profile method above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, verified, we don't need these authentication checks, they are inherited from adhocracy4 as a mixin in this view class declaration above.

Copy link
Collaborator Author

@sevfurneaux sevfurneaux Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks. But this view is for the plans map (/projects) page, so users can be unauthenticated here, so we'll still need it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, as this page can be viewed by anyone I think we need the check

@sevfurneaux
Copy link
Collaborator Author

sevfurneaux commented Jan 15, 2025

Looks good, only a check for the user that is not required, and waiting for Julien to confirm we are not in need of the district_polygons context.

@m4ra thank you! Looks like there's coverage/coveralls errors, presumably I need to add tests for the views.py changes?

@sevfurneaux
Copy link
Collaborator Author

@goapunk @m4ra Janek has confirmed we'll go with the backend auto-generated naming in #5928, so I'll remove my frontend implementation 👍

@sevfurneaux sevfurneaux mentioned this pull request Jan 15, 2025
5 tasks

useEffect(() => {
const handlePopState = () => {
window.location.reload()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try replaceState instead of pushState so we don't need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just changed to replaceState 👍. I misunderstood replaceState, thanks! So now when the user uses back/forward it goes to the previous page.

@m4ra
Copy link
Contributor

m4ra commented Jan 15, 2025

We should usually, but let's move on with this. Once Julian confirms, you can merge it.

@sevfurneaux sevfurneaux force-pushed the sf-2025-add-save-profile-search-action branch from 1a072c4 to b3826a4 Compare January 15, 2025 18:54
@sevfurneaux
Copy link
Collaborator Author

Hi 👋 @goapunk, I think @m4ra is away now. She had a question above about district_polygons above. Then there is the coveralls error about uncovered code: do we need to update a test to get this green? Or is there some kind of approval in coveralls?

@goapunk
Copy link
Contributor

goapunk commented Jan 16, 2025

Hi 👋 @goapunk, I think @m4ra is away now. She had a question above about district_polygons above. Then there is the coveralls error about uncovered code: do we need to update a test to get this green? Or is there some kind of approval in coveralls?

@sevfurneaux hey :) will have a look later today!

Copy link
Contributor

@goapunk goapunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sevfurneaux looks good to me, I left a question for you regarding the district polygons, if the answer is positive then go ahead and merge. Ignoring the coveralls check is ok

districts = AdministrativeDistrict.objects.all()
district_names_list = [district.name for district in districts]
district_names_list.append(str(city_wide))
return json.dumps(district_names_list)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sevfurneaux the map on the project list will not be highlighting the district borders any more? If that's the case I think removing this is fine

@@ -119,6 +137,12 @@ def get_search_profile(self):
pass
return None

def get_search_profiles_count(self):
if self.request.user.is_authenticated:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, as this page can be viewed by anyone I think we need the check

@sevfurneaux
Copy link
Collaborator Author

sevfurneaux commented Jan 20, 2025

Thanks for reviewing @goapunk.

@sevfurneaux the map on the project list will not be highlighting the district borders any more? If that's the case I think removing this is fine

From testing, get_district_polygons was used in context["districts"], but the context["districts"] data was never directly rendered or manipulated in any of the React components. For example on dev, districts is passed into the ProjectsControlBar here: https://github.com/liqd/a4-meinberlin/blob/dev/meinberlin/react/projects/ProjectsListMapBox.jsx#L117

...but ProjectsControlBar does not reference it from its component props: https://github.com/liqd/a4-meinberlin/blob/dev/meinberlin/react/projects/ProjectsControlBar.jsx#L56-L65

@vellip
Copy link
Collaborator

vellip commented Jan 20, 2025

Thanks for reviewing @goapunk.

@sevfurneaux the map on the project list will not be highlighting the district borders any more? If that's the case I think removing this is fine

I never saw any designs highlighting district borders anymore with the redesign.

@sevfurneaux sevfurneaux force-pushed the sf-2025-add-save-profile-search-action branch from b3826a4 to f6645e4 Compare January 20, 2025 13:08
@sevfurneaux sevfurneaux merged commit 218ffc3 into dev Jan 20, 2025
2 of 3 checks passed
@sevfurneaux sevfurneaux deleted the sf-2025-add-save-profile-search-action branch January 20, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants