Skip to content

Commit

Permalink
The method 'creme_core.apps.CremeCoreConfig.tag_ctype()' has been rem…
Browse files Browse the repository at this point in the history
…oved.

The work is done is the ContentType's AppConfig instead.
  • Loading branch information
genglert committed Feb 18, 2021
1 parent d187046 commit e4aed51
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@
* Projects :
- The <related_name> of the field 'models.AbstractProjectTask.parent_tasks' has been renamed "children" (it was "children_set").

Internal breaking changes :
---------------------------
(they should not cause problem if you have not deeply modified the source code of Creme)

# The method 'creme_core.apps.CremeCoreConfig.tag_ctype()' has been removed.


== Version 2.2 ==

Expand Down
29 changes: 17 additions & 12 deletions creme/creme_core/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,15 @@ def ready(self):
super().ready()

from django.contrib.contenttypes.models import ContentType
assert not ContentType._meta.ordering, \
'It seems ContentType has an ordering policy now ?!'

ContentType._meta.ordering = ('id', )
meta = ContentType._meta
assert not meta.ordering, 'It seems ContentType has an ordering policy now ?!'

meta.ordering = ('id', )

get_ct_field = meta.get_field
for fname in ('app_label', 'model'):
get_ct_field(fname).set_tags(viewable=False)


class CremeAppConfig(AppConfig):
Expand Down Expand Up @@ -385,7 +390,7 @@ def all_apps_ready(self):
if self.MIGRATION_MODE:
return

self.tag_ctype()
# self.tag_ctype()

self.hook_fk_formfield()
self.hook_fk_check()
Expand Down Expand Up @@ -765,14 +770,14 @@ def hook_multiselection_widgets():
forms.MultipleChoiceField.widget = forms.ModelMultipleChoiceField.widget = \
widgets.UnorderedMultipleChoiceWidget

@staticmethod
def tag_ctype():
from django.contrib.contenttypes.models import ContentType

get_ct_field = ContentType._meta.get_field

for fname in ('app_label', 'model'):
get_ct_field(fname).set_tags(viewable=False)
# @staticmethod
# def tag_ctype():
# from django.contrib.contenttypes.models import ContentType
#
# get_ct_field = ContentType._meta.get_field
#
# for fname in ('app_label', 'model'):
# get_ct_field(fname).set_tags(viewable=False)


def creme_app_configs():
Expand Down

0 comments on commit e4aed51

Please sign in to comment.