Esempio n. 1
0
def project_settings_edit(request, project):
    from pootle_project.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=project)

    response = {}
    rcode = 400

    if form.is_valid():
        form.save()
        rcode = 200

        if project.description:
            the_html = project.description
        else:
            the_html = u"".join([
                u'<p class="placeholder muted">',
                _(u"No description yet."),
                u"</p>",
            ])

        response["description"] = the_html

    context = {
        "form": form,
        "form_action": project.pootle_path + "edit_settings.html",
    }
    t = loader.get_template('admin/general_settings_form.html')
    c = RequestContext(request, context)
    response['form'] = t.render(c)

    return HttpResponse(jsonify(response), status=rcode,
                        mimetype="application/json")
Esempio n. 2
0
def project_settings_edit(request, project):
    from pootle_project.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=project)

    response = {}
    rcode = 400

    if form.is_valid():
        form.save()
        rcode = 200

        if project.description:
            the_html = project.description
        else:
            the_html = u"".join([
                u'<p class="placeholder muted">',
                _(u"No description yet."),
                u"</p>",
            ])

        response["description"] = the_html

    context = {
        "form": form,
        "form_action": project.pootle_path + "edit_settings.html",
    }
    t = loader.get_template('admin/general_settings_form.html')
    c = RequestContext(request, context)
    response['form'] = t.render(c)

    return HttpResponse(jsonify(response),
                        status=rcode,
                        mimetype="application/json")
Esempio n. 3
0
def project_settings_edit(request, project):
    from pootle_project.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=project)

    response = {}
    status = 400

    if form.is_valid():
        form.save()
        status = 200

        if project.description:
            the_html = project.description
        else:
            the_html = u"".join([
                u'<p class="placeholder muted">',
                _(u"No description yet."),
                u"</p>",
            ])

        response["description"] = the_html

    ctx = {
        "form": form,
        "form_action": reverse('pootle-project-admin-settings',
                               args=[project.code]),
    }

    template = loader.get_template('admin/_settings_form.html')
    response['form'] = template.render(RequestContext(request, ctx))

    return HttpResponse(jsonify(response), status=status,
                        mimetype="application/json")
Esempio n. 4
0
def project_settings_edit(request, project_code):
    project = get_object_or_404(Project, code=project_code)
    request.permissions = get_matching_permissions(
            get_profile(request.user), project.directory
    )
    if not check_permission('administrate', request):
        raise PermissionDenied

    from pootle_project.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=project)
    response = {}
    if form.is_valid():
        form.save()
        response = {
                "intro": form.cleaned_data['description'],
                "valid": True,
        }
    context = {
            "form": form,
            "form_action": project.pootle_path + "edit_settings.html",
    }
    t = loader.get_template('admin/general_settings_form.html')
    c = RequestContext(request, context)
    response['form'] = t.render(c)

    return HttpResponse(jsonify(response), mimetype="application/json")
Esempio n. 5
0
def project_settings_edit(request, project):
    from pootle_project.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=project)

    response = {}
    status = 400

    if form.is_valid():
        form.save()
        status = 200

        if project.description:
            the_html = project.description
        else:
            the_html = u"".join([
                u'<p class="placeholder muted">',
                _(u"No description yet."),
                u"</p>",
            ])

        response["description"] = the_html

    ctx = {
        "form":
        form,
        "form_action":
        reverse('pootle-project-admin-settings', args=[project.code]),
    }

    template = loader.get_template('admin/_settings_form.html')
    response['form'] = template.render(RequestContext(request, ctx))

    return HttpResponse(jsonify(response),
                        status=status,
                        mimetype="application/json")
Esempio n. 6
0
def project_settings_edit(request, project_code):
    project = get_object_or_404(Project, code=project_code)
    request.permissions = get_matching_permissions(get_profile(request.user),
                                                   project.directory)
    if not check_permission('administrate', request):
        raise PermissionDenied

    from pootle_project.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=project)

    response = {}
    rcode = 400

    if form.is_valid():
        form.save()
        rcode = 200

        if project.description:
            the_html = project.description
        else:
            the_html = u"".join([
                u'<p class="placeholder muted">',
                _(u"No description yet."),
                u"</p>",
            ])

        response["description"] = the_html

    context = {
        "form": form,
        "form_action": project.pootle_path + "edit_settings.html",
    }
    t = loader.get_template('admin/general_settings_form.html')
    c = RequestContext(request, context)
    response['form'] = t.render(c)

    return HttpResponse(jsonify(response), status=rcode,
                        mimetype="application/json")
Esempio n. 7
0
def project_settings_edit(request, project_code):
    project = get_object_or_404(Project, code=project_code)
    request.permissions = get_matching_permissions(get_profile(request.user),
                                                   project.directory)
    if not check_permission('administrate', request):
        raise PermissionDenied

    from pootle_project.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=project)

    response = {}
    rcode = 400

    if form.is_valid():
        form.save()
        rcode = 200

        if project.description_html:
            the_html = project.description_html
        else:
            the_html = u"".join([
                u'<p class="placeholder muted">',
                _(u"No description yet."), u"</p>"
            ])

        response["description_html"] = the_html

    context = {
        "form": form,
        "form_action": project.pootle_path + "edit_settings.html",
    }
    t = loader.get_template('admin/general_settings_form.html')
    c = RequestContext(request, context)
    response['form'] = t.render(c)

    return HttpResponse(jsonify(response),
                        status=rcode,
                        mimetype="application/json")