You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I looked into this a while ago and discovered that the issue (or at least an issue) is that coderedcms.models.page_models.CoderedLocationPage.save() (and .get_context() ) only uses the GoogleApiSetting associated with the default site. If the Setting is attached to a non-default site, it's not used.
I was going to write a pull request for this issue, but while the solution for the get_context() method was obvious (use the request context to find the appropriate setting), I really didn't know the right way to handle the retrieval of the setting for the save() method which lacks a request context and therefore the method doesn't really know the appropriate site to pull the setting from. A fix that addressed the API key setting in the template context but not at the underlying model save() (and therefore could result in different results) seemed wrong so I never finished the patch/pull request.
Considering the save() belongs to a Page object, each page is tied to a Site (via its chain of parent pages, all the way up to the Root page). So we should be able to get the correct site on page. It would require a bit of introspection into Wagtail's Page object.
@wamcvey I created a separate issue for the site settings problem (Issue #341) and attempted a "simple" fix (PR #342) which proved to be a more systemic issue. Please continue discussion there.
Activity
wamcvey commentedon Jul 14, 2020
I looked into this a while ago and discovered that the issue (or at least an issue) is that
coderedcms.models.page_models.CoderedLocationPage.save()(and.get_context()) only uses the GoogleApiSetting associated with the default site. If the Setting is attached to a non-default site, it's not used.For example:
coderedcms/coderedcms/models/page_models.py
Line 1794 in fa852eb
I was going to write a pull request for this issue, but while the solution for the get_context() method was obvious (use the request context to find the appropriate setting), I really didn't know the right way to handle the retrieval of the setting for the
save()method which lacks a request context and therefore the method doesn't really know the appropriate site to pull the setting from. A fix that addressed the API key setting in the template context but not at the underlying model save() (and therefore could result in different results) seemed wrong so I never finished the patch/pull request.vsalvino commentedon Jul 14, 2020
Considering the
save()belongs to a Page object, each page is tied to a Site (via its chain of parent pages, all the way up to the Root page). So we should be able to get the correct site on page. It would require a bit of introspection into Wagtail's Page object.vsalvino commentedon Aug 2, 2020
@wamcvey I created a separate issue for the site settings problem (Issue #341) and attempted a "simple" fix (PR #342) which proved to be a more systemic issue. Please continue discussion there.