fix adding added by to inline relations, get entity image from gallery where available

This commit is contained in:
Sanjay B 2015-08-01 15:41:02 +05:30
parent 48acee9d45
commit 1a43303123
2 changed files with 15 additions and 2 deletions

View File

@ -263,8 +263,12 @@ class ItfModel(models.Model):
imgfield = main_image_getter
if imgfield is None or imgfield.name == '':
if self.get_modelextra():
imgfield = self.get_modelextra().default_image
gallery_image = self.get_gallery_image()
if gallery_image:
imgfield = gallery_image
else:
if self.get_modelextra():
imgfield = self.get_modelextra().default_image
if imgfield:
try:

View File

@ -26,6 +26,10 @@ def add_object(request, module_slug, tab_slug):
all_valid = True
for inline in inlines:
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()
else:
all_valid = False
@ -68,6 +72,11 @@ def edit_object(request, module_slug, tab_slug, object_id):
all_valid = True
for inline in inlines:
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()
else:
all_valid = False