fix adding added by to inline relations, get entity image from gallery where available
This commit is contained in:
parent
48acee9d45
commit
1a43303123
|
@ -263,8 +263,12 @@ class ItfModel(models.Model):
|
||||||
imgfield = main_image_getter
|
imgfield = main_image_getter
|
||||||
|
|
||||||
if imgfield is None or imgfield.name == '':
|
if imgfield is None or imgfield.name == '':
|
||||||
if self.get_modelextra():
|
gallery_image = self.get_gallery_image()
|
||||||
imgfield = self.get_modelextra().default_image
|
if gallery_image:
|
||||||
|
imgfield = gallery_image
|
||||||
|
else:
|
||||||
|
if self.get_modelextra():
|
||||||
|
imgfield = self.get_modelextra().default_image
|
||||||
|
|
||||||
if imgfield:
|
if imgfield:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -26,6 +26,10 @@ def add_object(request, module_slug, tab_slug):
|
||||||
all_valid = True
|
all_valid = True
|
||||||
for inline in inlines:
|
for inline in inlines:
|
||||||
if inline.is_valid():
|
if inline.is_valid():
|
||||||
|
inline_instances = inline.save(commit=False)
|
||||||
|
for inline_instance in inline_instances:
|
||||||
|
if inline_instance.__dict__.has_key('added_by_id'):
|
||||||
|
inline_instance.added_by = request.user
|
||||||
inline.save()
|
inline.save()
|
||||||
else:
|
else:
|
||||||
all_valid = False
|
all_valid = False
|
||||||
|
@ -68,6 +72,11 @@ def edit_object(request, module_slug, tab_slug, object_id):
|
||||||
all_valid = True
|
all_valid = True
|
||||||
for inline in inlines:
|
for inline in inlines:
|
||||||
if inline.is_valid():
|
if inline.is_valid():
|
||||||
|
inline_instances = inline.save(commit=False)
|
||||||
|
for inline_instance in inline_instances:
|
||||||
|
if inline_instance.__dict__.has_key('added_by_id'):
|
||||||
|
if not inline_instance.added_by_id:
|
||||||
|
inline_instance.added_by = request.user
|
||||||
inline.save()
|
inline.save()
|
||||||
else:
|
else:
|
||||||
all_valid = False
|
all_valid = False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user