Esempio n. 1
0
def resource_delete(request, project_slug, resource_slug):
    """
    Delete a Translation Resource in a specific project.
    """
    resource = get_object_or_404(Resource, project__slug = project_slug,
                                 slug = resource_slug)
    if request.method == 'POST':
        xhr = request.GET.has_key('xhr')

        import copy
        resource_ = copy.copy(resource)
        resource.delete()

        post_resource_delete.send(sender=None, instance=resource_,
            user=request.user)

        # Signal for logging
        messages.success(request,
            _("The translation resource '%s' was deleted.") % resource_.name)

        if xhr:
            response_dict = {'status': 200}
            return HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript')

        return HttpResponseRedirect(reverse('project_detail',
                                    args=[resource.project.slug]),)
    else:
        return render_to_response(
            'resources/resource_confirm_delete.html', {'resource': resource,},
            context_instance=RequestContext(request))
Esempio n. 2
0
def resource_delete(request, project_slug, resource_slug):
    """
    Delete a Translation Resource in a specific project.
    """
    resource = get_object_or_404(Resource,
                                 project__slug=project_slug,
                                 slug=resource_slug)

    if request.method == 'POST':
        import copy
        resource_ = copy.copy(resource)
        resource.delete()

        # Signal for logging
        post_resource_delete.send(sender=None,
                                  instance=resource_,
                                  user=request.user)

        messages.success(
            request,
            _("The translation resource '%s' was deleted.") % resource_.name)

        return HttpResponseRedirect(
            reverse('project_detail', args=[resource.project.slug]), )
    else:
        return HttpResponseRedirect(
            reverse('resource_edit',
                    args=[resource.project.slug, resource.slug]))
Esempio n. 3
0
def resource_delete(request, project_slug, resource_slug):
    """
    Delete a Translation Resource in a specific project.
    """
    resource = get_object_or_404(Resource, project__slug=project_slug,
        slug=resource_slug)

    if request.method == 'POST':
        import copy
        resource_ = copy.copy(resource)
        resource.delete()

        # Signal for logging
        post_resource_delete.send(sender=None, instance=resource_,
            user=request.user)

        messages.success(request,
            _("The translation resource '%s' was deleted.") % resource_.name)

        return HttpResponseRedirect(reverse('project_detail',
                                    args=[resource.project.slug]),)
    else:
        return HttpResponseRedirect(reverse('resource_edit',
            args=[resource.project.slug, resource.slug]))