当前位置: 首页>>代码示例>>Python>>正文


Python helper.get_project函数代码示例

本文整理汇总了Python中trans.views.helper.get_project函数的典型用法代码示例。如果您正苦于以下问题:Python get_project函数的具体用法?Python get_project怎么用?Python get_project使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_project函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: data_project

def data_project(request, project):
    obj = get_project(request, project)
    return render_to_response('data.html', RequestContext(request, {
        'object': obj,
        'api_docs': weblate.get_doc_url('api', 'exports'),
        'rss_docs': weblate.get_doc_url('api', 'rss'),
    }))
开发者ID:thecantero,项目名称:weblate,代码行数:7,代码来源:basic.py

示例2: update_project

def update_project(request, project):
    obj = get_project(request, project)

    if obj.do_update(request):
        messages.info(request, _('All repositories were updated.'))

    return redirect(obj)
开发者ID:fluentglobe,项目名称:our,代码行数:7,代码来源:git.py

示例3: reset_project

def reset_project(request, project):
    obj = get_project(request, project)

    if obj.do_reset(request):
        messages.info(request, _('All repositories have been reset.'))

    return HttpResponseRedirect(obj.get_absolute_url())
开发者ID:ChrisOelmueller,项目名称:weblate,代码行数:7,代码来源:git.py

示例4: commit_project

def commit_project(request, project):
    obj = get_project(request, project)
    obj.commit_pending(request)

    messages.info(request, _('All pending translations were committed.'))

    return redirect(obj)
开发者ID:fluentglobe,项目名称:our,代码行数:7,代码来源:git.py

示例5: commit_project

def commit_project(request, project):
    obj = get_project(request, project)
    obj.commit_pending(request)

    messages.info(request, _('All pending translations were committed.'))

    return HttpResponseRedirect(obj.get_absolute_url())
开发者ID:ChrisOelmueller,项目名称:weblate,代码行数:7,代码来源:git.py

示例6: download_dictionary

def download_dictionary(request, project, lang):
    """
    Exports dictionary into various formats.
    """
    prj = get_project(request, project)
    lang = get_object_or_404(Language, code=lang)

    # Parse parameters
    export_format = None
    if "format" in request.GET:
        export_format = request.GET["format"]
    if not export_format in ["csv", "po", "tbx"]:
        export_format = "csv"

    # Grab all words
    words = Dictionary.objects.filter(project=prj, language=lang).order_by("source")

    # Translate toolkit based export
    if export_format in ("po", "tbx"):
        return download_dictionary_ttkit(export_format, prj, lang, words)

    # Manually create CSV file
    response = HttpResponse(mimetype="text/csv; charset=utf-8")
    filename = "dictionary-%s-%s.csv" % (prj.slug, lang.code)
    response["Content-Disposition"] = "attachment; filename=%s" % filename

    writer = csv.writer(response)

    for word in words.iterator():
        writer.writerow((word.source.encode("utf8"), word.target.encode("utf8")))

    return response
开发者ID:kasunchathuranga,项目名称:weblate,代码行数:32,代码来源:dictionary.py

示例7: reset_project

def reset_project(request, project):
    obj = get_project(request, project)

    if obj.do_reset(request):
        messages.info(request, _('All repositories have been reset.'))

    return redirect(obj)
开发者ID:fluentglobe,项目名称:our,代码行数:7,代码来源:git.py

示例8: edit_dictionary

def edit_dictionary(request, project, lang):
    prj = get_project(request, project)
    lang = get_object_or_404(Language, code=lang)
    word = get_object_or_404(Dictionary, project=prj, language=lang, id=request.GET.get("id"))

    if request.method == "POST":
        form = WordForm(request.POST)
        if form.is_valid():
            word.source = form.cleaned_data["source"]
            word.target = form.cleaned_data["target"]
            word.save()
            return HttpResponseRedirect(reverse("show_dictionary", kwargs={"project": prj.slug, "lang": lang.code}))
    else:
        form = WordForm(initial={"source": word.source, "target": word.target})

    return render_to_response(
        "edit_dictionary.html",
        RequestContext(
            request,
            {
                "title": _("%(language)s dictionary for %(project)s") % {"language": lang, "project": prj},
                "project": prj,
                "language": lang,
                "form": form,
            },
        ),
    )
开发者ID:kasunchathuranga,项目名称:weblate,代码行数:27,代码来源:dictionary.py

示例9: push_project

def push_project(request, project):
    obj = get_project(request, project)

    if obj.do_push(request):
        messages.info(request, _('All repositories were pushed.'))

    return HttpResponseRedirect(obj.get_absolute_url())
开发者ID:ChrisOelmueller,项目名称:weblate,代码行数:7,代码来源:git.py

示例10: show_project

