Create a select list containing each of the models that subclass the
    ``Page`` model.
434873
def models_for_pages(*args):
    
    from warnings import warn
    warn("template tag models_for_pages is deprectaed, use "
        "PageAdmin.get_content_models instead")
    from yacms.pages.admin import PageAdmin
    return PageAdmin.get_content_models()
1062045
def get_model_list(class_list):
    
    for idx, item in enumerate(class_list):
        if isinstance(item, six.string_types):
            model_class = apps.get_model(item)
            class_list[idx] = model_class
545373
def _set_seo_models(self, value):
        
        seo_models = []
        for model_name in value:
            if "." in model_name:
                app_label, model_name = model_name.split(".", 1)
                model = models.get_model(app_label, model_name)
                if model:
                    seo_models.append(model)
            else:
                app = models.get_app(model_name)
                if app:
                    seo_models.extend(models.get_models(app))
    
        self.seo_models = seo_models
1209406
def views(model: "Model") -> list:
    
    if not isinstance(model, Model):
        raise TypeError("Expected a Model, not %r." % model)
    return model._model_views[:]
32457
def get_related(page):
    
    related = []
    entry   = Entry.get_for_model(page)

    if entry:
        related = entry.related

    return related
109538
def define_sub_elements(model_class, submodel_class, props = [])
      attributes = submodel_class.new.attributes.keys

      props = attributes if props.empty?
      props.map! { |x| x.to_s } unless props.empty?

      attributes.each do |attri|
        if props.include?(attri)
          selector = '#' + "#{class_name(model_class)}_#{class_name(submodel_class)}_attributes_#{attri.to_s}"

          element attri, selector
        end
      end
    end
1233994
def models_from_model(model, include_related=False, exclude=None):
    ''''''
    if exclude is None:
        exclude = set()
    if model and model not in exclude:
        exclude.add(model)
        if isinstance(model, ModelType) and not model._meta.abstract:
            yield model
            if include_related:
                exclude.add(model)
                for field in model._meta.fields:
                    if hasattr(field, 'relmodel'):
                        through = getattr(field, 'through', None)
                        for rmodel in (field.relmodel, field.model, through):
                            for m in models_from_model(
                                    rmodel, include_related=include_related,
                                    exclude=exclude):
                                yield m
                for manytomany in model._meta.manytomany:
                    related = getattr(model, manytomany)
                    for m in models_from_model(related.model,
                                               include_related=include_related,
                                               exclude=exclude):
                        yield m
        elif not isinstance(model, ModelType) and isclass(model):
            # This is a class which is not o ModelType
            yield model
496013
def applicable_models(self):
        
        Page        = apps.get_model('wagtailcore', 'Page')
        applicable  = []

        for model in apps.get_models():
            if issubclass(model, Page):
                applicable.append(model)

        return applicable
944421
def _select_list(self, model=None, queryview=None, queryform=None,
                     auto_condition=True,
                     post_view=None, post_run=None, **kwargs):
        
        from uliweb import request, json
        from uliweb.utils.generic import get_sort_field
        import copy

        condition = None
        if queryview and auto_condition:
            queryview.run()
            if hasattr(queryview, 'get_condition'):
                condition = queryview.get_condition()

        if 'condition' in kwargs:
            condition = kwargs['condition'] & condition

        kwargs['condition'] = condition

        #process order
        if 'order_by' not in kwargs:
            order_by = get_sort_field(model)
            if order_by is not None:
                kwargs['order_by'] = order_by

        _fields = copy.copy(kwargs.get('fields_convert_map', []))
        self._process_fields_convert_map(kwargs)
        downloads = self._parse_download_args(kwargs, _fields)
        self._process_fields_convert_map(downloads, download=True)

        view = self._select_list_view(model, **kwargs)

        if post_view:
            post_view(view)

        if 'data' in request.values:
            return json(view.json())
        elif 'download' in request.GET:
            return view.download(**downloads)
        else:
            result = view.run()
            if queryform or queryview:
                result.update({'query_form':queryform or queryview.form})
            else:
                result.update({'query_form':''})
            result.update({'table':view})

            if post_run:
                post_run(view, result)
            return result
517626
def model_from_list(l, header):
        """"""
        col = groups.sortableListe(PseudoAccesCategorie(n) for n in l)
        return MultiSelectModel(col, header)
