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

Fix site title and keywords never get updated #2900

Conversation

tboye
Copy link
Contributor

@tboye tboye commented Oct 1, 2023

Currently changing SITE_TITLE and/or SITE_KEYWORDS settings doesn't have any effect as initial values stored in Mongo are taken. I'm not sure if this was done intentionally, but in my opinion such update might be needed every now and then, at least for keywords.

Note: upsert option could've been used in modify() to do everything in a single line but unfortunately this method doesn't seem to return the object. Maybe there's still a more elegant way that I'm overlooking.

Copy link
Contributor

@maudetes maudetes left a comment

Choose a reason for hiding this comment

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

Thank you for this PR. I don't think we've encountered the case recently, but we should indeed fix this behavior.

Maybe we could deal with creation at init time and only get the Site object in get_current_site?

})
if not created:
Site.objects(id=site_id).modify(set__title=site_title, set__keywords=site_keywords)
Copy link
Contributor

Choose a reason for hiding this comment

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

This would imply a modification every time with access current_site, which may be overkill.
Instead of using a not created as condition which will be true most of the time, would it be more efficient to compare if g.site.keyword != site_keyword and same with title?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, I somehow thought that it won't be called every time.

Copy link
Contributor

@maudetes maudetes left a comment

Choose a reason for hiding this comment

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

Nice, thank you :) I've shortly looked around for a different place to init the Site object but did not find something obvious, let's go this way ! 👍

@maudetes maudetes merged commit 2416a3e into opendatateam:master Oct 11, 2023
1 check passed
@tboye tboye deleted the fix/OR-408-site-title-and-keywords-are-never-updated branch March 21, 2024 23:58
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.

None yet

2 participants