def show_project(request, project):
    obj = get_project(request, project)

    dicts = Dictionary.objects.filter(
        project=obj
    ).values_list(
        'language', flat=True
    ).distinct()

    last_changes = Change.objects.prefetch().filter(
        Q(translation__subproject__project=obj) |
        Q(dictionary__project=obj)
    ).order_by('-timestamp')[:10]

    return render_to_response('project.html', RequestContext(request, {
        'object': obj,
        'dicts': Language.objects.filter(id__in=dicts),
        'last_changes': last_changes,
        'last_changes_rss': reverse(
            'rss-project',
            kwargs={'project': obj.slug}
        ),
        'last_changes_url': urlencode(
            {'project': obj.slug}
        ),
    }))
开发者ID:thecantero,项目名称:weblate,代码行数:26,代码来源:basic.py

示例11: push_project

def push_project(request, project):
    obj = get_project(request, project)

    if obj.do_push(request):
        messages.info(request, _('All repositories were pushed.'))

    return redirect(obj)
开发者ID:fluentglobe,项目名称:our,代码行数:7,代码来源:git.py

示例12: edit_dictionary

def edit_dictionary(request, project, lang):
    prj = get_project(request, project)
    lang = get_object_or_404(Language, code=lang)
    word = get_object_or_404(
        Dictionary,
        project=prj,
        language=lang,
        id=request.GET.get('id')
    )

    if request.method == 'POST':
        form = WordForm(request.POST)
        if form.is_valid():
            word.source = form.cleaned_data['source']
            word.target = form.cleaned_data['target']
            word.save()
            return HttpResponseRedirect(reverse(
                'show_dictionary',
                kwargs={'project': prj.slug, 'lang': lang.code}
            ))
    else:
        form = WordForm(
            initial={'source': word.source, 'target': word.target}
        )

    return render_to_response('edit_dictionary.html', RequestContext(request, {
        'title': _('%(language)s dictionary for %(project)s') %
        {'language': lang, 'project': prj},
        'project': prj,
        'language': lang,
        'form': form,
    }))
开发者ID:henricsson,项目名称:weblate,代码行数:32,代码来源:dictionary.py

示例13: show_dictionary

def show_dictionary(request, project, lang):
    prj = get_project(request, project)
    lang = get_object_or_404(Language, code=lang)

    if (request.method == 'POST'
            and request.user.has_perm('trans.add_dictionary')):
        form = WordForm(request.POST)
        if form.is_valid():
            Dictionary.objects.create(
                project=prj,
                language=lang,
                source=form.cleaned_data['source'],
                target=form.cleaned_data['target']
            )
        return HttpResponseRedirect(request.get_full_path())
    else:
        form = WordForm()

    uploadform = DictUploadForm()

    words = Dictionary.objects.filter(
        project=prj, language=lang
    ).order_by('source')

    limit = request.GET.get('limit', 25)
    page = request.GET.get('page', 1)

    letterform = LetterForm(request.GET)

    if letterform.is_valid() and letterform.cleaned_data['letter'] != '':
        words = words.filter(
            source__istartswith=letterform.cleaned_data['letter']
        )
        letter = letterform.cleaned_data['letter']
    else:
        letter = ''

    paginator = Paginator(words, limit)

    try:
        words = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        words = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        words = paginator.page(paginator.num_pages)

    return render_to_response('dictionary.html', RequestContext(request, {
        'title': _('%(language)s dictionary for %(project)s') %
        {'language': lang, 'project': prj},
        'project': prj,
        'language': lang,
        'words': words,
        'form': form,
        'uploadform': uploadform,
        'letterform': letterform,
        'letter': letter,
    }))
开发者ID:henricsson,项目名称:weblate,代码行数:59,代码来源:dictionary.py

示例14: delete_dictionary

def delete_dictionary(request, project, lang):
    prj = get_project(request, project)
    lang = get_object_or_404(Language, code=lang)
    word = get_object_or_404(Dictionary, project=prj, language=lang, id=request.POST.get("id"))

    word.delete()

    return HttpResponseRedirect(reverse("show_dictionary", kwargs={"project": prj.slug, "lang": lang.code}))
开发者ID:kasunchathuranga,项目名称:weblate,代码行数:8,代码来源:dictionary.py

示例15: data_project

def data_project(request, project):
    obj = get_project(request, project)
    site = Site.objects.get_current()
    return render_to_response('data.html', RequestContext(request, {
        'object': obj,
        'site_domain': site.domain,
        'api_docs': weblate.get_doc_url('api', 'exports'),
        'rss_docs': weblate.get_doc_url('api', 'rss'),
    }))
开发者ID:henricsson,项目名称:weblate,代码行数:9,代码来源:basic.py


注:本文中的trans.views.helper.get_project函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。