|
|
|
|
@ -420,7 +420,6 @@ class ImportEventForm(ImportForm): |
|
|
|
|
if setting is None: |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if setting.get('method'): |
|
|
|
|
# this cell contains data that must be written after creating object |
|
|
|
|
if cell != "": |
|
|
|
|
@ -549,40 +548,39 @@ class ImportEventForm(ImportForm): |
|
|
|
|
|
|
|
|
|
list_dicts.append(d) |
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
# go through row cells |
|
|
|
|
# field name current cell |
|
|
|
|
field_name = field_names[col_number] |
|
|
|
|
if field_name =='theme': |
|
|
|
|
# need save object before saving manytomany field |
|
|
|
|
#object.save() |
|
|
|
|
setting = import_settings.get(field_name) |
|
|
|
|
d[setting] = cell |
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
# go through row cells |
|
|
|
|
# field name current cell |
|
|
|
|
field_name = field_names[col_number] |
|
|
|
|
if field_name =='theme': |
|
|
|
|
# need save object before saving manytomany field |
|
|
|
|
#object.save() |
|
|
|
|
setting = import_settings.get(field_name) |
|
|
|
|
d[setting] = cell |
|
|
|
|
|
|
|
|
|
if setting is not None: |
|
|
|
|
# if setting exist for this field |
|
|
|
|
func = setting.get('func') |
|
|
|
|
if func is not None: |
|
|
|
|
extra_value = setting.get('extra_values') |
|
|
|
|
if extra_value is not None: |
|
|
|
|
# if setting has extra value then |
|
|
|
|
# it is some field like city, theme, tag |
|
|
|
|
# that has relation and can be created |
|
|
|
|
|
|
|
|
|
# in function we add language(need for relation fields) |
|
|
|
|
# and extra value from object (like for city need country) |
|
|
|
|
if cell: |
|
|
|
|
value = func(cell, lang, getattr(object, extra_value)) |
|
|
|
|
else: |
|
|
|
|
value = None |
|
|
|
|
else: |
|
|
|
|
value = func(cell) |
|
|
|
|
if value: |
|
|
|
|
setattr(object, field_name, value) |
|
|
|
|
""" |
|
|
|
|
if setting is not None: |
|
|
|
|
# if setting exist for this field |
|
|
|
|
func = setting.get('func') |
|
|
|
|
if func is not None: |
|
|
|
|
extra_value = setting.get('extra_values') |
|
|
|
|
if extra_value is not None: |
|
|
|
|
# if setting has extra value then |
|
|
|
|
# it is some field like city, theme, tag |
|
|
|
|
# that has relation and can be created |
|
|
|
|
|
|
|
|
|
# in function we add language(need for relation fields) |
|
|
|
|
# and extra value from object (like for city need country) |
|
|
|
|
if cell: |
|
|
|
|
value = func(cell, lang, getattr(object, extra_value)) |
|
|
|
|
else: |
|
|
|
|
value = None |
|
|
|
|
else: |
|
|
|
|
value = func(cell) |
|
|
|
|
if value: |
|
|
|
|
setattr(object, field_name, value) |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
#object.save() |
|
|
|
|
#object.save() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|