Add the option to edit a page from the Userbar #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have been experimenting with a headless setup and the dynamic Userbar. What I found lacking is the option to edit a page from the Userbar. This PR along with an edit to the feature in the headless branch of bakerydemo will accomplish that.
The changes needed in the backend to accomplish these changes are:
class UserbarView(TemplateView): template_name = Userbar.template_name http_method_names = ["get"] def dispatch(self, request, *args, **kwargs): response = super().dispatch(request, *args, **kwargs) client_url = headless_preview_settings.CLIENT_URLS["default"] response["Access-Control-Allow-Origin"] = client_url return response def get_context_data(self, **kwargs): + object = None + page_id = self.request.GET.get('page_id', None) + if page_id: + object = Page.objects.filter(id=page_id).first() - return Userbar(object=None, position="bottom-left").get_context_data( + return Userbar(object=object, position="bottom-left").get_context_data( super().get_context_data(request=self.request, **kwargs) )