mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 16:40:36 +00:00
Adds edit note view
This commit is contained in:
parent
ca0dbeb0ab
commit
9902794bbd
5 changed files with 33 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
{% endblocktrans %}
|
||||
</header>
|
||||
<p>
|
||||
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 }}
|
||||
</p>
|
||||
</div>
|
||||
{% if item.user == request.user %}
|
||||
|
@ -95,10 +95,11 @@
|
|||
{% trans "Edit:" %}
|
||||
<span class="details-close icon icon-pencil" aria-hidden></span>
|
||||
</summary>
|
||||
<form>
|
||||
<form name="edit-notes-{{ item.id }}" method="POST" action="{% url 'list-item' list.id item.id %}">
|
||||
{% csrf_token %}
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<textarea class="textarea">{{ item.note }}</textarea>
|
||||
<textarea class="textarea" maxlength="300" name="notes">{{ item.notes|default:'' }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
|
|
|
@ -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<list_id>\d+)(.json)?/?$", views.List.as_view(), name="list"),
|
||||
re_path(r"^list/(?P<list_id>\d+)/item/(?P<list_item>\d+)/?$", views.ListItem.as_view(), name="list-item"),
|
||||
re_path(r"^list/delete/(?P<list_id>\d+)/?$", views.delete_list, name="delete-list"),
|
||||
re_path(r"^list/add-book/?$", views.add_book, name="list-add-book"),
|
||||
re_path(
|
||||
|
|
|
@ -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,
|
||||
|
|
22
bookwyrm/views/list/list_item.py
Normal file
22
bookwyrm/views/list/list_item.py
Normal file
|
@ -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)
|
Loading…
Reference in a new issue