Ejemplo n.º 1
0
def language_settings_edit(request, language):
    from pootle_language.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=language)

    response = {}
    rcode = 400

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

        if language.description:
            the_html = language.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": language.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")
Ejemplo n.º 2
0
def language_settings_edit(request, language):
    from pootle_language.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=language)

    response = {}
    rcode = 400

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

        if language.description:
            the_html = language.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":
        reverse('pootle-language-admin-settings', args=[language.code]),
    }
    t = loader.get_template('admin/_settings_form.html')
    c = RequestContext(request, context)
    response['form'] = t.render(c)

    return HttpResponse(jsonify(response),
                        status=rcode,
                        mimetype="application/json")
Ejemplo n.º 3
0
def language_settings_edit(request, language_code):
    language = get_object_or_404(Language, code=language_code)
    request.permissions = get_matching_permissions(
            get_profile(request.user), language.directory
    )
    if not check_permission('administrate', request):
        raise PermissionDenied

    from pootle_language.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=language)
    response = {}
    if form.is_valid():
        form.save()
        response = {
                "intro": form.cleaned_data['description'],
                "valid": True,
        }
    context = {
            "form": form,
            "form_action": language.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")
Ejemplo n.º 4
0
def language_index(request, language_code):
    language = get_object_or_404(Language, code=language_code)
    request.permissions = get_matching_permissions(get_profile(request.user), language.directory)

    if not check_permission("view", request):
        raise PermissionDenied

    projects = language.translationproject_set.order_by('project__fullname')
    projectcount = len(projects)
    items = (make_project_item(translate_project) for translate_project in projects.iterator())

    totals = language.getquickstats()
    average = nice_percentage(totals['translatedsourcewords'] * 100.0 / max(totals['totalsourcewords'], 1))
    topstats = gentopstats_language(language)

    templatevars = {
        'language': {
          'code': language.code,
          'name': tr_lang(language.fullname),
          'description': language.description,
          'stats': ungettext('%(projects)d project, %(average)d%% translated',
                             '%(projects)d projects, %(average)d%% translated',
                             projectcount, {"projects": projectcount, "average": average}),
        },
        'feed_path': '%s/' % language.code,
        'description': language.description,
        'projects': items,
        'statsheadings': get_stats_headings(),
        'topstats': topstats,
        }
    if check_permission('administrate', request):
        from pootle_language.forms import DescriptionForm
        templatevars['form'] = DescriptionForm(instance=language)

    return render_to_response("language/language_index.html", templatevars, context_instance=RequestContext(request))
Ejemplo n.º 5
0
def overview(request, language):
    can_edit = check_permission('administrate', request)

    projects = language.translationproject_set.order_by('project__fullname')
    projectcount = len(projects)
    items = (make_project_item(translate_project)
             for translate_project in projects.iterator())

    totals = language.getquickstats()
    average = nice_percentage(totals['translatedsourcewords'] * 100.0 /
                              max(totals['totalsourcewords'], 1))
    topstats = gentopstats_language(language)

    table_fields = [
        'name', 'progress', 'total', 'need-translation', 'activity'
    ]
    table = {
        'id': 'language',
        'proportional': False,
        'fields': table_fields,
        'headings': get_table_headings(table_fields),
        'items': items,
    }

    templatevars = {
        'language': {
            'code':
            language.code,
            'name':
            tr_lang(language.fullname),
            'description':
            language.description,
            'summary':
            ungettext('%(projects)d project, %(average)d%% translated',
                      '%(projects)d projects, %(average)d%% translated',
                      projectcount, {
                          "projects": projectcount,
                          "average": average
                      }),
        },
        'feed_path': '%s/' % language.code,
        'topstats': topstats,
        'can_edit': can_edit,
        'table': table,
    }

    if can_edit:
        from pootle_language.forms import DescriptionForm
        templatevars['form'] = DescriptionForm(instance=language)

    return render_to_response("language/overview.html",
                              templatevars,
                              context_instance=RequestContext(request))
Ejemplo n.º 6
0
Archivo: views.py Proyecto: notz/pootle
def language_settings_edit(request, language_code):
    language = get_object_or_404(Language, code=language_code)
    request.permissions = get_matching_permissions(get_profile(request.user),
                                                   language.directory)
    if not check_permission('administrate', request):
        raise PermissionDenied

    from pootle_language.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=language)

    response = {}
    rcode = 400

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

        if language.description_html:
            the_html = language.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": language.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")
Ejemplo n.º 7
0
def language_settings_edit(request, language_code):
    language = get_object_or_404(Language, code=language_code)
    request.permissions = get_matching_permissions(
            get_profile(request.user), language.directory
    )
    if not check_permission('administrate', request):
        raise PermissionDenied

    from pootle_language.forms import DescriptionForm
    form = DescriptionForm(request.POST, instance=language)

    response = {}
    rcode = 400

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

        if language.description_html:
            the_html = language.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": language.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")
Ejemplo n.º 8
0
def overview(request, language):
    can_edit = check_permission('administrate', request)

    translation_projects = language.get_children() \
                                   .order_by('project__fullname')
    user_tps = filter(lambda x: x.is_accessible_by(request.user),
                      translation_projects)
    items = (make_project_item(tp) for tp in user_tps)

    table_fields = [
        'name', 'progress', 'total', 'need-translation', 'suggestions',
        'critical', 'last-updated', 'activity'
    ]
    table = {
        'id': 'language',
        'fields': table_fields,
        'headings': get_table_headings(table_fields),
        'items': items,
    }

    ctx = get_overview_context(request)
    ctx.update({
        'language': {
            'code': language.code,
            'name': tr_lang(language.fullname),
            'description': language.description,
        },
        'feed_path': '%s/' % language.code,
        'can_edit': can_edit,
        'table': table,
        'browser_extends': 'languages/base.html',
        'browser_body_id': 'languageoverview',
    })

    if can_edit:
        from pootle_language.forms import DescriptionForm
        ctx.update({
            'form':
            DescriptionForm(instance=language),
            'form_action':
            reverse('pootle-language-admin-settings', args=[language.code]),
        })

    return render_to_response("browser/overview.html",
                              ctx,
                              context_instance=RequestContext(request))