Merge pull request #113 from Simple2B/svyat/feat/hot_fix

Svyat/feat/hot fix
This commit is contained in:
Svyatoslav Artymovych 2023-06-02 11:53:20 +03:00 committed by GitHub
commit c11e811090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 77 additions and 56 deletions

View File

@ -46,7 +46,7 @@ def book_validator() -> Response | None:
return redirect(url_for("book.my_library"))
collection_id = request_args.get("collection_id")
if collection_id:
if collection_id is not None:
collection: m.Collection = db.session.get(m.Collection, collection_id)
if not collection or collection.is_deleted:
log(log.WARNING, "Collection with id [%s] not found", collection_id)
@ -54,7 +54,7 @@ def book_validator() -> Response | None:
return redirect(url_for("book.collection_view", book_id=book_id))
sub_collection_id = request_args.get("sub_collection_id")
if sub_collection_id:
if sub_collection_id is not None:
sub_collection: m.Collection = db.session.get(m.Collection, sub_collection_id)
if not sub_collection or sub_collection.is_deleted:
log(log.WARNING, "Sub_collection with id [%s] not found", sub_collection_id)
@ -66,7 +66,7 @@ def book_validator() -> Response | None:
)
section_id = request_args.get("section_id")
if section_id:
if section_id is not None:
section: m.Section = db.session.get(m.Section, section_id)
if not section:
log(log.WARNING, "Section with id [%s] not found", section)
@ -74,7 +74,7 @@ def book_validator() -> Response | None:
return redirect(url_for("book.collection_view", book_id=book_id))
interpretation_id = request_args.get("interpretation_id")
if interpretation_id:
if interpretation_id is not None:
interpretation: m.Interpretation = db.session.get(
m.Interpretation, interpretation_id
)
@ -88,7 +88,7 @@ def book_validator() -> Response | None:
)
comment_id = request_args.get("comment_id")
if comment_id:
if comment_id is not None:
comment: m.Comment = db.session.get(m.Comment, comment_id)
if not comment or comment.is_deleted:
log(log.WARNING, "Comment with id [%s] not found", comment_id)

View File

