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
65105d9d
Commit
65105d9d
authored
Jan 15, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge remote-tracking branch 'cc/develop/custom_float' into Develop
parent
3a4d351a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
db.py
cps/db.py
+8
-3
editbooks.py
cps/editbooks.py
+2
-2
book_edit.html
cps/templates/book_edit.html
+2
-2
No files found.
cps/db.py
View file @
65105d9d
...
...
@@ -25,13 +25,13 @@ import ast
from
sqlalchemy
import
create_engine
from
sqlalchemy
import
Table
,
Column
,
ForeignKey
from
sqlalchemy
import
String
,
Integer
,
Boolean
,
TIMESTAMP
from
sqlalchemy
import
String
,
Integer
,
Boolean
,
TIMESTAMP
,
Float
from
sqlalchemy.orm
import
relationship
,
sessionmaker
,
scoped_session
from
sqlalchemy.ext.declarative
import
declarative_base
session
=
None
cc_exceptions
=
[
'datetime'
,
'comments'
,
'
float'
,
'
composite'
,
'series'
]
cc_exceptions
=
[
'datetime'
,
'comments'
,
'composite'
,
'series'
]
cc_classes
=
{}
engine
=
None
...
...
@@ -378,6 +378,11 @@ def setup_db(config):
'id'
:
Column
(
Integer
,
primary_key
=
True
),
'book'
:
Column
(
Integer
,
ForeignKey
(
'books.id'
)),
'value'
:
Column
(
Integer
)}
elif
row
.
datatype
==
'float'
:
ccdict
=
{
'__tablename__'
:
'custom_column_'
+
str
(
row
.
id
),
'id'
:
Column
(
Integer
,
primary_key
=
True
),
'book'
:
Column
(
Integer
,
ForeignKey
(
'books.id'
)),
'value'
:
Column
(
Float
)}
else
:
ccdict
=
{
'__tablename__'
:
'custom_column_'
+
str
(
row
.
id
),
'id'
:
Column
(
Integer
,
primary_key
=
True
),
...
...
@@ -385,7 +390,7 @@ def setup_db(config):
cc_classes
[
row
.
id
]
=
type
(
str
(
'Custom_Column_'
+
str
(
row
.
id
)),
(
Base
,),
ccdict
)
for
cc_id
in
cc_ids
:
if
(
cc_id
[
1
]
==
'bool'
)
or
(
cc_id
[
1
]
==
'int'
):
if
(
cc_id
[
1
]
==
'bool'
)
or
(
cc_id
[
1
]
==
'int'
)
or
(
cc_id
[
1
]
==
'float'
)
:
setattr
(
Books
,
'custom_column_'
+
str
(
cc_id
[
0
]),
relationship
(
cc_classes
[
cc_id
[
0
]],
primaryjoin
=
(
Books
.
id
==
cc_classes
[
cc_id
[
0
]]
.
book
),
...
...
cps/editbooks.py
View file @
65105d9d
...
...
@@ -175,7 +175,7 @@ def delete_book(book_id, book_format):
cc_string
=
"custom_column_"
+
str
(
c
.
id
)
if
not
c
.
is_multiple
:
if
len
(
getattr
(
book
,
cc_string
))
>
0
:
if
c
.
datatype
==
'bool'
or
c
.
datatype
==
'integer'
:
if
c
.
datatype
==
'bool'
or
c
.
datatype
==
'integer'
or
c
.
datatype
==
'float'
:
del_cc
=
getattr
(
book
,
cc_string
)[
0
]
getattr
(
book
,
cc_string
)
.
remove
(
del_cc
)
db
.
session
.
delete
(
del_cc
)
...
...
@@ -254,7 +254,7 @@ def edit_cc_data(book_id, book, to_save):
else
:
cc_db_value
=
None
if
to_save
[
cc_string
]
.
strip
():
if
c
.
datatype
==
'int'
or
c
.
datatype
==
'bool'
:
if
c
.
datatype
==
'int'
or
c
.
datatype
==
'bool'
or
c
.
datatype
==
'float'
:
if
to_save
[
cc_string
]
==
'None'
:
to_save
[
cc_string
]
=
None
elif
c
.
datatype
==
'bool'
:
...
...
cps/templates/book_edit.html
View file @
65105d9d
...
...
@@ -113,8 +113,8 @@
</select>
{% endif %}
{% if c.datatype == 'int' %}
<input
type=
"number"
step=
"1
"
class=
"form-control"
name=
"{{ 'custom_column_' ~ c.id }}"
id=
"{{ 'custom_column_' ~ c.id }}"
value=
"{% if book['custom_column_' ~ c.id]|length > 0 %}{{ book['custom_column_' ~ c.id][0].value }}{% endif %}"
>
{% if c.datatype == 'int'
or c.datatype == 'float'
%}
<input
type=
"number"
step=
"{% if c.datatype == 'float' %}0.01{% else %}1{% endif %}
"
class=
"form-control"
name=
"{{ 'custom_column_' ~ c.id }}"
id=
"{{ 'custom_column_' ~ c.id }}"
value=
"{% if book['custom_column_' ~ c.id]|length > 0 %}{{ book['custom_column_' ~ c.id][0].value }}{% endif %}"
>
{% endif %}
{% if c.datatype in ['text', 'series'] and not c.is_multiple %}
...
...
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