mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-16 21:26:33 +00:00
Removes delete and redraft view
This commit is contained in:
parent
5b25811034
commit
803ad3c911
4 changed files with 6 additions and 41 deletions
|
@ -20,10 +20,10 @@
|
||||||
</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="delete-{{ status.id }}" action="{% url 'redraft' status.id %}" method="post">
|
<form class="" name="edit-{{ status.id }}" action="{% url 'create-status' status.id %}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button class="button is-radiusless is-danger is-light is-fullwidth is-small" type="submit">
|
<button class="button is-radiusless is-fullwidth is-small" type="submit">
|
||||||
{% trans "Delete & re-draft" %}
|
{% trans "Edit" %}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -330,11 +330,6 @@ urlpatterns = [
|
||||||
views.DeleteStatus.as_view(),
|
views.DeleteStatus.as_view(),
|
||||||
name="delete-status",
|
name="delete-status",
|
||||||
),
|
),
|
||||||
re_path(
|
|
||||||
r"^redraft-status/(?P<status_id>\d+)/?$",
|
|
||||||
views.DeleteAndRedraft.as_view(),
|
|
||||||
name="redraft",
|
|
||||||
),
|
|
||||||
# interact
|
# interact
|
||||||
re_path(r"^favorite/(?P<status_id>\d+)/?$", views.Favorite.as_view(), name="fav"),
|
re_path(r"^favorite/(?P<status_id>\d+)/?$", views.Favorite.as_view(), name="fav"),
|
||||||
re_path(
|
re_path(
|
||||||
|
|
|
@ -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, DeleteAndRedraft, update_progress
|
from .status import CreateStatus, 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
|
||||||
|
|
|
@ -27,13 +27,13 @@ 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 delete-and-redraft)"""
|
"""compose view (used for editing)"""
|
||||||
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)
|
||||||
|
|
||||||
def post(self, request, status_type):
|
def post(self, request, status_type):
|
||||||
"""create status of whatever type"""
|
"""create status of whatever type"""
|
||||||
status_type = status_type[0].upper() + status_type[1:]
|
status_type = status_type[0].upper() + status_type[1:]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -106,36 +106,6 @@ class DeleteStatus(View):
|
||||||
return redirect(request.headers.get("Referer", "/"))
|
return redirect(request.headers.get("Referer", "/"))
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(login_required, name="dispatch")
|
|
||||||
class DeleteAndRedraft(View):
|
|
||||||
"""delete a status but let the user re-create it"""
|
|
||||||
|
|
||||||
def post(self, request, status_id):
|
|
||||||
"""delete and tombstone a status"""
|
|
||||||
status = get_object_or_404(
|
|
||||||
models.Status.objects.select_subclasses(), id=status_id
|
|
||||||
)
|
|
||||||
# don't let people redraft other people's statuses
|
|
||||||
status.raise_not_editable(request.user)
|
|
||||||
|
|
||||||
status_type = status.status_type.lower()
|
|
||||||
if status.reply_parent:
|
|
||||||
status_type = "reply"
|
|
||||||
|
|
||||||
data = {
|
|
||||||
"draft": status,
|
|
||||||
"type": status_type,
|
|
||||||
}
|
|
||||||
if hasattr(status, "book"):
|
|
||||||
data["book"] = status.book
|
|
||||||
elif status.mention_books:
|
|
||||||
data["book"] = status.mention_books.first()
|
|
||||||
|
|
||||||
# perform deletion
|
|
||||||
status.delete()
|
|
||||||
return TemplateResponse(request, "compose.html", data)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@require_POST
|
@require_POST
|
||||||
def update_progress(request, book_id): # pylint: disable=unused-argument
|
def update_progress(request, book_id): # pylint: disable=unused-argument
|
||||||
|
|
Loading…
Reference in a new issue