resolved merge conflicts

This commit is contained in:
mmonkey 2020-12-24 03:04:32 -06:00
commit af24d4edbe
11 changed files with 160 additions and 87 deletions

View File

@ -261,6 +261,21 @@ def update_view_configuration():
return view_configuration()
@admi.route("/ajax/loaddialogtexts/<element_id>")
@login_required
def load_dialogtexts(element_id):
texts = { "header": "", "main": "" }
if element_id == "config_delete_kobo_token":
texts["main"] = _('Do you really want to delete the Kobo Token?')
elif element_id == "btndeletedomain":
texts["main"] = _('Do you really want to delete this domain?')
elif element_id == "btndeluser":
texts["main"] = _('Do you really want to delete this user?')
elif element_id == "delete_shelf":
texts["main"] = _('Are you sure you want to delete this shelf?')
return json.dumps(texts)
@admi.route("/ajax/editdomain/<int:allow>", methods=['POST'])
@login_required
@admin_required
@ -300,20 +315,23 @@ def add_domain(allow):
@login_required
@admin_required
def delete_domain():
domain_id = request.form.to_dict()['domainid'].replace('*', '%').replace('?', '_').lower()
ub.session.query(ub.Registration).filter(ub.Registration.id == domain_id).delete()
try:
ub.session.commit()
except OperationalError:
ub.session.rollback()
# If last domain was deleted, add all domains by default
if not ub.session.query(ub.Registration).filter(ub.Registration.allow==1).count():
new_domain = ub.Registration(domain="%.%",allow=1)
ub.session.add(new_domain)
domain_id = request.form.to_dict()['domainid'].replace('*', '%').replace('?', '_').lower()
ub.session.query(ub.Registration).filter(ub.Registration.id == domain_id).delete()
try:
ub.session.commit()
except OperationalError:
ub.session.rollback()
# If last domain was deleted, add all domains by default
if not ub.session.query(ub.Registration).filter(ub.Registration.allow==1).count():
new_domain = ub.Registration(domain="%.%",allow=1)
ub.session.add(new_domain)
try:
ub.session.commit()
except OperationalError:
ub.session.rollback()
except KeyError:
pass
return ""
@ -586,7 +604,8 @@ def list_restriction(res_type):
return response
@admi.route("/basicconfig/pathchooser/")
@unconfigured
# @unconfigured
@login_required
def config_pathchooser():
return pathchooser()

View File