@ -42,6 +42,9 @@ def check_permissions(
if type(entity) == m.Comment:
log(log.INFO, "Entity is Comment. Replace it by entity.interpretation")
entity = entity.interpretation
elif type(entity) == m.Interpretation and entity.user_id == current_user.id:
log(log.INFO, "User [%s] is interpretation creator [%s]", current_user, entity)
return None
if not entity or not entity.access_groups:
log(

BIN
app/static/img/logo.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,8 @@
<link
rel="icon"
type="image/x-icon"
href="{{ url_for('static', filename='img/logo.svg') }}" />
href="{{ url_for('static', filename='img/logo.ico') }}"
/>
<!-- styles -->
<!-- prettier-ignore -->
@ -103,7 +104,7 @@
<!-- DO NOT REMOVE THIS! -->
<!-- Adding tailwind classes that are not in html, but will be added by jinja -->
<span class="hid">
<span class="hidden">
<span class="border-sky-300 bg-sky-100 !dark:text-black hidden text-orange-500 !no-underline !dark:bg-blue-600 !dark:hover:bg-blue-700 !dark:text-white"></span>
</span>
</body>

View File

@ -97,6 +97,3 @@
{% include 'book/modals/add_book_modal.html' %}
<!-- prettier-ignore -->
{% endblock %}
<!-- prettier-ignore -->
{% block scripts %}
{% endblock %}

View File

@ -3,19 +3,20 @@
{% block right_sidebar %}
{% endblock %}
{% if current_user.is_authenticated %}
{% include 'book/modals/add_collection_modal.html' %}
{% include 'book/modals/delete_collection_modal.html' %}
{% include 'book/modals/add_sub_collection_modal.html' %}
{% include 'book/modals/delete_sub_collection_modal.html' %}
{% include 'book/modals/add_section_modal.html' %}
{% include 'book/modals/delete_section_modal.html' %}
{% endif %}
{% block title %}{{book.label[:32]}}{% endblock %}
{% block content %}
{% if current_user.is_authenticated %}
{% include 'book/modals/add_collection_modal.html' %}
{% include 'book/modals/delete_collection_modal.html' %}
{% include 'book/modals/add_sub_collection_modal.html' %}
{% include 'book/modals/delete_sub_collection_modal.html' %}
{% include 'book/modals/add_section_modal.html' %}
{% include 'book/modals/delete_section_modal.html' %}
{% endif %}
<div class="flex overflow-hidden">
<div
id="accordion-collapse"

View File

@ -1,17 +1,19 @@
<!-- prettier-ignore -->
{% extends 'base.html' %}
{% if current_user.is_authenticated %}
{% include 'book/modals/approve_interpretation_modal.html' %}
{% include 'book/modals/edit_interpretation_modal.html' %}
{% include 'book/modals/delete_interpretation_modal.html' %}
{% block right_sidebar %}
{% endblock %}
{% endif %}
{% block title %}{{section.label}}{% endblock %}
{% block content %}
{% if current_user.is_authenticated %}
{% include 'book/modals/approve_interpretation_modal.html' %}
{% include 'book/modals/edit_interpretation_modal.html' %}
{% include 'book/modals/delete_interpretation_modal.html' %}
{% block right_sidebar %}
{% endblock %}
{% endif %}
{% include 'book/breadcrumbs_navigation.html'%}
<div class="overflow-x-auto shadow-md sm:rounded-lg">
<!-- prettier-ignore -->
@ -146,7 +148,7 @@
</div>
{% endif %}
{% if interpretation.book.owner == current_user or access_to_delete_interpretation %}
{% if interpretation.book.owner == current_user or interpretation.user_id == current_user.id or access_to_delete_interpretation %}
<div class="relative mt-1">
<button id="callDeleteInterpretationModal" data-popover-target="popover-delete" data-interpretation-id="{{interpretation.id}}" type="button" data-modal-target="delete_interpretation_modal" data-modal-toggle="delete_interpretation_modal" class="space-x-0.5 flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"> <path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /> </svg>

View File

@ -5,7 +5,8 @@
<form
id="delete_section_modal_form"
action="{{ url_for('book.section_delete', book_id=book.id, section_id=0) }}"
method="post" class="relative bg-white rounded-lg shadow dark:bg-gray-700">
method="post" class="relative bg-white rounded-lg shadow dark:bg-gray-700"
>
{{ form_hidden_tag() }}
<input type="hidden" name="section_id" id="delete_section_modal_section_id" value="" />

View File

@ -1,18 +1,17 @@
<!-- prettier-ignore -->
{% extends 'base.html' %}
{% if current_user.is_authenticated %}
{% include 'book/modals/delete_comment_modal.html' %}
{% include 'book/modals/edit_comment_modal.html' %}
{% block right_sidebar %}
{% endblock %}
{% endif %}
{% block title %}{{ section.label[:32] }}{% endblock %}
{% block content %}
{% if current_user.is_authenticated %}
{% include 'book/modals/delete_comment_modal.html' %}
{% include 'book/modals/edit_comment_modal.html' %}
{% block right_sidebar %}
{% endblock %}
{% endif %}
{% include 'book/breadcrumbs_navigation.html'%}
<div class="shadow-md mt-5 h-auto overflow-x-hidden">
<div class="ql-snow mt-20">

View File

@ -1,13 +1,15 @@
<!-- prettier-ignore -->
{% extends 'base.html' %}
{% include 'book/modals/access_level_modal.html' %}
{% include 'book/modals/add_contributor_modal.html' %}
{% include 'book/modals/delete_book_modal.html' %}
{% block title %}Book Settings{% endblock %}
{% block content %}
{% include 'book/modals/access_level_modal.html' %}
{% include 'book/modals/add_contributor_modal.html' %}
{% include 'book/modals/delete_book_modal.html' %}
<!-- Hide right_sidebar -->
<!-- prettier-ignore -->
{% block right_sidebar %} {% endblock %}
@ -76,7 +78,9 @@
<div class="flex justify-between">
<button type="submit" class="mr-2 mb-2 text-center text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2.5 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Submit</button>
{% if book.user_id == current_user %}
<button type="button" data-modal-target="delete_book_modal" data-modal-toggle="delete_book_modal" class="text-red-700 hover:text-white border border-red-700 hover:bg-red-800 focus:ring-4 focus:outline-none focus:ring-red-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2 dark:border-red-500 dark:text-red-500 dark:hover:text-white dark:hover:bg-red-600 dark:focus:ring-red-900">Delete Book</button>
{% endif %}
</div>
</form>
</div>

View File

@ -1,10 +1,13 @@
<!-- prettier-ignore -->
{% extends 'base.html' %}
{% include 'user/delete_profile_modal.html' %}
{% block title %}Edit Profile{% endblock %}
{% block content %}
{% include 'user/delete_profile_modal.html' %}
<!-- component -->
<section>
<div class="w-full lg:w-4/12 px-4 mx-auto pt-6">

View File

@ -1,10 +1,12 @@
<!-- prettier-ignore -->
{% extends 'base.html' %}
{% include 'user/delete_profile_modal.html' %}
{% block title %}Reactivate Profile{% endblock %}
{% block content %}
{% include 'user/delete_profile_modal.html' %}
<!-- component -->
<section>
<div class="w-full lg:w-4/12 px-4 mx-auto pt-6">

View File

@ -222,22 +222,31 @@ def my_contributions():
log(log.INFO, "Creating query for interpretations")
interpretations = (
db.session.query(
m.Interpretation,
db.session.query(m.Interpretation)
.join(
m.Comment, m.Comment.interpretation_id == m.Interpretation.id, full=True
)
.join(
m.InterpretationVote,
m.InterpretationVote.interpretation_id == m.Interpretation.id,
full=True,
)
.filter(
or_(
and_(
m.Interpretation.id == m.Comment.interpretation_id,
m.Comment.user_id == current_user.id,
m.Comment.is_deleted.is_(False),
m.Interpretation.is_deleted.is_(False),
),
and_(
m.Interpretation.user_id == current_user.id,
m.Interpretation.is_deleted.is_(False),
),
)
and_(
m.InterpretationVote.user_id == current_user.id,
m.InterpretationVote.interpretation_id == m.Interpretation.id,
),
),
m.Interpretation.is_deleted == False, # noqa: E712
)
.group_by(m.Interpretation.id)
.order_by(m.Interpretation.created_at.desc())

View File

@ -63,8 +63,8 @@ export function editInterpretations() {
let newActionPath: string = '';
newActionPath = defaultActionPath.replace(
'0/interpretation_edit',
`${interpretationId}/interpretation_edit`,
'0/edit_interpretation',
`${interpretationId}/edit_interpretation`,
);
editInterpretationForm.setAttribute('action', `${newActionPath}`);

View File

@ -40,7 +40,7 @@ export function renameCollection() {
},
body: JSON.stringify({
label: newLabel,
csrf_token: scrfInput.value,
csrf_token: scrfInput ? scrfInput.value : '',
}),
});
if (response.status == 200) {

View File

@ -12,7 +12,6 @@ export function renameSection() {
document.querySelectorAll(`[id^="edit-section-label-"]`);
const scrfInput: HTMLInputElement =
document.querySelector('#csrf_token');
console.log(scrfInput.value);
const oldName = inputsForRename[index].value;
inputsForRename[index].removeAttribute('readonly');
inputsForRename[index].value = oldName;
@ -44,7 +43,7 @@ export function renameSection() {
body: JSON.stringify({
label: newLabel,
section_id: sectionId,
csrf_token: scrfInput.value,
csrf_token: scrfInput ? scrfInput.value : '',
}),
});
if (response.status == 200) {

View File

@ -44,7 +44,7 @@ export function renameSubCollection() {
},
body: JSON.stringify({
label: newLabel,
csrf_token: scrfInput.value,
csrf_token: scrfInput ? scrfInput.value : '',
}),
});
if (response.status == 200) {