diff --git a/gallery/__init__.py b/gallery/__init__.py
index a862223..17174dd 100644
--- a/gallery/__init__.py
+++ b/gallery/__init__.py
@@ -58,12 +58,9 @@ def create_app(test_config=None):
app.config.from_mapping(test_config)
# Load JS assets
- js_pre = Bundle('js/pre/*.js', output='gen/pre_packed.js')
- js_post = Bundle('js/post/*.js', output='gen/post_packed.js')
- styles = Bundle('sass/*.sass', filters='libsass', output='gen/styles.css')
- assets.register('js_pre', js_pre)
- assets.register('js_post', js_post)
- assets.register('styles', styles)
+ assets.register('js_pre', Bundle('js/pre/*.js', output='gen/pre_packed.js'))
+ assets.register('js_post', Bundle('js/post/*.js', output='gen/post_packed.js'))
+ assets.register('styles', Bundle('sass/*.sass', filters='libsass', output='gen/styles.css'))
# Error handlers, if the error is not a HTTP error, return 500
@app.errorhandler(Exception)
diff --git a/gallery/static/js/post/popup.js b/gallery/static/js/pre/popup.js
similarity index 100%
rename from gallery/static/js/post/popup.js
rename to gallery/static/js/pre/popup.js
diff --git a/gallery/templates/image.html b/gallery/templates/image.html
index a088615..e07320f 100644
--- a/gallery/templates/image.html
+++ b/gallery/templates/image.html
@@ -33,7 +33,7 @@
}
}
- {% if g.user['id'] == image['author_id'] %}
+ {% if g.user.id == image.author_id %}
cancelBtn = document.createElement('button');
cancelBtn.classList.add('btn-block');
cancelBtn.innerHTML = 'nuuuuuuuu';
@@ -46,26 +46,27 @@
deleteBtn.onclick = deleteConfirm;
function imageDelete() {
- popUpShow(
- 'DESTRUCTION!!!!!!',
- 'Do you want to delete this image along with all of its data??? This action is irreversible!',
- null,
- [cancelBtn, deleteBtn]
- );
+ popUpShow('DESTRUCTION!!!!!!',
+ 'Do you want to delete this image along with all of its data??? ' +
+ 'This action is irreversible!',
+ null,
+ [cancelBtn, deleteBtn]);
}
function deleteConfirm() {
popupDissmiss();
- $.ajax({
- url: '{{ url_for('api.delete_image', image_id=image['id']) }}',
- type: 'post',
- data: {
+ fetch('{{ url_for('api.delete_image', image_id=image['id']) }}', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
action: 'delete'
- },
- success: function (response) {
+ })
+ }).then(function(response) {
+ if (response.ok) {
window.location.href = '/';
- },
- error: function (response) {
+ } else {
addNotification(`Image *clings*: ${response}`, 2);
}
});
@@ -148,7 +149,7 @@
- {% if image.author_id == g.user.id %}
+ {% if g.user.id == image.author_id %}