def post(self, request, *args, **kwargs):
if not request.user.has_perm('file.manage_resources'):
raise PermissionDenied
parent = self._get_folder()
form = ResourceFolderForm(folder=parent, data=self.request.POST)
folder = ResourceFolder.objects.filter(parent=parent, name=form.data['name']).first()
if folder is not None:
messages.add_message(request, messages.ERROR, 'Un dossier existe déjà avec ce nom')
else:
folder = ResourceFolder.objects.create(
name=form.data['name'],
parent=parent
)
messages.add_message(request, messages.SUCCESS, 'Dossier créé')
return redirect(reverse('resource-folder-list', kwargs={'folder_pk': folder.id}))
评论列表
文章目录