Merge branch 'develop' into svyat/fix/issues

This commit is contained in:
SvyatoslavArtymovych 2023-06-16 12:45:15 +03:00
commit 592de90567
9 changed files with 226 additions and 248 deletions

View File

@ -17,6 +17,7 @@
"CLEANR",
"CUDA",
"Divs",
"favorited",
"flowbite",
"indeterminated",
"jsonify",

View File

@ -267,14 +267,14 @@ def contributor_notification(
book: m.Book = db.session.get(m.Book, entity_id)
match action:
case m.Notification.Actions.CONTRIBUTING:
text = f"You've been added to {book.label} as an Editor/Moderator"
text = f"You've been added to {book.label} as an Contributor"
link = url_for(
"book.collection_view",
book_id=book.id,
)
case m.Notification.Actions.DELETE:
text = f"You've been removed from {book.label} as an Editor/Moderator"
text = f"You've been removed from {book.label} as an Contributor"
link = url_for(
"book.collection_view",
book_id=book.id,

View File

@ -5,7 +5,7 @@ from app.controllers import create_pagination
def sort_by(query, sort: str):
match sort:
case "favored":
case "favorited":
query = query.order_by(text("stars_count DESC"))
case "upvoted":
query = query.order_by(text("score DESC"))

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,12 @@
<div class="bg-white dark:bg-gray-800 mr-5">
<ul class="flex font-medium">
<li>
{% if not selected_tab=='my_contributions' %}
<!-- prettier-ignore -->
<button type="button" data-modal-target="add-book-modal" data-modal-toggle="add-book-modal" class="text-white ml-2 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 text-center inline-flex items-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4"> <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" /> </svg>
New book
</button>
{% endif %}
</li>
<li>
<!-- prettier-ignore -->
@ -30,8 +32,8 @@
{% if selected_tab=='my_library' or selected_tab=='favorite_books' or selected_tab=='explore_books'%}
<li>
<a href="?sort=favored" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white" >
Most favored
<a href="?sort=favorited" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white" >
Most favorited
</a>
</li>
{% endif %}

View File

@ -26,7 +26,10 @@
{% else %}
<div class="ql-snow">
<div class="dark:text-white h-30 ql-editor-readonly !px-0">
<p> {{display_inline_elements(section.approved_interpretation.text)|safe }} </p>
<p>
{{display_inline_elements(section.approved_interpretation.text)|safe
}}
</p>
</div>
</div>
<div
@ -35,11 +38,11 @@
Interpretation by
<a
href="{{url_for('user.profile', user_id=section.approved_interpretation.user.id)}}"
class="text-blue-500 {% if section.approved_interpretation.user.is_deleted %}line-through{% endif %}"
>
class="text-blue-500 {% if section.approved_interpretation.user.is_deleted %}line-through{% endif %}">
{{section.approved_interpretation.user.username}}
</a>
on {{section.approved_interpretation.created_at.strftime('%B %d, %Y')}}
on {{section.approved_interpretation.created_at.strftime('%B %d,
%Y')}}
</span>
<button
data-tooltip-target="tooltip-click"
@ -47,16 +50,14 @@
id="copyLinkButton"
type="button"
class="hover:dark:text-white hover:text-black focus:ring-2 rounded-full font-medium text-sm p-2.5 text-center inline-flex items-center dark:hover:text-white"
data-link="{{ build_qa_url(section.approved_interpretation) }}"
>
data-link="{{ build_qa_url(section.approved_interpretation) }}">
<!-- prettier-ignore -->
<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="M9 8.25H7.5a2.25 2.25 0 00-2.25 2.25v9a2.25 2.25 0 002.25 2.25h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25H15m0-3l-3-3m0 0l-3 3m3-3V15" /> </svg>
</button>
<div
id="tooltip-click"
role="tooltip"
class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700"
>
class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700">
Link copied!
<div class="tooltip-arrow" data-popper-arrow></div>
</div>
@ -75,8 +76,7 @@
class="flex items-center bg-inherit justify-start w-full p-5 font-medium text-left"
data-accordion-target="#accordion-comments-collapse-{{loop.index}}-body-{{loop.index}}"
aria-expanded="false"
aria-controls="accordion-collapse-body-1"
>
aria-controls="accordion-collapse-body-1">
<!-- prettier-ignore -->
<svg data-accordion-icon class="w-6 h-6 rotate-180 shrink-0" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path> </svg>
<span><i>Comments:</i></span>
@ -85,8 +85,7 @@
<div
id="accordion-comments-collapse-{{loop.index}}-body-{{loop.index}}"
class="hidden"
aria-labelledby="accordion-collapse-heading-{{loop.index}}"
>
aria-labelledby="accordion-collapse-heading-{{loop.index}}">
{% for comment in section.approved_comments %}
<div class="p-5 ml-6">
<div class="dark:text-white h-30">
@ -97,39 +96,32 @@
</div>
</div>
<div
class="flex w-full ml-auto align-center justify-between space-x-3 border-t py-3"
>
class="flex w-full ml-auto align-center justify-between space-x-3 border-t py-3">
<span class="text-sm">
Created by
<a href="{{ url_for('user.profile', user_id=comment.user.id) }}" class="text-blue-500 {% if comment.user.is_deleted %}line-through{% endif %}" >
<a
href="{{ url_for('user.profile', user_id=comment.user.id) }}"
class="text-blue-500 {% if comment.user.is_deleted %}line-through{% endif %}">
{{comment.user.username}}
</a>
on {{comment.created_at.strftime('%B %d, %Y')}}
</span>
<button
data-tooltip-target="tooltip-click"
data-tooltip-trigger="click"
id="copyLinkButton"
type="button"
class="hover:dark:text-white hover:text-black focus:ring-2 rounded-full font-medium text-sm p-2.5 text-center inline-flex items-center dark:hover:text-white"
data-link="{{ build_qa_url(section.approved_interpretation) }}">
<div>
<!-- prettier-ignore -->
<a class="hover:dark:text-white hover:text-black focus:ring-2 rounded-full font-medium text-sm p-2.5 text-center inline-flex items-center dark:hover:text-white" href="{{ build_qa_url(section.approved_interpretation) }}">
<!-- prettier-ignore -->
<button data-tooltip-target="tooltip-click" data-tooltip-trigger="click" id="copyLinkButton" type="button" class="hover:dark:text-white hover:text-black focus:ring-2 rounded-full font-medium text-sm p-2.5 text-center inline-flex items-center dark:hover:text-white" data-link="{{ build_qa_url(section.approved_interpretation) }}">
<!-- prettier-ignore -->
<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="M9 8.25H7.5a2.25 2.25 0 00-2.25 2.25v9a2.25 2.25 0 002.25 2.25h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25H15m0-3l-3-3m0 0l-3 3m3-3V15" /> </svg>
</button>
<div
id="tooltip-click"
role="tooltip"
class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700"
>
Link copied!
<div class="tooltip-arrow" data-popper-arrow></div>
<div id="tooltip-click" role="tooltip" class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700"> Link copied! <div class="tooltip-arrow" data-popper-arrow></div> </div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% endif %}
{% endif %} {% endif %}
</div>
</div>
</div>
@ -139,10 +131,9 @@
{% endfor %}
{% else %}
{% for section in collection.active_sections %}
<a href="{{url_for('book.interpretation_view', book_id=book.id, section_id=section.copy_of or section.id)}}">
<p id="section-{{section.label}}" class="my-3">
{{ section.label }}
</p>
<a
href="{{url_for('book.interpretation_view', book_id=book.id, section_id=section.copy_of or section.id)}}">
<p id="section-{{section.label}}" class="my-3">{{ section.label }}</p>
</a>
{% if not section.active_interpretations %}
<p class="ml-3 my-3 italic text-sm">This section is empty</p>
@ -154,35 +145,32 @@
</p>
</div>
</div>
<div class="flex w-full ml-auto align-center justify-between space-x-3 border-t py-3">
<div
class="flex w-full ml-auto align-center justify-between space-x-3 border-t py-3">
<span class="text-sm">
Interpretation by
<a
href="{{url_for('user.profile',user_id=section.approved_interpretation.user.id)}}"
class="text-blue-500 {% if section.approved_interpretation.user.is_deleted %}line-through{% endif %}"
>
class="text-blue-500 {% if section.approved_interpretation.user.is_deleted %}line-through{% endif %}">
{{section.approved_interpretation.user.username}}
</a>
on {{section.approved_interpretation.created_at.strftime('%B %d, %Y')}}
</span>
<div>
<!-- prettier-ignore -->
<a class="hover:dark:text-white hover:text-black focus:ring-2 rounded-full font-medium text-sm p-2.5 text-center inline-flex items-center dark:hover:text-white" href="{{ build_qa_url(section.approved_interpretation) }}">
<!-- prettier-ignore -->
<button
data-tooltip-target="tooltip-click"
data-tooltip-trigger="click"
id="copyLinkButton"
type="button"
class="hover:dark:text-white hover:text-black focus:ring-2 rounded-full font-medium text-sm p-2.5 text-center inline-flex items-center dark:hover:text-white"
data-link="{{ build_qa_url(section.approved_interpretation) }}"
>
data-link="{{ build_qa_url(section.approved_interpretation) }}">
<!-- prettier-ignore -->
<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="M9 8.25H7.5a2.25 2.25 0 00-2.25 2.25v9a2.25 2.25 0 002.25 2.25h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25H15m0-3l-3-3m0 0l-3 3m3-3V15" /> </svg>
</button>
<div
id="tooltip-click"
role="tooltip"
class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700"
>
Link copied!
<div class="tooltip-arrow" data-popper-arrow></div>
</div>
<div id="tooltip-click" role="tooltip" class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700"> Link copied! <div class="tooltip-arrow" data-popper-arrow></div> </div> </div>
</div>
<!--Comments-->
@ -191,28 +179,18 @@
<p>No comments for current section</p>
</div>
{% else %}
<div
id="accordion-comments-collapse-nest{{loop.index}}"
data-accordion="collapse"
class="mb-3"
>
<!-- prettier-ignore -->
<div id="accordion-comments-collapse-nest{{loop.index}}" data-accordion="collapse" class="mb-3">
<h2 id="accordion-comments-collapse-nest{{loop.index}}-heading-{{loop.index}}">
<button
type="button"
class="flex items-center bg-inherit justify-start w-full p-5 font-medium text-left"
data-accordion-target="#accordion-comments-collapse-nest{{loop.index}}-body-{{loop.index}}"
aria-expanded="false"
aria-controls="accordion-collapse-body-1"
>
<!-- prettier-ignore -->
<button type="button" class="flex items-center bg-inherit justify-start w-full p-5 font-medium text-left" data-accordion-target="#accordion-comments-collapse-nest{{loop.index}}-body-{{loop.index}}" aria-expanded="false" aria-controls="accordion-collapse-body-1">
<!-- prettier-ignore -->
<svg data-accordion-icon class="w-6 h-6 rotate-180 shrink-0" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path> </svg>
<span><i>Comments:</i> </span>
</button>
</h2>
<div
id="accordion-comments-collapse-nest{{loop.index}}-body-{{loop.index}}"
class="hidden"
aria-labelledby="accordion-collapse-heading-1"
>
<!-- prettier-ignore -->
<div id="accordion-comments-collapse-nest{{loop.index}}-body-{{loop.index}}" class="hidden" aria-labelledby="accordion-collapse-heading-1">
{% for comment in section.approved_comments %}
<div class="p-5 ml-6">
<div class="dark:text-white h-30">
@ -233,30 +211,27 @@
</a>
on {{comment.created_at.strftime('%B %d, %Y')}}
</span>
<div>
<!-- prettier-ignore -->
<a class="hover:dark:text-white hover:text-black focus:ring-2 rounded-full font-medium text-sm p-2.5 text-center inline-flex items-center dark:hover:text-white" href="{{ build_qa_url(section.approved_interpretation) }}">
<!-- prettier-ignore -->
<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="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z" /> </svg>
</a>
<button
data-tooltip-target="tooltip-click"
data-tooltip-trigger="click"
id="copyLinkButton"
type="button"
class="hover:dark:text-white hover:text-black focus:ring-2 rounded-full font-medium text-sm p-2.5 text-center inline-flex items-center dark:hover:text-white"
data-link="{{ build_qa_url(section.approved_interpretation) }}"
>
data-link="{{ build_qa_url(section.approved_interpretation) }}">
<!-- prettier-ignore -->
<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="M9 8.25H7.5a2.25 2.25 0 00-2.25 2.25v9a2.25 2.25 0 002.25 2.25h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25H15m0-3l-3-3m0 0l-3 3m3-3V15" /> </svg>
</button>
<div
id="tooltip-click"
role="tooltip"
class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700"
>
Link copied!
<div class="tooltip-arrow" data-popper-arrow></div>
<div id="tooltip-click" role="tooltip" class="absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip dark:bg-gray-700"> Link copied! <div class="tooltip-arrow" data-popper-arrow></div> </div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %} {% endif %} {% endfor %} {% endif %}

View File

@ -65,6 +65,7 @@
<div class="ql-snow">
{% set local_breadcrumbs = interpretation.section.breadcrumbs_path %}
{% include 'book/local_breadcrumbs_navigation.html'%}
<a href="{{url_for('book.interpretation_view', book_id=interpretation.book.id, section_id=interpretation.section.id)}}">
<p>{{ interpretation.section.label }}</p>
</a>
<div class="dark:text-white h-30 ql-editor-readonly">

View File

@ -13,8 +13,9 @@ export function initWallet() {
// protocol, hostname and port number of the URL
const origin = window.location.origin;
// connect to ethereum network and sign transactions with Metamask
const showExtensionAlert = localStorage.getItem('showExtensionAlert');
if (!window.hasOwnProperty('ethereum') && showExtensionAlert != 'false') {
async function signInWithEthereum() {
if (!window.hasOwnProperty('ethereum')) {
let result = confirm(
"You don't have needed extension! Do you want to install it?",
);
@ -24,15 +25,13 @@ export function initWallet() {
}
return;
}
if (showExtensionAlert == 'false' && !window.hasOwnProperty('ethereum')) {
if (!window.hasOwnProperty('ethereum')) {
console.error('Required extension not found');
return;
}
const eOwner: IEthereumOwner = window as any;
const provider = new ethers.providers.Web3Provider(eOwner.ethereum);
const signer = provider.getSigner();
async function signInWithEthereum() {
// create siwe message and call backend to get a nonce
const res1 = await fetch('/nonce', {
credentials: 'include',

View File

@ -57,7 +57,7 @@ def test_notifications(client: FlaskClient):
)
assert response.status_code == 200
# check that user_2 have notification about he was added, deleted as Editor/Moderator and his comment was approved
# check that user_2 have notification about he was added, deleted as Contributor and his comment was approved
assert len(user_2.active_notifications) == 3
response: Response = client.post(