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
1e1d3a7c
Commit
1e1d3a7c
authored
Oct 17, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable edit of enum column in books list
parent
2ebddcfe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
18 deletions
+14
-18
editbooks.py
cps/editbooks.py
+11
-17
book_table.html
cps/templates/book_table.html
+3
-1
No files found.
cps/editbooks.py
View file @
1e1d3a7c
...
...
@@ -1088,23 +1088,17 @@ def convert_bookformat(book_id):
flash
(
_
(
u"There was an error converting this book:
%(res)
s"
,
res
=
rtn
),
category
=
"error"
)
return
redirect
(
url_for
(
'editbook.edit_book'
,
book_id
=
book_id
))
@
editbook
.
route
(
"/scholarsearch/<query>"
,
methods
=
[
'GET'
])
@
login_required_if_no_ano
@
edit_required
def
scholar_search
(
query
):
if
have_scholar
:
scholar_gen
=
scholarly
.
search_pubs
(
' '
.
join
(
query
.
split
(
'+'
)))
i
=
0
result
=
[]
for
publication
in
scholar_gen
:
del
publication
[
'source'
]
result
.
append
(
publication
)
i
+=
1
if
(
i
>=
10
):
break
return
Response
(
json
.
dumps
(
result
),
mimetype
=
'application/json'
)
else
:
return
"[]"
@
editbook
.
route
(
"/ajax/getcustomenum/<int:c_id>"
)
@
login_required
def
table_get_custom_enum
(
c_id
):
ret
=
list
()
cc
=
(
calibre_db
.
session
.
query
(
db
.
Custom_Columns
)
.
filter
(
db
.
Custom_Columns
.
id
==
c_id
)
.
filter
(
db
.
Custom_Columns
.
datatype
.
notin_
(
db
.
cc_exceptions
))
.
one_or_none
())
for
idx
,
en
in
enumerate
(
cc
.
get_display_dict
()[
'enum_values'
]):
ret
.
append
({
'value'
:
en
,
'text'
:
en
})
return
json
.
dumps
(
ret
)
@
editbook
.
route
(
"/ajax/editbooks/<param>"
,
methods
=
[
'POST'
])
@
login_required_if_no_ano
...
...
cps/templates/book_table.html
View file @
1e1d3a7c
...
...
@@ -63,9 +63,11 @@
{% if c.datatype == "int" %}
<th
data-field=
"custom_column_{{ c.id|string }}"
id=
"custom_column_{{ c.id|string }}"
data-visible=
"{{visiblility.get('custom_column_'+ c.id|string)}}"
data-sortable=
"false"
{%
if
g
.
user
.
role_edit
()
%}
data-editable-type=
"number"
data-editable-placeholder=
"1"
data-editable-step=
"1"
data-editable-url=
"{{ url_for('editbook.edit_list_book', param='custom_column_'+ c.id|string)}}"
data-edit=
"true"
data-editable-title=
"{{_('Enter ') + c.name}}"
{%
endif
%}
>
{{c.name}}
</th>
{% elif c.datatype == "rating" %}
<th
data-field=
"custom_column_{{ c.id|string }}"
id=
"custom_column_{{ c.id|string }}"
data-formatter=
"ratingFormatter"
data-visible=
"{{visiblility.get('custom_column_'+ c.id|string)}}"
data-sortable=
"false"
{%
if
g
.
user
.
role_edit
()
%}
data-editable-type=
"number"
data-editable-placeholder=
"1"
data-editable-step=
"1"
data-editable-min=
"0"
data-editable-max=
"
10
"
data-editable-url=
"{{ url_for('editbook.edit_list_book', param='custom_column_'+ c.id|string)}}"
data-edit=
"true"
data-editable-title=
"{{_('Enter ') + c.name}}"
{%
endif
%}
>
{{c.name}}
</th>
<th
data-field=
"custom_column_{{ c.id|string }}"
id=
"custom_column_{{ c.id|string }}"
data-formatter=
"ratingFormatter"
data-visible=
"{{visiblility.get('custom_column_'+ c.id|string)}}"
data-sortable=
"false"
{%
if
g
.
user
.
role_edit
()
%}
data-editable-type=
"number"
data-editable-placeholder=
"1"
data-editable-step=
"1"
data-editable-min=
"0"
data-editable-max=
"
5
"
data-editable-url=
"{{ url_for('editbook.edit_list_book', param='custom_column_'+ c.id|string)}}"
data-edit=
"true"
data-editable-title=
"{{_('Enter ') + c.name}}"
{%
endif
%}
>
{{c.name}}
</th>
{% elif c.datatype == "float" %}
<th
data-field=
"custom_column_{{ c.id|string }}"
id=
"custom_column_{{ c.id|string }}"
data-visible=
"{{visiblility.get('custom_column_'+ c.id|string)}}"
data-sortable=
"false"
{%
if
g
.
user
.
role_edit
()
%}
data-editable-type=
"number"
data-editable-placeholder=
"1"
data-editable-step=
"0.01"
data-editable-url=
"{{ url_for('editbook.edit_list_book', param='custom_column_'+ c.id|string)}}"
data-edit=
"true"
data-editable-title=
"{{_('Enter ') + c.name}}"
{%
endif
%}
>
{{c.name}}
</th>
{% elif c.datatype == "enumeration" %}
<th
data-field=
"custom_column_{{ c.id|string }}"
id=
"custom_column_{{ c.id|string }}"
data-visible=
"{{visiblility.get('custom_column_'+ c.id|string)}}"
data-sortable=
"false"
{%
if
g
.
user
.
role_edit
()
%}
data-editable-type=
"select"
data-editable-source=
{{
url_for
('
editbook
.
table_get_custom_enum
',
c_id=
c.id)
}}
data-editable-url=
"{{ url_for('editbook.edit_list_book', param='custom_column_'+ c.id|string)}}"
data-edit=
"true"
data-editable-title=
"{{_('Enter ') + c.name}}"
{%
endif
%}
>
{{c.name}}
</th>
{% else %}
<!--{{ text_table_row('custom_column_' + c.id|string, _('Enter ') + c.name, c.name, false, false) }} -->
{% 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