Renamed restrict -> deny
This commit is contained in:
parent
8b1444ebc2
commit
a9a6f5b97e
61
cps/admin.py
61
cps/admin.py
|
@ -171,10 +171,7 @@ def update_view_configuration():
|
||||||
_config_int("config_random_books")
|
_config_int("config_random_books")
|
||||||
_config_int("config_books_per_page")
|
_config_int("config_books_per_page")
|
||||||
_config_int("config_authors_max")
|
_config_int("config_authors_max")
|
||||||
|
|
||||||
_config_string("config_restricted_tags")
|
|
||||||
_config_int("config_restricted_column")
|
_config_int("config_restricted_column")
|
||||||
_config_string("config_restricted_column_value")
|
|
||||||
|
|
||||||
if config.config_google_drive_watch_changes_response:
|
if config.config_google_drive_watch_changes_response:
|
||||||
config.config_google_drive_watch_changes_response = json.dumps(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()
|
ub.session.commit()
|
||||||
if element['id'].startswith('d'):
|
if element['id'].startswith('d'):
|
||||||
if type == 0: # Tags as template
|
if type == 0: # Tags as template
|
||||||
elementlist = config.list_restricted_tags()
|
elementlist = config.list_denied_tags()
|
||||||
elementlist[int(element['id'][1:])]=element['Element']
|
elementlist[int(element['id'][1:])]=element['Element']
|
||||||
config.config_restricted_tags = ','.join(elementlist)
|
config.config_denied_tags = ','.join(elementlist)
|
||||||
config.save()
|
config.save()
|
||||||
if type == 1: # CustomC
|
if type == 1: # CustomC
|
||||||
elementlist = config.list_restricted_column_values()
|
elementlist = config.list_denied_column_values()
|
||||||
elementlist[int(element['id'][1:])]=element['Element']
|
elementlist[int(element['id'][1:])]=element['Element']
|
||||||
config.config_restricted_column_value = ','.join(elementlist)
|
config.config_denied_column_value = ','.join(elementlist)
|
||||||
config.save()
|
config.save()
|
||||||
pass
|
pass
|
||||||
if type == 2: # Tags per user
|
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()
|
usr = ub.session.query(ub.User).filter(ub.User.id == int(usr_id)).first()
|
||||||
else:
|
else:
|
||||||
usr = current_user
|
usr = current_user
|
||||||
elementlist = usr.list_restricted_tags()
|
elementlist = usr.list_denied_tags()
|
||||||
elementlist[int(element['id'][1:])]=element['Element']
|
elementlist[int(element['id'][1:])]=element['Element']
|
||||||
usr.restricted_tags = ','.join(elementlist)
|
usr.denied_tags = ','.join(elementlist)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
if type == 3: # CColumn per user
|
if type == 3: # CColumn per user
|
||||||
usr_id = os.path.split(request.referrer)[-1]
|
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()
|
usr = ub.session.query(ub.User).filter(ub.User.id == int(usr_id)).first()
|
||||||
else:
|
else:
|
||||||
usr = current_user
|
usr = current_user
|
||||||
elementlist = usr.list_restricted_column_values()
|
elementlist = usr.list_denied_column_values()
|
||||||
elementlist[int(element['id'][1:])]=element['Element']
|
elementlist[int(element['id'][1:])]=element['Element']
|
||||||
usr.restricted_column_value = ','.join(elementlist)
|
usr.denied_column_value = ','.join(elementlist)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@ -348,14 +345,14 @@ def add_restriction(type):
|
||||||
config.config_allowed_tags = restriction_addition(element, config.list_allowed_tags)
|
config.config_allowed_tags = restriction_addition(element, config.list_allowed_tags)
|
||||||
config.save()
|
config.save()
|
||||||
elif 'submit_deny' in element:
|
elif 'submit_deny' in element:
|
||||||
config.config_restricted_tags = restriction_addition(element, config.list_restricted_tags)
|
config.config_denied_tags = restriction_addition(element, config.list_denied_tags)
|
||||||
config.save()
|
config.save()
|
||||||
if type == 1: # CCustom as template
|
if type == 1: # CCustom as template
|
||||||
if 'submit_allow' in element:
|
if 'submit_allow' in element:
|
||||||
config.config_allowed_column_value = restriction_addition(element, config.list_restricted_column_values)
|
config.config_allowed_column_value = restriction_addition(element, config.list_denied_column_values)
|
||||||
config.save()
|
config.save()
|
||||||
elif 'submit_deny' in element:
|
elif 'submit_deny' in element:
|
||||||
config.config_restricted_column_value = restriction_addition(element, config.list_allowed_column_values)
|
config.config_denied_column_value = restriction_addition(element, config.list_allowed_column_values)
|
||||||
config.save()
|
config.save()
|
||||||
if type == 2: # Tags per user
|
if type == 2: # Tags per user
|
||||||
usr_id = os.path.split(request.referrer)[-1]
|
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)
|
usr.allowed_tags = restriction_addition(element, usr.list_allowed_tags)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
elif 'submit_deny' in element:
|
elif 'submit_deny' in element:
|
||||||
usr.restricted_tags = restriction_addition(element, usr.list_restricted_tags)
|
usr.denied_tags = restriction_addition(element, usr.list_denied_tags)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
if type == 3: # CustomC per user
|
if type == 3: # CustomC per user
|
||||||
usr_id = os.path.split(request.referrer)[-1]
|
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)
|
usr.allowed_column_value = restriction_addition(element, usr.list_allowed_column_values)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
elif 'submit_deny' in element:
|
elif 'submit_deny' in element:
|
||||||
usr.restricted_column_value = restriction_addition(element, usr.list_restricted_column_values)
|
usr.denied_column_value = restriction_addition(element, usr.list_denied_column_values)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@ -393,14 +390,14 @@ def delete_restriction(type):
|
||||||
config.config_allowed_tags = restriction_deletion(element, config.list_allowed_tags)
|
config.config_allowed_tags = restriction_deletion(element, config.list_allowed_tags)
|
||||||
config.save()
|
config.save()
|
||||||
elif element['id'].startswith('d'):
|
elif element['id'].startswith('d'):
|
||||||
config.config_restricted_tags = restriction_deletion(element, config.list_restricted_tags)
|
config.config_denied_tags = restriction_deletion(element, config.list_denied_tags)
|
||||||
config.save()
|
config.save()
|
||||||
elif type == 1: # CustomC as template
|
elif type == 1: # CustomC as template
|
||||||
if element['id'].startswith('a'):
|
if element['id'].startswith('a'):
|
||||||
config.config_allowed_column_value = restriction_deletion(element, config.list_allowed_column_values)
|
config.config_allowed_column_value = restriction_deletion(element, config.list_allowed_column_values)
|
||||||
config.save()
|
config.save()
|
||||||
elif element['id'].startswith('d'):
|
elif element['id'].startswith('d'):
|
||||||
config.config_restricted_column_value = restriction_deletion(element, config.list_restricted_column_values)
|
config.config_denied_column_value = restriction_deletion(element, config.list_denied_column_values)
|
||||||
config.save()
|
config.save()
|
||||||
elif type == 2: # Tags per user
|
elif type == 2: # Tags per user
|
||||||
usr_id = os.path.split(request.referrer)[-1]
|
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)
|
usr.allowed_tags = restriction_deletion(element, usr.list_allowed_tags)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
elif element['id'].startswith('d'):
|
elif element['id'].startswith('d'):
|
||||||
usr.restricted_tags = restriction_deletion(element, usr.list_restricted_tags)
|
usr.denied_tags = restriction_deletion(element, usr.list_denied_tags)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
elif type == 3: # Columns per user
|
elif type == 3: # Columns per user
|
||||||
usr_id = os.path.split(request.referrer)[-1]
|
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)
|
usr.allowed_column_value = restriction_deletion(element, usr.list_allowed_column_values)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
elif element['id'].startswith('d'):
|
elif element['id'].startswith('d'):
|
||||||
usr.restricted_column_value = restriction_deletion(element, usr.list_restricted_column_values)
|
usr.denied_column_value = restriction_deletion(element, usr.list_denied_column_values)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@ -436,13 +433,13 @@ def delete_restriction(type):
|
||||||
def list_restriction(type):
|
def list_restriction(type):
|
||||||
if type == 0: # Tags as template
|
if type == 0: # Tags as template
|
||||||
restrict = [{'Element': x, 'type':_('deny'), 'id': 'd'+str(i) }
|
restrict = [{'Element': x, 'type':_('deny'), 'id': 'd'+str(i) }
|
||||||
for i,x in enumerate(config.list_restricted_tags()) if x != '' ]
|
for i,x in enumerate(config.list_denied_tags()) if x != '' ]
|
||||||
allow = [{'Element': x, 'type':_('allow'), 'id': 'a'+str(i) }
|
allow = [{'Element': x, 'type':_('allow'), 'id': 'a'+str(i) }
|
||||||
for i,x in enumerate(config.list_allowed_tags()) if x != '']
|
for i,x in enumerate(config.list_allowed_tags()) if x != '']
|
||||||
json_dumps = restrict + allow
|
json_dumps = restrict + allow
|
||||||
elif type == 1: # CustomC as template
|
elif type == 1: # CustomC as template
|
||||||
restrict = [{'Element': x, 'type':_('deny'), 'id': 'd'+str(i) }
|
restrict = [{'Element': x, 'type':_('deny'), 'id': 'd'+str(i) }
|
||||||
for i,x in enumerate(config.list_restricted_column_values()) if x != '' ]
|
for i,x in enumerate(config.list_denied_column_values()) if x != '' ]
|
||||||
allow = [{'Element': x, 'type':_('allow'), 'id': 'a'+str(i) }
|
allow = [{'Element': x, 'type':_('allow'), 'id': 'a'+str(i) }
|
||||||
for i,x in enumerate(config.list_allowed_column_values()) if x != '']
|
for i,x in enumerate(config.list_allowed_column_values()) if x != '']
|
||||||
json_dumps = restrict + allow
|
json_dumps = restrict + allow
|
||||||
|
@ -453,7 +450,7 @@ def list_restriction(type):
|
||||||
else:
|
else:
|
||||||
usr = current_user
|
usr = current_user
|
||||||
restrict = [{'Element': x, 'type':_('deny'), 'id': 'd'+str(i) }
|
restrict = [{'Element': x, 'type':_('deny'), 'id': 'd'+str(i) }
|
||||||
for i,x in enumerate(usr.list_restricted_tags()) if x != '' ]
|
for i,x in enumerate(usr.list_denied_tags()) if x != '' ]
|
||||||
allow = [{'Element': x, 'type':_('allow'), 'id': 'a'+str(i) }
|
allow = [{'Element': x, 'type':_('allow'), 'id': 'a'+str(i) }
|
||||||
for i,x in enumerate(usr.list_allowed_tags()) if x != '']
|
for i,x in enumerate(usr.list_allowed_tags()) if x != '']
|
||||||
json_dumps = restrict + allow
|
json_dumps = restrict + allow
|
||||||
|
@ -464,7 +461,7 @@ def list_restriction(type):
|
||||||
else:
|
else:
|
||||||
usr = current_user
|
usr = current_user
|
||||||
restrict = [{'Element': x, 'type':_('deny'), 'id': 'd'+str(i) }
|
restrict = [{'Element': x, 'type':_('deny'), 'id': 'd'+str(i) }
|
||||||
for i,x in enumerate(usr.list_restricted_column_values()) if x != '' ]
|
for i,x in enumerate(usr.list_denied_column_values()) if x != '' ]
|
||||||
allow = [{'Element': x, 'type':_('allow'), 'id': 'a'+str(i) }
|
allow = [{'Element': x, 'type':_('allow'), 'id': 'a'+str(i) }
|
||||||
for i,x in enumerate(usr.list_allowed_column_values()) if x != '']
|
for i,x in enumerate(usr.list_allowed_column_values()) if x != '']
|
||||||
json_dumps = restrict + allow
|
json_dumps = restrict + allow
|
||||||
|
@ -726,10 +723,10 @@ def new_user():
|
||||||
else:
|
else:
|
||||||
content.role = config.config_default_role
|
content.role = config.config_default_role
|
||||||
content.sidebar_view = config.config_default_show
|
content.sidebar_view = config.config_default_show
|
||||||
content.restricted_tags = config.config_restricted_tags
|
content.allowed_tags = config.config_allowed_tags
|
||||||
content.restricted_column = config.config_restricted_column
|
content.denied_tags = config.config_denied_tags
|
||||||
content.restricted_column_value = config.config_restricted_column_value
|
content.allowed_column_value = config.config_allowed_column_value
|
||||||
# content.mature_content = bool(config.config_default_show & constants.MATURE_CONTENT)
|
content.allowed_column_value = config.config_denied_column_value
|
||||||
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
|
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
|
||||||
languages=languages, title=_(u"Add new user"), page="newuser",
|
languages=languages, title=_(u"Add new user"), page="newuser",
|
||||||
kobo_support=kobo_support, registered_oauth=oauth_check)
|
kobo_support=kobo_support, registered_oauth=oauth_check)
|
||||||
|
@ -833,14 +830,6 @@ def edit_user(user_id):
|
||||||
else:
|
else:
|
||||||
content.sidebar_view &= ~constants.DETAIL_RANDOM
|
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:
|
if "default_language" in to_save:
|
||||||
content.default_language = to_save["default_language"]
|
content.default_language = to_save["default_language"]
|
||||||
if "locale" in to_save and to_save["locale"]:
|
if "locale" in to_save and to_save["locale"]:
|
||||||
|
|
|
@ -74,10 +74,10 @@ class _Settings(_Base):
|
||||||
config_default_show = Column(SmallInteger, default=6143)
|
config_default_show = Column(SmallInteger, default=6143)
|
||||||
config_columns_to_ignore = Column(String)
|
config_columns_to_ignore = Column(String)
|
||||||
|
|
||||||
config_restricted_tags = Column(String, default="")
|
config_denied_tags = Column(String, default="")
|
||||||
config_allowed_tags = Column(String, default="")
|
config_allowed_tags = Column(String, default="")
|
||||||
config_restricted_column = Column(SmallInteger, default=0)
|
config_restricted_column = Column(SmallInteger, default=0)
|
||||||
config_restricted_column_value = Column(String, default="")
|
config_denied_column_value = Column(String, default="")
|
||||||
config_allowed_column_value = Column(String, default="")
|
config_allowed_column_value = Column(String, default="")
|
||||||
|
|
||||||
config_use_google_drive = Column(Boolean, default=False)
|
config_use_google_drive = Column(Boolean, default=False)
|
||||||
|
@ -186,16 +186,16 @@ class _ConfigSQL(object):
|
||||||
def show_detail_random(self):
|
def show_detail_random(self):
|
||||||
return self.show_element_new_user(constants.DETAIL_RANDOM)
|
return self.show_element_new_user(constants.DETAIL_RANDOM)
|
||||||
|
|
||||||
def list_restricted_tags(self):
|
def list_denied_tags(self):
|
||||||
mct = self.config_restricted_tags.split(",")
|
mct = self.config_denied_tags.split(",")
|
||||||
return [t.strip() for t in mct]
|
return [t.strip() for t in mct]
|
||||||
|
|
||||||
def list_allowed_tags(self):
|
def list_allowed_tags(self):
|
||||||
mct = self.config_allowed_tags.split(",")
|
mct = self.config_allowed_tags.split(",")
|
||||||
return [t.strip() for t in mct]
|
return [t.strip() for t in mct]
|
||||||
|
|
||||||
def list_restricted_column_values(self):
|
def list_denied_column_values(self):
|
||||||
mct = self.config_restricted_column_value.split(",")
|
mct = self.config_denied_column_value.split(",")
|
||||||
return [t.strip() for t in mct]
|
return [t.strip() for t in mct]
|
||||||
|
|
||||||
def list_allowed_column_values(self):
|
def list_allowed_column_values(self):
|
||||||
|
@ -341,8 +341,8 @@ def load_configuration(session):
|
||||||
session.commit()
|
session.commit()
|
||||||
conf = _ConfigSQL(session)
|
conf = _ConfigSQL(session)
|
||||||
# Migrate from global restrictions to user based restrictions
|
# Migrate from global restrictions to user based restrictions
|
||||||
if bool(conf.config_default_show & constants.MATURE_CONTENT) and conf.config_restricted_tags == "":
|
if bool(conf.config_default_show & constants.MATURE_CONTENT) and conf.config_denied_tags == "":
|
||||||
conf.config_restricted_tags = conf.config_mature_content_tags
|
conf.config_denied_tags = conf.config_mature_content_tags
|
||||||
conf.save()
|
conf.save()
|
||||||
session.query(ub.User).filter(ub.User.mature_content != True). \
|
session.query(ub.User).filter(ub.User.mature_content != True). \
|
||||||
update({"restricted_tags": conf.config_mature_content_tags}, synchronize_session=False)
|
update({"restricted_tags": conf.config_mature_content_tags}, synchronize_session=False)
|
||||||
|
|
|
@ -688,20 +688,17 @@ def common_filters():
|
||||||
lang_filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language())
|
lang_filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language())
|
||||||
else:
|
else:
|
||||||
lang_filter = true()
|
lang_filter = true()
|
||||||
negtags_list = current_user.list_restricted_tags()
|
negtags_list = current_user.list_denied_tags()
|
||||||
postags_list = current_user.list_allowed_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))
|
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))
|
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:
|
if config.config_restricted_column:
|
||||||
pos_cc_list = current_user.allowed_column_value.split(',')
|
pos_cc_list = current_user.allowed_column_value.split(',')
|
||||||
pos_content_cc_filter = true() if pos_cc_list == [''] else \
|
pos_content_cc_filter = true() if pos_cc_list == [''] else \
|
||||||
getattr(db.Books, 'custom_column_' + str(config.config_restricted_column)).\
|
getattr(db.Books, 'custom_column_' + str(config.config_restricted_column)).\
|
||||||
any(db.cc_classes[config.config_restricted_column].value.in_(pos_cc_list))
|
any(db.cc_classes[config.config_restricted_column].value.in_(pos_cc_list))
|
||||||
neg_cc_list = current_user.restricted_column_value.split(',')
|
neg_cc_list = current_user.denied_column_value.split(',')
|
||||||
neg_content_cc_filter = true() if neg_cc_list == [''] else \
|
neg_content_cc_filter = false() if neg_cc_list == [''] else \
|
||||||
getattr(db.Books, 'custom_column_' + str(config.config_restricted_column)).\
|
getattr(db.Books, 'custom_column_' + str(config.config_restricted_column)).\
|
||||||
any(db.cc_classes[config.config_restricted_column].value.in_(neg_cc_list))
|
any(db.cc_classes[config.config_restricted_column].value.in_(neg_cc_list))
|
||||||
else:
|
else:
|
||||||
|
@ -712,7 +709,7 @@ def common_filters():
|
||||||
|
|
||||||
|
|
||||||
def tags_filters():
|
def tags_filters():
|
||||||
negtags_list = current_user.list_restricted_tags()
|
negtags_list = current_user.list_denied_tags()
|
||||||
postags_list = current_user.list_allowed_tags()
|
postags_list = current_user.list_allowed_tags()
|
||||||
neg_content_tags_filter = false() if negtags_list == [''] else db.Tags.name.in_(negtags_list)
|
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)
|
pos_content_tags_filter = true() if postags_list == [''] else db.Tags.name.in_(postags_list)
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
<div class="modal-dialog modal-lg" role="document">
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h4 class="modal-title hidden" id="h1">{{_('Select allowed/restricted Tags')}}</h4>
|
<h4 class="modal-title hidden" id="h1">{{_('Select allowed/denied Tags')}}</h4>
|
||||||
<h4 class="modal-title hidden" id="h2">{{_('Select allowed/restricted Custom Column values')}}</h4>
|
<h4 class="modal-title hidden" id="h2">{{_('Select allowed/denied Custom Column values')}}</h4>
|
||||||
<h4 class="modal-title hidden" id="h3">{{_('Select allowed/restricted Tags of user')}}</h4>
|
<h4 class="modal-title hidden" id="h3">{{_('Select allowed/denied Tags of user')}}</h4>
|
||||||
<h4 class="modal-title hidden" id="h4">{{_('Select allowed/restricted Custom Column values of user')}}</h4>
|
<h4 class="modal-title hidden" id="h4">{{_('Select allowed/denied Custom Column values of user')}}</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<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">
|
<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>
|
</table>
|
||||||
<form id="add_restriction" action="" method="POST">
|
<form id="add_restriction" action="" method="POST">
|
||||||
<div class="form-group required">
|
<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" >
|
<input type="text" class="form-control" name="add_element" id="add_element" >
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group required">
|
<div class="form-group required">
|
||||||
|
|
22
cps/ub.py
22
cps/ub.py
|
@ -157,16 +157,16 @@ class UserBase:
|
||||||
def show_detail_random(self):
|
def show_detail_random(self):
|
||||||
return self.check_visibility(constants.DETAIL_RANDOM)
|
return self.check_visibility(constants.DETAIL_RANDOM)
|
||||||
|
|
||||||
def list_restricted_tags(self):
|
def list_denied_tags(self):
|
||||||
mct = self.restricted_tags.split(",")
|
mct = self.denied_tags.split(",")
|
||||||
return [t.strip() for t in mct]
|
return [t.strip() for t in mct]
|
||||||
|
|
||||||
def list_allowed_tags(self):
|
def list_allowed_tags(self):
|
||||||
mct = self.allowed_tags.split(",")
|
mct = self.allowed_tags.split(",")
|
||||||
return [t.strip() for t in mct]
|
return [t.strip() for t in mct]
|
||||||
|
|
||||||
def list_restricted_column_values(self):
|
def list_denied_column_values(self):
|
||||||
mct = self.restricted_column_value.split(",")
|
mct = self.denied_column_value.split(",")
|
||||||
return [t.strip() for t in mct]
|
return [t.strip() for t in mct]
|
||||||
|
|
||||||
def list_allowed_column_values(self):
|
def list_allowed_column_values(self):
|
||||||
|
@ -195,9 +195,9 @@ class User(UserBase, Base):
|
||||||
sidebar_view = Column(Integer, default=1)
|
sidebar_view = Column(Integer, default=1)
|
||||||
default_language = Column(String(3), default="all")
|
default_language = Column(String(3), default="all")
|
||||||
mature_content = Column(Boolean, default=True)
|
mature_content = Column(Boolean, default=True)
|
||||||
restricted_tags = Column(String, default="")
|
denied_tags = Column(String, default="")
|
||||||
allowed_tags = Column(String, default="")
|
allowed_tags = Column(String, default="")
|
||||||
restricted_column_value = Column(String, default="")
|
denied_column_value = Column(String, default="")
|
||||||
allowed_column_value = Column(String, default="")
|
allowed_column_value = Column(String, default="")
|
||||||
remote_auth_token = relationship('RemoteAuthToken', backref='user', lazy='dynamic')
|
remote_auth_token = relationship('RemoteAuthToken', backref='user', lazy='dynamic')
|
||||||
|
|
||||||
|
@ -235,9 +235,9 @@ class Anonymous(AnonymousUserMixin, UserBase):
|
||||||
self.locale = data.locale
|
self.locale = data.locale
|
||||||
self.mature_content = data.mature_content
|
self.mature_content = data.mature_content
|
||||||
self.kindle_mail = data.kindle_mail
|
self.kindle_mail = data.kindle_mail
|
||||||
self.restricted_tags = data.restricted_tags
|
self.denied_tags = data.denied_tags
|
||||||
self.allowed_tags = data.allowed_tags
|
self.allowed_tags = data.allowed_tags
|
||||||
self.restricted_column_value = data.restricted_column_value
|
self.denied_column_value = data.denied_column_value
|
||||||
self.allowed_column_value = data.allowed_column_value
|
self.allowed_column_value = data.allowed_column_value
|
||||||
|
|
||||||
def role_admin(self):
|
def role_admin(self):
|
||||||
|
@ -417,12 +417,12 @@ def migrate_Database(session):
|
||||||
conn = engine.connect()
|
conn = engine.connect()
|
||||||
conn.execute("ALTER TABLE user ADD column `mature_content` INTEGER DEFAULT 1")'''
|
conn.execute("ALTER TABLE user ADD column `mature_content` INTEGER DEFAULT 1")'''
|
||||||
try:
|
try:
|
||||||
session.query(exists().where(User.restricted_tags)).scalar()
|
session.query(exists().where(User.denied_tags)).scalar()
|
||||||
except exc.OperationalError: # Database is not compatible, some columns are missing
|
except exc.OperationalError: # Database is not compatible, some columns are missing
|
||||||
conn = engine.connect()
|
conn = engine.connect()
|
||||||
conn.execute("ALTER TABLE user ADD column `restricted_tags` String DEFAULT ''")
|
conn.execute("ALTER TABLE user ADD column `denied_tags` String DEFAULT ''")
|
||||||
conn.execute("ALTER TABLE user ADD column `allowed_tags` String DEFAULT ''")
|
conn.execute("ALTER TABLE user ADD column `allowed_tags` String DEFAULT ''")
|
||||||
conn.execute("ALTER TABLE user ADD column `restricted_column_value` DEFAULT ''")
|
conn.execute("ALTER TABLE user ADD column `denied_column_value` DEFAULT ''")
|
||||||
conn.execute("ALTER TABLE user ADD column `allowed_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:
|
if session.query(User).filter(User.role.op('&')(constants.ROLE_ANONYMOUS) == constants.ROLE_ANONYMOUS).first() is None:
|
||||||
create_anonymous_user(session)
|
create_anonymous_user(session)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user