mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27:59 +01:00
Allow repairing deleted images
This commit is contained in:
parent
8ba38c5633
commit
d35b7a2b0e
3 changed files with 8 additions and 19 deletions
|
@ -106,6 +106,9 @@ defmodule Philomena.Images.Thumbnailer do
|
|||
defp image_file(%Image{image: image}),
|
||||
do: Path.join(image_file_root(), image)
|
||||
|
||||
defp image_thumb_dir(%Image{created_at: created_at, id: id, hidden_from_users: true, hidden_image_key: key}),
|
||||
do: Path.join([image_thumbnail_root(), time_identifier(created_at), "#{id}-#{key}"])
|
||||
|
||||
defp image_thumb_dir(%Image{created_at: created_at, id: id}),
|
||||
do: Path.join([image_thumbnail_root(), time_identifier(created_at), to_string(id)])
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ defmodule PhilomenaWeb.Image.RepairController do
|
|||
|
||||
plug PhilomenaWeb.CanaryMapPlug, create: :hide
|
||||
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true
|
||||
plug :verify_not_deleted
|
||||
|
||||
def create(conn, _params) do
|
||||
spawn(fn ->
|
||||
|
@ -17,16 +16,4 @@ defmodule PhilomenaWeb.Image.RepairController do
|
|||
|> put_flash(:info, "Repair job started.")
|
||||
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|
||||
end
|
||||
|
||||
defp verify_not_deleted(conn, _opts) do
|
||||
case conn.assigns.image.hidden_from_users do
|
||||
true ->
|
||||
conn
|
||||
|> put_flash(:error, "Cannot repair a hidden image.")
|
||||
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|
||||
|
||||
_false ->
|
||||
conn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -91,19 +91,18 @@
|
|||
= text_input f, :deletion_reason, class: "input input--wide", placeholder: "Rule violation", required: true
|
||||
= submit "Delete", class: "button button--state-danger button--separate-left"
|
||||
|
||||
- else
|
||||
= button_to "Restore", Routes.image_delete_path(@conn, :delete, @image), method: "delete", class: "button button--state-success"
|
||||
|
||||
.flex.flex--spaced-out.flex--wrap
|
||||
= if not @image.hidden_from_users do
|
||||
= form_for @changeset, Routes.image_feature_path(@conn, :create, @image), [method: "post"], fn _f ->
|
||||
.field
|
||||
p Automatically tags 'featured image'
|
||||
= submit "Feature", data: [confirm: "Are you really, really sure?"], class: "button button--state-success"
|
||||
- else
|
||||
= button_to "Restore", Routes.image_delete_path(@conn, :delete, @image), method: "delete", class: "button button--state-success"
|
||||
|
||||
= form_for @changeset, Routes.image_repair_path(@conn, :create, @image), [method: "post"], fn _f ->
|
||||
.field
|
||||
= submit "Repair", class: "button button--state-success"
|
||||
= form_for @changeset, Routes.image_repair_path(@conn, :create, @image), [method: "post"], fn _f ->
|
||||
.field
|
||||
= submit "Repair", class: "button button--state-success"
|
||||
|
||||
= form_for @changeset, Routes.image_hash_path(@conn, :delete, @image), [method: "delete"], fn _f ->
|
||||
.field
|
||||
|
|
Loading…
Reference in a new issue