280257
def page_entries_info(collection, options = {})
      model = options[:model]
      model = collection.first.class unless model or collection.empty?
      model ||= 'entry'
      model_key = if model.respond_to? :model_name
                    model.model_name.i18n_key  # ActiveModel::Naming
                  else
                    model.to_s.underscore
                  end

      if options.fetch(:html, true)
        b, eb = '<b>', '</b>'
        sp = '&nbsp;'
        html_key = '_html'
      else
        b = eb = html_key = ''
        sp = ' '
      end

      model_count = collection.total_pages > 1 ? 5 : collection.size
      defaults = ["models.#{model_key}"]
      defaults << Proc.new { |_, opts|
        if model.respond_to? :model_name
          model.model_name.human(:count => opts[:count])
        else
          name = model_key.to_s.tr('_', ' ')
          raise "can't pluralize model name: #{model.inspect}" unless name.respond_to? :pluralize
          opts[:count] == 1 ? name : name.pluralize
        end
      }
      model_name = will_paginate_translate defaults, :count => model_count

      if collection.total_pages < 2
        i18n_key = :"page_entries_info.single_page#{html_key}"
        keys = [:"#{model_key}.#{i18n_key}", i18n_key]

        will_paginate_translate keys, :count => collection.total_entries, :model => model_name do |_, opts|
          case opts[:count]
          when 0; "No #{opts[:model]} found"
          when 1; "Displaying #{b}1#{eb} #{opts[:model]}"
          else    "Displaying #{b}all#{sp}#{opts[:count]}#{eb} #{opts[:model]}"
          end
        end
      else
        i18n_key = :"page_entries_info.multi_page#{html_key}"
        keys = [:"#{model_key}.#{i18n_key}", i18n_key]
        params = {
          :model => model_name, :count => collection.total_entries,
          :from => collection.offset + 1, :to => collection.offset + collection.length
        }
        will_paginate_translate keys, params do |_, opts|
          %{Displaying %s #{b}%d#{sp}-#{sp}%d#{eb} of #{b}%d#{eb} in total} %
            [ opts[:model], opts[:from], opts[:to], opts[:count] ]
        end
      end
    end
37853
def _build_app_models(request, admin_apps, models_tuples, ensure_all_models=False):
    

    app_models = []
    for app_and_model, config in models_tuples:
        if app_and_model:
            app_label, model_name = app_and_model.split('.')

            for app in admin_apps:
                if app['app_label'] == app_label:
                    for model in app['models']:
                        if model['object_name'] == model_name:
                            try:
                                model['name'] = \
                                    config['name']
                            except KeyError:
                                pass

                            # Get each of the polymorphic types to allow addition.
                            model_class = apps.get_model(app_and_model)
                            model_admin = admin.site._registry[model_class]

                            if hasattr(model_admin, 'get_child_type_choices'):
                                model['polymorphic_classes'] = \
                                    model_admin.get_child_type_choices(
                                        request, 'add'
                                    )

                            # TODO: Fluent/polymorphic has a way of sorting child order which should be used instead
                            if 'default_poly_child' in config.keys():
                                ct = ContentType.objects.get_by_natural_key(
                                    *config['default_poly_child'].lower().split('.')
                                )
                                model.default_poly_child = ct.id

                            app_models.append(model)

                    break

    return app_models
697422
private CmsListItemWidget createListWidget(final CmsModelPageEntry modelPage) {

        CmsListItemWidget result = new CmsModelPageListItemWidget(modelPage.getListInfoBean());
        if (modelPage.isDefault()) {
            Widget label = result.getShortExtraInfoLabel();
            label.addStyleName(I_CmsInputLayoutBundle.INSTANCE.inputCss().subtitleSuffix());
            result.setExtraInfo("(*)");
        }
        if (m_isModelGroup || CmsEditModelPageMenuEntry.checkVisible(modelPage.getStructureId())) {
            result.addIconClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {

                    CmsEditModelPageMenuEntry.editModelPage(modelPage.getSitePath(), isModelGroup());
                }
            });
        }
        return result;
    }
922668
def all
      attribute_maps = [] # [{...}, {...}]
      @pages = CEO::Paginator.new(
        @model,
        current_page: current_page,
        per_page: @options.fetch(:per_page, 20)
      )

      self.total_pages = @pages.total_pages

      @pages.each do |thing|
        attr_object = {}

        # TODO: Make all of this into a method.
        # map first-level values to a hash
        keys.each do |key|
          attr_object[self.class.acronymize(key)] = thing[key.to_s]
        end

        # map nested values to a hash
        @queries.each do |query|
          attr_object.merge! query_eval(thing, query)
        end
        attribute_maps << attr_object
      end
      attribute_maps
    end
581853
def model_to_list(model_class, filter_dict=None, order_by_list=None,
                  select_related_fields=None, q_filter=None,
                  values=None,
                  to_json_method='to_json'):
    
    return model_to_page_list(model_class, page_num=None,
                              filter_dict=filter_dict, order_by_list=order_by_list,
                              select_related_fields=select_related_fields,
                              q_filter=q_filter, values=values,
                              to_json_method=to_json_method)
271711
def as_models(self, klass):
        """"""
        try:
            return [klass(mod) for mod in self.tree.reply.data.results.array[0].item]
        except AttributeError:
            return []
1089899
def _get_list_widget(
        self,
        filters,
        actions=None,
        order_column="",
        order_direction="",
        page=None,
        page_size=None,
        widgets=None,
        **args
    ):

        
        widgets = widgets or {}
        actions = actions or self.actions
        page_size = page_size or self.page_size
        if not order_column and self.base_order:
            order_column, order_direction = self.base_order
        joined_filters = filters.get_joined_filters(self._base_filters)
        count, lst = self.datamodel.query(
            joined_filters,
            order_column,
            order_direction,
            page=page,
            page_size=page_size,
        )
        pks = self.datamodel.get_keys(lst)

        # serialize composite pks
        pks = [self._serialize_pk_if_composite(pk) for pk in pks]

        widgets["list"] = self.list_widget(
            label_columns=self.label_columns,
            include_columns=self.list_columns,
            value_columns=self.datamodel.get_values(lst, self.list_columns),
            order_columns=self.order_columns,
            formatters_columns=self.formatters_columns,
            page=page,
            page_size=page_size,
            count=count,
            pks=pks,
            actions=actions,
            filters=filters,
            modelview_name=self.__class__.__name__,
        )
        return widgets