Commits

Yohan Boniface committed c6316ee

Update map delete and clone views (cf yohanboniface/Leaflet.Storage#62)

  • Participants
  • Parent commits 7492bef

Comments (0)

Files changed (2)

leaflet_storage/base_models.py

 from django.core.signing import Signer
 from django.contrib import messages
 from django.template.defaultfilters import slugify
+from django.core.files.base import File
 
 from .fields import DictField
 
         new.pk = None
         if map_inst:
             new.map = map_inst
+        new.geojson = File(new.geojson.file.file)
         new.save()
-        for feature in self.features:
-            feature.clone(datalayer=new)
         return new
 
 

leaflet_storage/views.py

     model = Map
     pk_url_kwarg = "map_id"
 
-    def render_to_response(self, context, **response_kwargs):
-        return render_to_json(self.get_template_names(), response_kwargs, context, self.request)
-
     def delete(self, *args, **kwargs):
         self.object = self.get_object()
         if not self.request.user == self.object.owner:
         self.object.delete()
         return simple_json_response(redirect="/")
 
-    def get_context_data(self, **kwargs):
-        kwargs.update({
-            'action_url': reverse_lazy('map_delete', kwargs={'map_id': self.kwargs['map_id']})
-        })
-        return super(MapDelete, self).get_context_data(**kwargs)
-
 
 class MapClone(View):
 
-    def get(self, *args, **kwargs):
+    def post(self, *args, **kwargs):
         if not getattr(settings, "LEAFLET_STORAGE_ALLOW_ANONYMOUS", False) \
            and not self.request.user.is_authenticated():
             return HttpResponseForbidden('Forbidden')