@ -110,6 +110,34 @@ $(document).ready(function() {
}
});
function ConfirmDialog(id, dataValue, yesFn, noFn) {
var pathname = document.getElementsByTagName("script"), src = pathname[pathname.length - 1].src;
var path = src.substring(0, src.lastIndexOf("/"));
var $confirm = $("#GeneralDeleteModal");
// var dataValue= e.data('value'); // target.data('value');
$confirm.modal('show');
$.ajax({
method:"get",
dataType: "json",
url: path + "/../../ajax/loaddialogtexts/" + id,
success: function success(data) {
$("#header").html(data.header);
$("#text").html(data.main);
}
});
$("#btnConfirmYes").off('click').click(function () {
yesFn(dataValue);
$confirm.modal("hide");
});
$("#btnConfirmNo").off('click').click(function () {
if (typeof noFn !== 'undefined') {
noFn(dataValue);
}
$confirm.modal("hide");
});
}
$("#delete_confirm").click(function() {
//get data-id attribute of the clicked element
@ -464,6 +492,52 @@ $(function() {
$("#config_delete_kobo_token").show();
});
$("#config_delete_kobo_token").click(function() {
ConfirmDialog(
$(this).attr('id'),
$(this).data('value'),
function (value) {
var pathname = document.getElementsByTagName("script");
var src = pathname[pathname.length - 1].src;
var path = src.substring(0, src.lastIndexOf("/"));
$.ajax({
method: "get",
url: path + "/../../kobo_auth/deleteauthtoken/" + value,
});
$("#config_delete_kobo_token").hide();
}
);
});
$("#btndeluser").click(function() {
ConfirmDialog(
$(this).attr('id'),
$(this).data('value'),
function(value){
var subform = $('#user_submit').closest("form");
subform.submit(function(eventObj) {
$(this).append('<input type="hidden" name="delete" value="True" />');
return true;
});
subform.submit();
}
);
});
$("#user_submit").click(function() {
this.closest("form").submit();
});
$("#delete_shelf").click(function() {
ConfirmDialog(
$(this).attr('id'),
$(this).data('value'),
function(value){
window.location.href = window.location.pathname + "/../../shelf/delete/" + value
}
);
});
$("#fileModal").on("show.bs.modal", function(e) {
@ -499,19 +573,6 @@ $(function() {
}
});
$("#btndeletetoken").click(function() {
//get data-id attribute of the clicked element
var pathname = document.getElementsByTagName("script"), src = pathname[pathname.length - 1].src;
var path = src.substring(0, src.lastIndexOf("/"));
$.ajax({
method:"get",
url: path + "/../../kobo_auth/deleteauthtoken/" + this.value,
});
$("#modalDeleteToken").modal("hide");
$("#config_delete_kobo_token").hide();
});
$(window).resize(function() {
$(".discover .row").isotope("layout");
});

View File

@ -208,15 +208,13 @@ $(function() {
},
striped: false
});
$("#btndeletedomain").click(function() {
//get data-id attribute of the clicked element
var domainId = $(this).data("domainId");
function domain_handle(domainId) {
$.ajax({
method:"post",
url: window.location.pathname + "/../../ajax/deletedomain",
data: {"domainid":domainId}
});
$("#DeleteDomain").modal("hide");
$.ajax({
method:"get",
url: window.location.pathname + "/../../ajax/domainlist/1",
@ -235,12 +233,16 @@ $(function() {
$("#domain-deny-table").bootstrapTable("load", data);
}
});
}
$("#domain-allow-table").on("click-cell.bs.table", function (field, value, row, $element) {
if (value === 2) {
ConfirmDialog("btndeletedomain", $element.id, domain_handle);
}
});
//triggered when modal is about to be shown
$("#DeleteDomain").on("show.bs.modal", function(e) {
//get data-id attribute of the clicked element and store in button
var domainId = $(e.relatedTarget).data("domain-id");
$(e.currentTarget).find("#btndeletedomain").data("domainId", domainId);
$("#domain-deny-table").on("click-cell.bs.table", function (field, value, row, $element) {
if (value === 2) {
ConfirmDialog("btndeletedomain", $element.id, domain_handle);
}
});
$("#restrictModal").on("hidden.bs.modal", function () {
@ -347,7 +349,7 @@ $(function() {
/* Function for deleting domain restrictions */
function TableActions (value, row) {
return [
"<a class=\"danger remove\" data-toggle=\"modal\" data-target=\"#DeleteDomain\" data-domain-id=\"" + row.id
"<a class=\"danger remove\" data-value=\"" + row.id
+ "\" title=\"Remove\">",
"<i class=\"glyphicon glyphicon-trash\"></i>",
"</a>"

View File

@ -198,7 +198,8 @@
{% endblock %}
{% block modal %}
{{ delete_book(book.id) }}
{{ delete_book() }}
{{ delete_confirm_modal() }}
<div class="modal fade" id="metaModal" tabindex="-1" role="dialog" aria-labelledby="metaModalLabel">
<div class="modal-dialog modal-lg" role="document">

View File

@ -61,7 +61,7 @@
</table>
{% endblock %}
{% block modal %}
{{ delete_book(0) }}
{{ delete_book() }}
{% if g.user.role_edit() %}
<div class="modal fade" id="mergeModal" role="dialog" aria-labelledby="metaMergeLabel">
<div class="modal-dialog">

View File

@ -89,20 +89,7 @@
{% endblock %}
{% block modal %}
{% if g.allow_registration %}
<div id="DeleteDomain" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header bg-danger">
</div>
<div class="modal-body text-center">
<p>{{_('Are you sure you want to delete this domain?')}}</p>
<button type="button" class="btn btn-danger" id="btndeletedomain" >{{_('Delete')}}</button>
<button type="button" class="btn btn-default" id="btncancel" data-dismiss="modal">{{_('Cancel')}}</button>
</div>
</div>
</div>
</div>
{{ delete_confirm_modal() }}
{% endif %}
{% endblock %}
{% block js %}

View File

@ -1,4 +1,4 @@
{% from 'modal_dialogs.html' import restrict_modal, delete_book, filechooser_modal %}
{% from 'modal_dialogs.html' import restrict_modal, delete_book, filechooser_modal, delete_confirm_modal %}
{% from 'book_cover.html' import book_cover_image %}
<!DOCTYPE html>
<html lang="{{ g.user.locale }}">
@ -190,8 +190,6 @@
</div>
</div>
{% block modal %}{% endblock %}
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="{{ url_for('static', filename='js/libs/jquery.min.js') }}"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
@ -201,14 +199,7 @@
<script src="{{ url_for('static', filename='js/libs/context.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/plugins.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/jquery.form.js') }}"></script>
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
<script src="{{ url_for('static', filename='js/uploadprogress.js') }}"> </script>
{% if g.current_theme == 1 %}
<script src="{{ url_for('static', filename='js/libs/jquery.visible.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/compromise.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/readmore.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/caliBlur.js') }}"></script>
{% endif %}
<script type="text/javascript">
$(function() {
$("#form-upload").uploadprogress({
@ -220,6 +211,13 @@
});
});
</script>
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
{% if g.current_theme == 1 %}
<script src="{{ url_for('static', filename='js/libs/jquery.visible.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/compromise.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/readmore.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/caliBlur.js') }}"></script>
{% endif %}
{% block js %}{% endblock %}
</body>
</html>

View File

@ -37,7 +37,7 @@
</div>
</div>
{% endmacro %}
{% macro delete_book(bookid) %}
{% macro delete_book() %}
{% if g.user.role_delete_books() %}
<div class="modal fade" id="deleteModal" role="dialog" aria-labelledby="metaDeleteLabel">
<div class="modal-dialog">
@ -102,3 +102,22 @@
</div>
</div>
{% endmacro %}
{% macro delete_confirm_modal() %}
<div id="GeneralDeleteModal" class="modal fade" role="Dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header bg-danger text-center">
<span id="header"></span>
</div>
<div class="modal-body text-center">
<span id="text"></span>
<p></p>
<button id="btnConfirmYes" type="button" class="btn btn btn-danger">{{_('Delete')}}</button>
<button id="btnConfirmNo" type="button" class="btn btn-default">{{_('Cancel')}}</button>
</div>
</div>
</div>
</div>
{% endmacro %}

View File

@ -8,7 +8,7 @@
{% endif %}
{% if g.user.is_authenticated %}
{% if (g.user.role_edit_shelfs() and shelf.is_public ) or not shelf.is_public %}
<div id="delete_shelf" data-toggle="modal" data-target="#DeleteShelfDialog" class="btn btn-danger">{{ _('Delete this Shelf') }} </div>
<div class="btn btn-danger" id="delete_shelf" data-value="{{ shelf.id }}">{{ _('Delete this Shelf') }}</div>
<a id="edit_shelf" href="{{ url_for('shelf.edit_shelf', shelf_id=shelf.id) }}" class="btn btn-primary">{{ _('Edit Shelf') }} </a>
{% if entries.__len__() %}
<div class="filterheader hidden-xs hidden-sm">
@ -81,7 +81,7 @@
{% endfor %}
</div>
</div>
<div id="DeleteShelfDialog" class="modal fade" role="dialog">
<!--div id="DeleteShelfDialog" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header bg-danger text-center">
@ -95,6 +95,9 @@
</div>
</div>
</div>
</div>
</div-->
{% endblock %}
{% block modal %}
{{ delete_confirm_modal() }}
{% endblock %}

View File

@ -63,7 +63,7 @@
<label>{{ _('Kobo Sync Token')}}</label>
<div class="form-group col">
<a class="btn btn-default" id="config_create_kobo_token" data-toggle="modal" data-target="#modal_kobo_token" data-remote="false" href="{{ url_for('kobo_auth.generate_auth_token', user_id=content.id) }}">{{_('Create/View')}}</a>
<div class="btn btn-danger" id="config_delete_kobo_token" data-toggle="modal" data-target="#modalDeleteToken" data-remote="false" {% if not content.remote_auth_token.first() %} style="display: none;" {% endif %}>{{_('Delete')}}</div>
<div class="btn btn-danger" id="config_delete_kobo_token" data-value="{{ content.id }}" data-remote="false" {% if not content.remote_auth_token.first() %} style="display: none;" {% endif %}>{{_('Delete')}}</div>
</div>
{% endif %}
</div>
@ -125,19 +125,15 @@
</div>
{% endif %}
{% endif %}
{% if g.user and g.user.role_admin() and not profile and not new_user and not content.role_anonymous() %}
<div class="checkbox">
<label>
<input type="checkbox" id="delete" name="delete"> {{_('Delete User')}}
</label>
</div>
{% endif %}
</div>
<div class="col-sm-12">
<button type="submit" id="submit" class="btn btn-default">{{_('Save')}}</button>
<div id="user_submit" class="btn btn-default">{{_('Save')}}</div>
{% if not profile %}
<a href="{{ url_for('admin.admin') }}" id="back" class="btn btn-default">{{_('Cancel')}}</a>
{% endif %}
{% if g.user and g.user.role_admin() and not profile and not new_user and not content.role_anonymous() %}
<div class="btn btn-danger" id="btndeluser" data-value="{{ content.id }}" data-remote="false" >{{_('Delete User')}}</div>
{% endif %}
</div>
</form>
</div>
@ -157,23 +153,10 @@
</div>
</div>
<div id="modalDeleteToken" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header bg-danger">
</div>
<div class="modal-body text-center">
<p>{{_('Do you really want to delete the Kobo Token?')}}</p>
<button type="button" class="btn btn-danger" id="btndeletetoken" value="{{content.id}}">{{_('Delete')}}</button>
<button type="button" class="btn btn-default" id="btncancel" data-dismiss="modal">{{_('Back')}}</button>
</div>
</div>
</div>
</div>
{% endblock %}
{% block modal %}
{{ restrict_modal() }}
{{ delete_confirm_modal() }}
{% endblock %}
{% block js %}
<script src="{{ url_for('static', filename='js/libs/bootstrap-table/bootstrap-table.min.js') }}"></script>

View File

@ -424,7 +424,7 @@ def render_books_list(data, sort, book_id, page):
elif data == "language":
return render_language_books(page, book_id, order)
elif data == "archived":
return render_archived_books(page, book_id, order)
return render_archived_books(page, order)
elif data == "search":
term = (request.args.get('query') or '')
offset = int(int(config.config_books_per_page) * (page - 1))