mirror of https://github.com/logos-co/open-law.git
Merge branch 'develop' into kostia/fix/bug_fix
This commit is contained in:
commit
7c9f92a2d4
|
@ -6,7 +6,7 @@
|
|||
|
||||
{% block content %}
|
||||
<div
|
||||
class="pt-1 relative pr-5 shadow-md sm:rounded-lg mt-1 h-box flex">
|
||||
class="pt-1 relative shadow-md sm:rounded-lg mt-1 h-box flex">
|
||||
{% if not current_user.is_authenticated %}
|
||||
<!-- prettier-ignore -->
|
||||
<div class="mx-auto my-auto h-full w-full p-2">
|
||||
|
@ -31,7 +31,7 @@
|
|||
{% endif %}
|
||||
{% for book in books %}
|
||||
<!-- prettier-ignore -->
|
||||
<dl class="bg-white dark:bg-gray-900 h-max w-full p-5 text-gray-900 divide-y divide-gray-200 dark:text-white dark:divide-gray-700 m-3 border-2 border-gray-200 border-solid rounded-lg dark:border-gray-700">
|
||||
<dl class="bg-white dark:bg-gray-900 h-max p-5 text-gray-900 divide-y divide-gray-200 dark:text-white dark:divide-gray-700 m-3 border-2 border-gray-200 border-solid rounded-lg dark:border-gray-700">
|
||||
<dt class="mb-2"><a class="flex flex-col pb-4" href="{{url_for('book.collection_view',book_id=book.id)}}">{{book.label}}</a></dt>
|
||||
<dd class="flex flex-col md:flex-row text-lg font-semibold text-gray-500 md:text-lg dark:text-gray-400">
|
||||
{% if book.versions %}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
{% block content %}
|
||||
<div
|
||||
class="pt-1 relative pr-5 shadow-md sm:rounded-lg mt-1 h-box flex">
|
||||
class="pt-1 relative shadow-md sm:rounded-lg mt-1 h-box flex">
|
||||
{% if not current_user.is_authenticated %}
|
||||
<!-- prettier-ignore -->
|
||||
<div class="mx-auto my-auto h-full w-full p-2">
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
{% endif %}
|
||||
|
||||
|
||||
<div class="pt-1 relative pr-5 shadow-md sm:rounded-lg mt-1 h-box flex">
|
||||
<div class="pt-1 relative shadow-md sm:rounded-lg mt-1 h-box flex flex-col">
|
||||
{% if not current_user.is_authenticated %}
|
||||
<div class="mx-auto my-auto h-full w-full p-2">
|
||||
<button type="button" id="connectWalletBtn" class="w-full h-full text-black dark:text-white focus:ring-4 focus:outline-none focus:ring-blue-100 font-medium rounded-lg text-sm px-4 py-2.5 justify-center text-center inline-flex items-center border border-gray-200 dark:border-gray-700">
|
||||
|
@ -25,28 +25,29 @@
|
|||
{% if current_user.is_authenticated and not books.total %}
|
||||
<div class="mx-auto my-auto h-full w-full p-2">
|
||||
<button type="button" data-modal-target="add-book-modal" data-modal-toggle="add-book-modal" class="w-full h-full text-black dark:text-white focus:ring-4 focus:outline-none focus:ring-blue-100 font-medium rounded-lg text-sm px-4 py-2.5 justify-center text-center inline-flex items-center border border-gray-200 dark:border-gray-700">
|
||||
<div class="my-auto">
|
||||
<div class="my-auto flex items-center space-x-2">
|
||||
<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="M12 4.5v15m7.5-7.5h-15" /> </svg>
|
||||
New book
|
||||
<span>New book</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
<div class="flex flex-col w-full">
|
||||
{% if current_user.is_authenticated and books.total %}
|
||||
<div class="flex justify-between mt-1">
|
||||
<h1 class=" text-lg font-extrabold dark:text-white ml-4">My library</h1>
|
||||
{% if current_user.is_authenticated %}
|
||||
{% include 'book/components/header_buttons.html' %}
|
||||
{% endif %}
|
||||
{% if current_user.is_authenticated and books.total %}
|
||||
<div class="flex flex-col w-full">
|
||||
<div class="flex justify-between mt-1">
|
||||
<h1 class=" text-lg font-extrabold dark:text-white ml-4">My library</h1>
|
||||
{% if current_user.is_authenticated %}
|
||||
{% include 'book/components/header_buttons.html' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% for book in books if not book.is_deleted %}
|
||||
<!-- prettier-ignore -->
|
||||
<dl class="bg-white dark:bg-gray-900 h-max w-full p-5 text-gray-900 divide-y divide-gray-200 dark:text-white dark:divide-gray-700 m-3 border-2 border-gray-200 border-solid rounded-lg dark:border-gray-700">
|
||||
<dl class="bg-white dark:bg-gray-900 h-max p-5 text-gray-900 divide-y divide-gray-200 dark:text-white dark:divide-gray-700 m-3 border-2 border-gray-200 border-solid rounded-lg dark:border-gray-700">
|
||||
<dt class="mb-2 flex">
|
||||
{% if book.original_book %}
|
||||
<a href="{{ url_for('book.collection_view', book_id=book.original_book.id ) }}" target="_blank" class="flex pb-4">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from flask import render_template, flash, redirect, url_for, request
|
||||
from flask_login import login_required, current_user
|
||||
from sqlalchemy import and_, or_, func
|
||||
from sqlalchemy import and_, or_, func, distinct
|
||||
|
||||
from app.controllers import (
|
||||
register_book_verify_route,
|
||||
|
@ -32,8 +32,10 @@ def my_library():
|
|||
db.session.query(
|
||||
m.Book,
|
||||
m.Book.created_at.label("created_at"),
|
||||
func.count(m.Interpretation.id).label("interpretations_count"),
|
||||
func.count(m.BookStar.id).label("stars_count"),
|
||||
func.count(distinct(m.Interpretation.id)).label(
|
||||
"interpretations_count"
|
||||
),
|
||||
func.count(distinct(m.BookStar.id)).label("stars_count"),
|
||||
)
|
||||
.join(
|
||||
m.BookStar,
|
||||
|
@ -49,6 +51,7 @@ def my_library():
|
|||
m.BookVersion.book_id == m.Book.id,
|
||||
m.BookVersion.is_deleted == False, # noqa: E712
|
||||
),
|
||||
full=True,
|
||||
)
|
||||
.join(
|
||||
m.Section,
|
||||
|
@ -210,8 +213,10 @@ def favorite_books():
|
|||
db.session.query(
|
||||
m.Book,
|
||||
m.Book.created_at.label("created_at"),
|
||||
func.count(m.Interpretation.id).label("interpretations_count"),
|
||||
func.count(m.BookStar.id).label("stars_count"),
|
||||
func.count(distinct(m.Interpretation.id)).label(
|
||||
"interpretations_count"
|
||||
),
|
||||
func.count(distinct(m.BookStar.id)).label("stars_count"),
|
||||
)
|
||||
.join(
|
||||
m.BookStar,
|
||||
|
@ -275,14 +280,24 @@ def my_contributions():
|
|||
m.Interpretation,
|
||||
m.Interpretation.score.label("score"),
|
||||
m.Interpretation.created_at.label("created_at"),
|
||||
func.count(m.Comment.interpretation_id).label("comments_count"),
|
||||
func.count(distinct(m.Comment.interpretation_id)).label(
|
||||
"comments_count"
|
||||
),
|
||||
)
|
||||
.join(
|
||||
m.Comment, m.Comment.interpretation_id == m.Interpretation.id, full=True
|
||||
m.Comment,
|
||||
and_(
|
||||
m.Comment.interpretation_id == m.Interpretation.id,
|
||||
m.Comment.is_deleted == False, # noqa: E712
|
||||
),
|
||||
full=True,
|
||||
)
|
||||
.join(
|
||||
m.InterpretationVote,
|
||||
m.InterpretationVote.interpretation_id == m.Interpretation.id,
|
||||
and_(
|
||||
m.InterpretationVote.interpretation_id == m.Interpretation.id,
|
||||
m.Interpretation.is_deleted == False, # noqa: E712
|
||||
),
|
||||
full=True,
|
||||
)
|
||||
.filter(
|
||||
|
@ -301,7 +316,7 @@ def my_contributions():
|
|||
),
|
||||
),
|
||||
m.Interpretation.is_deleted == False, # noqa: E712
|
||||
m.Interpretation.copy_of == None, # noqa: E711
|
||||
m.Interpretation.copy_of == 0,
|
||||
)
|
||||
.group_by(m.Interpretation.id)
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ from flask import (
|
|||
render_template,
|
||||
request,
|
||||
)
|
||||
from sqlalchemy import and_, func
|
||||
from sqlalchemy import and_, func, distinct
|
||||
from app import models as m, db
|
||||
from app.logger import log
|
||||
from app.controllers.sorting import sort_by
|
||||
|
@ -20,7 +20,7 @@ def get_all():
|
|||
m.Interpretation,
|
||||
m.Interpretation.score.label("score"),
|
||||
m.Interpretation.created_at.label("created_at"),
|
||||
func.count(m.Comment.interpretation_id).label("comments_count"),
|
||||
func.count(distinct(m.Comment.interpretation_id)).label("comments_count"),
|
||||
)
|
||||
.join(
|
||||
m.Comment,
|
||||
|
@ -53,8 +53,8 @@ def explore_books():
|
|||
db.session.query(
|
||||
m.Book,
|
||||
m.Book.created_at.label("created_at"),
|
||||
func.count(m.Interpretation.id).label("interpretations_count"),
|
||||
func.count(m.BookStar.id).label("stars_count"),
|
||||
func.count(distinct(m.Interpretation.id)).label("interpretations_count"),
|
||||
func.count(distinct(m.BookStar.id)).label("stars_count"),
|
||||
)
|
||||
.join(
|
||||
m.BookStar,
|
||||
|
|
|
@ -18,7 +18,7 @@ def search_interpretations():
|
|||
log(log.INFO, "Starting to build query for interpretations")
|
||||
interpretations = m.Interpretation.query.order_by(m.Interpretation.id).filter(
|
||||
(func.lower(m.Interpretation.plain_text).like(f"%{q}%")),
|
||||
m.Interpretation.copy_of == None, # noqa: E711
|
||||
m.Interpretation.copy_of == 0,
|
||||
)
|
||||
log(log.INFO, "Get count of interpretations")
|
||||
count = interpretations.count()
|
||||
|
@ -55,18 +55,18 @@ def search_books():
|
|||
and_(
|
||||
func.lower(m.Collection.label).like(f"%{q}%"),
|
||||
m.Collection.is_deleted == False, # noqa: E712
|
||||
m.Collection.copy_of == None, # noqa: E711
|
||||
m.Collection.copy_of == 0,
|
||||
m.Collection.is_root == False, # noqa: E712
|
||||
),
|
||||
and_(
|
||||
func.lower(m.Section.label).like(f"%{q}%"),
|
||||
m.Section.copy_of == None, # noqa: E711
|
||||
m.Section.copy_of == 0,
|
||||
m.Section.is_deleted == False, # noqa: E712
|
||||
),
|
||||
and_(
|
||||
func.lower(m.Interpretation.plain_text).like(f"%{q}%"),
|
||||
m.Interpretation.is_deleted == False, # noqa: E712
|
||||
m.Interpretation.copy_of == None, # noqa: E711
|
||||
m.Interpretation.copy_of == 0,
|
||||
m.Section.is_deleted == False, # noqa: E712
|
||||
),
|
||||
),
|
||||
|
@ -157,7 +157,7 @@ def tag_search_interpretations():
|
|||
func.lower(m.Tag.name) == (tag_name),
|
||||
m.InterpretationTag.tag_id == m.Tag.id,
|
||||
m.Interpretation.id == m.InterpretationTag.interpretation_id,
|
||||
m.Interpretation.copy_of == None, # noqa: E711
|
||||
m.Interpretation.copy_of == 0,
|
||||
m.Interpretation.is_deleted == False, # noqa: E712
|
||||
)
|
||||
)
|
||||
|
@ -221,7 +221,7 @@ def quick_search():
|
|||
m.Interpretation.query.order_by(m.Interpretation.id)
|
||||
.filter(
|
||||
(func.lower(m.Interpretation.plain_text).like(f"%{search_query}%")),
|
||||
m.Interpretation.copy_of == None, # noqa: E711
|
||||
m.Interpretation.copy_of == 0,
|
||||
m.Interpretation.is_deleted == False, # noqa: E712,
|
||||
)
|
||||
.limit(2)
|
||||
|
|
Loading…
Reference in New Issue