Настройки редактирования
1. Редактирование по клику 2. Текст после сохранения 3. Текст пустой ячейки
This commit is contained in:
@@ -14,18 +14,19 @@ class EditableColumn(tables.TemplateColumn):
|
|||||||
{main_part}
|
{main_part}
|
||||||
'''
|
'''
|
||||||
main_part = ''
|
main_part = ''
|
||||||
|
params = 'auto_height = 1, auto_width = 1'
|
||||||
if object_name == '':
|
if object_name == '':
|
||||||
main_part = '''
|
main_part = '''
|
||||||
{{% inplace_edit "record.{field}" auto_height = 1, auto_width = 1 %}}
|
{{% inplace_edit "record.{field}" {params} %}}
|
||||||
'''
|
'''
|
||||||
else:
|
else:
|
||||||
main_part = '''
|
main_part = '''
|
||||||
{{% if record.{object_name} %}}
|
{{% if record.{object_name} %}}
|
||||||
{{% inplace_edit "record.{object_name}.{field}" auto_height = 1, auto_width = 1 %}}
|
{{% inplace_edit "record.{object_name}.{field}" {params} %}}
|
||||||
{{% endif %}}
|
{{% endif %}}
|
||||||
'''
|
'''
|
||||||
template = template.format(main_part = main_part)
|
template = template.format(main_part = main_part)
|
||||||
template = template.format(field = field_name, object_name = object_name)
|
template = template.format(field = field_name, object_name = object_name, params = params)
|
||||||
|
|
||||||
super(EditableColumn, self).__init__(template, *args, **kwargs)
|
super(EditableColumn, self).__init__(template, *args, **kwargs)
|
||||||
|
|
||||||
@@ -35,7 +36,6 @@ class ColoredEditableColumn(EditableColumn):
|
|||||||
self.condition_field = condition_field
|
self.condition_field = condition_field
|
||||||
|
|
||||||
def render(self, record, **kwargs):
|
def render(self, record, **kwargs):
|
||||||
print eval('record.%s' % self.condition_field)
|
|
||||||
if self.condition_field != None and eval('record.%s' % self.condition_field):
|
if self.condition_field != None and eval('record.%s' % self.condition_field):
|
||||||
self.attrs = {'td': {'bgcolor': '#FFE4E1'}}
|
self.attrs = {'td': {'bgcolor': '#FFE4E1'}}
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Django settings for record project.
|
Django settings for record project.
|
||||||
|
|
||||||
@@ -96,3 +98,9 @@ MEDIA_ROOT = 'media/'
|
|||||||
MEDIA_URL = 'http://127.0.0.1:8000/media/'
|
MEDIA_URL = 'http://127.0.0.1:8000/media/'
|
||||||
|
|
||||||
THUMBNAIL_ENGINE = 'sorl.thumbnail.engines.convert_engine.Engine'
|
THUMBNAIL_ENGINE = 'sorl.thumbnail.engines.convert_engine.Engine'
|
||||||
|
|
||||||
|
INPLACEEDIT_EVENT = 'click'
|
||||||
|
|
||||||
|
INPLACEEDIT_SUCCESS_TEXT = u'Сохранено'
|
||||||
|
|
||||||
|
INPLACEEDIT_EDIT_EMPTY_VALUE = u'Редактировать'
|
||||||
|
|||||||
Reference in New Issue
Block a user