def edit_priority(request, pk): """ Change source string priority. """ source = get_object_or_404(Source, pk=pk) form = PriorityForm(request.POST) if form.is_valid(): source.priority = form.cleaned_data['priority'] source.save() else: messages.error(request, _('Failed to change a priority!')) return redirect(request.POST.get('next', source.get_absolute_url()))
def edit_priority(request, pk): """ Change source string priority. """ source = get_object_or_404(Source, pk=pk) form = PriorityForm(request.POST) if form.is_valid(): source.priority = form.cleaned_data['priority'] source.save() else: messages.error(request, _('Failed to change a priority!')) return redirect(request.POST.get('next', source.get_absolute_url()))
def edit_priority(request, pk): """Change source string priority.""" source = get_object_or_404(Source, pk=pk) if not request.user.has_perm('source.edit', source.component): raise PermissionDenied() form = PriorityForm(request.POST) if form.is_valid(): source.priority = form.cleaned_data['priority'] source.save() else: messages.error(request, _('Failed to change a priority!')) return redirect_next(request.POST.get('next'), source.get_absolute_url())
def edit_priority(request, pk): """Change source string priority.""" source = get_object_or_404(Source, pk=pk) if not can_edit_priority(request.user, source.subproject.project): raise PermissionDenied() form = PriorityForm(request.POST) if form.is_valid(): source.priority = form.cleaned_data['priority'] source.save() else: messages.error(request, _('Failed to change a priority!')) return redirect_next(request.POST.get('next'), source.get_absolute_url())
def get_detail(request, project, subproject, checksum): ''' Returns source translation detail in all languages. ''' subproject = get_subproject(request, project, subproject) units = Unit.objects.filter( checksum=checksum, translation__subproject=subproject ) source = units[0].source_info check_flags = [ (CHECKS[x].ignore_string, CHECKS[x].name) for x in CHECKS ] extra_flags = [(x, EXTRA_FLAGS[x]) for x in EXTRA_FLAGS] return render( request, 'js/detail.html', { 'units': units, 'source': source, 'next': request.GET.get('next', ''), 'priority_form': PriorityForm( initial={'priority': source.priority} ), 'check_flags_form': CheckFlagsForm( initial={'flags': source.check_flags} ), 'extra_flags': extra_flags, 'check_flags': check_flags, } )
def get_detail(request, project, subproject, checksum): ''' Returns source translation detail in all languages. ''' subproject = get_subproject(request, project, subproject) units = Unit.objects.filter(checksum=checksum, translation__subproject=subproject) source = units[0].source_info return render( request, 'js/detail.html', { 'units': units, 'source': source, 'next': request.GET.get('next', ''), 'priority_form': PriorityForm(initial={'priority': source.priority}), })
def get_detail(request, project, component, checksum): """Return source translation detail in all languages.""" component = get_component(request, project, component) try: units = Unit.objects.filter( id_hash=checksum_to_hash(checksum), translation__component=component ).order_by(*Unit.ordering) except ValueError: raise Http404('Non existing unit!') try: source = units[0].source_info except IndexError: raise Http404('Non existing unit!') check_flags = [ (CHECKS[x].ignore_string, CHECKS[x].name) for x in CHECKS ] extra_flags = [(x, EXTRA_FLAGS[x]) for x in EXTRA_FLAGS] return render( request, 'js/detail.html', { 'units': units, 'source': source, 'project': component.project, 'next': request.GET.get('next', ''), 'priority_form': PriorityForm( initial={'priority': source.priority} ), 'context_form': ContextForm( initial={'context': source.context} ), 'check_flags_form': CheckFlagsForm( initial={'flags': source.check_flags} ), 'screenshot_form': ScreenshotForm(), 'extra_flags': extra_flags, 'check_flags': check_flags, } )
def review_source(request, project, subproject): """ Listing of source strings to review. """ obj = get_subproject(request, project, subproject) # Grab first translation in subproject # (this assumes all have same source strings) try: source = obj.translation_set.all()[0] except Translation.DoesNotExist: raise Http404('No translation exists in this subproject.') # Grab search type and page number rqtype = request.GET.get('type', 'all') limit = request.GET.get('limit', 50) page = request.GET.get('page', 1) ignored = 'ignored' in request.GET # Filter units: sources = source.unit_set.filter_type(rqtype, source, ignored) paginator = Paginator(sources, limit) try: sources = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. sources = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. sources = paginator.page(paginator.num_pages) return render( request, 'source-review.html', { 'object': obj, 'source': source, 'sources': sources, 'rqtype': rqtype, 'priority_form': PriorityForm(), 'title': _('Review source strings in %s') % obj.__unicode__(), })
def get_detail(request, project, subproject, checksum): ''' Returns source translation detail in all languages. ''' subproject = get_subproject(request, project, subproject) units = Unit.objects.filter( checksum=checksum, translation__subproject=subproject ) try: source = units[0].source_info except IndexError: raise Http404('Non existing unit!') check_flags = [ (CHECKS[x].ignore_string, CHECKS[x].name) for x in CHECKS ] extra_flags = [(x, EXTRA_FLAGS[x]) for x in EXTRA_FLAGS] return render( request, 'js/detail.html', { 'units': units, 'source': source, 'project': subproject.project, 'next': request.GET.get('next', ''), 'priority_form': PriorityForm( initial={'priority': source.priority} ), 'check_flags_form': CheckFlagsForm( initial={'flags': source.check_flags} ), 'screenshot_form': ScreenshotUploadForm(instance=source), 'extra_flags': extra_flags, 'check_flags': check_flags, } )