<commit_before>from django.utils.text import capfirst

from admin_tools.menu.items import MenuItem

from dockitcms.models import Collection, Application

class CollectionList(MenuItem):
    def __init__(self, title=None, models=None, exclude=None, **kwargs):
        """
        ``CollectionList`` constructor.
        """
        self.models = list(models or [])
        self.exclude = list(exclude or [])
        self._init = False
        super(CollectionList, self).__init__(title, **kwargs)

    def init_with_context(self, context):
        if self._init:
            return
        items = Collection.objects.all()
        for collection in items:
            if collection.key in self.exclude:
                continue
            title = capfirst(collection.title)
            url = collection.get_admin_manage_url()
            item = MenuItem(title=title, url=url)
            self.children.append(item)
        self._init = True

    def is_empty(self):
        return len(self.children) == 0

class ApplicationList(MenuItem):
    def __init__(self, title=None, models=None, exclude=None, **kwargs):
        """
        ``CollectionList`` constructor.
        """
        self.title = title
        self.models = list(models or [])
        self.exclude = list(exclude or [])
        self._init = False
        super(ApplicationList, self).__init__(title, **kwargs)

    def init_with_context(self, context):
        if self._init:
            return
        items = Application.objects.all()
        collections = Collection.objects.all()
        for application in items:
            #if application.key in self.exclude:
            #    continue
            title = capfirst(application.name)
            #url = collection.get_admin_manage_url()
            item = MenuItem(title=title)
            #TODO this is not efficient
            for collection in collections:
                if collection.application == application:
                    item.children.append(self.create_menu_item_for_collection(collection))
            self.children.append(item)
        self._init = True
    
    def create_menu_item_for_collection(self, collection):
        title = capfirst(collection.title)
        url = collection.get_admin_manage_url()
        return MenuItem(title=title, url=url)
    
    def is_empty(self):
        return len(self.children) == 0
<commit_msg>CONSIDER: admin tools support should be dropped<commit_after>from django.utils.text import capfirst

from admin_tools.menu.items import MenuItem

from dockitcms.models import Collection, Application

class CollectionList(MenuItem):
    def __init__(self, title=None, models=None, exclude=None, **kwargs):
        """
        ``CollectionList`` constructor.
        """
        self.models = list(models or [])
        self.exclude = list(exclude or [])
        self._init = False
        super(CollectionList, self).__init__(title, **kwargs)

    def init_with_context(self, context):
        if self._init:
            return
        items = Collection.objects.all()
        for collection in items:
            if collection.key in self.exclude:
                continue
            title = capfirst(collection.title)
            url = collection.get_admin_manage_url()
            item = MenuItem(title=title, url=url)
            self.children.append(item)
        self._init = True

    def is_empty(self):
        return len(self.children) == 0

class ApplicationList(MenuItem):
    def __init__(self, title=None, models=None, exclude=None, **kwargs):
        """
        ``CollectionList`` constructor.
        """
        self.title = title
        self.models = list(models or [])
        self.exclude = list(exclude or [])
        self._init = False
        super(ApplicationList, self).__init__(title, **kwargs)

    def init_with_context(self, context):
        if self._init:
            return
        items = Application.objects.all()
        collections = Collection.objects.all()
        for application in items:
            #if application.key in self.exclude:
            #    continue
            title = capfirst(application.name)
            #url = collection.get_admin_manage_url()
            item = MenuItem(title=title)
            #TODO this is not efficient
            for collection in collections:
                if collection.application == application:
                    item.children.append(self.create_menu_item_for_collection(collection))
            self.children.append(item)
        self._init = True

    def create_menu_item_for_collection(self, collection):
        title = capfirst(collection.title)
        #url = collection.get_admin_manage_url()
        url = '/admin/dockitcms/collection/%s/manage/' % collection.key
        return MenuItem(title=title, url=url)

    def is_empty(self):
        return len(self.children) == 0

{'fraction_non_alphanumeric': 0.09800288243771875, 'fraction_numerical': 0.0008235536339304097, 'mean_word_length': 2.2625923438549362, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3215696', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1259, 'n_words': 299}