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
a9a6f5b9
Commit
a9a6f5b9
authored
Feb 15, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed restrict -> deny
parent
8b1444eb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
67 deletions
+53
-67
admin.py
cps/admin.py
+25
-36
config_sql.py
cps/config_sql.py
+8
-8
helper.py
cps/helper.py
+4
-7
modal_restriction.html
cps/templates/modal_restriction.html
+5
-5
ub.py
cps/ub.py
+11
-11
No files found.
cps/admin.py
View file @
a9a6f5b9
...
...
@@ -171,10 +171,7 @@ def update_view_configuration():
_config_int
(
"config_random_books"
)
_config_int
(
"config_books_per_page"
)
_config_int
(
"config_authors_max"
)
_config_string
(
"config_restricted_tags"
)
_config_int
(
"config_restricted_column"
)
_config_string
(
"config_restricted_column_value"
)
if
config
.
config_google_drive_watch_changes_response
:
config
.
config_google_drive_watch_changes_response
=
json
.
dumps
(
config
.
config_google_drive_watch_changes_response
)
...
...
@@ -289,14 +286,14 @@ def edit_restriction(type):
ub
.
session
.
commit
()
if
element
[
'id'
]
.
startswith
(
'd'
):
if
type
==
0
:
# Tags as template
elementlist
=
config
.
list_
restrict
ed_tags
()
elementlist
=
config
.
list_
deni
ed_tags
()
elementlist
[
int
(
element
[
'id'
][
1
:])]
=
element
[
'Element'
]
config
.
config_
restrict
ed_tags
=
','
.
join
(
elementlist
)
config
.
config_
deni
ed_tags
=
','
.
join
(
elementlist
)
config
.
save
()
if
type
==
1
:
# CustomC
elementlist
=
config
.
list_
restrict
ed_column_values
()
elementlist
=
config
.
list_
deni
ed_column_values
()
elementlist
[
int
(
element
[
'id'
][
1
:])]
=
element
[
'Element'
]
config
.
config_
restrict
ed_column_value
=
','
.
join
(
elementlist
)
config
.
config_
deni
ed_column_value
=
','
.
join
(
elementlist
)
config
.
save
()
pass
if
type
==
2
:
# Tags per user
...
...
@@ -305,9 +302,9 @@ def edit_restriction(type):
usr
=
ub
.
session
.
query
(
ub
.
User
)
.
filter
(
ub
.
User
.
id
==
int
(
usr_id
))
.
first
()
else
:
usr
=
current_user
elementlist
=
usr
.
list_
restrict
ed_tags
()
elementlist
=
usr
.
list_
deni
ed_tags
()
elementlist
[
int
(
element
[
'id'
][
1
:])]
=
element
[
'Element'
]
usr
.
restrict
ed_tags
=
','
.
join
(
elementlist
)
usr
.
deni
ed_tags
=
','
.
join
(
elementlist
)
ub
.
session
.
commit
()
if
type
==
3
:
# CColumn per user
usr_id
=
os
.
path
.
split
(
request
.
referrer
)[
-
1
]
...
...
@@ -315,9 +312,9 @@ def edit_restriction(type):
usr
=
ub
.
session
.
query
(
ub
.
User
)
.
filter
(
ub
.
User
.
id
==
int
(
usr_id
))
.
first
()
else
:
usr
=
current_user
elementlist
=
usr
.
list_
restrict
ed_column_values
()
elementlist
=
usr
.
list_
deni
ed_column_values
()
elementlist
[
int
(
element
[
'id'
][
1
:])]
=
element
[
'Element'
]
usr
.
restrict
ed_column_value
=
','
.
join
(
elementlist
)
usr
.
deni
ed_column_value
=
','
.
join
(
elementlist
)
ub
.
session
.
commit
()
return
""
...
...
@@ -348,14 +345,14 @@ def add_restriction(type):
config
.
config_allowed_tags
=
restriction_addition
(
element
,
config
.
list_allowed_tags
)
config
.
save
()
elif
'submit_deny'
in
element
:
config
.
config_
restricted_tags
=
restriction_addition
(
element
,
config
.
list_restrict
ed_tags
)
config
.
config_
denied_tags
=
restriction_addition
(
element
,
config
.
list_deni
ed_tags
)
config
.
save
()
if
type
==
1
:
# CCustom as template
if
'submit_allow'
in
element
:
config
.
config_allowed_column_value
=
restriction_addition
(
element
,
config
.
list_
restrict
ed_column_values
)
config
.
config_allowed_column_value
=
restriction_addition
(
element
,
config
.
list_
deni
ed_column_values
)
config
.
save
()
elif
'submit_deny'
in
element
:
config
.
config_
restrict
ed_column_value
=
restriction_addition
(
element
,
config
.
list_allowed_column_values
)
config
.
config_
deni
ed_column_value
=
restriction_addition
(
element
,
config
.
list_allowed_column_values
)
config
.
save
()
if
type
==
2
:
# Tags per user
usr_id
=
os
.
path
.
split
(
request
.
referrer
)[
-
1
]
...
...
@@ -367,7 +364,7 @@ def add_restriction(type):
usr
.
allowed_tags
=
restriction_addition
(
element
,
usr
.
list_allowed_tags
)
ub
.
session
.
commit
()
elif
'submit_deny'
in
element
:
usr
.
restricted_tags
=
restriction_addition
(
element
,
usr
.
list_restrict
ed_tags
)
usr
.
denied_tags
=
restriction_addition
(
element
,
usr
.
list_deni
ed_tags
)
ub
.
session
.
commit
()
if
type
==
3
:
# CustomC per user
usr_id
=
os
.
path
.
split
(
request
.
referrer
)[
-
1
]
...
...
@@ -379,7 +376,7 @@ def add_restriction(type):
usr
.
allowed_column_value
=
restriction_addition
(
element
,
usr
.
list_allowed_column_values
)
ub
.
session
.
commit
()
elif
'submit_deny'
in
element
:
usr
.
restricted_column_value
=
restriction_addition
(
element
,
usr
.
list_restrict
ed_column_values
)
usr
.
denied_column_value
=
restriction_addition
(
element
,
usr
.
list_deni
ed_column_values
)
ub
.
session
.
commit
()
return
""
...
...
@@ -393,14 +390,14 @@ def delete_restriction(type):
config
.
config_allowed_tags
=
restriction_deletion
(
element
,
config
.
list_allowed_tags
)
config
.
save
()
elif
element
[
'id'
]
.
startswith
(
'd'
):
config
.
config_
restricted_tags
=
restriction_deletion
(
element
,
config
.
list_restrict
ed_tags
)
config
.
config_
denied_tags
=
restriction_deletion
(
element
,
config
.
list_deni
ed_tags
)
config
.
save
()
elif
type
==
1
:
# CustomC as template
if
element
[
'id'
]
.
startswith
(
'a'
):
config
.
config_allowed_column_value
=
restriction_deletion
(
element
,
config
.
list_allowed_column_values
)
config
.
save
()
elif
element
[
'id'
]
.
startswith
(
'd'
):
config
.
config_
restricted_column_value
=
restriction_deletion
(
element
,
config
.
list_restrict
ed_column_values
)
config
.
config_
denied_column_value
=
restriction_deletion
(
element
,
config
.
list_deni
ed_column_values
)
config
.
save
()
elif
type
==
2
:
# Tags per user
usr_id
=
os
.
path
.
split
(
request
.
referrer
)[
-
1
]
...
...
@@ -412,7 +409,7 @@ def delete_restriction(type):
usr
.
allowed_tags
=
restriction_deletion
(
element
,
usr
.
list_allowed_tags
)
ub
.
session
.
commit
()
elif
element
[
'id'
]
.
startswith
(
'd'
):
usr
.
restricted_tags
=
restriction_deletion
(
element
,
usr
.
list_restrict
ed_tags
)
usr
.
denied_tags
=
restriction_deletion
(
element
,
usr
.
list_deni
ed_tags
)
ub
.
session
.
commit
()
elif
type
==
3
:
# Columns per user
usr_id
=
os
.
path
.
split
(
request
.
referrer
)[
-
1
]
...
...
@@ -424,7 +421,7 @@ def delete_restriction(type):
usr
.
allowed_column_value
=
restriction_deletion
(
element
,
usr
.
list_allowed_column_values
)
ub
.
session
.
commit
()
elif
element
[
'id'
]
.
startswith
(
'd'
):
usr
.
restricted_column_value
=
restriction_deletion
(
element
,
usr
.
list_restrict
ed_column_values
)
usr
.
denied_column_value
=
restriction_deletion
(
element
,
usr
.
list_deni
ed_column_values
)
ub
.
session
.
commit
()
return
""
...
...
@@ -436,13 +433,13 @@ def delete_restriction(type):
def
list_restriction
(
type
):
if
type
==
0
:
# Tags as template
restrict
=
[{
'Element'
:
x
,
'type'
:
_
(
'deny'
),
'id'
:
'd'
+
str
(
i
)
}
for
i
,
x
in
enumerate
(
config
.
list_
restrict
ed_tags
())
if
x
!=
''
]
for
i
,
x
in
enumerate
(
config
.
list_
deni
ed_tags
())
if
x
!=
''
]
allow
=
[{
'Element'
:
x
,
'type'
:
_
(
'allow'
),
'id'
:
'a'
+
str
(
i
)
}
for
i
,
x
in
enumerate
(
config
.
list_allowed_tags
())
if
x
!=
''
]
json_dumps
=
restrict
+
allow
elif
type
==
1
:
# CustomC as template
restrict
=
[{
'Element'
:
x
,
'type'
:
_
(
'deny'
),
'id'
:
'd'
+
str
(
i
)
}
for
i
,
x
in
enumerate
(
config
.
list_
restrict
ed_column_values
())
if
x
!=
''
]
for
i
,
x
in
enumerate
(
config
.
list_
deni
ed_column_values
())
if
x
!=
''
]
allow
=
[{
'Element'
:
x
,
'type'
:
_
(
'allow'
),
'id'
:
'a'
+
str
(
i
)
}
for
i
,
x
in
enumerate
(
config
.
list_allowed_column_values
())
if
x
!=
''
]
json_dumps
=
restrict
+
allow
...
...
@@ -453,7 +450,7 @@ def list_restriction(type):
else
:
usr
=
current_user
restrict
=
[{
'Element'
:
x
,
'type'
:
_
(
'deny'
),
'id'
:
'd'
+
str
(
i
)
}
for
i
,
x
in
enumerate
(
usr
.
list_
restrict
ed_tags
())
if
x
!=
''
]
for
i
,
x
in
enumerate
(
usr
.
list_
deni
ed_tags
())
if
x
!=
''
]
allow
=
[{
'Element'
:
x
,
'type'
:
_
(
'allow'
),
'id'
:
'a'
+
str
(
i
)
}
for
i
,
x
in
enumerate
(
usr
.
list_allowed_tags
())
if
x
!=
''
]
json_dumps
=
restrict
+
allow
...
...
@@ -464,7 +461,7 @@ def list_restriction(type):
else
:
usr
=
current_user
restrict
=
[{
'Element'
:
x
,
'type'
:
_
(
'deny'
),
'id'
:
'd'
+
str
(
i
)
}
for
i
,
x
in
enumerate
(
usr
.
list_
restrict
ed_column_values
())
if
x
!=
''
]
for
i
,
x
in
enumerate
(
usr
.
list_
deni
ed_column_values
())
if
x
!=
''
]
allow
=
[{
'Element'
:
x
,
'type'
:
_
(
'allow'
),
'id'
:
'a'
+
str
(
i
)
}
for
i
,
x
in
enumerate
(
usr
.
list_allowed_column_values
())
if
x
!=
''
]
json_dumps
=
restrict
+
allow
...
...
@@ -726,10 +723,10 @@ def new_user():
else
:
content
.
role
=
config
.
config_default_role
content
.
sidebar_view
=
config
.
config_default_show
content
.
restricted_tags
=
config
.
config_restrict
ed_tags
content
.
restricted_column
=
config
.
config_restricted_column
content
.
restricted_column_value
=
config
.
config_restrict
ed_column_value
# content.mature_content = bool(config.config_default_show & constants.MATURE_CONTENT)
content
.
allowed_tags
=
config
.
config_allow
ed_tags
content
.
denied_tags
=
config
.
config_denied_tags
content
.
allowed_column_value
=
config
.
config_allow
ed_column_value
content
.
allowed_column_value
=
config
.
config_denied_column_value
return
render_title_template
(
"user_edit.html"
,
new_user
=
1
,
content
=
content
,
translations
=
translations
,
languages
=
languages
,
title
=
_
(
u"Add new user"
),
page
=
"newuser"
,
kobo_support
=
kobo_support
,
registered_oauth
=
oauth_check
)
...
...
@@ -833,14 +830,6 @@ def edit_user(user_id):
else
:
content
.
sidebar_view
&=
~
constants
.
DETAIL_RANDOM
# content.mature_content = "Show_mature_content" in to_save
if
"restricted_tags"
in
to_save
:
content
.
restricted_tags
=
to_save
[
"restricted_tags"
]
if
"config_restricted_column"
in
to_save
:
content
.
restricted_tags
=
to_save
[
"config_restricted_column"
]
if
"config_restricted_column_value"
in
to_save
:
content
.
restricted_tags
=
to_save
[
"config_restricted_column_value"
]
if
"default_language"
in
to_save
:
content
.
default_language
=
to_save
[
"default_language"
]
if
"locale"
in
to_save
and
to_save
[
"locale"
]:
...
...
cps/config_sql.py
View file @
a9a6f5b9
...
...
@@ -74,10 +74,10 @@ class _Settings(_Base):
config_default_show
=
Column
(
SmallInteger
,
default
=
6143
)
config_columns_to_ignore
=
Column
(
String
)
config_
restrict
ed_tags
=
Column
(
String
,
default
=
""
)
config_
deni
ed_tags
=
Column
(
String
,
default
=
""
)
config_allowed_tags
=
Column
(
String
,
default
=
""
)
config_restricted_column
=
Column
(
SmallInteger
,
default
=
0
)
config_
restrict
ed_column_value
=
Column
(
String
,
default
=
""
)
config_
deni
ed_column_value
=
Column
(
String
,
default
=
""
)
config_allowed_column_value
=
Column
(
String
,
default
=
""
)
config_use_google_drive
=
Column
(
Boolean
,
default
=
False
)
...
...
@@ -186,16 +186,16 @@ class _ConfigSQL(object):
def
show_detail_random
(
self
):
return
self
.
show_element_new_user
(
constants
.
DETAIL_RANDOM
)
def
list_
restrict
ed_tags
(
self
):
mct
=
self
.
config_
restrict
ed_tags
.
split
(
","
)
def
list_
deni
ed_tags
(
self
):
mct
=
self
.
config_
deni
ed_tags
.
split
(
","
)
return
[
t
.
strip
()
for
t
in
mct
]
def
list_allowed_tags
(
self
):
mct
=
self
.
config_allowed_tags
.
split
(
","
)
return
[
t
.
strip
()
for
t
in
mct
]
def
list_
restrict
ed_column_values
(
self
):
mct
=
self
.
config_
restrict
ed_column_value
.
split
(
","
)
def
list_
deni
ed_column_values
(
self
):
mct
=
self
.
config_
deni
ed_column_value
.
split
(
","
)
return
[
t
.
strip
()
for
t
in
mct
]
def
list_allowed_column_values
(
self
):
...
...
@@ -341,8 +341,8 @@ def load_configuration(session):
session
.
commit
()
conf
=
_ConfigSQL
(
session
)
# Migrate from global restrictions to user based restrictions
if
bool
(
conf
.
config_default_show
&
constants
.
MATURE_CONTENT
)
and
conf
.
config_
restrict
ed_tags
==
""
:
conf
.
config_
restrict
ed_tags
=
conf
.
config_mature_content_tags
if
bool
(
conf
.
config_default_show
&
constants
.
MATURE_CONTENT
)
and
conf
.
config_
deni
ed_tags
==
""
:
conf
.
config_
deni
ed_tags
=
conf
.
config_mature_content_tags
conf
.
save
()
session
.
query
(
ub
.
User
)
.
filter
(
ub
.
User
.
mature_content
!=
True
)
.
\
update
({
"restricted_tags"
:
conf
.
config_mature_content_tags
},
synchronize_session
=
False
)
...
...
cps/helper.py
View file @
a9a6f5b9
...
...
@@ -688,20 +688,17 @@ def common_filters():
lang_filter
=
db
.
Books
.
languages
.
any
(
db
.
Languages
.
lang_code
==
current_user
.
filter_language
())
else
:
lang_filter
=
true
()
negtags_list
=
current_user
.
list_
restrict
ed_tags
()
negtags_list
=
current_user
.
list_
deni
ed_tags
()
postags_list
=
current_user
.
list_allowed_tags
()
neg_content_tags_filter
=
false
()
if
negtags_list
==
[
''
]
else
db
.
Books
.
tags
.
any
(
db
.
Tags
.
name
.
in_
(
negtags_list
))
pos_content_tags_filter
=
true
()
if
postags_list
==
[
''
]
else
db
.
Books
.
tags
.
any
(
db
.
Tags
.
name
.
in_
(
postags_list
))
# db.session.query(db.Books).filter(db.Books.custom_column_5.any(db.cc_classes[5].value == 'nikto')).first()
# db.session.query(db.Books).filter(
# getattr(db.Books, 'custom_column_' + str(5)).any(db.cc_classes[5].value == 'nikto').first())
if
config
.
config_restricted_column
:
pos_cc_list
=
current_user
.
allowed_column_value
.
split
(
','
)
pos_content_cc_filter
=
true
()
if
pos_cc_list
==
[
''
]
else
\
getattr
(
db
.
Books
,
'custom_column_'
+
str
(
config
.
config_restricted_column
))
.
\
any
(
db
.
cc_classes
[
config
.
config_restricted_column
]
.
value
.
in_
(
pos_cc_list
))
neg_cc_list
=
current_user
.
restrict
ed_column_value
.
split
(
','
)
neg_content_cc_filter
=
tru
e
()
if
neg_cc_list
==
[
''
]
else
\
neg_cc_list
=
current_user
.
deni
ed_column_value
.
split
(
','
)
neg_content_cc_filter
=
fals
e
()
if
neg_cc_list
==
[
''
]
else
\
getattr
(
db
.
Books
,
'custom_column_'
+
str
(
config
.
config_restricted_column
))
.
\
any
(
db
.
cc_classes
[
config
.
config_restricted_column
]
.
value
.
in_
(
neg_cc_list
))
else
:
...
...
@@ -712,7 +709,7 @@ def common_filters():
def
tags_filters
():
negtags_list
=
current_user
.
list_
restrict
ed_tags
()
negtags_list
=
current_user
.
list_
deni
ed_tags
()
postags_list
=
current_user
.
list_allowed_tags
()
neg_content_tags_filter
=
false
()
if
negtags_list
==
[
''
]
else
db
.
Tags
.
name
.
in_
(
negtags_list
)
pos_content_tags_filter
=
true
()
if
postags_list
==
[
''
]
else
db
.
Tags
.
name
.
in_
(
postags_list
)
...
...
cps/templates/modal_restriction.html
View file @
a9a6f5b9
...
...
@@ -3,10 +3,10 @@
<div
class=
"modal-dialog modal-lg"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h4
class=
"modal-title hidden"
id=
"h1"
>
{{_('Select allowed/
restrict
ed Tags')}}
</h4>
<h4
class=
"modal-title hidden"
id=
"h2"
>
{{_('Select allowed/
restrict
ed Custom Column values')}}
</h4>
<h4
class=
"modal-title hidden"
id=
"h3"
>
{{_('Select allowed/
restrict
ed Tags of user')}}
</h4>
<h4
class=
"modal-title hidden"
id=
"h4"
>
{{_('Select allowed/
restrict
ed Custom Column values of user')}}
</h4>
<h4
class=
"modal-title hidden"
id=
"h1"
>
{{_('Select allowed/
deni
ed Tags')}}
</h4>
<h4
class=
"modal-title hidden"
id=
"h2"
>
{{_('Select allowed/
deni
ed Custom Column values')}}
</h4>
<h4
class=
"modal-title hidden"
id=
"h3"
>
{{_('Select allowed/
deni
ed Tags of user')}}
</h4>
<h4
class=
"modal-title hidden"
id=
"h4"
>
{{_('Select allowed/
deni
ed Custom Column values of user')}}
</h4>
</div>
<div
class=
"modal-body"
>
<table
class=
"table table-no-bordered"
id=
"restrict-elements-table"
data-id-field=
"id"
data-show-header=
"false"
data-editable-mode=
"inline"
>
...
...
@@ -21,7 +21,7 @@
</table>
<form
id=
"add_restriction"
action=
""
method=
"POST"
>
<div
class=
"form-group required"
>
<label
for=
"add_element"
>
{{_('Add
Tag
')}}
</label>
<label
for=
"add_element"
>
{{_('Add
View Restriction
')}}
</label>
<input
type=
"text"
class=
"form-control"
name=
"add_element"
id=
"add_element"
>
</div>
<div
class=
"form-group required"
>
...
...
cps/ub.py
View file @
a9a6f5b9
...
...
@@ -157,16 +157,16 @@ class UserBase:
def
show_detail_random
(
self
):
return
self
.
check_visibility
(
constants
.
DETAIL_RANDOM
)
def
list_
restrict
ed_tags
(
self
):
mct
=
self
.
restrict
ed_tags
.
split
(
","
)
def
list_
deni
ed_tags
(
self
):
mct
=
self
.
deni
ed_tags
.
split
(
","
)
return
[
t
.
strip
()
for
t
in
mct
]
def
list_allowed_tags
(
self
):
mct
=
self
.
allowed_tags
.
split
(
","
)
return
[
t
.
strip
()
for
t
in
mct
]
def
list_
restrict
ed_column_values
(
self
):
mct
=
self
.
restrict
ed_column_value
.
split
(
","
)
def
list_
deni
ed_column_values
(
self
):
mct
=
self
.
deni
ed_column_value
.
split
(
","
)
return
[
t
.
strip
()
for
t
in
mct
]
def
list_allowed_column_values
(
self
):
...
...
@@ -195,9 +195,9 @@ class User(UserBase, Base):
sidebar_view
=
Column
(
Integer
,
default
=
1
)
default_language
=
Column
(
String
(
3
),
default
=
"all"
)
mature_content
=
Column
(
Boolean
,
default
=
True
)
restrict
ed_tags
=
Column
(
String
,
default
=
""
)
deni
ed_tags
=
Column
(
String
,
default
=
""
)
allowed_tags
=
Column
(
String
,
default
=
""
)
restrict
ed_column_value
=
Column
(
String
,
default
=
""
)
deni
ed_column_value
=
Column
(
String
,
default
=
""
)
allowed_column_value
=
Column
(
String
,
default
=
""
)
remote_auth_token
=
relationship
(
'RemoteAuthToken'
,
backref
=
'user'
,
lazy
=
'dynamic'
)
...
...
@@ -235,9 +235,9 @@ class Anonymous(AnonymousUserMixin, UserBase):
self
.
locale
=
data
.
locale
self
.
mature_content
=
data
.
mature_content
self
.
kindle_mail
=
data
.
kindle_mail
self
.
restricted_tags
=
data
.
restrict
ed_tags
self
.
denied_tags
=
data
.
deni
ed_tags
self
.
allowed_tags
=
data
.
allowed_tags
self
.
restricted_column_value
=
data
.
restrict
ed_column_value
self
.
denied_column_value
=
data
.
deni
ed_column_value
self
.
allowed_column_value
=
data
.
allowed_column_value
def
role_admin
(
self
):
...
...
@@ -417,12 +417,12 @@ def migrate_Database(session):
conn = engine.connect()
conn.execute("ALTER TABLE user ADD column `mature_content` INTEGER DEFAULT 1")'''
try
:
session
.
query
(
exists
()
.
where
(
User
.
restrict
ed_tags
))
.
scalar
()
session
.
query
(
exists
()
.
where
(
User
.
deni
ed_tags
))
.
scalar
()
except
exc
.
OperationalError
:
# Database is not compatible, some columns are missing
conn
=
engine
.
connect
()
conn
.
execute
(
"ALTER TABLE user ADD column `
restrict
ed_tags` String DEFAULT ''"
)
conn
.
execute
(
"ALTER TABLE user ADD column `
deni
ed_tags` String DEFAULT ''"
)
conn
.
execute
(
"ALTER TABLE user ADD column `allowed_tags` String DEFAULT ''"
)
conn
.
execute
(
"ALTER TABLE user ADD column `
restrict
ed_column_value` DEFAULT ''"
)
conn
.
execute
(
"ALTER TABLE user ADD column `
deni
ed_column_value` DEFAULT ''"
)
conn
.
execute
(
"ALTER TABLE user ADD column `allowed_column_value` DEFAULT ''"
)
if
session
.
query
(
User
)
.
filter
(
User
.
role
.
op
(
'&'
)(
constants
.
ROLE_ANONYMOUS
)
==
constants
.
ROLE_ANONYMOUS
)
.
first
()
is
None
:
create_anonymous_user
(
session
)
...
...
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