misc: initialize cell library once application is ready (#9066)
This commit is contained in:
parent
d02d6ec080
commit
6ef2900451
|
@ -0,0 +1 @@
|
|||
default_app_config = 'combo.data.apps.DataConfig'
|
|
@ -0,0 +1,25 @@
|
|||
# combo - content management system
|
||||
# Copyright (C) 2014-2015 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
class DataConfig(AppConfig):
|
||||
name = 'combo.data'
|
||||
verbose_name = 'Data'
|
||||
|
||||
def ready(self):
|
||||
from .library import library
|
||||
library.ready()
|
|
@ -27,14 +27,15 @@ class Library(object):
|
|||
def get_cell_classes(self):
|
||||
return self.classes
|
||||
|
||||
def ready(self):
|
||||
# initialize the dictionary
|
||||
self.classes_by_content_str = {}
|
||||
for klass in self.classes:
|
||||
content_type = ContentType.objects.get_for_model(klass)
|
||||
content_type_str_v = '%s_%s' % (content_type.app_label, content_type.model)
|
||||
self.classes_by_content_str[content_type_str_v] = klass
|
||||
|
||||
def get_cell_class(self, content_type_str):
|
||||
if self.classes_by_content_str is None:
|
||||
# initialize the dictionary
|
||||
self.classes_by_content_str = {}
|
||||
for klass in self.classes:
|
||||
content_type = ContentType.objects.get_for_model(klass)
|
||||
content_type_str_v = '%s_%s' % (content_type.app_label, content_type.model)
|
||||
self.classes_by_content_str[content_type_str_v] = klass
|
||||
return self.classes_by_content_str[content_type_str]
|
||||
|
||||
def register_cell_class(self, klass):
|
||||
|
|
Loading…
Reference in New Issue