diff --git a/cms/models.py b/cms/models.py index a97b43b..6ded6dc 100644 --- a/cms/models.py +++ b/cms/models.py @@ -317,6 +317,7 @@ class RelatedMeta (models.base.ModelBase): elif rel.auto_create(instance) if callable(rel.auto_create) else \ rel.auto_create: post = model(related = instance) + # TODO: hackish way: model.objects.filter(related=null,...).delete() else: return post.rel_to_post() @@ -325,7 +326,6 @@ class RelatedMeta (models.base.ModelBase): post_save.connect(handler_rel, model._relation.model, False) def __new__ (cl, name, bases, attrs): - # TODO: allow proxy models and better inheritance # TODO: check bindings if name == 'RelatedPost': return super().__new__(cl, name, bases, attrs) @@ -348,7 +348,6 @@ class RelatedMeta (models.base.ModelBase): name = rel.model._meta.object_name if name == model._meta.object_name: model._meta.default_related_name = '{} Post'.format(name) - return model @@ -401,7 +400,7 @@ class RelatedPost (Post, metaclass = RelatedMeta): bindings = None """ dict of `post_attr: rel_attr` that represent bindings of values - between the post and the related object. Field are updated according + between the post and the related object. Fields are updated according to `post_to_rel` and `rel_to_post`. If there is a post_attr "thread", the corresponding rel_attr is used @@ -413,6 +412,11 @@ class RelatedPost (Post, metaclass = RelatedMeta): note: bound values can be any value, not only Django field. """ + defaults = None + """ + dict of `post_attr: value` that gives default value for the given + fields. + """ post_to_rel = False """ update related object when the post is saved, using bindings @@ -474,7 +478,6 @@ class RelatedPost (Post, metaclass = RelatedMeta): if save: self.related.save() - def rel_to_post(self, save = True): """ Change the post using the related object bound values. Save the @@ -508,13 +511,6 @@ class RelatedPost (Post, metaclass = RelatedMeta): if has_changed and save: self.save() - def __init__ (self, *kargs, **kwargs): - super().__init__(*kargs, **kwargs) - # we use this method for sync, in order to avoid intrusive code on other - # applications, e.g. using signals. - if self.pk and self._relation.rel_to_post: - self.rel_to_post(False) - def save (self, avoid_sync = False, save = True, *args, **kwargs): """ * avoid_sync: do not synchronise the post/related object; diff --git a/cms/sections.py b/cms/sections.py index 160be3f..7f1a78c 100644 --- a/cms/sections.py +++ b/cms/sections.py @@ -288,9 +288,6 @@ class List(Section): """ Prepare objects before context is sent to the template renderer. Return the object_list that is prepared. - - Remember: since we are in a rendering process, the items should - not be saved. """ return object_list diff --git a/cms/templates/aircox/cms/list.html b/cms/templates/aircox/cms/list.html index 8ce2d98..864de04 100644 --- a/cms/templates/aircox/cms/list.html +++ b/cms/templates/aircox/cms/list.html @@ -7,7 +7,7 @@ {% block content %}