Closed Mike-Heneghan closed 5 years ago
To do list:
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.
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.
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.
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.
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:
query_transform
.query_transform
with the new root=''
syntax.Need to check the behaviour and make sure I'm using best practices.
Need to add tests for new 'places' view.
/search
(indirect query_transform test)Need to make sure the view is handling errors with both place names and categories.
Information on templatetag testing:
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.
The pagination for /places
is problematic as it redirects to /search
need to sort in query_transform.
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.
Need to update the query_transform
method to reduce DB operations and increase reliability by using context data.
Merged into master
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.