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
8e848649
Commit
8e848649
authored
Mar 19, 2019
by
tomjmul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restirct a user to a set of tags
parent
a0a15b45
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
79 additions
and
2 deletions
+79
-2
.gitignore
.gitignore
+1
-0
user_edit.html
cps/templates/user_edit.html
+5
-0
messages.po
cps/translations/de/LC_MESSAGES/messages.po
+5
-0
messages.po
cps/translations/es/LC_MESSAGES/messages.po
+4
-0
messages.po
cps/translations/fr/LC_MESSAGES/messages.po
+4
-0
messages.po
cps/translations/hu/LC_MESSAGES/messages.po
+4
-0
messages.po
cps/translations/it/LC_MESSAGES/messages.po
+4
-0
messages.po
cps/translations/ja/LC_MESSAGES/messages.po
+4
-0
messages.po
cps/translations/km/LC_MESSAGES/messages.po
+4
-0
messages.po
cps/translations/nl/LC_MESSAGES/messages.po
+4
-0
messages.po
cps/translations/pl/LC_MESSAGES/messages.po
+4
-0
messages.po
cps/translations/ru/LC_MESSAGES/messages.po
+4
-0
messages.po
cps/translations/sv/LC_MESSAGES/messages.po
+4
-0
messages.po
cps/translations/uk/LC_MESSAGES/messages.po
+4
-0
messages.po
cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po
+4
-0
ub.py
cps/ub.py
+1
-0
web.py
cps/web.py
+19
-2
No files found.
.gitignore
View file @
8e848649
...
...
@@ -29,3 +29,4 @@ gdrive_credentials
vendor
client_secrets.json
venv/
cps/templates/user_edit.html
View file @
8e848649
...
...
@@ -44,6 +44,11 @@
{% endfor %}
</select>
</div>
<div
class=
"form-group"
>
<label
for=
"allowed_tags"
>
{{_('Allowed Tags')}}
</label>
<input
type=
"text"
class=
"form-control"
name=
"allowed_tags"
id=
"allowed_tags"
value=
"{{ content.allowed_tags if content.allowed_tags != None }}"
autocomplete=
"off"
>
</div>
<div
class=
"col-sm-6"
>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"show_random"
id=
"show_random"
{%
if
content
.
show_random_books
()
%}
checked
{%
endif
%}
>
...
...
cps/translations/de/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -1997,6 +1997,10 @@ msgstr "Zeige nur Bücher mit dieser Sprache"
msgid "Show all"
msgstr "Zeige alle"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "Zulässige Tags"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "Benutzer löschen"
...
...
@@ -2005,3 +2009,4 @@ msgstr "Benutzer löschen"
msgid "Recent Downloads"
msgstr "Letzte Downloads"
cps/translations/es/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -1997,6 +1997,10 @@ msgstr "Mostrar libros con idioma"
msgid "Show all"
msgstr "Mostrar todo"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "Etiquetas permitidas"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "Borrar este usuario"
...
...
cps/translations/fr/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -2010,6 +2010,10 @@ msgstr "Montrer les livres dans la langue"
msgid "Show all"
msgstr "Montrer tout"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "Tags autorisés"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "Supprimer cet utilisateur"
...
...
cps/translations/hu/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -1997,6 +1997,10 @@ msgstr "Mutasd a könyveket a következő nyelvvel"
msgid "Show all"
msgstr "Mindent mutass"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "Engedélyezett címkék"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "A felhasználó törlése"
...
...
cps/translations/it/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -1996,6 +1996,10 @@ msgstr "Mostra libri per lingua"
msgid "Show all"
msgstr "Mostra tutto"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "Tag consentiti"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "Elimina questo utente"
...
...
cps/translations/ja/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -1997,6 +1997,10 @@ msgstr "言語で本を表示する"
msgid "Show all"
msgstr "全て表示"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "許可されたタグ"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "このユーザを削除する"
...
...
cps/translations/km/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -1998,6 +1998,10 @@ msgstr "បង្ហាញសៀវភៅដែលមានភាសា"
msgid "Show all"
msgstr "បង្ហាញទាំងអស់"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "ស្លាកដែលបានអនុញ្ញាត"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "លុបអ្នកប្រើប្រាស់នេះ"
...
...
cps/translations/nl/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -1998,6 +1998,10 @@ msgstr "Toon boeken met taal"
msgid "Show all"
msgstr "Toon alles"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "Toegestane tags"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "Wis deze gebruiker"
...
...
cps/translations/pl/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -2000,6 +2000,10 @@ msgstr "Pokaż książki w języku"
msgid "Show all"
msgstr "Pokaż wszystko"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "Dozwolone tagi"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "Usuń tego użytkownika"
...
...
cps/translations/ru/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -1997,6 +1997,10 @@ msgstr "Показать книги на языках"
msgid "Show all"
msgstr "Показать все"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "Разрешенные теги"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "Удалить этого пользователя"
...
...
cps/translations/sv/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -1997,6 +1997,10 @@ msgstr "Visa böcker med språk"
msgid "Show all"
msgstr "Visa alla"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "Tillåten etiketter"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "Ta bort den här användaren"
...
...
cps/translations/uk/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -1995,6 +1995,10 @@ msgstr "Показувати книги на мовах"
msgid "Show all"
msgstr "Показати всі"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "Дозволені теги"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "Видалити цього користувача"
...
...
cps/translations/zh_Hans_CN/LC_MESSAGES/messages.po
View file @
8e848649
...
...
@@ -1997,6 +1997,10 @@ msgstr "按语言显示书籍"
msgid "Show all"
msgstr "显示全部"
#: cps/templates/user_edit.html:48
msgid "Allowed Tags"
msgstr "允许的标签"
#: cps/templates/user_edit.html:141
msgid "Delete this user"
msgstr "删除此用户"
...
...
cps/ub.py
View file @
8e848649
...
...
@@ -192,6 +192,7 @@ class User(UserBase, Base):
sidebar_view
=
Column
(
Integer
,
default
=
1
)
default_language
=
Column
(
String
(
3
),
default
=
"all"
)
mature_content
=
Column
(
Boolean
,
default
=
True
)
allowed_tags
=
Column
(
String
)
# Class for anonymous user is derived from User base and completly overrides methods and properties for the
...
...
cps/web.py
View file @
8e848649
...
...
@@ -497,6 +497,12 @@ def edit_required(f):
return
inner
def
allowed_tags
(
tags
):
if
sys
.
version_info
>
(
3
,
0
):
# Python3 str, Python2 unicode
lstrip
=
str
.
lstrip
else
:
lstrip
=
unicode
.
lstrip
return
list
(
map
(
lstrip
,
tags
.
split
(
","
)))
# Language and content filters for displaying in the UI
def
common_filters
():
...
...
@@ -504,9 +510,14 @@ def common_filters():
lang_filter
=
db
.
Books
.
languages
.
any
(
db
.
Languages
.
lang_code
==
current_user
.
filter_language
())
else
:
lang_filter
=
true
()
if
current_user
.
allowed_tags
is
not
None
and
current_user
.
allowed_tags
!=
''
:
tags_filter
=
db
.
Books
.
tags
.
any
(
db
.
Tags
.
name
.
in_
(
allowed_tags
(
current_user
.
allowed_tags
)))
else
:
tags_filter
=
true
()
content_rating_filter
=
false
()
if
current_user
.
mature_content
else
\
db
.
Books
.
tags
.
any
(
db
.
Tags
.
name
.
in_
(
config
.
mature_content_tags
()))
return
and_
(
lang_filter
,
~
content_rating_filter
)
return
and_
(
tags_filter
,
lang_filter
,
~
content_rating_filter
)
# Creates for all stored languages a translated speaking name in the array for the UI
...
...
@@ -1085,7 +1096,8 @@ def get_comic_book(book_id, book_format, page):
def
get_authors_json
():
if
request
.
method
==
"GET"
:
query
=
request
.
args
.
get
(
'q'
)
entries
=
db
.
session
.
query
(
db
.
Authors
)
.
filter
(
db
.
Authors
.
name
.
ilike
(
"
%
"
+
query
+
"
%
"
))
.
all
()
entries
=
db
.
session
.
query
(
db
.
Authors
)
.
join
(
db
.
books_authors_link
)
.
join
(
db
.
Books
)
.
filter
(
common_filters
())
\
.
filter
(
db
.
Authors
.
name
.
ilike
(
"
%
"
+
query
+
"
%
"
))
.
all
()
json_dumps
=
json
.
dumps
([
dict
(
name
=
r
.
name
.
replace
(
'|'
,
','
))
for
r
in
entries
])
return
json_dumps
...
...
@@ -2710,6 +2722,8 @@ def profile():
content
.
password
=
generate_password_hash
(
to_save
[
"password"
])
if
"kindle_mail"
in
to_save
and
to_save
[
"kindle_mail"
]
!=
content
.
kindle_mail
:
content
.
kindle_mail
=
to_save
[
"kindle_mail"
]
if
"allowed_tags"
in
to_save
and
to_save
[
"allowed_tags"
]
!=
content
.
allowed_tags
:
content
.
allowed_tags
=
to_save
[
"allowed_tags"
]
.
strip
()
if
to_save
[
"email"
]
and
to_save
[
"email"
]
!=
content
.
email
:
if
config
.
config_public_reg
and
not
check_valid_domain
(
to_save
[
"email"
]):
flash
(
_
(
u"E-mail is not from valid domain"
),
category
=
"error"
)
...
...
@@ -2872,6 +2886,7 @@ def view_configuration():
content
.
config_default_show
=
content
.
config_default_show
+
ub
.
SIDEBAR_SORTED
if
"show_mature_content"
in
to_save
:
content
.
config_default_show
=
content
.
config_default_show
+
ub
.
MATURE_CONTENT
ub
.
session
.
commit
()
flash
(
_
(
u"Calibre-Web configuration updated"
),
category
=
"success"
)
config
.
loadSettings
()
...
...
@@ -3336,6 +3351,8 @@ def edit_user(user_id):
content
.
email
=
to_save
[
"email"
]
if
"kindle_mail"
in
to_save
and
to_save
[
"kindle_mail"
]
!=
content
.
kindle_mail
:
content
.
kindle_mail
=
to_save
[
"kindle_mail"
]
if
"allowed_tags"
in
to_save
and
to_save
[
"allowed_tags"
]
!=
content
.
allowed_tags
:
content
.
allowed_tags
=
to_save
[
"allowed_tags"
]
try
:
ub
.
session
.
commit
()
flash
(
_
(
u"User '
%(nick)
s' updated"
,
nick
=
content
.
nickname
),
category
=
"success"
)
...
...
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