Make that Map.get_anonymous_edit_url returns full URL
This commit is contained in:
parent
7f2545f09b
commit
eb32dcc9b6
5 changed files with 8 additions and 14 deletions
|
@ -40,8 +40,7 @@ class AnonymousMapPermissionsForm(forms.ModelForm):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(AnonymousMapPermissionsForm, self).__init__(*args, **kwargs)
|
super(AnonymousMapPermissionsForm, self).__init__(*args, **kwargs)
|
||||||
full_secret_link = "%s%s" % (settings.SITE_URL, self.instance.get_anonymous_edit_url())
|
help_text = _('Secret edit link is %s') % self.instance.get_anonymous_edit_url()
|
||||||
help_text = _('Secret edit link is %s') % full_secret_link
|
|
||||||
self.fields['edit_status'].help_text = _(help_text)
|
self.fields['edit_status'].help_text = _(help_text)
|
||||||
|
|
||||||
STATUS = (
|
STATUS = (
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
from umap.models import Map
|
from umap.models import Map
|
||||||
|
|
||||||
|
@ -25,4 +24,4 @@ class Command(BaseCommand):
|
||||||
self.abort('Map with pk {} not found'.format(pk))
|
self.abort('Map with pk {} not found'.format(pk))
|
||||||
if map_.owner:
|
if map_.owner:
|
||||||
self.abort('Map is not anonymous (owner: {})'.format(map_.owner))
|
self.abort('Map is not anonymous (owner: {})'.format(map_.owner))
|
||||||
print(settings.SITE_URL + map_.get_anonymous_edit_url())
|
print(map_.get_anonymous_edit_url())
|
||||||
|
|
|
@ -162,7 +162,8 @@ class Map(NamedModel):
|
||||||
def get_anonymous_edit_url(self):
|
def get_anonymous_edit_url(self):
|
||||||
signer = Signer()
|
signer = Signer()
|
||||||
signature = signer.sign(self.pk)
|
signature = signer.sign(self.pk)
|
||||||
return reverse("map_anonymous_edit_url", kwargs={"signature": signature})
|
path = reverse("map_anonymous_edit_url", kwargs={"signature": signature})
|
||||||
|
return settings.SITE_URL + path
|
||||||
|
|
||||||
def is_anonymous_owner(self, request):
|
def is_anonymous_owner(self, request):
|
||||||
if self.owner:
|
if self.owner:
|
||||||
|
|
|
@ -45,8 +45,7 @@ def test_create(client, user, post_data):
|
||||||
'url': '/en/user/Joe/'
|
'url': '/en/user/Joe/'
|
||||||
},
|
},
|
||||||
'editors': [],
|
'editors': [],
|
||||||
'anonymous_edit_url': ('http://umap.org'
|
'anonymous_edit_url': created_map.get_anonymous_edit_url()
|
||||||
+ created_map.get_anonymous_edit_url())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -466,13 +466,9 @@ class PermissionsMixin:
|
||||||
for editor in self.object.editors.all()
|
for editor in self.object.editors.all()
|
||||||
]
|
]
|
||||||
if not self.object.owner and self.object.is_anonymous_owner(self.request):
|
if not self.object.owner and self.object.is_anonymous_owner(self.request):
|
||||||
permissions["anonymous_edit_url"] = self.get_anonymous_edit_url()
|
permissions["anonymous_edit_url"] = self.object.get_anonymous_edit_url()
|
||||||
return permissions
|
return permissions
|
||||||
|
|
||||||
def get_anonymous_edit_url(self):
|
|
||||||
anonymous_url = self.object.get_anonymous_edit_url()
|
|
||||||
return settings.SITE_URL + anonymous_url
|
|
||||||
|
|
||||||
|
|
||||||
class MapView(MapDetailMixin, PermissionsMixin, DetailView):
|
class MapView(MapDetailMixin, PermissionsMixin, DetailView):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
@ -541,7 +537,7 @@ class MapCreate(FormLessEditMixin, PermissionsMixin, CreateView):
|
||||||
if self.request.user.is_authenticated:
|
if self.request.user.is_authenticated:
|
||||||
form.instance.owner = self.request.user
|
form.instance.owner = self.request.user
|
||||||
self.object = form.save()
|
self.object = form.save()
|
||||||
anonymous_url = self.get_anonymous_edit_url()
|
anonymous_url = self.object.get_anonymous_edit_url()
|
||||||
if not self.request.user.is_authenticated:
|
if not self.request.user.is_authenticated:
|
||||||
msg = _(
|
msg = _(
|
||||||
"Your map has been created! If you want to edit this map from "
|
"Your map has been created! If you want to edit this map from "
|
||||||
|
@ -676,7 +672,7 @@ class MapClone(PermissionsMixin, View):
|
||||||
msg = _(
|
msg = _(
|
||||||
"Your map has been cloned! If you want to edit this map from "
|
"Your map has been cloned! If you want to edit this map from "
|
||||||
"another computer, please use this link: %(anonymous_url)s"
|
"another computer, please use this link: %(anonymous_url)s"
|
||||||
% {"anonymous_url": self.get_anonymous_edit_url()}
|
% {"anonymous_url": self.object.get_anonymous_edit_url()}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
msg = _("Congratulations, your map has been cloned!")
|
msg = _("Congratulations, your map has been cloned!")
|
||||||
|
|
Loading…
Reference in a new issue