Only return anonymous_url in anonymous context
Otherwise the frontend will treat map as anonymous even with and owner and display a wrong message creation. Also, this edit URL does not make sense (and will not work) when there is an owner.
This commit is contained in:
parent
90f7680d8d
commit
51a904dc07
2 changed files with 3 additions and 3 deletions
|
@ -42,7 +42,6 @@ def test_create(client, user, post_data):
|
|||
"share_status": 1,
|
||||
"owner": {"id": user.pk, "name": "Joe", "url": "/en/user/Joe/"},
|
||||
"editors": [],
|
||||
"anonymous_edit_url": created_map.get_anonymous_edit_url(),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -545,9 +545,10 @@ class MapCreate(FormLessEditMixin, PermissionsMixin, CreateView):
|
|||
if self.request.user.is_authenticated:
|
||||
form.instance.owner = self.request.user
|
||||
self.object = form.save()
|
||||
anonymous_url = self.object.get_anonymous_edit_url()
|
||||
permissions = self.get_permissions()
|
||||
# User does not have the cookie yet.
|
||||
if not self.object.owner:
|
||||
anonymous_url = self.object.get_anonymous_edit_url()
|
||||
permissions["anonymous_edit_url"] = anonymous_url
|
||||
response = simple_json_response(
|
||||
id=self.object.pk,
|
||||
|
|
Loading…
Reference in a new issue