def folder_edit(request, folder_id): folder = get_object_or_404(Folder, pk=folder_id) if not request.user.is_staff and not request.user.is_superuser and not request.user == folder.user: raise PermissionDenied if request.method == 'POST': form = FolderForm(request.POST) if form.is_valid(): folder.title = form.cleaned_data['title'] try: folder.save() messages.success(request, _(u'Folder edited successfully')) return HttpResponseRedirect(reverse('folder_list')) except Exception, e: messages.error(request, _(u'Error editing folder; %s') % e)
def folder_edit(request, folder_id): folder = get_object_or_404(Folder, pk=folder_id) if not request.user.is_staff and not request.user.is_superuser and not request.user == folder.user: raise PermissionDenied if request.method == 'POST': form = FolderForm(request.POST) if form.is_valid(): folder.title = form.cleaned_data['title'] try: folder.save() messages.success(request, _(u'Folder edited successfully')) return HttpResponseRedirect(reverse('folder_list')) except Exception, e: messages.error(request, _(u'Error editing folder; %s') % e)
def folder_create(request): if request.method == 'POST': form = FolderForm(request.POST) if form.is_valid(): folder, created = Folder.objects.get_or_create(user=request.user, title=form.cleaned_data['title']) if created: messages.success(request, _(u'Folder created successfully')) return HttpResponseRedirect(reverse('folder_list')) else: messages.error(request, _(u'A folder named: %s, already exists.') % form.cleaned_data['title']) else: form = FolderForm() return render_to_response('generic_form.html', { 'title': _(u'create folder'), 'form': form, }, context_instance=RequestContext(request))
def folder_create(request): if request.method == 'POST': form = FolderForm(request.POST) if form.is_valid(): folder, created = Folder.objects.get_or_create( user=request.user, title=form.cleaned_data['title']) if created: messages.success(request, _(u'Folder created successfully')) return HttpResponseRedirect(reverse('folder_list')) else: messages.error( request, _(u'A folder named: %s, already exists.') % form.cleaned_data['title']) else: form = FolderForm() return render_to_response('generic_form.html', { 'title': _(u'create folder'), 'form': form, }, context_instance=RequestContext(request))