def createdir(self, request): "Create Directory" from filebrowser.forms import CreateDirForm query = request.GET path = u'%s' % os.path.join(self.directory, query.get('dir', '')) if request.method == 'POST': form = CreateDirForm(path, request.POST, filebrowser_site=self) if form.is_valid(): server_path = os.path.join(path, form.cleaned_data['name']) try: signals.filebrowser_pre_createdir.send(sender=request, path=server_path, name=form.cleaned_data['name'], site=self) self.storage.makedirs(server_path) signals.filebrowser_post_createdir.send(sender=request, path=server_path, name=form.cleaned_data['name'], site=self) messages.add_message(request, messages.SUCCESS, _('The Folder %s was successfully created.') % form.cleaned_data['name']) redirect_url = reverse("filebrowser:fb_browse", current_app=self.name) + query_helper(query, "ot=desc,o=date", "ot,o,filter_type,filter_date,q,p") return HttpResponseRedirect(redirect_url) except OSError as e: errno = e.args[0] if errno == 13: form.errors['name'] = forms.util.ErrorList([_('Permission denied.')]) else: form.errors['name'] = forms.util.ErrorList([_('Error creating folder.')]) else: form = CreateDirForm(path, filebrowser_site=self) return render_to_response('filebrowser/createdir.html', { 'form': form, 'query': query, 'title': _(u'New Folder'), 'settings_var': get_settings_var(directory=self.directory), 'breadcrumbs': get_breadcrumbs(query, query.get('dir', '')), 'breadcrumbs_title': _(u'New Folder'), 'filebrowser_site': self }, context_instance=Context(request, current_app=self.name))
def createdir(self, request): """ Create Directory. """ from filebrowser.forms import CreateDirForm query = request.GET path = u'%s' % os.path.join(self.directory, query.get('dir', '')) if request.method == 'POST': form = CreateDirForm(path, request.POST, filebrowser_site=self) if form.is_valid(): server_path = os.path.join(path, form.cleaned_data['name']) try: self.filebrowser_pre_createdir.send(sender=request, path=server_path, name=form.cleaned_data['name']) self.storage.makedirs(server_path) # os.mkdir(server_path) # os.chmod(server_path, 0775) # ??? PERMISSIONS self.filebrowser_post_createdir.send(sender=request, path=server_path, name=form.cleaned_data['name']) messages.add_message(request, messages.SUCCESS, _('The Folder %s was successfully created.') % form.cleaned_data['name']) redirect_url = reverse("filebrowser:fb_browse", current_app=self.name) + query_helper(query, "ot=desc,o=date", "ot,o,filter_type,filter_date,q,p") return HttpResponseRedirect(redirect_url) except OSError, (errno, strerror): if errno == 13: form.errors['name'] = forms.util.ErrorList([_('Permission denied.')]) else: form.errors['name'] = forms.util.ErrorList([_('Error creating folder.')])
def createdir(self, request): "Create Directory" from filebrowser.forms import CreateDirForm query = request.GET path = u"%s" % os.path.join(self.directory, query.get("dir", "")) if request.method == "POST": form = CreateDirForm(path, request.POST, filebrowser_site=self) if form.is_valid(): server_path = os.path.join(path, form.cleaned_data["name"]) try: signals.filebrowser_pre_createdir.send( sender=request, path=server_path, name=form.cleaned_data["name"], site=self ) self.storage.makedirs(server_path) signals.filebrowser_post_createdir.send( sender=request, path=server_path, name=form.cleaned_data["name"], site=self ) messages.add_message( request, messages.SUCCESS, _("The Folder %s was successfully created.") % form.cleaned_data["name"], ) redirect_url = reverse("filebrowser:fb_browse", current_app=self.name) + query_helper( query, "ot=desc,o=date", "ot,o,filter_type,filter_date,q,p" ) return HttpResponseRedirect(redirect_url) except OSError as e: errno = e.args[0] if errno == 13: form.errors["name"] = forms.util.ErrorList([_("Permission denied.")]) else: form.errors["name"] = forms.util.ErrorList([_("Error creating folder.")]) else: form = CreateDirForm(path, filebrowser_site=self) return render_to_response( "filebrowser/createdir.html", { "form": form, "query": query, "title": _(u"New Folder"), "settings_var": get_settings_var(directory=self.directory), "breadcrumbs": get_breadcrumbs(query, query.get("dir", "")), "breadcrumbs_title": _(u"New Folder"), "filebrowser_site": self, }, context_instance=Context(request, current_app=self.name), )
def createdir(self, request): """ Create Directory. """ from filebrowser.forms import CreateDirForm query = request.GET abs_path = u"%s" % os.path.join(self.media_root, query.get("dir", "")) if request.method == "POST": form = CreateDirForm(abs_path, request.POST) if form.is_valid(): abs_server_path = os.path.join(abs_path, form.cleaned_data["name"]) try: self.filebrowser_pre_createdir.send( sender=request, path=abs_server_path, name=form.cleaned_data["name"] ) os.mkdir(abs_server_path) os.chmod(abs_server_path, 0775) # ??? PERMISSIONS self.filebrowser_post_createdir.send( sender=request, path=abs_server_path, name=form.cleaned_data["name"] ) messages.add_message( request, messages.SUCCESS, _("The Folder %s was successfully created.") % form.cleaned_data["name"], ) redirect_url = reverse("filebrowser:fb_browse", current_app=self.name) + query_helper( query, "ot=desc,o=date", "ot,o,filter_type,filter_date,q,p" ) return HttpResponseRedirect(redirect_url) except OSError, (errno, strerror): if errno == 13: form.errors["name"] = forms.util.ErrorList([_("Permission denied.")]) else: form.errors["name"] = forms.util.ErrorList([_("Error creating folder.")])
form.cleaned_data['name']) redirect_url = reverse( "filebrowser:fb_browse", current_app=self.name) + query_helper( query, "ot=desc,o=date", "ot,o,filter_type,filter_date,q,p") return HttpResponseRedirect(redirect_url) except OSError, (errno, strerror): if errno == 13: form.errors['name'] = forms.util.ErrorList( [_('Permission denied.')]) else: form.errors['name'] = forms.util.ErrorList( [_('Error creating folder.')]) else: form = CreateDirForm(path, filebrowser_site=self) return render_to_response( 'filebrowser/createdir.html', { 'form': form, 'query': query, 'title': _(u'New Folder'), 'settings_var': get_settings_var(directory=self.directory), 'breadcrumbs': get_breadcrumbs(query, query.get('dir', '')), 'breadcrumbs_title': _(u'New Folder'), 'filebrowser_site': self }, context_instance=Context(request, current_app=self.name)) def upload(self, request): """
form.cleaned_data['name']) redirect_url = reverse( "filebrowser:fb_browse", current_app=self.name) + query_helper( query, "ot=desc,o=date", "ot,o,filter_type,filter_date,q,p") return HttpResponseRedirect(redirect_url) except OSError, (errno, strerror): if errno == 13: form.errors['name'] = forms.util.ErrorList( [_('Permission denied.')]) else: form.errors['name'] = forms.util.ErrorList( [_('Error creating folder.')]) else: form = CreateDirForm(path, site=self) return render_to_response( 'filebrowser/createdir.html', { 'form': form, 'query': query, 'title': _(u'New Folder'), 'settings_var': get_settings_var(directory=self.directory), 'breadcrumbs': get_breadcrumbs(query, query.get('dir', '')), 'breadcrumbs_title': _(u'New Folder'), 'site': self }, context_instance=Context(request, current_app=self.name)) def upload(self, request): """
request, messages.SUCCESS, _('The Folder %s was successfully created.') % form.cleaned_data['name']) redirect_url = reverse("fb_browse") + query_helper( query, "ot=desc,o=date", "ot,o,filter_type,filter_date,q,p") return HttpResponseRedirect(redirect_url) except OSError, (errno, strerror): if errno == 13: form.errors['name'] = forms.util.ErrorList( [_('Permission denied.')]) else: form.errors['name'] = forms.util.ErrorList( [_('Error creating folder.')]) else: form = CreateDirForm(abs_path) return render_to_response( 'filebrowser/createdir.html', { 'form': form, 'query': query, 'title': _(u'New Folder'), 'settings_var': get_settings_var(), 'breadcrumbs': get_breadcrumbs(query, query.get('dir', '')), 'breadcrumbs_title': _(u'New Folder') }, context_instance=Context(request)) createdir = staff_member_required(never_cache(createdir))