Ejemplo n.º 1
0
def upload_gateway_flag_file(request):
    """ Flag each language matching the language code in a newline-delimited list of codes as "gateway" languages.
    Unflag any languages which were previously marked as "gateway" languages but are not submitted in the form.
    """
    if request.method == "POST":
        form = UploadGatewayForm(request.POST, request.FILES)
        if form.is_valid():
            Language.objects.filter(gateway_flag=True).update(
                gateway_flag=False)
            Language.objects.filter(
                code__in=form.cleaned_data["languages"]).update(
                    gateway_flag=True)
            messages.add_message(request, messages.SUCCESS,
                                 "Gateway languages updated")
            return redirect("gateway_flag_update")
    else:
        form = UploadGatewayForm(
            initial={
                "languages":
                "\n".join([
                    l.code.lower() for l in Language.objects.filter(
                        gateway_flag=True).order_by("code")
                ])
            })
    return render(request, "resources/gateway_languages_update.html",
                  {"form": form})
Ejemplo n.º 2
0
def upload_gateway_flag_file(request):
    if request.method == "POST":
        form = UploadGatewayForm(request.POST, request.FILES)
        if form.is_valid():
            for lang in Language.objects.filter(code__in=form.cleaned_data["languages"]):
                lang.gateway_flag = True
                lang.source = request.user
                lang.save()
            messages.add_message(request, messages.SUCCESS, "Gateway languages updated")
            return redirect("gateway_flag_update")
    else:
        form = UploadGatewayForm(
            initial={
                "languages": "\n".join([
                    l.code.lower()
                    for l in Language.objects.filter(gateway_flag=True).order_by("code")
                ])
            }
        )
    return render(request, "resources/gateway_languages_update.html", {"form": form})
Ejemplo n.º 3
0
def upload_rtl_list(request):
    if request.method == "POST":
        form = UploadGatewayForm(request.POST)
        if form.is_valid():
            for lang in Language.objects.filter(code__in=form.cleaned_data["languages"]):
                lang.direction = "r"
                lang.source = request.user
                lang.save()
            messages.add_message(request, messages.SUCCESS, "RTL languages updated")
            return redirect("rtl_languages_update")
    else:
        form = UploadGatewayForm(
            initial={
                "languages": "\n".join([
                    l.code.lower()
                    for l in Language.objects.filter(direction="r").order_by("code")
                ])
            }
        )
    return render(request, "resources/rtl_languages_update.html", {"form": form})
Ejemplo n.º 4
0
def upload_gateway_flag_file(request):
    """ Flag each language matching the language code in a newline-delimited list of codes as "gateway" languages.
    Unflag any languages which were previously marked as "gateway" languages but are not submitted in the form.
    """
    if request.method == "POST":
        form = UploadGatewayForm(request.POST, request.FILES)
        if form.is_valid():
            Language.objects.filter(gateway_flag=True).update(gateway_flag=False)
            Language.objects.filter(code__in=form.cleaned_data["languages"]).update(gateway_flag=True)
            messages.add_message(request, messages.SUCCESS, "Gateway languages updated")
            return redirect("gateway_flag_update")
    else:
        form = UploadGatewayForm(
            initial={
                "languages": "\n".join([
                    l.code.lower()
                    for l in Language.objects.filter(gateway_flag=True).order_by("code")
                ])
            }
        )
    return render(request, "resources/gateway_languages_update.html", {"form": form})
Ejemplo n.º 5
0
def upload_rtl_list(request):
    if request.method == "POST":
        form = UploadGatewayForm(request.POST)
        if form.is_valid():
            for lang in Language.objects.filter(
                    code__in=form.cleaned_data["languages"]):
                lang.direction = "r"
                lang.source = request.user
                lang.save()
            messages.add_message(request, messages.SUCCESS,
                                 "RTL languages updated")
            return redirect("rtl_languages_update")
    else:
        form = UploadGatewayForm(
            initial={
                "languages":
                "\n".join([
                    l.code.lower() for l in Language.objects.filter(
                        direction="r").order_by("code")
                ])
            })
    return render(request, "resources/rtl_languages_update.html",
                  {"form": form})