mirror of
https://github.com/logos-co/open-law.git
synced 2025-02-03 02:24:45 +00:00
remove interpretation label
This commit is contained in:
parent
c1579a7715
commit
7ab0eb1dec
@ -99,25 +99,4 @@ def create_breadcrumbs(
|
|||||||
label=section.label,
|
label=section.label,
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
if interpretation_id:
|
|
||||||
interpretation: m.Interpretation = db.session.get(
|
|
||||||
m.Interpretation, interpretation_id
|
|
||||||
)
|
|
||||||
crumples += [
|
|
||||||
s.BreadCrumb(
|
|
||||||
type=s.BreadCrumbType.Interpretation,
|
|
||||||
url=url_for(
|
|
||||||
"book.qa_view",
|
|
||||||
book_id=book_id,
|
|
||||||
collection_id=collection_path[0],
|
|
||||||
sub_collection_id=collection_path[-1]
|
|
||||||
if len(collection_path) == 2
|
|
||||||
else collection_path[0],
|
|
||||||
section_id=section_id,
|
|
||||||
interpretation_id=interpretation_id,
|
|
||||||
),
|
|
||||||
label=interpretation.label,
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
return crumples
|
return crumples
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from wtforms import StringField, SubmitField
|
from wtforms import StringField, SubmitField
|
||||||
from wtforms.validators import DataRequired, Length
|
from wtforms.validators import DataRequired
|
||||||
|
|
||||||
|
|
||||||
class BaseInterpretationForm(FlaskForm):
|
class BaseInterpretationForm(FlaskForm):
|
||||||
@ -9,7 +9,6 @@ class BaseInterpretationForm(FlaskForm):
|
|||||||
|
|
||||||
|
|
||||||
class CreateInterpretationForm(BaseInterpretationForm):
|
class CreateInterpretationForm(BaseInterpretationForm):
|
||||||
label = StringField("Label", [DataRequired(), Length(3, 256)])
|
|
||||||
section_id = StringField("Interpretation ID", [DataRequired()])
|
section_id = StringField("Interpretation ID", [DataRequired()])
|
||||||
submit = SubmitField("Create")
|
submit = SubmitField("Create")
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ from app.models.utils import BaseModel
|
|||||||
class Interpretation(BaseModel):
|
class Interpretation(BaseModel):
|
||||||
__tablename__ = "interpretations"
|
__tablename__ = "interpretations"
|
||||||
|
|
||||||
label = db.Column(db.String(256), unique=False, nullable=False)
|
|
||||||
text = db.Column(db.Text, unique=False, nullable=False)
|
text = db.Column(db.Text, unique=False, nullable=False)
|
||||||
approved = db.Column(db.Boolean, default=False)
|
approved = db.Column(db.Boolean, default=False)
|
||||||
marked = db.Column(db.Boolean, default=False)
|
marked = db.Column(db.Boolean, default=False)
|
||||||
@ -55,4 +54,4 @@ class Interpretation(BaseModel):
|
|||||||
return self.section.version.book
|
return self.section.version.book
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<{self.id}: {self.label}>"
|
return f"<{self.id}: {self.text[:15]}>"
|
||||||
|
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% if current_user.is_authenticated %}
|
{% if current_user.is_authenticated %}
|
||||||
{% include 'book/delete_interpretation_modal.html' %}
|
{% include 'book/delete_interpretation_modal.html' %}
|
||||||
{% include 'book/delete_comment_modal.html' %}
|
{% include 'book/delete_comment_modal.html' %}
|
||||||
@ -21,7 +21,7 @@
|
|||||||
<div class="shadow-md mt-5 md:mr-64 h-auto overflow-x-hidden">
|
<div class="shadow-md mt-5 md:mr-64 h-auto overflow-x-hidden">
|
||||||
<div class="ql-snow mt-20">
|
<div class="ql-snow mt-20">
|
||||||
<h1 class="text-l font-extrabold dark:text-white ml-4 truncate">
|
<h1 class="text-l font-extrabold dark:text-white ml-4 truncate">
|
||||||
{{ interpretation.label }}
|
{{ section.label }}
|
||||||
</h1>
|
</h1>
|
||||||
<div class="ql-editor-readonly text-lg dark:text-white p-3">{{interpretation.text|safe}}</div>
|
<div class="ql-editor-readonly text-lg dark:text-white p-3">{{interpretation.text|safe}}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -814,7 +814,6 @@ def interpretation_create(
|
|||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
interpretation: m.Interpretation = m.Interpretation(
|
interpretation: m.Interpretation = m.Interpretation(
|
||||||
label=form.label.data,
|
|
||||||
text=form.text.data,
|
text=form.text.data,
|
||||||
section_id=section_id,
|
section_id=section_id,
|
||||||
user_id=current_user.id,
|
user_id=current_user.id,
|
||||||
|
@ -113,14 +113,12 @@ def create_dummy_data():
|
|||||||
# - interpretation 4
|
# - interpretation 4
|
||||||
|
|
||||||
interpretation_1 = m.Interpretation(
|
interpretation_1 = m.Interpretation(
|
||||||
label="Dummy Interpretation 1 Label",
|
|
||||||
text="Dummy Interpretation 1 About",
|
text="Dummy Interpretation 1 About",
|
||||||
section_id=section_1_1.id,
|
section_id=section_1_1.id,
|
||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
).save()
|
).save()
|
||||||
|
|
||||||
interpretation_2 = m.Interpretation(
|
interpretation_2 = m.Interpretation(
|
||||||
label="Dummy Interpretation 2 Label",
|
|
||||||
text="Dummy Interpretation 2 About",
|
text="Dummy Interpretation 2 About",
|
||||||
section_id=section_2_1_1.id,
|
section_id=section_2_1_1.id,
|
||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
@ -128,7 +126,6 @@ def create_dummy_data():
|
|||||||
).save()
|
).save()
|
||||||
|
|
||||||
interpretation_3 = m.Interpretation(
|
interpretation_3 = m.Interpretation(
|
||||||
label="Dummy Interpretation 3 Label",
|
|
||||||
text="Dummy Interpretation 3 About",
|
text="Dummy Interpretation 3 About",
|
||||||
section_id=section_2_1_2.id,
|
section_id=section_2_1_2.id,
|
||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
@ -136,7 +133,6 @@ def create_dummy_data():
|
|||||||
).save()
|
).save()
|
||||||
|
|
||||||
m.Interpretation(
|
m.Interpretation(
|
||||||
label="Dummy Interpretation 4 Label",
|
|
||||||
text="Dummy Interpretation 4 About",
|
text="Dummy Interpretation 4 About",
|
||||||
section_id=section_2_1_2.id,
|
section_id=section_2_1_2.id,
|
||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
|
@ -818,18 +818,17 @@ def test_crud_interpretation(client: FlaskClient, runner: FlaskCliRunner):
|
|||||||
version_id=book.last_version.id,
|
version_id=book.last_version.id,
|
||||||
).save()
|
).save()
|
||||||
|
|
||||||
label_1 = "Test Interpretation #1 Label"
|
|
||||||
text_1 = "Test Interpretation #1 Text"
|
text_1 = "Test Interpretation #1 Text"
|
||||||
|
|
||||||
response: Response = client.post(
|
response: Response = client.post(
|
||||||
f"/book/{book.id}/{collection.id}/{sub_collection.id}/{section_in_subcollection.id}/create_interpretation",
|
f"/book/{book.id}/{collection.id}/{sub_collection.id}/{section_in_subcollection.id}/create_interpretation",
|
||||||
data=dict(section_id=section_in_subcollection.id, label=label_1, text=text_1),
|
data=dict(section_id=section_in_subcollection.id, text=text_1),
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
||||||
label=label_1, section_id=section_in_subcollection.id
|
section_id=section_in_subcollection.id, text=text_1
|
||||||
).first()
|
).first()
|
||||||
assert interpretation
|
assert interpretation
|
||||||
assert interpretation.section_id == section_in_subcollection.id
|
assert interpretation.section_id == section_in_subcollection.id
|
||||||
@ -837,13 +836,13 @@ def test_crud_interpretation(client: FlaskClient, runner: FlaskCliRunner):
|
|||||||
|
|
||||||
response: Response = client.post(
|
response: Response = client.post(
|
||||||
f"/book/{book.id}/{leaf_collection.id}/{section_in_collection.id}/create_interpretation",
|
f"/book/{book.id}/{leaf_collection.id}/{section_in_collection.id}/create_interpretation",
|
||||||
data=dict(section_id=section_in_collection.id, label=label_1, text=text_1),
|
data=dict(section_id=section_in_collection.id, text=text_1),
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
||||||
label=label_1, section_id=section_in_collection.id
|
text=text_1, section_id=section_in_collection.id
|
||||||
).first()
|
).first()
|
||||||
assert interpretation
|
assert interpretation
|
||||||
assert interpretation.section_id == section_in_collection.id
|
assert interpretation.section_id == section_in_collection.id
|
||||||
@ -851,7 +850,7 @@ def test_crud_interpretation(client: FlaskClient, runner: FlaskCliRunner):
|
|||||||
|
|
||||||
response: Response = client.post(
|
response: Response = client.post(
|
||||||
f"/book/{book.id}/{collection.id}/999/create_section",
|
f"/book/{book.id}/{collection.id}/999/create_section",
|
||||||
data=dict(collection_id=999, label=label_1, text=text_1),
|
data=dict(collection_id=999, text=text_1),
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -860,7 +859,7 @@ def test_crud_interpretation(client: FlaskClient, runner: FlaskCliRunner):
|
|||||||
|
|
||||||
response: Response = client.post(
|
response: Response = client.post(
|
||||||
f"/book/{book.id}/{leaf_collection.id}/999/create_interpretation",
|
f"/book/{book.id}/{leaf_collection.id}/999/create_interpretation",
|
||||||
data=dict(collection_id=999, label=label_1, text=text_1),
|
data=dict(collection_id=999, text=text_1),
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -869,7 +868,7 @@ def test_crud_interpretation(client: FlaskClient, runner: FlaskCliRunner):
|
|||||||
|
|
||||||
response: Response = client.post(
|
response: Response = client.post(
|
||||||
f"/book/{book.id}/{collection.id}/{sub_collection.id}/888/create_interpretation",
|
f"/book/{book.id}/{collection.id}/{sub_collection.id}/888/create_interpretation",
|
||||||
data=dict(collection_id=999, label=label_1, text=text_1),
|
data=dict(collection_id=999, text=text_1),
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -879,17 +878,16 @@ def test_crud_interpretation(client: FlaskClient, runner: FlaskCliRunner):
|
|||||||
# edit
|
# edit
|
||||||
|
|
||||||
m.Interpretation(
|
m.Interpretation(
|
||||||
label="Test", text="Test", section_id=section_in_collection.id, user_id=user.id
|
text="Test", section_id=section_in_collection.id, user_id=user.id
|
||||||
).save()
|
).save()
|
||||||
|
|
||||||
m.Interpretation(
|
m.Interpretation(
|
||||||
label="Test",
|
|
||||||
text="Test",
|
text="Test",
|
||||||
section_id=section_in_subcollection.id,
|
section_id=section_in_subcollection.id,
|
||||||
).save()
|
).save()
|
||||||
|
|
||||||
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
||||||
label=label_1, section_id=section_in_collection.id
|
section_id=section_in_collection.id
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
new_label = "Test Interpretation #1 Label(edited)"
|
new_label = "Test Interpretation #1 Label(edited)"
|
||||||
@ -898,7 +896,6 @@ def test_crud_interpretation(client: FlaskClient, runner: FlaskCliRunner):
|
|||||||
response: Response = client.post(
|
response: Response = client.post(
|
||||||
f"/book/{book.id}/{leaf_collection.id}/{section_in_collection.id}/{interpretation.id}/edit_interpretation",
|
f"/book/{book.id}/{leaf_collection.id}/{section_in_collection.id}/{interpretation.id}/edit_interpretation",
|
||||||
data=dict(
|
data=dict(
|
||||||
label=new_label,
|
|
||||||
interpretation_id=interpretation.id,
|
interpretation_id=interpretation.id,
|
||||||
text=new_text,
|
text=new_text,
|
||||||
),
|
),
|
||||||
@ -908,7 +905,7 @@ def test_crud_interpretation(client: FlaskClient, runner: FlaskCliRunner):
|
|||||||
assert b"Success!" in response.data
|
assert b"Success!" in response.data
|
||||||
|
|
||||||
edited_interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
edited_interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
||||||
label=new_label, text=new_text, id=interpretation.id
|
text=new_text, id=interpretation.id
|
||||||
).first()
|
).first()
|
||||||
assert edited_interpretation
|
assert edited_interpretation
|
||||||
|
|
||||||
@ -916,7 +913,6 @@ def test_crud_interpretation(client: FlaskClient, runner: FlaskCliRunner):
|
|||||||
f"/book/{book.id}/{leaf_collection.id}/{section_in_collection.id}/999/edit_interpretation",
|
f"/book/{book.id}/{leaf_collection.id}/{section_in_collection.id}/999/edit_interpretation",
|
||||||
data=dict(
|
data=dict(
|
||||||
interpretation_id=interpretation.id,
|
interpretation_id=interpretation.id,
|
||||||
label=new_label,
|
|
||||||
text=new_text,
|
text=new_text,
|
||||||
),
|
),
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
@ -1018,7 +1014,7 @@ def test_crud_comment(client: FlaskClient, runner: FlaskCliRunner):
|
|||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
||||||
label=label_1, section_id=section_in_subcollection.id
|
section_id=section_in_subcollection.id
|
||||||
).first()
|
).first()
|
||||||
assert interpretation
|
assert interpretation
|
||||||
assert interpretation.section_id == section_in_subcollection.id
|
assert interpretation.section_id == section_in_subcollection.id
|
||||||
@ -1170,7 +1166,7 @@ def test_interpretation_in_home_last_inter_section(
|
|||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
||||||
label=label_1, section_id=section_in_subcollection.id
|
section_id=section_in_subcollection.id
|
||||||
).first()
|
).first()
|
||||||
assert interpretation
|
assert interpretation
|
||||||
assert interpretation.section_id == section_in_subcollection.id
|
assert interpretation.section_id == section_in_subcollection.id
|
||||||
@ -1184,7 +1180,7 @@ def test_interpretation_in_home_last_inter_section(
|
|||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
interpretation: m.Interpretation = m.Interpretation.query.filter_by(
|
||||||
label=label_1, section_id=section_in_collection.id
|
section_id=section_in_collection.id
|
||||||
).first()
|
).first()
|
||||||
assert interpretation
|
assert interpretation
|
||||||
assert interpretation.section_id == section_in_collection.id
|
assert interpretation.section_id == section_in_collection.id
|
||||||
|
@ -24,7 +24,7 @@ def test_approved_interpretations(client: FlaskClient):
|
|||||||
section: m.Section = m.Section.query.first()
|
section: m.Section = m.Section.query.first()
|
||||||
assert section
|
assert section
|
||||||
interpretation: m.Interpretation = m.Interpretation(
|
interpretation: m.Interpretation = m.Interpretation(
|
||||||
section_id=section.id, label="231", text="123", approved=True
|
section_id=section.id, text="123", approved=True
|
||||||
).save()
|
).save()
|
||||||
|
|
||||||
assert len(book.approved_interpretations) == 2
|
assert len(book.approved_interpretations) == 2
|
||||||
@ -43,7 +43,7 @@ def test_approved_interpretations(client: FlaskClient):
|
|||||||
label="123", collection_id=sub_collection.id, version_id=book.last_version.id
|
label="123", collection_id=sub_collection.id, version_id=book.last_version.id
|
||||||
).save()
|
).save()
|
||||||
interpretation: m.Interpretation = m.Interpretation(
|
interpretation: m.Interpretation = m.Interpretation(
|
||||||
section_id=section.id, label="231", text="123", approved=True
|
section_id=section.id, text="123", approved=True
|
||||||
).save()
|
).save()
|
||||||
|
|
||||||
assert len(book.approved_interpretations) == 2
|
assert len(book.approved_interpretations) == 2
|
||||||
|
@ -149,7 +149,7 @@ def test_dummy_data(runner: FlaskCliRunner):
|
|||||||
# - interpretation 4
|
# - interpretation 4
|
||||||
|
|
||||||
interpretation_1: m.Interpretation = m.Interpretation.query.filter_by(
|
interpretation_1: m.Interpretation = m.Interpretation.query.filter_by(
|
||||||
label="Dummy Interpretation 1 Label"
|
text="Dummy Interpretation 1 About"
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
assert interpretation_1
|
assert interpretation_1
|
||||||
@ -157,7 +157,7 @@ def test_dummy_data(runner: FlaskCliRunner):
|
|||||||
assert interpretation_1.section == section_1_1
|
assert interpretation_1.section == section_1_1
|
||||||
|
|
||||||
interpretation_2: m.Interpretation = m.Interpretation.query.filter_by(
|
interpretation_2: m.Interpretation = m.Interpretation.query.filter_by(
|
||||||
label="Dummy Interpretation 2 Label"
|
text="Dummy Interpretation 2 About"
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
assert interpretation_2
|
assert interpretation_2
|
||||||
@ -166,7 +166,7 @@ def test_dummy_data(runner: FlaskCliRunner):
|
|||||||
assert interpretation_2.section == section_2_1_1
|
assert interpretation_2.section == section_2_1_1
|
||||||
|
|
||||||
interpretation_3: m.Interpretation = m.Interpretation.query.filter_by(
|
interpretation_3: m.Interpretation = m.Interpretation.query.filter_by(
|
||||||
label="Dummy Interpretation 3 Label"
|
text="Dummy Interpretation 3 About"
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
assert interpretation_3
|
assert interpretation_3
|
||||||
@ -175,7 +175,7 @@ def test_dummy_data(runner: FlaskCliRunner):
|
|||||||
assert interpretation_3.section == section_2_1_2
|
assert interpretation_3.section == section_2_1_2
|
||||||
|
|
||||||
interpretation_4: m.Interpretation = m.Interpretation.query.filter_by(
|
interpretation_4: m.Interpretation = m.Interpretation.query.filter_by(
|
||||||
label="Dummy Interpretation 3 Label"
|
text="Dummy Interpretation 3 About"
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
assert interpretation_4
|
assert interpretation_4
|
||||||
|
@ -21,7 +21,6 @@ def test_upvote_interpretation(client: FlaskClient):
|
|||||||
assert response.json["message"] == "Interpretation not found"
|
assert response.json["message"] == "Interpretation not found"
|
||||||
|
|
||||||
interpretation = m.Interpretation(
|
interpretation = m.Interpretation(
|
||||||
label="Test Interpretation 1 Label",
|
|
||||||
text="Test Interpretation 1 Text",
|
text="Test Interpretation 1 Text",
|
||||||
user_id=user.id,
|
user_id=user.id,
|
||||||
).save()
|
).save()
|
||||||
|
@ -46,7 +46,6 @@ def create_test_book(owner_id: int, entity_id: int = randint(1, 100)):
|
|||||||
|
|
||||||
interpretation: m.Interpretation = m.Interpretation(
|
interpretation: m.Interpretation = m.Interpretation(
|
||||||
section_id=section.id,
|
section_id=section.id,
|
||||||
label=f"Interpretation {entity_id}",
|
|
||||||
text=f"Interpretation Text {entity_id}",
|
text=f"Interpretation Text {entity_id}",
|
||||||
user_id=owner_id,
|
user_id=owner_id,
|
||||||
).save()
|
).save()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user