Mike-Heneghan / ALISS

ALISS (A Local Information System for Scotland) is a service to help you find help and support close to you when you need it most.
https://aliss.org
0 stars 0 forks source link

Landing Pages #74

Closed Mike-Heneghan closed 5 years ago

Mike-Heneghan commented 5 years ago

We are going to have landing pages which combine a location and category. places/aberdeen/mental-health.

Landing page view. It'll take a place name and a category URL and do the search.

Need a slug based on a place name which may not be allowed to be null. Instead, make a postcode slug.

Slug fields are generated from another field need to read the docs.

To start with category pre-selected will be a piece of copy at the top of the search page.

Create the view and confirm that things are working by adding a placeholder page.

Mike-Heneghan commented 5 years ago

To do list:

Mike-Heneghan commented 5 years ago

Although there is a SlugField for both the Organisation and Service models a field slug is a CharField. This starts blank and a method generate_slug is called to populate it based on the name.

I think it would be best to research with the intention of using a built in SlugField if it reduces complexity.

Mike-Heneghan commented 5 years ago

https://stackoverflow.com/questions/837828/how-do-i-create-a-slug-in-django

It seems like there are a few different ways to assign slugs. As per the above link, we could overwrite the save method and slugify the place-name. Although I'm unsure as to whether we'd need a way triggering a save on all postcode records for this to take effect?

def save(self, *args, **kwargs):
  self.slug = slugify(self.place_name)
  super(Test, self).save(*args, **kwargs)

Although this doesn't seem to be very different from the example of Organisation and Service models slug generation.

Mike-Heneghan commented 5 years ago

As per discussion need to handle situations where a place name needs to be distinguished from another using a region i.e.

'Westhill, Aberdeenshire', 'Westhill, Highland' or 'Blackburn, Aberdeenshire', 'Blackburn, West Lothian' ' Going to leave the edge cases of locations with more than one instance until later.

Mike-Heneghan commented 5 years ago

Went down a rabbit hole of default methods but confirmed a model cannot have a field which points to another field in the same instance on creation.

Steps which were taken:

My local DB now has slug fields with place_names.

Mike-Heneghan commented 5 years ago

Now when we pass the url /places/aberdeen/goods the <place_slug>/<category_slug> are used to redirect to the search results.

We need to add more sophisticated behaviour to reuse the majority of the search/results.html with the addition of summary text for the result.

To do list:

Mike-Heneghan commented 5 years ago

Need to check the behaviour and make sure I'm using best practices.

Mike-Heneghan commented 5 years ago

Need to add tests for new 'places' view.

Mike-Heneghan commented 5 years ago

Need to make sure the view is handling errors with both place names and categories.

Mike-Heneghan commented 5 years ago

Information on templatetag testing:

Mike-Heneghan commented 5 years ago

The only non-ideal behaviour for the places/ result page is the category link does redirect to search but the category isn't updated.

Updated the aliss.js query_transform method to only create category key if it isn't there already.

Mike-Heneghan commented 5 years ago

The pagination for /places is problematic as it redirects to /search need to sort in query_transform.

Mike-Heneghan commented 5 years ago

Might be worth rolling back the migration for the postcode field and try reapplying.

generate_place_name_slugs() as the method has been changed since it was applied.

Mike-Heneghan commented 5 years ago

Need to update the query_transform method to reduce DB operations and increase reliability by using context data.

Mike-Heneghan commented 5 years ago

Merged into master