diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index ef9bbc159..5f068a935 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -443,6 +443,11 @@ class ListForm(CustomForm): model = models.List fields = ["user", "name", "description", "curation", "privacy", "group"] +class ListItemForm(CustomForm): + class Meta: + model = models.ListItem + fields = ["notes"] + class GroupForm(CustomForm): class Meta: diff --git a/bookwyrm/templates/lists/list.html b/bookwyrm/templates/lists/list.html index 73172bd54..6cfb9b20f 100644 --- a/bookwyrm/templates/lists/list.html +++ b/bookwyrm/templates/lists/list.html @@ -85,7 +85,7 @@ {% endblocktrans %}

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ornare magna eros, eu pellentesque tortor vestibulum ut. Maecenas non massa sem. Etiam finibus odio quis feugiat facilisis. + {{ item.notes|to_markdown|safe }}

{% if item.user == request.user %} @@ -95,10 +95,11 @@ {% trans "Edit:" %} -
+ + {% csrf_token %}
- +
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 01e864110..b1485789b 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -357,6 +357,7 @@ urlpatterns = [ re_path(r"^list/?$", views.Lists.as_view(), name="lists"), re_path(r"^list/saved/?$", views.SavedLists.as_view(), name="saved-lists"), re_path(r"^list/(?P\d+)(.json)?/?$", views.List.as_view(), name="list"), + re_path(r"^list/(?P\d+)/item/(?P\d+)/?$", views.ListItem.as_view(), name="list-item"), re_path(r"^list/delete/(?P\d+)/?$", views.delete_list, name="delete-list"), re_path(r"^list/add-book/?$", views.add_book, name="list-add-book"), re_path( diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index da9098dc3..f4bbbfcac 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -63,6 +63,7 @@ from .imports.manually_review import ( # lists from .list.curate import Curate +from .list.list_item import ListItem from .list.lists import Lists, SavedLists, UserLists from .list.list import ( List, diff --git a/bookwyrm/views/list/list_item.py b/bookwyrm/views/list/list_item.py new file mode 100644 index 000000000..29cfbee84 --- /dev/null +++ b/bookwyrm/views/list/list_item.py @@ -0,0 +1,22 @@ +""" book list views""" +from django.contrib.auth.decorators import login_required +from django.shortcuts import get_object_or_404, redirect +from django.utils.decorators import method_decorator +from django.views import View + +from bookwyrm import forms, models + + +# pylint: disable=no-self-use +@method_decorator(login_required, name="dispatch") +class ListItem(View): + """book list page""" + + def post(self, request, list_id, list_item): + """Edit a list item's notes""" + list_item = get_object_or_404(models.ListItem, id=list_item, book_list=list_id) + list_item.raise_not_editable(request.user) + form = forms.ListItemForm(request.POST, instance=list_item) + if form.is_valid(): + form.save() + return redirect("list", list_item.book_list.id)