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
Fix site title and keywords never get updated #2900
Conversation
There was a problem hiding this 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
?
udata/core/site/models.py
Outdated
}) | ||
if not created: | ||
Site.objects(id=site_id).modify(set__title=site_title, set__keywords=site_keywords) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…er-updated # Conflicts: # CHANGELOG.md
There was a problem hiding this 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 ! 👍
Currently changing
SITE_TITLE
and/orSITE_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 inmodify()
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.