work on admin interface

This commit is contained in:
bkfox
2016-06-07 17:25:38 +02:00
parent 21f3e89101
commit 83e425349b
6 changed files with 118 additions and 44 deletions

View File

@ -288,7 +288,8 @@ class RelatedPostBase (models.base.ModelBase):
post = model.objects.filter(related = instance)
if post.count():
post = post[0]
elif rel.auto_create:
elif rel.auto_create(instance) if callable(rel.auto_create) else \
rel.auto_create:
post = model(related = instance)
else:
return
@ -375,12 +376,12 @@ class RelatedPost (Post, metaclass = RelatedPostBase):
* post_to_rel: auto update related object when post is updated
* rel_to_post: auto update the post when related object is updated
* thread_model: generated by the metaclass, points to the RelatedPost
model generated for the bindings.thread object.
model generated for the bindings.thread object.
* field_args: dict of arguments to pass to the ForeignKey constructor,
such as: ForeignKey(related_model, **field_args)
such as: ForeignKey(related_model, **field_args)
* auto_create: automatically create a RelatedPost for each new item of
the related object and init it with bounded values. Use signals
'', ''.
the related object and init it with bounded values. Use 'post_save'
signal. If auto_create is callable, use `auto_create(related_object)`.
Be careful with post_to_rel!
* There is no check of permissions when related object is synchronised