def __init__(self, obj, user, *args, **kwargs): """Generate choices for other subproject in same project.""" other_subprojects = obj.subproject.project.subproject_set.exclude( id=obj.subproject.id) choices = [(s.id, force_text(s)) for s in other_subprojects] # Add components from other owned projects owned_components = SubProject.objects.filter( project__groupacl__groups__name__endswith='@Administration' ).exclude(project=obj.subproject.project).distinct() for component in owned_components: choices.append((component.id, force_text(component))) super(AutoForm, self).__init__(*args, **kwargs) self.fields['subproject'].choices = \ [('', _('All components in current project'))] + choices self.fields['engines'].choices = [ (key, mt.name) for key, mt in MACHINE_TRANSLATION_SERVICES.items() ] if 'weblate' in MACHINE_TRANSLATION_SERVICES.keys(): self.fields['engines'].initial = 'weblate' self.helper = FormHelper(self) self.helper.layout = Layout( Field('overwrite'), Field('inconsistent'), InlineRadios('auto_source', id='select_auto_source'), Div('subproject', css_id='auto_source_others'), Div('engines', 'threshold', css_id='auto_source_mt'), )
def mt_services(request): """ Generates list of installed machine translation services in JSON. """ # Machine translation machine_services = MACHINE_TRANSLATION_SERVICES.keys() return HttpResponse(json.dumps(machine_services), content_type="application/json")
def mt_services(request): """ Generates list of installed machine translation services in JSON. """ # Machine translation machine_services = list(MACHINE_TRANSLATION_SERVICES.keys()) return JsonResponse(data=machine_services, safe=False)
def mt_services(request): """Generate list of installed machine translation services in JSON.""" # Machine translation machine_services = list(MACHINE_TRANSLATION_SERVICES.keys()) return JsonResponse( data=machine_services, safe=False, )
def mt_services(request): ''' Generates list of installed machine translation services in JSON. ''' # Machine translation machine_services = MACHINE_TRANSLATION_SERVICES.keys() return HttpResponse(json.dumps(machine_services), content_type='application/json')
def js_config(request): ''' Generates settings for javascript. Includes things like translaiton services. ''' # Machine translation machine_services = MACHINE_TRANSLATION_SERVICES.keys() return render(request, 'js/config.js', { 'machine_services': machine_services, }, content_type='application/javascript')
def js_config(request): ''' Generates settings for javascript. Includes things like translaiton services. ''' # Machine translation machine_services = MACHINE_TRANSLATION_SERVICES.keys() return render( request, 'js/config.js', { 'machine_services': machine_services, }, content_type='application/javascript' )