Ejemplo n.º 1
0
def sort_cms_models(cms_models):
    """
    Sort a set of CMS-related models in a custom (predefined) order.
    """
    cms_models.sort(
        key=lambda model: (get_cms_model_order(model['name']) if is_cms_app(
            model['app_name']) else 999, model['app_name'], model['title']))
Ejemplo n.º 2
0
    def init_with_context(self, context):
        """
        Initializes the icon list.
        """
        super(CmsAppIconList, self).init_with_context(context)
        apps = self.children

        cms_apps = [a for a in apps if is_cms_app(a['name'])]
        non_cms_apps = [a for a in apps if a not in cms_apps]

        if cms_apps:
            # Group the models of all CMS apps in one group.
            cms_models = []
            for app in cms_apps:
                cms_models += app['models']

            sort_cms_models(cms_models)
            single_cms_app = {
                'name': "Modules",
                'title': "Modules",
                'url': "",
                'models': cms_models
            }

            # Put remaining groups after the first CMS group.
            self.children = [single_cms_app] + non_cms_apps
Ejemplo n.º 3
0
def sort_cms_models(cms_models):
    """
    Sort a set of CMS-related models in a custom (predefined) order.
    """
    cms_models.sort(key=lambda model: (
        get_cms_model_order(model['name']) if is_cms_app(model['app_name']) else 999,
        model['app_name'],
        model['title']
    ))
Ejemplo n.º 4
0
    def init_with_context(self, context):
        """
        Initializes the icon list.
        """
        super(CmsAppIconList, self).init_with_context(context)
        apps = self.children

        cms_apps = [a for a in apps if is_cms_app(a["name"])]
        non_cms_apps = [a for a in apps if a not in cms_apps]

        if cms_apps:
            # Group the models of all CMS apps in one group.
            cms_models = []
            for app in cms_apps:
                cms_models += app["models"]

            sort_cms_models(cms_models)
            single_cms_app = {"name": "Modules", "title": "Modules", "url": "", "models": cms_models}

            # Put remaining groups after the first CMS group.
            self.children = [single_cms_app] + non_cms_apps