Beispiel #1
0
 def get(self,request,*args,**kwargs):
     # check readme exists
     # check external doc URL
     extension = self.get_object()
     if extension.url:
         return redirect(extension.url)
     if not extension.public:
         if not (request.user == extension.author or request.user.is_superuser):
             return forbidden_response(self.request)
     return super().get(request,*args,**kwargs)
Beispiel #2
0
    def form_valid(self, form):
        if not self.object.can_be_edited_by(self.request.user):
            return forbidden_response(self.request,
                                      "You may not edit this package.")

        messages.info(
            self.request, "The file <code>{filename}</code> has been saved. "
            "If you're editing any items using this package, you'll need to reload the editor for changes to take effect."
            .format(filename=self.get_filename()))
        return super().form_valid(form)
 def dispatch(self,request,*args,**kwargs):
     package = self.get_object()
     if not package.editable:
         return forbidden_response(self.request,"This package is not editable.")
     return super().dispatch(request,*args,**kwargs)
 def dispatch(self, request, *args, **kwargs):
     package = self.get_package()
     if request.user != package.author:
         return forbidden_response("You may not grant other users access to this package.")
     return super().dispatch(request,*args,**kwargs)
Beispiel #5
0
 def dispatch(self, request, *args, **kwargs):
     extension = self.get_object()
     if not extension.editable:
         return forbidden_response(self.request,
                                   "This extension is not editable.")
     return super().dispatch(request, *args, **kwargs)
Beispiel #6
0
 def dispatch(self, request, *args, **kwargs):
     extension = self.get_extension()
     if request.user != extension.author:
         return forbidden_response(
             "You may not grant other users access to this extension.")
     return super().dispatch(request, *args, **kwargs)