mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-25 17:40:31 +00:00
Added "comments" type to supported custom columns
This commit is contained in:
parent
380292a8aa
commit
6bf360fbfb
@ -59,7 +59,7 @@ except ImportError:
|
|||||||
|
|
||||||
log = logger.create()
|
log = logger.create()
|
||||||
|
|
||||||
cc_exceptions = ['comments', 'composite', 'series']
|
cc_exceptions = ['composite', 'series']
|
||||||
cc_classes = {}
|
cc_classes = {}
|
||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
@ -473,7 +473,7 @@ class CalibreDB():
|
|||||||
}
|
}
|
||||||
books_custom_column_links[row.id] = type(str('books_custom_column_' + str(row.id) + '_link'),
|
books_custom_column_links[row.id] = type(str('books_custom_column_' + str(row.id) + '_link'),
|
||||||
(Base,), dicttable)
|
(Base,), dicttable)
|
||||||
else:
|
if row.datatype in ['rating', 'text', 'enumeration']:
|
||||||
books_custom_column_links[row.id] = Table('books_custom_column_' + str(row.id) + '_link',
|
books_custom_column_links[row.id] = Table('books_custom_column_' + str(row.id) + '_link',
|
||||||
Base.metadata,
|
Base.metadata,
|
||||||
Column('book', Integer, ForeignKey('books.id'),
|
Column('book', Integer, ForeignKey('books.id'),
|
||||||
@ -497,12 +497,12 @@ class CalibreDB():
|
|||||||
ccdict['value'] = Column(Boolean)
|
ccdict['value'] = Column(Boolean)
|
||||||
else:
|
else:
|
||||||
ccdict['value'] = Column(String)
|
ccdict['value'] = Column(String)
|
||||||
if row.datatype in ['float', 'int', 'bool', 'datetime']:
|
if row.datatype in ['float', 'int', 'bool', 'datetime', 'comments']:
|
||||||
ccdict['book'] = Column(Integer, ForeignKey('books.id'))
|
ccdict['book'] = Column(Integer, ForeignKey('books.id'))
|
||||||
cc_classes[row.id] = type(str('custom_column_' + str(row.id)), (Base,), ccdict)
|
cc_classes[row.id] = type(str('custom_column_' + str(row.id)), (Base,), ccdict)
|
||||||
|
|
||||||
for cc_id in cc_ids:
|
for cc_id in cc_ids:
|
||||||
if cc_id[1] in ['bool', 'int', 'float', 'datetime']:
|
if cc_id[1] in ['bool', 'int', 'float', 'datetime', 'comments']:
|
||||||
setattr(Books,
|
setattr(Books,
|
||||||
'custom_column_' + str(cc_id[0]),
|
'custom_column_' + str(cc_id[0]),
|
||||||
relationship(cc_classes[cc_id[0]],
|
relationship(cc_classes[cc_id[0]],
|
||||||
|
@ -495,7 +495,7 @@ def edit_book_publisher(publishers, book):
|
|||||||
return changed
|
return changed
|
||||||
|
|
||||||
|
|
||||||
def edit_cc_data_number(book_id, book, c, to_save, cc_db_value, cc_string):
|
def edit_cc_data_value(book_id, book, c, to_save, cc_db_value, cc_string):
|
||||||
changed = False
|
changed = False
|
||||||
if to_save[cc_string] == 'None':
|
if to_save[cc_string] == 'None':
|
||||||
to_save[cc_string] = None
|
to_save[cc_string] = None
|
||||||
@ -564,8 +564,8 @@ def edit_cc_data(book_id, book, to_save):
|
|||||||
else:
|
else:
|
||||||
cc_db_value = None
|
cc_db_value = None
|
||||||
if to_save[cc_string].strip():
|
if to_save[cc_string].strip():
|
||||||
if c.datatype in ['int', 'bool', 'float', "datetime"]:
|
if c.datatype in ['int', 'bool', 'float', "datetime", "comments"]:
|
||||||
changed, to_save = edit_cc_data_number(book_id, book, c, to_save, cc_db_value, cc_string)
|
changed, to_save = edit_cc_data_value(book_id, book, c, to_save, cc_db_value, cc_string)
|
||||||
else:
|
else:
|
||||||
changed, to_save = edit_cc_data_string(book, c, to_save, cc_db_value, cc_string)
|
changed, to_save = edit_cc_data_string(book, c, to_save, cc_db_value, cc_string)
|
||||||
else:
|
else:
|
||||||
|
@ -10,25 +10,36 @@ if ($("#description").length) {
|
|||||||
menubar: "edit view format",
|
menubar: "edit view format",
|
||||||
language: language
|
language: language
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Modernizr.inputtypes.date) {
|
|
||||||
$("#pubdate").datepicker({
|
|
||||||
format: "yyyy-mm-dd",
|
|
||||||
language: language
|
|
||||||
}).on("change", function () {
|
|
||||||
// Show localized date over top of the standard YYYY-MM-DD date
|
|
||||||
var pubDate;
|
|
||||||
var results = /(\d{4})[-\/\\](\d{1,2})[-\/\\](\d{1,2})/.exec(this.value); // YYYY-MM-DD
|
|
||||||
if (results) {
|
|
||||||
pubDate = new Date(results[1], parseInt(results[2], 10) - 1, results[3]) || new Date(this.value);
|
|
||||||
$("#fake_pubdate")
|
|
||||||
.val(pubDate.toLocaleDateString(language))
|
|
||||||
.removeClass("hidden");
|
|
||||||
}
|
|
||||||
}).trigger("change");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($(".tiny_editor").length) {
|
||||||
|
tinymce.init({
|
||||||
|
selector: ".tiny_editor",
|
||||||
|
branding: false,
|
||||||
|
menubar: "edit view format",
|
||||||
|
language: language
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
tiny_editor
|
||||||
|
if (!Modernizr.inputtypes.date) {
|
||||||
|
$("#pubdate").datepicker({
|
||||||
|
format: "yyyy-mm-dd",
|
||||||
|
language: language
|
||||||
|
}).on("change", function () {
|
||||||
|
// Show localized date over top of the standard YYYY-MM-DD date
|
||||||
|
var pubDate;
|
||||||
|
var results = /(\d{4})[-\/\\](\d{1,2})[-\/\\](\d{1,2})/.exec(this.value); // YYYY-MM-DD
|
||||||
|
if (results) {
|
||||||
|
pubDate = new Date(results[1], parseInt(results[2], 10) - 1, results[3]) || new Date(this.value);
|
||||||
|
$("#fake_pubdate")
|
||||||
|
.val(pubDate.toLocaleDateString(language))
|
||||||
|
.removeClass("hidden");
|
||||||
|
}
|
||||||
|
}).trigger("change");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!Modernizr.inputtypes.date) {
|
if (!Modernizr.inputtypes.date) {
|
||||||
$("#Publishstart").datepicker({
|
$("#Publishstart").datepicker({
|
||||||
format: "yyyy-mm-dd",
|
format: "yyyy-mm-dd",
|
||||||
|
@ -150,7 +150,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if c.datatype == 'datetime' %}
|
{% if c.datatype == 'datetime' %}
|
||||||
|
|
||||||
<div style="position: relative">
|
<div style="position: relative">
|
||||||
<input type="date" class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}"
|
<input type="date" class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}"
|
||||||
{% if book['custom_column_' ~ c.id]|length > 0 %}
|
{% if book['custom_column_' ~ c.id]|length > 0 %}
|
||||||
@ -163,7 +162,9 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if c.datatype == 'comments' %}
|
||||||
|
<textarea class="form-control tiny_editor" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}" rows="7">{% if book['custom_column_' ~ c.id]|length > 0 %}{{book['custom_column_' ~ c.id][0].value}}{%endif%}</textarea>
|
||||||
|
{% endif %}
|
||||||
{% if c.datatype == 'enumeration' %}
|
{% if c.datatype == 'enumeration' %}
|
||||||
<select class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}">
|
<select class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}">
|
||||||
<option></option>
|
<option></option>
|
||||||
|
@ -195,14 +195,14 @@
|
|||||||
{{ column.value|formatfloat(2) }}
|
{{ column.value|formatfloat(2) }}
|
||||||
{% elif c.datatype == 'datetime' %}
|
{% elif c.datatype == 'datetime' %}
|
||||||
{{ column.value|formatdate }}
|
{{ column.value|formatdate }}
|
||||||
{% else %}
|
{% elif c.datatype == 'comments' %}
|
||||||
{% if c.datatype == 'series' %}
|
{{column.value|safe}}
|
||||||
|
{% elif c.datatype == 'series' %}
|
||||||
{{ '%s [%s]' % (column.value, column.extra|formatfloat(2)) }}
|
{{ '%s [%s]' % (column.value, column.extra|formatfloat(2)) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ column.value }}
|
{{ column.value }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -186,7 +186,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if c.datatype in ['text', 'series'] and not c.is_multiple %}
|
{% if c.datatype in ['text', 'series', 'comments'] and not c.is_multiple %}
|
||||||
<input type="text" class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}" value="">
|
<input type="text" class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}" value="">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user