Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
6bf360fb
Commit
6bf360fb
authored
May 13, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added "comments" type to supported custom columns
parent
380292a8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
29 deletions
+41
-29
db.py
cps/db.py
+4
-4
editbooks.py
cps/editbooks.py
+3
-3
edit_books.js
cps/static/js/edit_books.js
+27
-16
book_edit.html
cps/templates/book_edit.html
+3
-2
detail.html
cps/templates/detail.html
+3
-3
search_form.html
cps/templates/search_form.html
+1
-1
No files found.
cps/db.py
View file @
6bf360fb
...
...
@@ -59,7 +59,7 @@ except ImportError:
log
=
logger
.
create
()
cc_exceptions
=
[
'com
ments'
,
'com
posite'
,
'series'
]
cc_exceptions
=
[
'composite'
,
'series'
]
cc_classes
=
{}
Base
=
declarative_base
()
...
...
@@ -473,7 +473,7 @@ class CalibreDB():
}
books_custom_column_links
[
row
.
id
]
=
type
(
str
(
'books_custom_column_'
+
str
(
row
.
id
)
+
'_link'
),
(
Base
,),
dicttable
)
else
:
if
row
.
datatype
in
[
'rating'
,
'text'
,
'enumeration'
]
:
books_custom_column_links
[
row
.
id
]
=
Table
(
'books_custom_column_'
+
str
(
row
.
id
)
+
'_link'
,
Base
.
metadata
,
Column
(
'book'
,
Integer
,
ForeignKey
(
'books.id'
),
...
...
@@ -497,12 +497,12 @@ class CalibreDB():
ccdict
[
'value'
]
=
Column
(
Boolean
)
else
:
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'
))
cc_classes
[
row
.
id
]
=
type
(
str
(
'custom_column_'
+
str
(
row
.
id
)),
(
Base
,),
ccdict
)
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
,
'custom_column_'
+
str
(
cc_id
[
0
]),
relationship
(
cc_classes
[
cc_id
[
0
]],
...
...
cps/editbooks.py
View file @
6bf360fb
...
...
@@ -495,7 +495,7 @@ def edit_book_publisher(publishers, book):
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
if
to_save
[
cc_string
]
==
'None'
:
to_save
[
cc_string
]
=
None
...
...
@@ -564,8 +564,8 @@ def edit_cc_data(book_id, book, to_save):
else
:
cc_db_value
=
None
if
to_save
[
cc_string
]
.
strip
():
if
c
.
datatype
in
[
'int'
,
'bool'
,
'float'
,
"datetime"
]:
changed
,
to_save
=
edit_cc_data_
number
(
book_id
,
book
,
c
,
to_save
,
cc_db_value
,
cc_string
)
if
c
.
datatype
in
[
'int'
,
'bool'
,
'float'
,
"datetime"
,
"comments"
]:
changed
,
to_save
=
edit_cc_data_
value
(
book_id
,
book
,
c
,
to_save
,
cc_db_value
,
cc_string
)
else
:
changed
,
to_save
=
edit_cc_data_string
(
book
,
c
,
to_save
,
cc_db_value
,
cc_string
)
else
:
...
...
cps/static/js/edit_books.js
View file @
6bf360fb
...
...
@@ -10,25 +10,36 @@ if ($("#description").length) {
menubar
:
"edit view format"
,
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
)
{
$
(
"#Publishstart"
).
datepicker
({
format
:
"yyyy-mm-dd"
,
...
...
cps/templates/book_edit.html
View file @
6bf360fb
...
...
@@ -150,7 +150,6 @@
{% endif %}
{% if c.datatype == 'datetime' %}
<div
style=
"position: relative"
>
<input
type=
"date"
class=
"form-control"
name=
"{{ 'custom_column_' ~ c.id }}"
id=
"{{ 'custom_column_' ~ c.id }}"
{%
if
book
['
custom_column_
'
~
c
.
id
]|
length
>
0 %}
...
...
@@ -163,7 +162,9 @@
</div>
{% 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' %}
<select
class=
"form-control"
name=
"{{ 'custom_column_' ~ c.id }}"
id=
"{{ 'custom_column_' ~ c.id }}"
>
<option></option>
...
...
cps/templates/detail.html
View file @
6bf360fb
...
...
@@ -195,14 +195,14 @@
{{ column.value|formatfloat(2) }}
{% elif c.datatype == 'datetime' %}
{{ column.value|formatdate }}
{% else %}
{% if c.datatype == 'series' %}
{% elif c.datatype == 'comments' %}
{{column.value|safe}}
{% elif c.datatype == 'series' %}
{{ '%s [%s]' % (column.value, column.extra|formatfloat(2)) }}
{% else %}
{{ column.value }}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
...
...
cps/templates/search_form.html
View file @
6bf360fb
...
...
@@ -186,7 +186,7 @@
</div>
{% 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=
""
>
{% endif %}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment