def weblink_edit(request, weblink_id, response_format='html'): "WebLink edit page" link = get_object_or_404(WebLink, pk=weblink_id) if not request.user.get_profile().has_permission(link, mode='w'): return user_denied(request, message="You don't have access to this Web Link") if request.POST: if not 'cancel' in request.POST: form = WebLinkForm( request.user.get_profile(), None, request.POST, instance=link) if form.is_valid(): link = form.save() return HttpResponseRedirect(reverse('documents_weblink_view', args=[link.id])) else: return HttpResponseRedirect(reverse('documents_weblink_view', args=[link.id])) else: form = WebLinkForm(request.user.get_profile(), None, instance=link) context = _get_default_context(request) context.update({'form': form, 'link': link}) return render_to_response('documents/weblink_edit', context, context_instance=RequestContext(request), response_format=response_format)
def weblink_add_typed(request, folder_id=None, response_format='html'): "Web link add to preselected folder" folder = None if folder_id: folder = get_object_or_404(Folder, pk=folder_id) if not request.user.get_profile().has_permission(folder, mode='x'): folder = None if request.POST: if not 'cancel' in request.POST: link = WebLink() form = WebLinkForm( request.user.get_profile(), folder_id, request.POST, instance=link) if form.is_valid(): link = form.save() link.set_user_from_request(request) return HttpResponseRedirect(reverse('documents_weblink_view', args=[link.id])) else: return HttpResponseRedirect(reverse('document_index')) else: form = WebLinkForm(request.user.get_profile(), folder_id) context = _get_default_context(request) context.update({'form': form, 'folder': folder}) return render_to_response('documents/weblink_add_typed', context, context_instance=RequestContext(request), response_format=response_format)
def weblink_add(request, response_format='html'): "New web link form" if request.POST: if not 'cancel' in request.POST: link = WebLink() form = WebLinkForm( request.user.get_profile(), None, request.POST, instance=link) if form.is_valid(): link = form.save() link.set_user_from_request(request) return HttpResponseRedirect(reverse('documents_weblink_view', args=[link.id])) else: return HttpResponseRedirect(reverse('document_index')) else: form = WebLinkForm(request.user.get_profile(), None) context = _get_default_context(request) context.update({'form': form, 'file': file}) return render_to_response('documents/weblink_add', context, context_instance=RequestContext(request), response_format=response_format)
def weblink_edit(request, weblink_id, response_format='html'): "WebLink edit page" link = get_object_or_404(WebLink, pk=weblink_id) if not request.user.get_profile().has_permission(link, mode='w'): return user_denied(request, message="You don't have access to this Web Link") if request.POST: if not 'cancel' in request.POST: form = WebLinkForm(request.user.get_profile(), None, request.POST, instance=link) if form.is_valid(): link = form.save() return HttpResponseRedirect( reverse('documents_weblink_view', args=[link.id])) else: return HttpResponseRedirect( reverse('documents_weblink_view', args=[link.id])) else: form = WebLinkForm(request.user.get_profile(), None, instance=link) context = _get_default_context(request) context.update({'form': form, 'link': link}) return render_to_response('documents/weblink_edit', context, context_instance=RequestContext(request), response_format=response_format)
def weblink_add_typed(request, folder_id=None, response_format='html'): "Web link add to preselected folder" folder = None if folder_id: folder = get_object_or_404(Folder, pk=folder_id) if not request.user.get_profile().has_permission(folder, mode='x'): folder = None if request.POST: if not 'cancel' in request.POST: link = WebLink() form = WebLinkForm(request.user.get_profile(), folder_id, request.POST, instance=link) if form.is_valid(): link = form.save() link.set_user_from_request(request) return HttpResponseRedirect( reverse('documents_weblink_view', args=[link.id])) else: return HttpResponseRedirect(reverse('document_index')) else: form = WebLinkForm(request.user.get_profile(), folder_id) context = _get_default_context(request) context.update({'form': form, 'folder': folder}) return render_to_response('documents/weblink_add_typed', context, context_instance=RequestContext(request), response_format=response_format)
def weblink_add(request, response_format='html'): "New web link form" if request.POST: if not 'cancel' in request.POST: link = WebLink() form = WebLinkForm(request.user.get_profile(), None, request.POST, instance=link) if form.is_valid(): link = form.save() link.set_user_from_request(request) return HttpResponseRedirect( reverse('documents_weblink_view', args=[link.id])) else: return HttpResponseRedirect(reverse('document_index')) else: form = WebLinkForm(request.user.get_profile(), None) context = _get_default_context(request) context.update({'form': form, 'file': file}) return render_to_response('documents/weblink_add', context, context_instance=RequestContext(request), response_format=response_format)