forked from mirrors/bookwyrm
Merge pull request #1917 from bookwyrm-social/list-page-error
Fixes errors in how lists with notes display
This commit is contained in:
commit
70bd6b9a65
6 changed files with 31 additions and 7 deletions
21
bookwyrm/migrations/0133_alter_listitem_notes.py
Normal file
21
bookwyrm/migrations/0133_alter_listitem_notes.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Generated by Django 3.2.11 on 2022-02-04 20:06
|
||||
|
||||
import bookwyrm.models.fields
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bookwyrm", "0132_alter_user_preferred_language"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="listitem",
|
||||
name="notes",
|
||||
field=bookwyrm.models.fields.HtmlField(
|
||||
blank=True, max_length=300, null=True
|
||||
),
|
||||
),
|
||||
]
|
|
@ -142,7 +142,7 @@ class ListItem(CollectionItemMixin, BookWyrmModel):
|
|||
user = fields.ForeignKey(
|
||||
"User", on_delete=models.PROTECT, activitypub_field="actor"
|
||||
)
|
||||
notes = fields.TextField(blank=True, null=True, max_length=300)
|
||||
notes = fields.HtmlField(blank=True, null=True, max_length=300)
|
||||
approved = models.BooleanField(default=True)
|
||||
order = fields.IntegerField()
|
||||
endorsement = models.ManyToManyField("User", related_name="endorsers")
|
||||
|
|
|
@ -79,14 +79,12 @@
|
|||
<div class="media-content">
|
||||
<div class="content">
|
||||
<header>
|
||||
{% url 'user-feed' user|username as user_path %}
|
||||
{% url 'user-feed' item.user|username as user_path %}
|
||||
{% blocktrans trimmed with username=user.display_name %}
|
||||
<a href="{{ user_path }}">{{ username }}</a> says:
|
||||
{% endblocktrans %}
|
||||
</header>
|
||||
<p>
|
||||
{{ item.notes|to_markdown|safe }}
|
||||
</p>
|
||||
{{ item.notes|to_markdown|safe }}
|
||||
</div>
|
||||
{% if item.user == request.user %}
|
||||
<div>
|
||||
|
|
|
@ -85,6 +85,7 @@ class ListViews(TestCase):
|
|||
user=self.local_user,
|
||||
book=self.book,
|
||||
approved=True,
|
||||
notes="hello",
|
||||
order=1,
|
||||
)
|
||||
|
||||
|
@ -178,6 +179,7 @@ class ListViews(TestCase):
|
|||
book_list=self.list,
|
||||
user=self.local_user,
|
||||
book=self.book,
|
||||
notes="hi hello",
|
||||
approved=True,
|
||||
order=1,
|
||||
)
|
||||
|
|
|
@ -67,4 +67,4 @@ class ListItemViews(TestCase):
|
|||
self.assertEqual(mock.call_count, 1)
|
||||
|
||||
item.refresh_from_db()
|
||||
self.assertEqual(item.notes, "beep boop")
|
||||
self.assertEqual(item.notes, "<p>beep boop</p>")
|
||||
|
|
|
@ -5,6 +5,7 @@ from django.utils.decorators import method_decorator
|
|||
from django.views import View
|
||||
|
||||
from bookwyrm import forms, models
|
||||
from bookwyrm.views.status import to_markdown
|
||||
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
|
@ -18,7 +19,9 @@ class ListItem(View):
|
|||
list_item.raise_not_editable(request.user)
|
||||
form = forms.ListItemForm(request.POST, instance=list_item)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
item = form.save(commit=False)
|
||||
item.notes = to_markdown(item.notes)
|
||||
item.save()
|
||||
else:
|
||||
raise Exception(form.errors)
|
||||
return redirect("list", list_item.book_list.id)
|
||||
|
|
Loading…
Reference in a new issue