mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
automatic route conversion
This commit is contained in:
parent
44e99997e0
commit
fd2d8462c2
340 changed files with 1217 additions and 1223 deletions
|
@ -22,7 +22,7 @@ defmodule PhilomenaWeb.Admin.Advert.ImageController do
|
|||
{:ok, _advert} ->
|
||||
conn
|
||||
|> put_flash(:info, "Advert was successfully updated.")
|
||||
|> redirect(to: Routes.admin_advert_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/adverts")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
|
@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Admin.AdvertController do
|
|||
{:ok, _advert} ->
|
||||
conn
|
||||
|> put_flash(:info, "Advert was successfully created.")
|
||||
|> redirect(to: Routes.admin_advert_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/adverts")
|
||||
|
||||
{:error, :advert, changeset, _changes} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -49,7 +49,7 @@ defmodule PhilomenaWeb.Admin.AdvertController do
|
|||
{:ok, _advert} ->
|
||||
conn
|
||||
|> put_flash(:info, "Advert was successfully updated.")
|
||||
|> redirect(to: Routes.admin_advert_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/adverts")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -61,7 +61,7 @@ defmodule PhilomenaWeb.Admin.AdvertController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Advert was successfully deleted.")
|
||||
|> redirect(to: Routes.admin_advert_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/adverts")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -18,14 +18,14 @@ defmodule PhilomenaWeb.Admin.ArtistLink.ContactController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Artist successfully marked as contacted.")
|
||||
|> moderation_log(details: &log_details/3, data: artist_link)
|
||||
|> redirect(to: Routes.admin_artist_link_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: artist_link)
|
||||
|> redirect(to: ~p"/admin/artist_links")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, artist_link) do
|
||||
defp log_details(_action, artist_link) do
|
||||
%{
|
||||
body: "Contacted artist #{artist_link.user.name} at #{artist_link.uri}",
|
||||
subject_path: Routes.profile_artist_link_path(conn, :show, artist_link.user, artist_link)
|
||||
subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,14 +17,14 @@ defmodule PhilomenaWeb.Admin.ArtistLink.RejectController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Artist link successfully marked as rejected.")
|
||||
|> moderation_log(details: &log_details/3, data: artist_link)
|
||||
|> redirect(to: Routes.admin_artist_link_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: artist_link)
|
||||
|> redirect(to: ~p"/admin/artist_links")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, artist_link) do
|
||||
defp log_details(_action, artist_link) do
|
||||
%{
|
||||
body: "Rejected artist link #{artist_link.uri} created by #{artist_link.user.name}",
|
||||
subject_path: Routes.profile_artist_link_path(conn, :show, artist_link.user, artist_link)
|
||||
subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,14 +18,14 @@ defmodule PhilomenaWeb.Admin.ArtistLink.VerificationController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Artist link successfully verified.")
|
||||
|> moderation_log(details: &log_details/3, data: result.artist_link)
|
||||
|> redirect(to: Routes.admin_artist_link_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: result.artist_link)
|
||||
|> redirect(to: ~p"/admin/artist_links")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, artist_link) do
|
||||
defp log_details(_action, artist_link) do
|
||||
%{
|
||||
body: "Verified artist link #{artist_link.uri} created by #{artist_link.user.name}",
|
||||
subject_path: Routes.profile_artist_link_path(conn, :show, artist_link.user, artist_link)
|
||||
subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Admin.Badge.ImageController do
|
|||
{:ok, _badge} ->
|
||||
conn
|
||||
|> put_flash(:info, "Badge updated successfully.")
|
||||
|> redirect(to: Routes.admin_badge_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/badges")
|
||||
|
||||
{:error, :badge, changeset, _changes} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
|
@ -28,7 +28,7 @@ defmodule PhilomenaWeb.Admin.BadgeController do
|
|||
{:ok, _badge} ->
|
||||
conn
|
||||
|> put_flash(:info, "Badge created successfully.")
|
||||
|> redirect(to: Routes.admin_badge_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/badges")
|
||||
|
||||
{:error, :badge, changeset, _changes} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -45,7 +45,7 @@ defmodule PhilomenaWeb.Admin.BadgeController do
|
|||
{:ok, _badge} ->
|
||||
conn
|
||||
|> put_flash(:info, "Badge updated successfully.")
|
||||
|> redirect(to: Routes.admin_badge_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/badges")
|
||||
|
||||
{:error, :badge, changeset, _changes} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
|
@ -48,10 +48,11 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do
|
|||
{:ok, _} ->
|
||||
conn
|
||||
|> moderation_log(
|
||||
details: &log_details/3,
|
||||
details: &log_details/2,
|
||||
data: %{
|
||||
tag_list: tag_list,
|
||||
image_count: Enum.count(image_ids)
|
||||
image_count: Enum.count(image_ids),
|
||||
user: conn.assigns.current_user
|
||||
}
|
||||
)
|
||||
|> json(%{succeeded: image_ids, failed: []})
|
||||
|
@ -68,10 +69,10 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, data) do
|
||||
defp log_details(_action, data) do
|
||||
%{
|
||||
body: "Batch tagged '#{data.tag_list}' on #{data.image_count} images",
|
||||
subject_path: Routes.profile_path(conn, :show, conn.assigns.current_user)
|
||||
subject_path: ~p"/profiles/#{data.user}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,12 +16,12 @@ defmodule PhilomenaWeb.Admin.DnpEntry.TransitionController do
|
|||
{:ok, dnp_entry} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully updated DNP entry.")
|
||||
|> redirect(to: Routes.dnp_entry_path(conn, :show, dnp_entry))
|
||||
|> redirect(to: ~p"/dnp/#{dnp_entry}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Failed to update DNP entry!")
|
||||
|> redirect(to: Routes.dnp_entry_path(conn, :show, conn.assigns.dnp_entry))
|
||||
|> redirect(to: ~p"/dnp/#{conn.assigns.dnp_entry}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -23,12 +23,12 @@ defmodule PhilomenaWeb.Admin.DonationController do
|
|||
{:ok, _donation} ->
|
||||
conn
|
||||
|> put_flash(:info, "Donation successfully created.")
|
||||
|> redirect(to: Routes.admin_donation_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/donations")
|
||||
|
||||
_error ->
|
||||
conn
|
||||
|> put_flash(:error, "Error creating donation!")
|
||||
|> redirect(to: Routes.admin_donation_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/donations")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
|
|||
{:ok, fingerprint_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "Fingerprint was successfully banned.")
|
||||
|> moderation_log(details: &log_details/3, data: fingerprint_ban)
|
||||
|> redirect(to: Routes.admin_fingerprint_ban_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: fingerprint_ban)
|
||||
|> redirect(to: ~p"/admin/fingerprint_bans")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -65,8 +65,8 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
|
|||
{:ok, fingerprint_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "Fingerprint ban successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: fingerprint_ban)
|
||||
|> redirect(to: Routes.admin_fingerprint_ban_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: fingerprint_ban)
|
||||
|> redirect(to: ~p"/admin/fingerprint_bans")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -78,8 +78,8 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Fingerprint ban successfully deleted.")
|
||||
|> moderation_log(details: &log_details/3, data: fingerprint_ban)
|
||||
|> redirect(to: Routes.admin_fingerprint_ban_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: fingerprint_ban)
|
||||
|> redirect(to: ~p"/admin/fingerprint_bans")
|
||||
end
|
||||
|
||||
defp load_bans(queryable, conn) do
|
||||
|
@ -110,7 +110,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, action, ban) do
|
||||
defp log_details(action, ban) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Created a fingerprint ban #{ban.generated_ban_id}"
|
||||
|
@ -118,6 +118,6 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
|
|||
:delete -> "Deleted a fingerprint ban #{ban.generated_ban_id}"
|
||||
end
|
||||
|
||||
%{body: body, subject_path: Routes.admin_fingerprint_ban_path(conn, :index)}
|
||||
%{body: body, subject_path: ~p"/admin/fingerprint_bans"}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Admin.ForumController do
|
|||
{:ok, _forum} ->
|
||||
conn
|
||||
|> put_flash(:info, "Forum created successfully.")
|
||||
|> redirect(to: Routes.admin_forum_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/forums")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -38,7 +38,7 @@ defmodule PhilomenaWeb.Admin.ForumController do
|
|||
{:ok, _forum} ->
|
||||
conn
|
||||
|> put_flash(:info, "Forum updated successfully.")
|
||||
|> redirect(to: Routes.admin_forum_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/forums")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
|
@ -46,7 +46,7 @@ defmodule PhilomenaWeb.Admin.ModNoteController do
|
|||
{:ok, _mod_note} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully created mod note.")
|
||||
|> redirect(to: Routes.admin_mod_note_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/mod_notes")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -63,7 +63,7 @@ defmodule PhilomenaWeb.Admin.ModNoteController do
|
|||
{:ok, _mod_note} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully updated mod note.")
|
||||
|> redirect(to: Routes.admin_mod_note_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/mod_notes")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -75,7 +75,7 @@ defmodule PhilomenaWeb.Admin.ModNoteController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully deleted mod note.")
|
||||
|> redirect(to: Routes.admin_mod_note_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/mod_notes")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -12,12 +12,12 @@ defmodule PhilomenaWeb.Admin.Report.ClaimController do
|
|||
{:ok, _report} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully marked report as in progress")
|
||||
|> redirect(to: Routes.admin_report_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/reports")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:warning, "Couldn't claim that report!")
|
||||
|> redirect(to: Routes.admin_report_path(conn, :show, conn.assigns.report))
|
||||
|> redirect(to: ~p"/admin/reports/#{conn.assigns.report}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -26,6 +26,6 @@ defmodule PhilomenaWeb.Admin.Report.ClaimController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully released report.")
|
||||
|> redirect(to: Routes.admin_report_path(conn, :show, report))
|
||||
|> redirect(to: ~p"/admin/reports/#{report}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,6 @@ defmodule PhilomenaWeb.Admin.Report.CloseController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully closed report")
|
||||
|> redirect(to: Routes.admin_report_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/reports")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ defmodule PhilomenaWeb.Admin.SiteNoticeController do
|
|||
{:ok, _site_notice} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully created site notice.")
|
||||
|> redirect(to: Routes.admin_site_notice_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/site_notices")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -45,7 +45,7 @@ defmodule PhilomenaWeb.Admin.SiteNoticeController do
|
|||
{:ok, _site_notice} ->
|
||||
conn
|
||||
|> put_flash(:info, "Succesfully updated site notice.")
|
||||
|> redirect(to: Routes.admin_site_notice_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/site_notices")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -57,7 +57,7 @@ defmodule PhilomenaWeb.Admin.SiteNoticeController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Sucessfully deleted site notice.")
|
||||
|> redirect(to: Routes.admin_site_notice_path(conn, :index))
|
||||
|> redirect(to: ~p"/admin/site_notices")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -49,8 +49,8 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do
|
|||
{:ok, subnet_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "Subnet was successfully banned.")
|
||||
|> moderation_log(details: &log_details/3, data: subnet_ban)
|
||||
|> redirect(to: Routes.admin_subnet_ban_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: subnet_ban)
|
||||
|> redirect(to: ~p"/admin/subnet_bans")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -67,8 +67,8 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do
|
|||
{:ok, subnet_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "Subnet ban successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: subnet_ban)
|
||||
|> redirect(to: Routes.admin_subnet_ban_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: subnet_ban)
|
||||
|> redirect(to: ~p"/admin/subnet_bans")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -80,8 +80,8 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Subnet ban successfully deleted.")
|
||||
|> moderation_log(details: &log_details/3, data: subnet_ban)
|
||||
|> redirect(to: Routes.admin_subnet_ban_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: subnet_ban)
|
||||
|> redirect(to: ~p"/admin/subnet_bans")
|
||||
end
|
||||
|
||||
defp load_bans(queryable, conn) do
|
||||
|
@ -112,7 +112,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, action, ban) do
|
||||
defp log_details(action, ban) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Created a subnet ban #{ban.generated_ban_id}"
|
||||
|
@ -120,6 +120,6 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do
|
|||
:delete -> "Deleted a subnet ban #{ban.generated_ban_id}"
|
||||
end
|
||||
|
||||
%{body: body, subject_path: Routes.admin_subnet_ban_path(conn, :index)}
|
||||
%{body: body, subject_path: ~p"/admin/subnet_bans"}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.ActivationController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "User was reactivated.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
end
|
||||
|
||||
def delete(conn, _params) do
|
||||
|
@ -20,7 +20,7 @@ defmodule PhilomenaWeb.Admin.User.ActivationController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "User was deactivated.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.ApiKeyController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "API token was successfully reset.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.AvatarController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully removed avatar.")
|
||||
|> redirect(to: Routes.admin_user_path(conn, :edit, conn.assigns.user))
|
||||
|> redirect(to: ~p"/admin/users/#{conn.assigns.user}/edit")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.DownvoteController do
|
|||
|
||||
conn
|
||||
|> put_flash(:alert, "Downvote wipe started.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user))
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -18,7 +18,7 @@ defmodule PhilomenaWeb.Admin.User.ForceFilterController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Filter was forced.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
end
|
||||
|
||||
def delete(conn, _params) do
|
||||
|
@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Admin.User.ForceFilterController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Forced filter was removed.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.UnlockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "User was unlocked.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -12,8 +12,8 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "User verification granted.")
|
||||
|> moderation_log(details: &log_details/3, data: user)
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> moderation_log(details: &log_details/2, data: user)
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
end
|
||||
|
||||
def delete(conn, _params) do
|
||||
|
@ -21,8 +21,8 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "User verification revoked.")
|
||||
|> moderation_log(details: &log_details/3, data: user)
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> moderation_log(details: &log_details/2, data: user)
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
@ -32,13 +32,13 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, action, user) do
|
||||
defp log_details(action, user) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Granted verification to #{user.name}"
|
||||
:delete -> "Revoked verification from #{user.name}"
|
||||
end
|
||||
|
||||
%{body: body, subject_path: Routes.profile_path(conn, :show, user)}
|
||||
%{body: body, subject_path: ~p"/profiles/#{user}"}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.VoteController do
|
|||
|
||||
conn
|
||||
|> put_flash(:alert, "Vote and fave wipe started.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user))
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Admin.User.WipeController do
|
|||
:alert,
|
||||
"PII wipe queued, please verify and then deactivate the account as necessary."
|
||||
)
|
||||
|> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user))
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -50,8 +50,8 @@ defmodule PhilomenaWeb.Admin.UserBanController do
|
|||
{:ok, user_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "User was successfully banned.")
|
||||
|> moderation_log(details: &log_details/3, data: user_ban)
|
||||
|> redirect(to: Routes.admin_user_ban_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: user_ban)
|
||||
|> redirect(to: ~p"/admin/user_bans")
|
||||
|
||||
{:error, :user_ban, changeset, _changes} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -71,8 +71,8 @@ defmodule PhilomenaWeb.Admin.UserBanController do
|
|||
{:ok, user_ban} ->
|
||||
conn
|
||||
|> put_flash(:info, "User ban successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: user_ban)
|
||||
|> redirect(to: Routes.admin_user_ban_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: user_ban)
|
||||
|> redirect(to: ~p"/admin/user_bans")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -84,8 +84,8 @@ defmodule PhilomenaWeb.Admin.UserBanController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "User ban successfully deleted.")
|
||||
|> moderation_log(details: &log_details/3, data: user_ban)
|
||||
|> redirect(to: Routes.admin_user_ban_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: user_ban)
|
||||
|> redirect(to: ~p"/admin/user_bans")
|
||||
end
|
||||
|
||||
defp load_bans(queryable, conn) do
|
||||
|
@ -116,7 +116,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, action, ban) do
|
||||
defp log_details(action, ban) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Created a user ban #{ban.generated_ban_id}"
|
||||
|
@ -124,6 +124,6 @@ defmodule PhilomenaWeb.Admin.UserBanController do
|
|||
:delete -> "Deleted a user ban #{ban.generated_ban_id}"
|
||||
end
|
||||
|
||||
%{body: body, subject_path: Routes.admin_user_ban_path(conn, :index)}
|
||||
%{body: body, subject_path: ~p"/admin/user_bans"}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -62,8 +62,8 @@ defmodule PhilomenaWeb.Admin.UserController do
|
|||
{:ok, user} ->
|
||||
conn
|
||||
|> put_flash(:info, "User successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: user)
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> moderation_log(details: &log_details/2, data: user)
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -81,10 +81,10 @@ defmodule PhilomenaWeb.Admin.UserController do
|
|||
assign(conn, :roles, Repo.all(Role))
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, user) do
|
||||
defp log_details(_action, user) do
|
||||
%{
|
||||
body: "Updated user details for #{user.name}",
|
||||
subject_path: Routes.profile_path(conn, :show, user)
|
||||
subject_path: ~p"/profiles/#{user}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ defmodule PhilomenaWeb.AvatarController do
|
|||
{:ok, _user} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully updated avatar.")
|
||||
|> redirect(to: Routes.avatar_path(conn, :edit))
|
||||
|> redirect(to: ~p"/avatar/edit")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -30,6 +30,6 @@ defmodule PhilomenaWeb.AvatarController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully removed avatar.")
|
||||
|> redirect(to: Routes.avatar_path(conn, :edit))
|
||||
|> redirect(to: ~p"/avatar/edit")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,14 +7,14 @@ defmodule PhilomenaWeb.Channel.NsfwController do
|
|||
conn
|
||||
|> set_cookie("chan_nsfw", "true")
|
||||
|> put_flash(:info, "Successfully updated channel visibility.")
|
||||
|> redirect(to: Routes.channel_path(conn, :index))
|
||||
|> redirect(to: ~p"/channels")
|
||||
end
|
||||
|
||||
def delete(conn, _params) do
|
||||
conn
|
||||
|> set_cookie("chan_nsfw", "false")
|
||||
|> put_flash(:info, "Successfully updated channel visibility.")
|
||||
|> redirect(to: Routes.channel_path(conn, :index))
|
||||
|> redirect(to: ~p"/channels")
|
||||
end
|
||||
|
||||
# Duplicated from setting controller
|
||||
|
|
|
@ -52,7 +52,7 @@ defmodule PhilomenaWeb.ChannelController do
|
|||
{:ok, _channel} ->
|
||||
conn
|
||||
|> put_flash(:info, "Channel created successfully.")
|
||||
|> redirect(to: Routes.channel_path(conn, :index))
|
||||
|> redirect(to: ~p"/channels")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -69,7 +69,7 @@ defmodule PhilomenaWeb.ChannelController do
|
|||
{:ok, _channel} ->
|
||||
conn
|
||||
|> put_flash(:info, "Channel updated successfully.")
|
||||
|> redirect(to: Routes.channel_path(conn, :index))
|
||||
|> redirect(to: ~p"/channels")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -81,7 +81,7 @@ defmodule PhilomenaWeb.ChannelController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Channel destroyed successfully.")
|
||||
|> redirect(to: Routes.channel_path(conn, :index))
|
||||
|> redirect(to: ~p"/channels")
|
||||
end
|
||||
|
||||
defp maybe_search(query, %{"cq" => cq}) when is_binary(cq) and cq != "" do
|
||||
|
|
|
@ -14,7 +14,7 @@ defmodule PhilomenaWeb.ConfirmationController do
|
|||
if user = Users.get_user_by_email(email) do
|
||||
Users.deliver_user_confirmation_instructions(
|
||||
user,
|
||||
&Routes.confirmation_url(conn, :show, &1)
|
||||
&url(~p"/confirmations/#{&1}")
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule PhilomenaWeb.Conversation.HideController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Conversation hidden.")
|
||||
|> redirect(to: Routes.conversation_path(conn, :index))
|
||||
|> redirect(to: ~p"/conversations")
|
||||
end
|
||||
|
||||
def delete(conn, _params) do
|
||||
|
@ -31,6 +31,6 @@ defmodule PhilomenaWeb.Conversation.HideController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Conversation restored.")
|
||||
|> redirect(to: Routes.conversation_path(conn, :show, conversation))
|
||||
|> redirect(to: ~p"/conversations/#{conversation}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,11 +20,11 @@ defmodule PhilomenaWeb.Conversation.Message.ApproveController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Conversation message approved.")
|
||||
|> moderation_log(details: &log_details/3, data: message)
|
||||
|> moderation_log(details: &log_details/2, data: message)
|
||||
|> redirect(to: "/")
|
||||
end
|
||||
|
||||
defp log_details(_conn, _action, message) do
|
||||
defp log_details(_action, message) do
|
||||
%{
|
||||
body: "Approved private message in conversation ##{message.conversation_id}",
|
||||
subject_path: "/"
|
||||
|
|
|
@ -36,12 +36,12 @@ defmodule PhilomenaWeb.Conversation.MessageController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Message successfully sent.")
|
||||
|> redirect(to: Routes.conversation_path(conn, :show, conversation, page: page))
|
||||
|> redirect(to: ~p"/conversations/#{conversation}?#{[page: page]}")
|
||||
|
||||
_error ->
|
||||
conn
|
||||
|> put_flash(:error, "There was an error posting your message")
|
||||
|> redirect(to: Routes.conversation_path(conn, :show, conversation))
|
||||
|> redirect(to: ~p"/conversations/#{conversation}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule PhilomenaWeb.Conversation.ReadController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Conversation marked as read.")
|
||||
|> redirect(to: Routes.conversation_path(conn, :show, conversation))
|
||||
|> redirect(to: ~p"/conversations/#{conversation}")
|
||||
end
|
||||
|
||||
def delete(conn, _params) do
|
||||
|
@ -31,6 +31,6 @@ defmodule PhilomenaWeb.Conversation.ReadController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Conversation marked as unread.")
|
||||
|> redirect(to: Routes.conversation_path(conn, :index))
|
||||
|> redirect(to: ~p"/conversations")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ defmodule PhilomenaWeb.Conversation.ReportController do
|
|||
|
||||
def new(conn, _params) do
|
||||
conversation = conn.assigns.conversation
|
||||
action = Routes.conversation_report_path(conn, :create, conversation)
|
||||
action = ~p"/conversations/#{conversation}/reports"
|
||||
|
||||
changeset =
|
||||
%Report{reportable_type: "Conversation", reportable_id: conversation.id}
|
||||
|
@ -40,7 +40,7 @@ defmodule PhilomenaWeb.Conversation.ReportController do
|
|||
|
||||
def create(conn, params) do
|
||||
conversation = conn.assigns.conversation
|
||||
action = Routes.conversation_report_path(conn, :create, conversation)
|
||||
action = ~p"/conversations/#{conversation}/reports"
|
||||
|
||||
ReportController.create(conn, action, conversation, "Conversation", params)
|
||||
end
|
||||
|
|
|
@ -115,7 +115,7 @@ defmodule PhilomenaWeb.ConversationController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Conversation successfully created.")
|
||||
|> redirect(to: Routes.conversation_path(conn, :show, conversation))
|
||||
|> redirect(to: ~p"/conversations/#{conversation}")
|
||||
|
||||
{:error, changeset} ->
|
||||
conn
|
||||
|
|
|
@ -97,7 +97,7 @@ defmodule PhilomenaWeb.DnpEntryController do
|
|||
{:ok, dnp_entry} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully submitted DNP request.")
|
||||
|> redirect(to: Routes.dnp_entry_path(conn, :show, dnp_entry))
|
||||
|> redirect(to: ~p"/dnp/#{dnp_entry}")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -122,7 +122,7 @@ defmodule PhilomenaWeb.DnpEntryController do
|
|||
{:ok, dnp_entry} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully updated DNP request.")
|
||||
|> redirect(to: Routes.dnp_entry_path(conn, :show, dnp_entry))
|
||||
|> redirect(to: ~p"/dnp/#{dnp_entry}")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
|
@ -20,21 +20,21 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController do
|
|||
{:ok, report} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully accepted report.")
|
||||
|> moderation_log(details: &log_details/3, data: report.duplicate_report)
|
||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: report.duplicate_report)
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
|
||||
_error ->
|
||||
conn
|
||||
|> put_flash(:warning, "Failed to accept report! Maybe someone else already accepted it.")
|
||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, report) do
|
||||
defp log_details(_action, report) do
|
||||
%{
|
||||
body:
|
||||
"Accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}",
|
||||
subject_path: Routes.image_path(conn, :show, report.image)
|
||||
subject_path: ~p"/images/#{report.image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,21 +20,21 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController do
|
|||
{:ok, report} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully accepted report in reverse.")
|
||||
|> moderation_log(details: &log_details/3, data: report.duplicate_report)
|
||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: report.duplicate_report)
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
|
||||
_error ->
|
||||
conn
|
||||
|> put_flash(:warning, "Failed to accept report! Maybe someone else already accepted it.")
|
||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, report) do
|
||||
defp log_details(_action, report) do
|
||||
%{
|
||||
body:
|
||||
"Reverse-accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}",
|
||||
subject_path: Routes.image_path(conn, :show, report.image)
|
||||
subject_path: ~p"/images/#{report.image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,8 +20,8 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully claimed report.")
|
||||
|> moderation_log(details: &log_details/3, data: report)
|
||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: report)
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
end
|
||||
|
||||
def delete(conn, _params) do
|
||||
|
@ -29,11 +29,11 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully released report.")
|
||||
|> moderation_log(details: &log_details/3)
|
||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2)
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
end
|
||||
|
||||
defp log_details(conn, action, _) do
|
||||
defp log_details(action, _) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Claimed a duplicate report"
|
||||
|
@ -42,7 +42,7 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.duplicate_report_path(conn, :index)
|
||||
subject_path: ~p"/duplicate_reports"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,14 +21,14 @@ defmodule PhilomenaWeb.DuplicateReport.RejectController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully rejected report.")
|
||||
|> moderation_log(details: &log_details/3, data: report)
|
||||
|> redirect(to: Routes.duplicate_report_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: report)
|
||||
|> redirect(to: ~p"/duplicate_reports")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, report) do
|
||||
defp log_details(_action, report) do
|
||||
%{
|
||||
body: "Rejected duplicate report (#{report.image.id} -> #{report.duplicate_of_image.id})",
|
||||
subject_path: Routes.duplicate_report_path(conn, :index)
|
||||
subject_path: ~p"/duplicate_reports"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -56,12 +56,12 @@ defmodule PhilomenaWeb.DuplicateReportController do
|
|||
{:ok, duplicate_report} ->
|
||||
conn
|
||||
|> put_flash(:info, "Duplicate report created successfully.")
|
||||
|> redirect(to: Routes.image_path(conn, :show, duplicate_report.image_id))
|
||||
|> redirect(to: ~p"/images/#{duplicate_report.image_id}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Failed to submit duplicate report")
|
||||
|> redirect(to: Routes.image_path(conn, :show, source))
|
||||
|> redirect(to: ~p"/images/#{source}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -10,6 +10,6 @@ defmodule PhilomenaWeb.Filter.ClearRecentController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Cleared recent filters.")
|
||||
|> redirect(to: Routes.filter_path(conn, :index))
|
||||
|> redirect(to: ~p"/filters")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,12 +12,12 @@ defmodule PhilomenaWeb.Filter.PublicController do
|
|||
{:ok, filter} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully made filter public.")
|
||||
|> redirect(to: Routes.filter_path(conn, :show, filter))
|
||||
|> redirect(to: ~p"/filters/#{filter}")
|
||||
|
||||
_error ->
|
||||
conn
|
||||
|> put_flash(:error, "Couldn't make filter public!")
|
||||
|> redirect(to: Routes.filter_path(conn, :show, conn.assigns.filter))
|
||||
|> redirect(to: ~p"/filters/#{conn.assigns.filter}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -146,7 +146,7 @@ defmodule PhilomenaWeb.FilterController do
|
|||
{:ok, filter} ->
|
||||
conn
|
||||
|> put_flash(:info, "Filter created successfully.")
|
||||
|> redirect(to: Routes.filter_path(conn, :show, filter))
|
||||
|> redirect(to: ~p"/filters/#{filter}")
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -171,7 +171,7 @@ defmodule PhilomenaWeb.FilterController do
|
|||
{:ok, filter} ->
|
||||
conn
|
||||
|> put_flash(:info, "Filter updated successfully.")
|
||||
|> redirect(to: Routes.filter_path(conn, :show, filter))
|
||||
|> redirect(to: ~p"/filters/#{filter}")
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, "edit.html", filter: filter, changeset: changeset)
|
||||
|
@ -185,12 +185,12 @@ defmodule PhilomenaWeb.FilterController do
|
|||
{:ok, _filter} ->
|
||||
conn
|
||||
|> put_flash(:info, "Filter deleted successfully.")
|
||||
|> redirect(to: Routes.filter_path(conn, :index))
|
||||
|> redirect(to: ~p"/filters")
|
||||
|
||||
_error ->
|
||||
conn
|
||||
|> put_flash(:warning, "Filter is still in use, not deleted.")
|
||||
|> redirect(to: Routes.filter_path(conn, :show, filter))
|
||||
|> redirect(to: ~p"/filters/#{filter}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Gallery.ReportController do
|
|||
|
||||
def new(conn, _params) do
|
||||
gallery = conn.assigns.gallery
|
||||
action = Routes.gallery_report_path(conn, :create, gallery)
|
||||
action = ~p"/galleries/#{gallery}/reports"
|
||||
|
||||
changeset =
|
||||
%Report{reportable_type: "Gallery", reportable_id: gallery.id}
|
||||
|
@ -39,7 +39,7 @@ defmodule PhilomenaWeb.Gallery.ReportController do
|
|||
|
||||
def create(conn, params) do
|
||||
gallery = conn.assigns.gallery
|
||||
action = Routes.gallery_report_path(conn, :create, gallery)
|
||||
action = ~p"/galleries/#{gallery}/reports"
|
||||
|
||||
ReportController.create(conn, action, gallery, "Gallery", params)
|
||||
end
|
||||
|
|
|
@ -110,7 +110,7 @@ defmodule PhilomenaWeb.GalleryController do
|
|||
{:ok, gallery} ->
|
||||
conn
|
||||
|> put_flash(:info, "Gallery successfully created.")
|
||||
|> redirect(to: Routes.gallery_path(conn, :show, gallery))
|
||||
|> redirect(to: ~p"/galleries/#{gallery}")
|
||||
|
||||
{:error, changeset} ->
|
||||
conn
|
||||
|
@ -132,7 +132,7 @@ defmodule PhilomenaWeb.GalleryController do
|
|||
{:ok, gallery} ->
|
||||
conn
|
||||
|> put_flash(:info, "Gallery successfully updated.")
|
||||
|> redirect(to: Routes.gallery_path(conn, :show, gallery))
|
||||
|> redirect(to: ~p"/galleries/#{gallery}")
|
||||
|
||||
{:error, changeset} ->
|
||||
conn
|
||||
|
@ -147,7 +147,7 @@ defmodule PhilomenaWeb.GalleryController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Gallery successfully destroyed.")
|
||||
|> redirect(to: Routes.gallery_path(conn, :index))
|
||||
|> redirect(to: ~p"/galleries")
|
||||
end
|
||||
|
||||
defp prev_next_page_images(conn, query) do
|
||||
|
|
|
@ -22,8 +22,8 @@ defmodule PhilomenaWeb.Image.AnonymousController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully updated anonymity.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
@ -33,10 +33,10 @@ defmodule PhilomenaWeb.Image.AnonymousController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Updated anonymity of image >>#{image.id}",
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,11 +14,11 @@ defmodule PhilomenaWeb.Image.ApproveController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Image has been approved.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.admin_approval_path(conn, :index))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/admin/approvals")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, image) do
|
||||
%{body: "Approved image #{image.id}", subject_path: Routes.image_path(conn, :show, image)}
|
||||
defp log_details(_action, image) do
|
||||
%{body: "Approved image #{image.id}", subject_path: ~p"/images/#{image}"}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,14 +22,14 @@ defmodule PhilomenaWeb.Image.Comment.ApproveController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Comment has been approved.")
|
||||
|> moderation_log(details: &log_details/3, data: comment)
|
||||
|> redirect(to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}")
|
||||
|> moderation_log(details: &log_details/2, data: comment)
|
||||
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, comment) do
|
||||
defp log_details(_action, comment) do
|
||||
%{
|
||||
body: "Approved comment on image >>#{comment.image_id}",
|
||||
subject_path: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}"
|
||||
subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,24 +16,20 @@ defmodule PhilomenaWeb.Image.Comment.DeleteController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Comment successfully destroyed!")
|
||||
|> moderation_log(details: &log_details/3, data: comment)
|
||||
|> redirect(
|
||||
to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}"
|
||||
)
|
||||
|> moderation_log(details: &log_details/2, data: comment)
|
||||
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Unable to destroy comment!")
|
||||
|> redirect(
|
||||
to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}"
|
||||
)
|
||||
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
|
||||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, comment) do
|
||||
defp log_details(_action, comment) do
|
||||
%{
|
||||
body: "Destroyed comment on image >>#{comment.image_id}",
|
||||
subject_path: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}"
|
||||
subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,17 +15,13 @@ defmodule PhilomenaWeb.Image.Comment.HideController do
|
|||
{:ok, comment} ->
|
||||
conn
|
||||
|> put_flash(:info, "Comment successfully hidden!")
|
||||
|> moderation_log(details: &log_details/3, data: comment)
|
||||
|> redirect(
|
||||
to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}"
|
||||
)
|
||||
|> moderation_log(details: &log_details/2, data: comment)
|
||||
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
|
||||
|
||||
_error ->
|
||||
conn
|
||||
|> put_flash(:error, "Unable to hide comment!")
|
||||
|> redirect(
|
||||
to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}"
|
||||
)
|
||||
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,21 +32,17 @@ defmodule PhilomenaWeb.Image.Comment.HideController do
|
|||
{:ok, comment} ->
|
||||
conn
|
||||
|> put_flash(:info, "Comment successfully unhidden!")
|
||||
|> moderation_log(details: &log_details/3, data: comment)
|
||||
|> redirect(
|
||||
to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}"
|
||||
)
|
||||
|> moderation_log(details: &log_details/2, data: comment)
|
||||
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Unable to unhide comment!")
|
||||
|> redirect(
|
||||
to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}"
|
||||
)
|
||||
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
|
||||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, action, comment) do
|
||||
defp log_details(action, comment) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Hidden comment on image >>#{comment.image_id} (#{comment.deletion_reason})"
|
||||
|
@ -59,7 +51,7 @@ defmodule PhilomenaWeb.Image.Comment.HideController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}"
|
||||
subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ defmodule PhilomenaWeb.Image.Comment.ReportController do
|
|||
|
||||
def new(conn, _params) do
|
||||
comment = conn.assigns.comment
|
||||
action = Routes.image_comment_report_path(conn, :create, comment.image, comment)
|
||||
action = ~p"/images/#{comment.image}/comments/#{comment}/reports"
|
||||
|
||||
changeset =
|
||||
%Report{reportable_type: "Comment", reportable_id: comment.id}
|
||||
|
@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Image.Comment.ReportController do
|
|||
|
||||
def create(conn, params) do
|
||||
comment = conn.assigns.comment
|
||||
action = Routes.image_comment_report_path(conn, :create, comment.image, comment)
|
||||
action = ~p"/images/#{comment.image}/comments/#{comment}/reports"
|
||||
|
||||
ReportController.create(conn, action, comment, "Comment", params)
|
||||
end
|
||||
|
|
|
@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Image.CommentController do
|
|||
def index(conn, %{"comment_id" => comment_id}) do
|
||||
page = CommentLoader.find_page(conn, conn.assigns.image, comment_id)
|
||||
|
||||
redirect(conn, to: Routes.image_comment_path(conn, :index, conn.assigns.image, page: page))
|
||||
redirect(conn, to: ~p"/images/#{conn.assigns.image}/comments?#{[page: page]}")
|
||||
end
|
||||
|
||||
def index(conn, _params) do
|
||||
|
@ -93,7 +93,7 @@ defmodule PhilomenaWeb.Image.CommentController do
|
|||
_error ->
|
||||
conn
|
||||
|> put_flash(:error, "There was an error posting your comment")
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -126,9 +126,7 @@ defmodule PhilomenaWeb.Image.CommentController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Comment updated successfully.")
|
||||
|> redirect(
|
||||
to: Routes.image_path(conn, :show, conn.assigns.image) <> "#comment_#{comment.id}"
|
||||
)
|
||||
|> redirect(to: ~p"/images/#{conn.assigns.image}" <> "#comment_#{comment.id}")
|
||||
|
||||
{:error, :comment, changeset, _changes} ->
|
||||
render(conn, "edit.html", comment: conn.assigns.comment, changeset: changeset)
|
||||
|
|
|
@ -12,8 +12,8 @@ defmodule PhilomenaWeb.Image.CommentLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully locked comments.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
def delete(conn, _params) do
|
||||
|
@ -21,11 +21,11 @@ defmodule PhilomenaWeb.Image.CommentLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully unlocked comments.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(conn, action, image) do
|
||||
defp log_details(action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Locked comments on image >>#{image.id}"
|
||||
|
@ -34,7 +34,7 @@ defmodule PhilomenaWeb.Image.CommentLockController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,13 +19,13 @@ defmodule PhilomenaWeb.Image.DeleteController do
|
|||
{:ok, result} ->
|
||||
conn
|
||||
|> put_flash(:info, "Image successfully hidden.")
|
||||
|> moderation_log(details: &log_details/3, data: result.image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: result.image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
|
||||
_error ->
|
||||
conn
|
||||
|> put_flash(:error, "Failed to hide image.")
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,13 +36,13 @@ defmodule PhilomenaWeb.Image.DeleteController do
|
|||
{:ok, image} ->
|
||||
conn
|
||||
|> put_flash(:info, "Hide reason updated.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Couldn't update hide reason.")
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -54,7 +54,7 @@ defmodule PhilomenaWeb.Image.DeleteController do
|
|||
_false ->
|
||||
conn
|
||||
|> put_flash(:error, "Cannot change hide reason on a non-hidden image!")
|
||||
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|
||||
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
@ -66,11 +66,11 @@ defmodule PhilomenaWeb.Image.DeleteController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Image successfully unhidden.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(conn, action, image) do
|
||||
defp log_details(action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Hidden image >>#{image.id} (#{image.deletion_reason})"
|
||||
|
@ -80,7 +80,7 @@ defmodule PhilomenaWeb.Image.DeleteController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,8 +12,8 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully locked description.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
def delete(conn, _params) do
|
||||
|
@ -21,11 +21,11 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully unlocked description.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(conn, action, image) do
|
||||
defp log_details(action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Locked description editing on image >>#{image.id}"
|
||||
|
@ -34,7 +34,7 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,13 +15,13 @@ defmodule PhilomenaWeb.Image.DestroyController do
|
|||
{:ok, image} ->
|
||||
conn
|
||||
|> put_flash(:info, "Image contents destroyed.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
|
||||
_error ->
|
||||
conn
|
||||
|> put_flash(:error, "Failed to destroy image.")
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -33,15 +33,15 @@ defmodule PhilomenaWeb.Image.DestroyController do
|
|||
_false ->
|
||||
conn
|
||||
|> put_flash(:error, "Cannot destroy a non-hidden image!")
|
||||
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|
||||
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Hard-deleted image >>#{image.id}",
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,8 +16,8 @@ defmodule PhilomenaWeb.Image.FeatureController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Image marked as featured image.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp verify_not_deleted(conn, _opts) do
|
||||
|
@ -25,7 +25,7 @@ defmodule PhilomenaWeb.Image.FeatureController do
|
|||
true ->
|
||||
conn
|
||||
|> put_flash(:warning, "Cannot feature a hidden image.")
|
||||
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|
||||
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|
||||
|> halt()
|
||||
|
||||
_false ->
|
||||
|
@ -33,10 +33,10 @@ defmodule PhilomenaWeb.Image.FeatureController do
|
|||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Featured image >>#{image.id}",
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,12 +16,12 @@ defmodule PhilomenaWeb.Image.FileController do
|
|||
{:ok, image} ->
|
||||
conn
|
||||
|> put_flash(:info, "Successfully updated file.")
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
|
||||
_error ->
|
||||
conn
|
||||
|> put_flash(:error, "Failed to update file!")
|
||||
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|
||||
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,7 @@ defmodule PhilomenaWeb.Image.FileController do
|
|||
true ->
|
||||
conn
|
||||
|> put_flash(:warning, "Cannot replace a hidden image.")
|
||||
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|
||||
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|
||||
|> halt()
|
||||
|
||||
_false ->
|
||||
|
|
|
@ -12,14 +12,14 @@ defmodule PhilomenaWeb.Image.HashController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully cleared hash.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Cleared hash of image >>#{image.id}",
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,11 +21,11 @@ defmodule PhilomenaWeb.Image.NavigateController do
|
|||
|> case do
|
||||
{next_image, hit} ->
|
||||
redirect(conn,
|
||||
to: Routes.image_path(conn, :show, next_image, Keyword.put(scope, :sort, hit["sort"]))
|
||||
to: ~p"/images/#{next_image}?#{Keyword.put(scope, :sort, hit["sort"])}"
|
||||
)
|
||||
|
||||
nil ->
|
||||
redirect(conn, to: Routes.image_path(conn, :show, image, scope))
|
||||
redirect(conn, to: ~p"/images/#{image}?#{scope}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,7 +41,7 @@ defmodule PhilomenaWeb.Image.NavigateController do
|
|||
|
||||
page_num = page_for_offset(pagination.page_size, images.total_entries)
|
||||
|
||||
redirect(conn, to: Routes.search_path(conn, :index, q: "*", page: page_num))
|
||||
redirect(conn, to: ~p"/search?#{[q: "*", page: page_num]}")
|
||||
end
|
||||
|
||||
defp page_for_offset(per_page, offset) do
|
||||
|
|
|
@ -20,10 +20,10 @@ defmodule PhilomenaWeb.Image.RandomController do
|
|||
|
||||
case unwrap_random_result(search_definition) do
|
||||
nil ->
|
||||
redirect(conn, to: Routes.image_path(conn, :index))
|
||||
redirect(conn, to: ~p"/images")
|
||||
|
||||
random_id ->
|
||||
redirect(conn, to: Routes.image_path(conn, :show, random_id, scope))
|
||||
redirect(conn, to: ~p"/images/#{random_id}?#{scope}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@ defmodule PhilomenaWeb.Image.RepairController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Repair job enqueued.")
|
||||
|> moderation_log(details: &log_details/3, data: conn.assigns.image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|
||||
|> moderation_log(details: &log_details/2, data: conn.assigns.image)
|
||||
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Repaired image >>#{image.id}",
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Image.ReportController do
|
|||
|
||||
def new(conn, _params) do
|
||||
image = conn.assigns.image
|
||||
action = Routes.image_report_path(conn, :create, image)
|
||||
action = ~p"/images/#{image}/reports"
|
||||
|
||||
changeset =
|
||||
%Report{reportable_type: "Image", reportable_id: image.id}
|
||||
|
@ -39,7 +39,7 @@ defmodule PhilomenaWeb.Image.ReportController do
|
|||
|
||||
def create(conn, params) do
|
||||
image = conn.assigns.image
|
||||
action = Routes.image_report_path(conn, :create, image)
|
||||
action = ~p"/images/#{image}/reports"
|
||||
|
||||
ReportController.create(conn, action, image, "Image", params)
|
||||
end
|
||||
|
|
|
@ -17,14 +17,14 @@ defmodule PhilomenaWeb.Image.ScratchpadController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully updated moderation notes.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Updated mod notes on image >>#{image.id} (#{image.scratchpad})",
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,14 +14,14 @@ defmodule PhilomenaWeb.Image.SourceHistoryController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully deleted source history.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, image) do
|
||||
defp log_details(_action, image) do
|
||||
%{
|
||||
body: "Deleted source history for image >>#{image.id}",
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,10 +43,10 @@ defmodule PhilomenaWeb.Image.TagChangeController do
|
|||
conn
|
||||
|> put_flash(:info, "Successfully deleted tag change from history.")
|
||||
|> moderation_log(
|
||||
details: &log_details/3,
|
||||
details: &log_details/2,
|
||||
data: %{image: image, details: tag_change_details(tag_change)}
|
||||
)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp added_filter(query, %{"added" => "1"}),
|
||||
|
@ -58,10 +58,10 @@ defmodule PhilomenaWeb.Image.TagChangeController do
|
|||
defp added_filter(query, _params),
|
||||
do: query
|
||||
|
||||
defp log_details(conn, _action, %{image: image, details: details}) do
|
||||
defp log_details(_action, %{image: image, details: details}) do
|
||||
%{
|
||||
body: "Deleted tag change #{details} on >>#{image.id} from history",
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ defmodule PhilomenaWeb.Image.TagLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully updated list of locked tags.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
def create(conn, _params) do
|
||||
|
@ -32,8 +32,8 @@ defmodule PhilomenaWeb.Image.TagLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully locked tags.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
def delete(conn, _params) do
|
||||
|
@ -41,11 +41,11 @@ defmodule PhilomenaWeb.Image.TagLockController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Successfully unlocked tags.")
|
||||
|> moderation_log(details: &log_details/3, data: image)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> moderation_log(details: &log_details/2, data: image)
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
end
|
||||
|
||||
defp log_details(conn, action, image) do
|
||||
defp log_details(action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Locked tags on image >>#{image.id}"
|
||||
|
@ -55,7 +55,7 @@ defmodule PhilomenaWeb.Image.TagLockController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,13 +25,13 @@ defmodule PhilomenaWeb.Image.TamperController do
|
|||
conn
|
||||
|> put_flash(:info, "Vote removed.")
|
||||
|> moderation_log(
|
||||
details: &log_details/3,
|
||||
data: %{vote: result, image: image}
|
||||
details: &log_details/2,
|
||||
data: %{vote: result, image: image, username: conn.assigns.user.name}
|
||||
)
|
||||
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|
||||
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, data) do
|
||||
defp log_details(_action, data) do
|
||||
image = data.image
|
||||
|
||||
vote_type =
|
||||
|
@ -42,8 +42,8 @@ defmodule PhilomenaWeb.Image.TamperController do
|
|||
end
|
||||
|
||||
%{
|
||||
body: "Deleted #{vote_type} by #{conn.assigns.user.name} on image >>#{data.image.id}",
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
body: "Deleted #{vote_type} by #{data.username} on image >>#{data.image.id}",
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -128,7 +128,7 @@ defmodule PhilomenaWeb.ImageController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Image created successfully.")
|
||||
|> redirect(to: Routes.image_path(conn, :show, image))
|
||||
|> redirect(to: ~p"/images/#{image}")
|
||||
|
||||
{:error, :image, changeset, _} ->
|
||||
conn
|
||||
|
@ -208,7 +208,7 @@ defmodule PhilomenaWeb.ImageController do
|
|||
:alert,
|
||||
"The image you were looking for has been marked a duplicate of the image below"
|
||||
)
|
||||
|> redirect(to: Routes.image_path(conn, :show, image.duplicate_id))
|
||||
|> redirect(to: ~p"/images/#{image.duplicate_id}")
|
||||
|> halt()
|
||||
|
||||
true ->
|
||||
|
|
|
@ -26,7 +26,7 @@ defmodule PhilomenaWeb.PageController do
|
|||
{:ok, %{static_page: static_page}} ->
|
||||
conn
|
||||
|> put_flash(:info, "Static page successfully created.")
|
||||
|> redirect(to: Routes.page_path(conn, :show, static_page))
|
||||
|> redirect(to: ~p"/pages/#{static_page}")
|
||||
|
||||
{:error, :static_page, changeset, _changes} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -47,7 +47,7 @@ defmodule PhilomenaWeb.PageController do
|
|||
{:ok, %{static_page: static_page}} ->
|
||||
conn
|
||||
|> put_flash(:info, "Static page successfully updated.")
|
||||
|> redirect(to: Routes.page_path(conn, :show, static_page))
|
||||
|> redirect(to: ~p"/pages/#{static_page}")
|
||||
|
||||
{:error, :static_page, changeset, _changes} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule PhilomenaWeb.PasswordController do
|
|||
if user = Users.get_user_by_email(email) do
|
||||
Users.deliver_user_reset_password_instructions(
|
||||
user,
|
||||
&Routes.password_url(conn, :edit, &1)
|
||||
&url(~p"/passwords/#{&1}/edit")
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -40,7 +40,7 @@ defmodule PhilomenaWeb.PasswordController do
|
|||
{:ok, _} ->
|
||||
conn
|
||||
|> put_flash(:info, "Password reset successfully.")
|
||||
|> redirect(to: Routes.session_path(conn, :new))
|
||||
|> redirect(to: ~p"/sessions/new")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
|
@ -52,9 +52,7 @@ defmodule PhilomenaWeb.Profile.ArtistLinkController do
|
|||
:alert,
|
||||
"Link submitted! Please put '#{artist_link.verification_code}' on your linked webpage now."
|
||||
)
|
||||
|> redirect(
|
||||
to: Routes.profile_artist_link_path(conn, :show, conn.assigns.user, artist_link)
|
||||
)
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}/artist_links/#{artist_link}")
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -77,9 +75,7 @@ defmodule PhilomenaWeb.Profile.ArtistLinkController do
|
|||
{:ok, artist_link} ->
|
||||
conn
|
||||
|> put_flash(:info, "Link successfully updated.")
|
||||
|> redirect(
|
||||
to: Routes.profile_artist_link_path(conn, :show, conn.assigns.user, artist_link)
|
||||
)
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}/artist_links/#{artist_link}")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
|
@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Profile.AwardController do
|
|||
{:ok, _award} ->
|
||||
conn
|
||||
|> put_flash(:info, "Award successfully created.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user))
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -40,7 +40,7 @@ defmodule PhilomenaWeb.Profile.AwardController do
|
|||
{:ok, _award} ->
|
||||
conn
|
||||
|> put_flash(:info, "Award successfully updated.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user))
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -52,7 +52,7 @@ defmodule PhilomenaWeb.Profile.AwardController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Award successfully destroyed. By cruel and unusual means.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user))
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -47,7 +47,7 @@ defmodule PhilomenaWeb.Profile.Commission.ItemController do
|
|||
{:ok, _multi} ->
|
||||
conn
|
||||
|> put_flash(:info, "Item successfully created.")
|
||||
|> redirect(to: Routes.profile_commission_path(conn, :show, conn.assigns.user))
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}/commission")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "new.html", user: user, commission: commission, changeset: changeset)
|
||||
|
@ -79,7 +79,7 @@ defmodule PhilomenaWeb.Profile.Commission.ItemController do
|
|||
{:ok, _commission} ->
|
||||
conn
|
||||
|> put_flash(:info, "Item successfully updated.")
|
||||
|> redirect(to: Routes.profile_commission_path(conn, :show, conn.assigns.user))
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}/commission")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html",
|
||||
|
@ -100,7 +100,7 @@ defmodule PhilomenaWeb.Profile.Commission.ItemController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Item successfully deleted.")
|
||||
|> redirect(to: Routes.profile_commission_path(conn, :show, conn.assigns.user))
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}/commission")
|
||||
end
|
||||
|
||||
defp ensure_commission(conn, _opts) do
|
||||
|
|
|
@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Profile.Commission.ReportController do
|
|||
def new(conn, _params) do
|
||||
user = conn.assigns.user
|
||||
commission = conn.assigns.user.commission
|
||||
action = Routes.profile_commission_report_path(conn, :create, user)
|
||||
action = ~p"/profiles/#{user}/commission/reports"
|
||||
|
||||
changeset =
|
||||
%Report{reportable_type: "Commission", reportable_id: commission.id}
|
||||
|
@ -51,7 +51,7 @@ defmodule PhilomenaWeb.Profile.Commission.ReportController do
|
|||
def create(conn, params) do
|
||||
user = conn.assigns.user
|
||||
commission = conn.assigns.user.commission
|
||||
action = Routes.profile_commission_report_path(conn, :create, user)
|
||||
action = ~p"/profiles/#{user}/commission/reports"
|
||||
|
||||
ReportController.create(conn, action, commission, "Commission", params)
|
||||
end
|
||||
|
|
|
@ -85,7 +85,7 @@ defmodule PhilomenaWeb.Profile.CommissionController do
|
|||
{:ok, _commission} ->
|
||||
conn
|
||||
|> put_flash(:info, "Commission successfully created.")
|
||||
|> redirect(to: Routes.profile_commission_path(conn, :show, user))
|
||||
|> redirect(to: ~p"/profiles/#{user}/commission")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
|
@ -104,7 +104,7 @@ defmodule PhilomenaWeb.Profile.CommissionController do
|
|||
{:ok, _commission} ->
|
||||
conn
|
||||
|> put_flash(:info, "Commission successfully updated.")
|
||||
|> redirect(to: Routes.profile_commission_path(conn, :show, conn.assigns.user))
|
||||
|> redirect(to: ~p"/profiles/#{conn.assigns.user}/commission")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -118,7 +118,7 @@ defmodule PhilomenaWeb.Profile.CommissionController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Commission deleted successfully.")
|
||||
|> redirect(to: Routes.commission_path(conn, :index))
|
||||
|> redirect(to: ~p"/commissions")
|
||||
end
|
||||
|
||||
defp ensure_commission(conn, _opts) do
|
||||
|
@ -156,7 +156,7 @@ defmodule PhilomenaWeb.Profile.CommissionController do
|
|||
:warning,
|
||||
"You must have a verified artist link to create a commission listing."
|
||||
)
|
||||
|> redirect(to: Routes.commission_path(conn, :index))
|
||||
|> redirect(to: ~p"/commissions")
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ defmodule PhilomenaWeb.Profile.DescriptionController do
|
|||
{:ok, _user} ->
|
||||
conn
|
||||
|> put_flash(:info, "Description successfully updated.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
|
@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Profile.ReportController do
|
|||
|
||||
def new(conn, _params) do
|
||||
user = conn.assigns.user
|
||||
action = Routes.profile_report_path(conn, :create, user)
|
||||
action = ~p"/profiles/#{user}/reports"
|
||||
|
||||
changeset =
|
||||
%Report{reportable_type: "User", reportable_id: user.id}
|
||||
|
@ -39,7 +39,7 @@ defmodule PhilomenaWeb.Profile.ReportController do
|
|||
|
||||
def create(conn, params) do
|
||||
user = conn.assigns.user
|
||||
action = Routes.profile_report_path(conn, :create, user)
|
||||
action = ~p"/profiles/#{user}/reports"
|
||||
|
||||
ReportController.create(conn, action, user, "User", params)
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ defmodule PhilomenaWeb.Profile.ScratchpadController do
|
|||
{:ok, _user} ->
|
||||
conn
|
||||
|> put_flash(:info, "Moderation scratchpad successfully updated.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
|
@ -11,7 +11,7 @@ defmodule PhilomenaWeb.Registration.EmailController do
|
|||
Users.deliver_update_email_instructions(
|
||||
applied_user,
|
||||
user.email,
|
||||
&Routes.registration_email_url(conn, :show, &1)
|
||||
&url(~p"/registrations/email/#{&1}")
|
||||
)
|
||||
|
||||
conn
|
||||
|
@ -19,12 +19,12 @@ defmodule PhilomenaWeb.Registration.EmailController do
|
|||
:alert,
|
||||
"A link to confirm your email change has been sent to the new address."
|
||||
)
|
||||
|> redirect(to: Routes.registration_path(conn, :edit))
|
||||
|> redirect(to: ~p"/registrations/edit")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Failed to update email.")
|
||||
|> redirect(to: Routes.registration_path(conn, :edit))
|
||||
|> redirect(to: ~p"/registrations/edit")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -33,12 +33,12 @@ defmodule PhilomenaWeb.Registration.EmailController do
|
|||
:ok ->
|
||||
conn
|
||||
|> put_flash(:info, "Email changed successfully.")
|
||||
|> redirect(to: Routes.registration_path(conn, :edit))
|
||||
|> redirect(to: ~p"/registrations/edit")
|
||||
|
||||
:error ->
|
||||
conn
|
||||
|> put_flash(:warning, "Email change link is invalid or it has expired.")
|
||||
|> redirect(to: Routes.registration_path(conn, :edit))
|
||||
|> redirect(to: ~p"/registrations/edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Registration.NameController do
|
|||
{:ok, user} ->
|
||||
conn
|
||||
|> put_flash(:info, "Name successfully updated.")
|
||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||
|> redirect(to: ~p"/profiles/#{user}")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
|
@ -13,13 +13,13 @@ defmodule PhilomenaWeb.Registration.PasswordController do
|
|||
{:ok, user} ->
|
||||
conn
|
||||
|> put_flash(:info, "Password updated successfully.")
|
||||
|> put_session(:user_return_to, Routes.registration_path(conn, :edit))
|
||||
|> put_session(:user_return_to, ~p"/registrations/edit")
|
||||
|> UserAuth.log_in_user(user)
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Failed to update password.")
|
||||
|> redirect(to: Routes.registration_path(conn, :edit))
|
||||
|> redirect(to: ~p"/registrations/edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Registration.TotpController do
|
|||
|> Repo.update()
|
||||
|
||||
# Redirect to have the conn pick up the changes
|
||||
redirect(conn, to: Routes.registration_totp_path(conn, :edit))
|
||||
redirect(conn, to: ~p"/registrations/totp/edit")
|
||||
|
||||
_ ->
|
||||
changeset = Users.change_user(user)
|
||||
|
@ -48,7 +48,7 @@ defmodule PhilomenaWeb.Registration.TotpController do
|
|||
{:ok, user} ->
|
||||
conn
|
||||
|> put_flash(:totp_backup_codes, backup_codes)
|
||||
|> put_session(:user_return_to, Routes.registration_totp_path(conn, :edit))
|
||||
|> put_session(:user_return_to, ~p"/registrations/totp/edit")
|
||||
|> UserAuth.totp_auth_user(user, %{})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule PhilomenaWeb.RegistrationController do
|
|||
{:ok, _} =
|
||||
Users.deliver_user_confirmation_instructions(
|
||||
user,
|
||||
&Routes.confirmation_url(conn, :show, &1)
|
||||
&url(~p"/confirmations/#{&1}")
|
||||
)
|
||||
|
||||
conn
|
||||
|
|
|
@ -53,7 +53,7 @@ defmodule PhilomenaWeb.ReportController do
|
|||
:alert,
|
||||
"Your report has been received and will be checked by staff shortly."
|
||||
)
|
||||
|> redirect(to: redirect_path(conn, conn.assigns.current_user))
|
||||
|> redirect(to: redirect_path(conn.assigns.current_user))
|
||||
|
||||
{:error, changeset} ->
|
||||
# Note that we are depending on the controller that called
|
||||
|
@ -100,8 +100,8 @@ defmodule PhilomenaWeb.ReportController do
|
|||
reports_open >= max_reports()
|
||||
end
|
||||
|
||||
defp redirect_path(_conn, nil), do: "/"
|
||||
defp redirect_path(conn, _user), do: Routes.report_path(conn, :index)
|
||||
defp redirect_path(nil), do: "/"
|
||||
defp redirect_path(_user), do: ~p"/reports"
|
||||
|
||||
defp max_reports do
|
||||
5
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule PhilomenaWeb.SessionController do
|
|||
Users.get_user_by_email_and_password(
|
||||
email,
|
||||
password,
|
||||
&Routes.unlock_url(conn, :show, &1)
|
||||
&url(~p"/unlocks/#{&1}")
|
||||
)
|
||||
|
||||
cond do
|
||||
|
|
|
@ -25,7 +25,7 @@ defmodule PhilomenaWeb.SettingController do
|
|||
{:ok, conn} ->
|
||||
conn
|
||||
|> put_flash(:info, "Settings updated successfully.")
|
||||
|> redirect(to: Routes.setting_path(conn, :edit))
|
||||
|> redirect(to: ~p"/settings/edit")
|
||||
|
||||
{:error, changeset} ->
|
||||
conn
|
||||
|
|
|
@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Tag.AliasController do
|
|||
{:ok, tag} ->
|
||||
conn
|
||||
|> put_flash(:info, "Tag alias queued.")
|
||||
|> redirect(to: Routes.tag_alias_path(conn, :edit, tag))
|
||||
|> redirect(to: ~p"/tags/#{tag}/alias/edit")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -35,6 +35,6 @@ defmodule PhilomenaWeb.Tag.AliasController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Tag dealias queued.")
|
||||
|> redirect(to: Routes.tag_path(conn, :show, tag))
|
||||
|> redirect(to: ~p"/tags/#{tag}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,8 +23,8 @@ defmodule PhilomenaWeb.Tag.ImageController do
|
|||
{:ok, tag} ->
|
||||
conn
|
||||
|> put_flash(:info, "Tag image successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: tag)
|
||||
|> redirect(to: Routes.tag_path(conn, :show, tag))
|
||||
|> moderation_log(details: &log_details/2, data: tag)
|
||||
|> redirect(to: ~p"/tags/#{tag}")
|
||||
|
||||
{:error, :tag, changeset, _changes} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -36,11 +36,11 @@ defmodule PhilomenaWeb.Tag.ImageController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Tag image successfully removed.")
|
||||
|> moderation_log(details: &log_details/3, data: tag)
|
||||
|> redirect(to: Routes.tag_path(conn, :show, conn.assigns.tag))
|
||||
|> moderation_log(details: &log_details/2, data: tag)
|
||||
|> redirect(to: ~p"/tags/#{conn.assigns.tag}")
|
||||
end
|
||||
|
||||
defp log_details(conn, action, tag) do
|
||||
defp log_details(action, tag) do
|
||||
body =
|
||||
case action do
|
||||
:update -> "Updated image on tag '#{tag.name}'"
|
||||
|
@ -49,7 +49,7 @@ defmodule PhilomenaWeb.Tag.ImageController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.tag_path(conn, :show, tag)
|
||||
subject_path: ~p"/tags/#{tag}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,6 @@ defmodule PhilomenaWeb.Tag.ReindexController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Tag reindex started.")
|
||||
|> redirect(to: Routes.tag_path(conn, :edit, tag))
|
||||
|> redirect(to: ~p"/tags/#{tag}/edit")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -97,8 +97,8 @@ defmodule PhilomenaWeb.TagController do
|
|||
{:ok, tag} ->
|
||||
conn
|
||||
|> put_flash(:info, "Tag successfully updated.")
|
||||
|> moderation_log(details: &log_details/3, data: tag)
|
||||
|> redirect(to: Routes.tag_path(conn, :show, tag))
|
||||
|> moderation_log(details: &log_details/2, data: tag)
|
||||
|> redirect(to: ~p"/tags/#{tag}")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
@ -110,7 +110,7 @@ defmodule PhilomenaWeb.TagController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Tag queued for deletion.")
|
||||
|> moderation_log(details: &log_details/3, data: tag)
|
||||
|> moderation_log(details: &log_details/2, data: tag)
|
||||
|> redirect(to: "/")
|
||||
end
|
||||
|
||||
|
@ -167,12 +167,12 @@ defmodule PhilomenaWeb.TagController do
|
|||
:alert,
|
||||
"This tag (\"#{conn.assigns.tag.name}\") has been aliased into the tag \"#{tag.name}\"."
|
||||
)
|
||||
|> redirect(to: Routes.tag_path(conn, :show, tag))
|
||||
|> redirect(to: ~p"/tags/#{tag}")
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, action, tag) do
|
||||
defp log_details(action, tag) do
|
||||
body =
|
||||
case action do
|
||||
:update -> "Updated details on tag '#{tag.name}'"
|
||||
|
@ -181,7 +181,7 @@ defmodule PhilomenaWeb.TagController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.tag_path(conn, :show, tag)
|
||||
subject_path: ~p"/tags/#{tag}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,13 +27,13 @@ defmodule PhilomenaWeb.Topic.HideController do
|
|||
{:ok, topic} ->
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully hidden!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Unable to hide the topic!")
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -44,17 +44,17 @@ defmodule PhilomenaWeb.Topic.HideController do
|
|||
{:ok, topic} ->
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully restored!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Unable to restore the topic!")
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, action, topic) do
|
||||
defp log_details(action, topic) do
|
||||
body =
|
||||
case action do
|
||||
:create ->
|
||||
|
@ -66,7 +66,7 @@ defmodule PhilomenaWeb.Topic.HideController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.forum_topic_path(conn, :show, topic.forum, topic)
|
||||
subject_path: ~p"/forums/#{topic.forum}/topics/#{topic}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,13 +26,13 @@ defmodule PhilomenaWeb.Topic.LockController do
|
|||
{:ok, topic} ->
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully locked!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Unable to lock the topic!")
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -43,17 +43,17 @@ defmodule PhilomenaWeb.Topic.LockController do
|
|||
{:ok, topic} ->
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully unlocked!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Unable to unlock the topic!")
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, action, topic) do
|
||||
defp log_details(action, topic) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Locked topic '#{topic.title}' (#{topic.lock_reason}) in #{topic.forum.name}"
|
||||
|
@ -62,7 +62,7 @@ defmodule PhilomenaWeb.Topic.LockController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.forum_topic_path(conn, :show, topic.forum, topic)
|
||||
subject_path: ~p"/forums/#{topic.forum}/topics/#{topic}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,20 +29,20 @@ defmodule PhilomenaWeb.Topic.MoveController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Topic successfully moved!")
|
||||
|> moderation_log(details: &log_details/3, data: topic)
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> moderation_log(details: &log_details/2, data: topic)
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
{:error, _changeset} ->
|
||||
conn
|
||||
|> put_flash(:error, "Unable to move the topic!")
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, conn.assigns.forum, topic))
|
||||
|> redirect(to: ~p"/forums/#{conn.assigns.forum}/topics/#{topic}")
|
||||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, topic) do
|
||||
defp log_details(_action, topic) do
|
||||
%{
|
||||
body: "Topic '#{topic.title}' moved to #{topic.forum.name}",
|
||||
subject_path: Routes.forum_topic_path(conn, :show, topic.forum, topic)
|
||||
subject_path: ~p"/forums/#{topic.forum}/topics/#{topic}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,12 +42,12 @@ defmodule PhilomenaWeb.Topic.Poll.VoteController do
|
|||
{:ok, _votes} ->
|
||||
conn
|
||||
|> put_flash(:info, "Your vote has been recorded.")
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
|
||||
_error ->
|
||||
conn
|
||||
|> put_flash(:warning, "Your vote was not recorded.")
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -56,7 +56,7 @@ defmodule PhilomenaWeb.Topic.Poll.VoteController do
|
|||
|
||||
conn
|
||||
|> put_flash(:error, "Your vote was not recorded.")
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
end
|
||||
|
||||
def delete(conn, %{"id" => poll_vote_id}) do
|
||||
|
@ -67,7 +67,7 @@ defmodule PhilomenaWeb.Topic.Poll.VoteController do
|
|||
|
||||
conn
|
||||
|> put_flash(:info, "Vote successfully removed.")
|
||||
|> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic))
|
||||
|> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}")
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
|
|
|
@ -27,9 +27,7 @@ defmodule PhilomenaWeb.Topic.PollController do
|
|||
{:ok, _poll} ->
|
||||
conn
|
||||
|> put_flash(:info, "Poll successfully updated.")
|
||||
|> redirect(
|
||||
to: Routes.forum_topic_path(conn, :show, conn.assigns.forum, conn.assigns.topic)
|
||||
)
|
||||
|> redirect(to: ~p"/forums/#{conn.assigns.forum}/topics/#{conn.assigns.topic}")
|
||||
|
||||
{:error, changeset} ->
|
||||
render(conn, "edit.html", changeset: changeset)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue