mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-16 13:16:33 +00:00
Creates edit status endpoint
This commit is contained in:
parent
1f6f543847
commit
7488f8da96
4 changed files with 26 additions and 3 deletions
|
@ -20,7 +20,7 @@
|
||||||
</li>
|
</li>
|
||||||
{% if status.status_type != 'GeneratedNote' and status.status_type != 'Rating' %}
|
{% if status.status_type != 'GeneratedNote' and status.status_type != 'Rating' %}
|
||||||
<li role="menuitem" class="dropdown-item p-0">
|
<li role="menuitem" class="dropdown-item p-0">
|
||||||
<form class="" name="edit-{{ status.id }}" action="{% url 'create-status' status.id %}" method="post">
|
<form class="" name="edit-{{ status.id }}" action="{% url 'edit-status' status.id %}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button class="button is-radiusless is-fullwidth is-small" type="submit">
|
<button class="button is-radiusless is-fullwidth is-small" type="submit">
|
||||||
{% trans "Edit" %}
|
{% trans "Edit" %}
|
||||||
|
|
|
@ -315,6 +315,7 @@ urlpatterns = [
|
||||||
re_path(
|
re_path(
|
||||||
rf"{STATUS_PATH}/replies(.json)?/?$", views.Replies.as_view(), name="replies"
|
rf"{STATUS_PATH}/replies(.json)?/?$", views.Replies.as_view(), name="replies"
|
||||||
),
|
),
|
||||||
|
re_path(r"^edit/(?P<status_id>\d+)/?$", views.EditStatus.as_view(), name="edit-status"),
|
||||||
re_path(
|
re_path(
|
||||||
r"^post/?$",
|
r"^post/?$",
|
||||||
views.CreateStatus.as_view(),
|
views.CreateStatus.as_view(),
|
||||||
|
|
|
@ -60,7 +60,7 @@ from .search import Search
|
||||||
from .shelf import Shelf
|
from .shelf import Shelf
|
||||||
from .shelf import create_shelf, delete_shelf
|
from .shelf import create_shelf, delete_shelf
|
||||||
from .shelf import shelve, unshelve
|
from .shelf import shelve, unshelve
|
||||||
from .status import CreateStatus, DeleteStatus, update_progress
|
from .status import CreateStatus, EditStatus, DeleteStatus, update_progress
|
||||||
from .status import edit_readthrough
|
from .status import edit_readthrough
|
||||||
from .updates import get_notification_count, get_unread_status_count
|
from .updates import get_notification_count, get_unread_status_count
|
||||||
from .user import User, Followers, Following, hide_suggestions
|
from .user import User, Followers, Following, hide_suggestions
|
||||||
|
|
|
@ -21,13 +21,35 @@ from .helpers import handle_remote_webfinger, is_api_request
|
||||||
from .helpers import load_date_in_user_tz_as_utc
|
from .helpers import load_date_in_user_tz_as_utc
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable= no-self-use
|
||||||
|
@method_decorator(login_required, name="dispatch")
|
||||||
|
class EditStatus(View):
|
||||||
|
"""the view for *posting*"""
|
||||||
|
|
||||||
|
def get(self, request, status_id): # pylint: disable=unused-argument
|
||||||
|
"""load the edit panel"""
|
||||||
|
status = get_object_or_404(models.Status.select_subclasses(), id=status_id)
|
||||||
|
status.raise_not_editable(request.user)
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"status": status,
|
||||||
|
}
|
||||||
|
return TemplateResponse(request, "compose.html", data)
|
||||||
|
|
||||||
|
def post(self, request, status_id):
|
||||||
|
"""save an edited status"""
|
||||||
|
status = get_object_or_404(models.Status.select_subclasses(), id=status_id)
|
||||||
|
status.raise_not_editable(request.user)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable= no-self-use
|
# pylint: disable= no-self-use
|
||||||
@method_decorator(login_required, name="dispatch")
|
@method_decorator(login_required, name="dispatch")
|
||||||
class CreateStatus(View):
|
class CreateStatus(View):
|
||||||
"""the view for *posting*"""
|
"""the view for *posting*"""
|
||||||
|
|
||||||
def get(self, request, status_type): # pylint: disable=unused-argument
|
def get(self, request, status_type): # pylint: disable=unused-argument
|
||||||
"""compose view (used for editing)"""
|
"""compose view (...not used?)"""
|
||||||
book = get_object_or_404(models.Edition, id=request.GET.get("book"))
|
book = get_object_or_404(models.Edition, id=request.GET.get("book"))
|
||||||
data = {"book": book}
|
data = {"book": book}
|
||||||
return TemplateResponse(request, "compose.html", data)
|
return TemplateResponse(request, "compose.html", data)
|
||||||
|
|
Loading…
Reference in a new issue