diff --git a/books/views.py b/books/views.py index 77ae6af5..9b02bfc6 100644 --- a/books/views.py +++ b/books/views.py @@ -306,7 +306,6 @@ def create_update_mark(request): return HttpResponseServerError("integrity error") if form.cleaned_data['share_to_mastodon']: - print(form.cleaned_data) if form.cleaned_data['visibility'] == 2: visibility = TootVisibilityEnum.DIRECT elif form.cleaned_data['visibility'] == 1: diff --git a/collection/templates/edit_item_comment.html b/collection/templates/edit_item_comment.html new file mode 100644 index 00000000..f299b513 --- /dev/null +++ b/collection/templates/edit_item_comment.html @@ -0,0 +1,5 @@ +
+ + + +
\ No newline at end of file diff --git a/collection/templates/entity_list.html b/collection/templates/entity_list.html index 50bb86d6..cecbd682 100644 --- a/collection/templates/entity_list.html +++ b/collection/templates/entity_list.html @@ -50,7 +50,9 @@
diff --git a/collection/templates/show_item_comment.html b/collection/templates/show_item_comment.html new file mode 100644 index 00000000..0f9208aa --- /dev/null +++ b/collection/templates/show_item_comment.html @@ -0,0 +1,4 @@ +{{ item.comment }} +{% if editable %} + +{% endif %} \ No newline at end of file diff --git a/collection/urls.py b/collection/urls.py index 2f9491dc..35fd3f7f 100644 --- a/collection/urls.py +++ b/collection/urls.py @@ -16,6 +16,8 @@ urlpatterns = [ path('/delete_item/', delete_item, name='delete_item'), path('/move_up_item/', move_up_item, name='move_up_item'), path('/move_down_item/', move_down_item, name='move_down_item'), + path('/update_item_comment/', update_item_comment, name='update_item_comment'), + path('/show_item_comment/', show_item_comment, name='show_item_comment'), path('with///', list_with, name='list_with'), path('add_to_list///', add_to_list, name='add_to_list'), diff --git a/collection/views.py b/collection/views.py index fa1473e2..08d2344e 100644 --- a/collection/views.py +++ b/collection/views.py @@ -340,6 +340,29 @@ def move_down_item(request, id, item_id): return HttpResponseBadRequest() +def show_item_comment(request, id, item_id): + collection = get_object_or_404(Collection, pk=id) + item = CollectionItem.objects.get(id=item_id) + editable = collection.is_editable_by(request.user) + return render(request, 'show_item_comment.html', {'collection': collection, 'item': item, 'editable': editable}) + +@login_required +def update_item_comment(request, id, item_id): + collection = get_object_or_404(Collection, pk=id) + if collection.is_editable_by(request.user): + # item_id = int(request.POST.get('item_id')) + item = CollectionItem.objects.get(id=item_id) + if item is not None and item.collection == collection: + if request.method == 'POST': + item.comment = request.POST.get('comment', default='') + item.save() + return render(request, 'show_item_comment.html', {'collection': collection, 'item': item, 'editable': True}) + else: + return render(request, 'edit_item_comment.html', {'collection': collection, 'item': item}) + return retrieve_entity_list(request, id) + return HttpResponseBadRequest() + + @login_required def list_with(request, type, id): pass