本文整理汇总了Python中trans.views.helper.get_subproject函数的典型用法代码示例。如果您正苦于以下问题:Python get_subproject函数的具体用法?Python get_subproject怎么用?Python get_subproject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_subproject函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: push_subproject
def push_subproject(request, project, subproject):
obj = get_subproject(request, project, subproject)
if obj.do_push(request):
messages.info(request, _('All repositories were pushed.'))
return redirect(obj)
示例2: commit_subproject
def commit_subproject(request, project, subproject):
obj = get_subproject(request, project, subproject)
obj.commit_pending(request)
messages.info(request, _('All pending translations were committed.'))
return redirect(obj)
示例3: reset_subproject
def reset_subproject(request, project, subproject):
obj = get_subproject(request, project, subproject)
if obj.do_reset(request):
messages.info(request, _('All repositories have been reset.'))
return redirect(obj)
示例4: show_check_subproject
def show_check_subproject(request, name, project, subproject):
'''
Show checks failing in a subproject.
'''
subprj = get_subproject(request, project, subproject)
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=subprj.project,
ignore=False
).values_list(
'language', flat=True
).distinct()
for lang in langs:
checks = Check.objects.filter(
check=name,
project=subprj.project,
language=lang,
ignore=False
).values_list('checksum', flat=True)
res = Unit.objects.filter(
translation__subproject=subprj,
checksum__in=checks,
translation__language=lang,
translated=True
).values(
'translation__language__code'
).annotate(count=Count('id'))
units |= res
source_checks = []
if check.source:
checks = Check.objects.filter(
check=name, project=subprj.project,
language=None,
ignore=False
).values_list('checksum', flat=True)
lang = subprj.translation_set.all()[0].language
res = Unit.objects.filter(
translation__subproject=subprj,
checksum__in=checks,
translation__language=lang
).count()
if res > 0:
source_checks.append(res)
return render_to_response(
'check_subproject.html',
RequestContext(request, {
'checks': units,
'source_checks': source_checks,
'anychecks': len(units) + len(source_checks) > 0,
'title': '%s/%s' % (subprj.__unicode__(), check.name),
'check': check,
'subproject': subprj,
})
)
示例5: update_subproject
def update_subproject(request, project, subproject):
obj = get_subproject(request, project, subproject)
if obj.do_update(request):
messages.info(request, _('All repositories were updated.'))
return redirect(obj)
示例6: export_stats
def export_stats(request, project, subproject):
"""
Exports stats in JSON format.
"""
subprj = get_subproject(request, project, subproject)
try:
indent = int(request.GET["indent"])
except:
indent = None
response = []
for trans in subprj.translation_set.all():
response.append(
{
"code": trans.language.code,
"name": trans.language.name,
"total": trans.total,
"last_change": trans.get_last_change(),
"last_author": trans.get_last_author(False),
"translated": trans.translated,
"translated_percent": trans.get_translated_percent(),
"fuzzy": trans.fuzzy,
"fuzzy_percent": trans.get_fuzzy_percent(),
"failing": trans.get_failing_checks(),
"failing_percent": trans.get_failing_checks_percent(),
"url": trans.get_share_url(),
"url_translate": get_site_url(trans.get_absolute_url()),
}
)
return HttpResponse(json.dumps(response, default=json_dt_handler, indent=indent), mimetype="application/json")
示例7: reset_subproject
def reset_subproject(request, project, subproject):
obj = get_subproject(request, project, subproject)
if obj.do_reset(request):
messages.info(request, _('All repositories have been reset.'))
return HttpResponseRedirect(obj.get_absolute_url())
示例8: commit_subproject
def commit_subproject(request, project, subproject):
obj = get_subproject(request, project, subproject)
obj.commit_pending(request)
messages.info(request, _('All pending translations were committed.'))
return HttpResponseRedirect(obj.get_absolute_url())
示例9: update_subproject
def update_subproject(request, project, subproject):
obj = get_subproject(request, project, subproject)
if obj.do_update(request):
messages.info(request, _('All repositories were updated.'))
return HttpResponseRedirect(obj.get_absolute_url())
示例10: new_language
def new_language(request, project, subproject):
obj = get_subproject(request, project, subproject)
form = NewLanguageForm(request.POST)
if form.is_valid():
language = Language.objects.get(code=form.cleaned_data['lang'])
same_lang = obj.translation_set.filter(language=language)
if same_lang.exists():
messages.error(
request,
_('Chosen translation already exists in this project!')
)
elif obj.project.new_lang == 'contact':
notify_new_language(obj, language, request.user)
messages.info(
request,
_(
"A request for a new translation has been "
"sent to the project's maintainers."
)
)
elif obj.project.new_lang == 'add':
obj.add_new_language(language, request)
else:
messages.error(
request,
_('Failed to process new translation request!')
)
return HttpResponseRedirect(reverse(
'subproject',
kwargs={'subproject': obj.slug, 'project': obj.project.slug}
))
示例11: export_stats
def export_stats(request, project, subproject):
"""
Exports stats in JSON format.
"""
subprj = get_subproject(request, project, subproject)
response = []
site = Site.objects.get_current()
for trans in subprj.translation_set.all():
response.append(
{
"code": trans.language.code,
"name": trans.language.name,
"total": trans.total,
"last_change": trans.get_last_change(),
"last_author": trans.get_last_author(False),
"translated": trans.translated,
"translated_percent": trans.get_translated_percent(),
"fuzzy": trans.fuzzy,
"fuzzy_percent": trans.get_fuzzy_percent(),
"failing": trans.get_failing_checks(),
"failing_percent": trans.get_failing_checks_percent(),
"url": trans.get_share_url(),
"url_translate": "http://%s%s" % (site.domain, trans.get_absolute_url()),
}
)
return HttpResponse(json.dumps(response, default=dt_handler), mimetype="application/json")
示例12: export_stats
def export_stats(request, project, subproject):
'''
Exports stats in JSON format.
'''
subprj = get_subproject(request, project, subproject)
response = []
for trans in subprj.translation_set.all():
response.append({
'code': trans.language.code,
'name': trans.language.name,
'total': trans.total,
'last_change': trans.get_last_change(),
'last_author': trans.get_last_author(False),
'translated': trans.translated,
'translated_percent': trans.get_translated_percent(),
'fuzzy': trans.fuzzy,
'fuzzy_percent': trans.get_fuzzy_percent(),
'failing': trans.get_failing_checks(),
'failing_percent': trans.get_failing_checks_percent(),
'url': trans.get_share_url(),
'url_translate': get_site_url(trans.get_absolute_url()),
})
return HttpResponse(
json.dumps(response, default=dt_handler),
mimetype='application/json'
)
示例13: unlock_subproject
def unlock_subproject(request, project, subproject):
obj = get_subproject(request, project, subproject)
obj.locked = False
obj.save()
messages.info(request, _("Subproject is now open for translation updates."))
return HttpResponseRedirect(obj.get_absolute_url())
示例14: update_subproject
def update_subproject(request, project, subproject):
'''
API hook for updating git repos.
'''
if not appsettings.ENABLE_HOOKS:
return HttpResponseNotAllowed([])
obj = get_subproject(request, project, subproject, True)
perform_update(obj)
return HttpResponse('update triggered')
示例15: lock_subproject
def lock_subproject(request, project, subproject):
obj = get_subproject(request, project, subproject)
obj.commit_pending(request)
obj.locked = True
obj.save()
messages.info(request, _("Subproject is now locked for translation updates!"))
return HttpResponseRedirect(obj.get_absolute_url())