本文整理汇总了Python中trans.views.helper.get_project函数的典型用法代码示例。如果您正苦于以下问题:Python get_project函数的具体用法?Python get_project怎么用?Python get_project使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_project函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: update_project
def update_project(request, project):
'''
API hook for updating git repos.
'''
if not appsettings.ENABLE_HOOKS:
return HttpResponseNotAllowed([])
obj = get_project(request, project, True)
perform_update(obj)
return HttpResponse('update triggered')
开发者ID:fluentglobe,项目名称:our,代码行数:9,代码来源:api.py
示例17: 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:kasunchathuranga,项目名称:weblate,代码行数:56,代码来源:dictionary.py
示例18: unlock_project
def unlock_project(request, project):
obj = get_project(request, project)
for subproject in obj.subproject_set.all():
subproject.locked = False
subproject.save()
messages.info(request, _('Project is now open for translation updates.'))
return HttpResponseRedirect(obj.get_absolute_url())
开发者ID:camilonova,项目名称:weblate,代码行数:10,代码来源:lock.py
示例19: show_dictionaries
def show_dictionaries(request, project):
obj = get_project(request, project)
dicts = Translation.objects.filter(subproject__project=obj).values_list("language", flat=True).distinct()
return render_to_response(
"dictionaries.html",
RequestContext(
request, {"title": _("Dictionaries"), "dicts": Language.objects.filter(id__in=dicts), "project": obj}
),
)
开发者ID:kasunchathuranga,项目名称:weblate,代码行数:10,代码来源:dictionary.py
示例20: show_check_project
def show_check_project(request, name, project):
'''
Show checks failing in a project.
'''
prj = get_project(request, project)
try:
check = CHECKS[name]
except KeyError:
raise Http404('No check matches the given query.')
units = Unit.objects.none()
if check.target:
langs = Check.objects.filter(
check=name, project=prj, ignore=False
).values_list('language', flat=True).distinct()
for lang in langs:
checks = Check.objects.filter(
check=name, project=prj, language=lang, ignore=False
).values_list('checksum', flat=True)
res = Unit.objects.filter(
checksum__in=checks,
translation__language=lang,
translation__subproject__project=prj,
translated=True
).values(
'translation__subproject__slug',
'translation__subproject__project__slug'
).annotate(count=Count('id'))
units |= res
if check.source:
checks = Check.objects.filter(
check=name,
project=prj,
language=None,
ignore=False
).values_list(
'checksum', flat=True
)
for subproject in prj.subproject_set.all():
lang = subproject.translation_set.all()[0].language
res = Unit.objects.filter(
checksum__in=checks,
translation__language=lang,
translation__subproject=subproject
).values(
'translation__subproject__slug',
'translation__subproject__project__slug'
).annotate(count=Count('id'))
units |= res
return render_to_response('check_project.html', RequestContext(request, {
'checks': units,
'title': '%s/%s' % (prj.__unicode__(), check.name),
'check': check,
'project': prj,
}))
开发者ID:kasunchathuranga,项目名称:weblate,代码行数:55,代码来源:checks.py
注:本文中的trans.views.helper.get_project函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论