Returns a tuple of translation field names to exclude based on
        `exclude_languages` arg.
        TODO: Currently unused?
171502
def get_translation_field_excludes(self, exclude_languages=None):
        
        if exclude_languages is None:
            exclude_languages = []
        excl_languages = []
        if exclude_languages:
            excl_languages = exclude_languages
        exclude = []
        for orig_fieldname, translation_fields in self.trans_opts.fields.items():
            for tfield in translation_fields:
                if tfield.language in excl_languages and tfield not in exclude:
                    exclude.append(tfield)
        return tuple(exclude)
645881
def get_field_names(ctx):
    """"""
    # this does not include labels and literals, only rule names and token names
    # TODO: check ANTLR parser template for full exclusion list
    fields = [
        field
        for field in type(ctx).__dict__
        if not field.startswith("__")
        and field not in ["accept", "enterRule", "exitRule", "getRuleIndex", "copyFrom"]
    ]
    return fields
46643
def get_field_names(self):
        
        if self.add:
            return ['date', 'elem', 'value'] + [flag for flag in self.add]
        else:
            field_names = ['date']
            for elem in self.parameter:
                # namedtuple doesn't like numeric field names
                if elem.isdigit():
                    elem = "e%s" % elem
                field_names.append(elem)
            return field_names
1347755
def show_list_translations(context, item):
    
    if not item:
        return

    manager = Manager()
    manager.set_master(item)

    ct_item = ContentType.objects.get_for_model(item)

    item_language_codes = manager.get_languages_from_item(ct_item, item)
    model_language_codes = manager.get_languages_from_model(ct_item.app_label, ct_item.model)

    item_languages = [{'lang': lang, 'from_model': lang.code in model_language_codes}
                      for lang in TransLanguage.objects.filter(code__in=item_language_codes).order_by('name')]

    more_languages = [{'lang': lang, 'from_model': lang.code in model_language_codes}
                      for lang in TransLanguage.objects.exclude(main_language=True).order_by('name')]

    return render_to_string('languages/translation_language_selector.html', {
        'item_languages': item_languages,
        'more_languages': more_languages,
        'api_url': TM_API_URL,
        'app_label': manager.app_label,
        'model': manager.model_label,
        'object_pk': item.pk
    })
220136
def available_languages(self):
        
        from .models import Translation

        return (
            Translation.objects.filter(
                identifier=self.linguist_identifier, object_id=self.pk
            )
            .values_list("language", flat=True)
            .distinct()
            .order_by("language")
        )
313626
def _filter_or_exclude(self, negate, *args, **kwargs):
        
        from .models import Translation

        new_args = self.get_cleaned_args(args)
        new_kwargs = self.get_cleaned_kwargs(kwargs)

        translation_args = self.get_translation_args(args)
        translation_kwargs = self.get_translation_kwargs(kwargs)

        has_linguist_args = self.has_linguist_args(args)
        has_linguist_kwargs = self.has_linguist_kwargs(kwargs)

        if translation_args or translation_kwargs:
            ids = list(
                set(
                    Translation.objects.filter(
                        *translation_args, **translation_kwargs
                    ).values_list("object_id", flat=True)
                )
            )
            if ids:
                new_kwargs["id__in"] = ids

        has_kwargs = has_linguist_kwargs and not (new_kwargs or new_args)
        has_args = has_linguist_args and not (new_args or new_kwargs)

        # No translations but we looked for translations?
        # Returns empty queryset.
        if has_kwargs or has_args:
            return self._clone().none()

        return super(QuerySetMixin, self)._filter_or_exclude(
            negate, *new_args, **new_kwargs
        )
1272351
def getter_generator(field_name, short_description):
    
    def get_translation_field(cls, language_code=None, fallback=False):
        try:
            return cls.get_translation(language_code,
                                       fallback=fallback,
                                       field=field_name)
        except TranslationDoesNotExist:
            return None
    get_translation_field.short_description = short_description
    return get_translation_field
89733
def get_filter_fields(self, exclude=None):
        

        exclude_set = set(self.exclude)
        if exclude:
            exclude_set = exclude_set.union(set(exclude))

        return [name for name in self.fields
                if name not in exclude_set]
1023550
def _get_prefetched_translations(self, meta=None):
        
        if meta is None:
            meta = self._parler_meta.root

        related_name = meta.rel_name
        try:
            # Read the list directly, avoid QuerySet construction.
            # Accessing self._get_translated_queryset(parler_meta)._prefetch_done is more expensive.
            return self._prefetched_objects_cache[related_name]
        except (AttributeError, KeyError):
            return None
87960
def translations_lists(self):
        ''''''
        return (getattr(self.generator, name) for name in
                self.info.get('translations_lists', []))
844975
def get_translations(self, language=None):
        
        from .models import Translation

        if not self.pk:
            return Translation.objects.none()

        return Translation.objects.get_translations(obj=self, language=language)
844972
def get_search_fields(self, exclude=None):
        
        exclude = set(exclude)
        if self.search_fields and len(self.search_fields) > 1:
            exclude = exclude.union(self.search_fields)

        return self.get_filter_fields(exclude=exclude)
164230
def get_translation_args(self, args):
        
        translation_args = []
        for arg in args:
            condition = self._get_linguist_condition(arg, transform=True)
            if condition:
                translation_args.append(condition)
        return translation_args
916271
def field_factory(base_class):
    
    from .fields import TranslationField

    class TranslationFieldField(TranslationField, base_class):
        pass

    TranslationFieldField.__name__ = "Translation%s" % base_class.__name__

    return TranslationFieldField
605034
def get_cleaned_kwargs(self, kwargs):
        
        cleaned_kwargs = kwargs.copy()

        if kwargs is not None:
            for k in kwargs:
                if self.is_linguist_lookup(k):
                    del cleaned_kwargs[k]

        return cleaned_kwargs
21810
def get_field(cls, model, opts, label, field):
    

    trans_model = model._meta.translation_model
    try:
        (f, lang_id) = trans_model._meta.translated_fields[field]
        return f
    except KeyError:
        # fall back to the old way -- see if model contains the field
        # directly
        pass

    try:
        return opts.get_field(field)
    except models.FieldDoesNotExist:
        raise ImproperlyConfigured("'%s.%s' refers to field '%s' that is " \
            "missing from model '%s'." \
            % (cls.__name__, label, field, model.__name__))
181505
def get_languages_from_model(app_label, model_label):
        
        try:
            mod_lan = TransModelLanguage.objects.filter(model='{} - {}'.format(app_label, model_label)).get()
            languages = [lang.code for lang in mod_lan.languages.all()]
            return languages
        except TransModelLanguage.DoesNotExist:
            return []