mix convert_to_verified_routes && mix format

This commit is contained in:
Liam 2024-04-28 20:55:27 -04:00
parent e15e22ed38
commit ae985927bd
331 changed files with 1034 additions and 1056 deletions

View file

@ -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)

View file

@ -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

View file

@ -19,13 +19,13 @@ 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))
|> redirect(to: ~p"/admin/artist_links")
end
defp log_details(conn, _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

View file

@ -18,13 +18,13 @@ 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))
|> redirect(to: ~p"/admin/artist_links")
end
defp log_details(conn, _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

View file

@ -19,13 +19,13 @@ 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))
|> redirect(to: ~p"/admin/artist_links")
end
defp log_details(conn, _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

View file

@ -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)

View file

@ -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)

View file

@ -71,7 +71,7 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do
defp log_details(conn, _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/#{conn.assigns.current_user}"
}
end
end

View file

@ -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

View file

@ -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

View file

@ -48,7 +48,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
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))
|> redirect(to: ~p"/admin/fingerprint_bans")
{:error, changeset} ->
render(conn, "new.html", changeset: changeset)
@ -66,7 +66,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
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))
|> redirect(to: ~p"/admin/fingerprint_bans")
{:error, changeset} ->
render(conn, "edit.html", changeset: changeset)
@ -79,7 +79,7 @@ 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))
|> redirect(to: ~p"/admin/fingerprint_bans")
end
defp load_bans(queryable, conn) do
@ -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

View file

@ -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)

View file

@ -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

View file

@ -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(:error, "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

View file

@ -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

View file

@ -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

View file

@ -50,7 +50,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do
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))
|> redirect(to: ~p"/admin/subnet_bans")
{:error, changeset} ->
render(conn, "new.html", changeset: changeset)
@ -68,7 +68,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do
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))
|> redirect(to: ~p"/admin/subnet_bans")
{:error, changeset} ->
render(conn, "edit.html", changeset: changeset)
@ -81,7 +81,7 @@ 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))
|> redirect(to: ~p"/admin/subnet_bans")
end
defp load_bans(queryable, conn) do
@ -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

View file

@ -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

View file

@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.ApiKeyController do
conn
|> put_flash(:info, "API token successfully reset.")
|> redirect(to: Routes.profile_path(conn, :show, user))
|> redirect(to: ~p"/profiles/#{user}")
end
defp verify_authorized(conn, _opts) do

View file

@ -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

View file

@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.DownvoteController do
conn
|> put_flash(:info, "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

View file

@ -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

View file

@ -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

View file

@ -13,7 +13,7 @@ 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))
|> redirect(to: ~p"/profiles/#{user}")
end
def delete(conn, _params) do
@ -22,7 +22,7 @@ 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))
|> redirect(to: ~p"/profiles/#{user}")
end
defp verify_authorized(conn, _opts) do
@ -39,6 +39,6 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do
: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

View file

@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.VoteController do
conn
|> put_flash(:info, "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

View file

@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Admin.User.WipeController do
:info,
"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

View file

@ -51,7 +51,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do
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))
|> redirect(to: ~p"/admin/user_bans")
{:error, :user_ban, changeset, _changes} ->
render(conn, "new.html", changeset: changeset)
@ -72,7 +72,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do
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))
|> redirect(to: ~p"/admin/user_bans")
{:error, changeset} ->
render(conn, "edit.html", changeset: changeset)
@ -85,7 +85,7 @@ 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))
|> redirect(to: ~p"/admin/user_bans")
end
defp load_bans(queryable, conn) do
@ -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

View file

@ -63,7 +63,7 @@ defmodule PhilomenaWeb.Admin.UserController do
conn
|> put_flash(:info, "User successfully updated.")
|> moderation_log(details: &log_details/3, data: user)
|> redirect(to: Routes.profile_path(conn, :show, user))
|> redirect(to: ~p"/profiles/#{user}")
{:error, changeset} ->
render(conn, "edit.html", changeset: changeset)
@ -84,7 +84,7 @@ defmodule PhilomenaWeb.Admin.UserController do
defp log_details(conn, _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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -21,12 +21,12 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController do
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))
|> redirect(to: ~p"/duplicate_reports")
_error ->
conn
|> put_flash(:error, "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
@ -34,7 +34,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController 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

View file

@ -21,12 +21,12 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController do
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))
|> redirect(to: ~p"/duplicate_reports")
_error ->
conn
|> put_flash(:error, "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
@ -34,7 +34,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController 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

View file

@ -21,7 +21,7 @@ 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))
|> redirect(to: ~p"/duplicate_reports")
end
def delete(conn, _params) do
@ -30,7 +30,7 @@ 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))
|> redirect(to: ~p"/duplicate_reports")
end
defp log_details(conn, action, _) do
@ -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

View file

@ -22,13 +22,13 @@ 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))
|> redirect(to: ~p"/duplicate_reports")
end
defp log_details(conn, _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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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(:error, "Filter is still in use, not deleted.")
|> redirect(to: Routes.filter_path(conn, :show, filter))
|> redirect(to: ~p"/filters/#{filter}")
end
end
end

View file

@ -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

View file

@ -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

View file

@ -23,7 +23,7 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
defp verify_authorized(conn, _opts) do
@ -36,7 +36,7 @@ defmodule PhilomenaWeb.Image.AnonymousController do
defp log_details(conn, _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

View file

@ -15,10 +15,10 @@ 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))
|> 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)}
%{body: "Approved image #{image.id}", subject_path: ~p"/images/#{image}"}
end
end

View file

@ -23,13 +23,13 @@ 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}")
|> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}")
end
defp log_details(conn, _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

View file

@ -17,23 +17,19 @@ 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}"
)
|> 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
%{
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

View file

@ -16,16 +16,12 @@ defmodule PhilomenaWeb.Image.Comment.HideController do
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}"
)
|> 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
@ -37,16 +33,12 @@ defmodule PhilomenaWeb.Image.Comment.HideController do
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}"
)
|> 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
@ -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

View file

@ -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

View file

@ -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)

View file

@ -13,7 +13,7 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
def delete(conn, _params) do
@ -22,7 +22,7 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
defp log_details(conn, action, image) do
@ -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

View file

@ -20,12 +20,12 @@ defmodule PhilomenaWeb.Image.DeleteController do
conn
|> put_flash(:info, "Image successfully hidden.")
|> moderation_log(details: &log_details/3, data: result.image)
|> redirect(to: Routes.image_path(conn, :show, 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
@ -37,12 +37,12 @@ defmodule PhilomenaWeb.Image.DeleteController do
conn
|> put_flash(:info, "Hide reason updated.")
|> moderation_log(details: &log_details/3, data: image)
|> redirect(to: Routes.image_path(conn, :show, 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
@ -67,7 +67,7 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
defp log_details(conn, action, image) do
@ -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

View file

@ -13,7 +13,7 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
def delete(conn, _params) do
@ -22,7 +22,7 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
defp log_details(conn, action, image) do
@ -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

View file

@ -16,12 +16,12 @@ defmodule PhilomenaWeb.Image.DestroyController do
conn
|> put_flash(:info, "Image contents destroyed.")
|> moderation_log(details: &log_details/3, data: image)
|> redirect(to: Routes.image_path(conn, :show, 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,7 +33,7 @@ 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
@ -41,7 +41,7 @@ defmodule PhilomenaWeb.Image.DestroyController do
defp log_details(conn, _action, image) do
%{
body: "Hard-deleted image >>#{image.id}",
subject_path: Routes.image_path(conn, :show, image)
subject_path: ~p"/images/#{image}"
}
end
end

View file

@ -17,7 +17,7 @@ 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))
|> 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(:error, "Cannot feature a hidden image.")
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|> halt()
_false ->
@ -36,7 +36,7 @@ defmodule PhilomenaWeb.Image.FeatureController do
defp log_details(conn, _action, image) do
%{
body: "Featured image >>#{image.id}",
subject_path: Routes.image_path(conn, :show, image)
subject_path: ~p"/images/#{image}"
}
end
end

View file

@ -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(:error, "Cannot replace a hidden image.")
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|> halt()
_false ->

View file

@ -13,13 +13,13 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
defp log_details(conn, _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

View file

@ -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

View file

@ -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

View file

@ -14,13 +14,13 @@ 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))
|> redirect(to: ~p"/images/#{conn.assigns.image}")
end
defp log_details(conn, _action, image) do
%{
body: "Repaired image >>#{image.id}",
subject_path: Routes.image_path(conn, :show, image)
subject_path: ~p"/images/#{image}"
}
end
end

View file

@ -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

View file

@ -18,13 +18,13 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
defp log_details(conn, _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

View file

@ -15,13 +15,13 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
defp log_details(conn, _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

View file

@ -46,7 +46,7 @@ defmodule PhilomenaWeb.Image.TagChangeController do
details: &log_details/3,
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"}),
@ -61,7 +61,7 @@ defmodule PhilomenaWeb.Image.TagChangeController do
defp log_details(conn, _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

View file

@ -24,7 +24,7 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
def create(conn, _params) do
@ -33,7 +33,7 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
def delete(conn, _params) do
@ -42,7 +42,7 @@ 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))
|> redirect(to: ~p"/images/#{image}")
end
defp log_details(conn, action, image) do
@ -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

View file

@ -28,7 +28,7 @@ defmodule PhilomenaWeb.Image.TamperController do
details: &log_details/3,
data: %{vote: result, image: image}
)
|> 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
@ -43,7 +43,7 @@ defmodule PhilomenaWeb.Image.TamperController do
%{
body: "Deleted #{vote_type} by #{conn.assigns.user.name} on image >>#{data.image.id}",
subject_path: Routes.image_path(conn, :show, image)
subject_path: ~p"/images/#{image}"
}
end
end

View file

@ -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
:info,
"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 ->

View file

@ -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)

View file

@ -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)

View file

@ -52,9 +52,7 @@ defmodule PhilomenaWeb.Profile.ArtistLinkController do
:info,
"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)

View file

@ -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

View file

@ -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 deleted successfully.")
|> 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

View file

@ -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

View file

@ -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
:error,
"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

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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
:info,
"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(:error, "Email change link is invalid or it has expired.")
|> redirect(to: Routes.registration_path(conn, :edit))
|> redirect(to: ~p"/registrations/edit")
end
end
end

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -101,7 +101,7 @@ defmodule PhilomenaWeb.ReportController do
end
defp redirect_path(_conn, nil), do: "/"
defp redirect_path(conn, _user), do: Routes.report_path(conn, :index)
defp redirect_path(conn, _user), do: ~p"/reports"
defp max_reports do
5

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -24,7 +24,7 @@ defmodule PhilomenaWeb.Tag.ImageController do
conn
|> put_flash(:info, "Tag image successfully updated.")
|> moderation_log(details: &log_details/3, data: tag)
|> redirect(to: Routes.tag_path(conn, :show, tag))
|> redirect(to: ~p"/tags/#{tag}")
{:error, :tag, changeset, _changes} ->
render(conn, "edit.html", changeset: changeset)
@ -37,7 +37,7 @@ 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))
|> redirect(to: ~p"/tags/#{conn.assigns.tag}")
end
defp log_details(conn, action, tag) do
@ -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

View file

@ -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

View file

@ -98,7 +98,7 @@ defmodule PhilomenaWeb.TagController do
conn
|> put_flash(:info, "Tag successfully updated.")
|> moderation_log(details: &log_details/3, data: tag)
|> redirect(to: Routes.tag_path(conn, :show, tag))
|> redirect(to: ~p"/tags/#{tag}")
{:error, changeset} ->
render(conn, "edit.html", changeset: changeset)
@ -167,7 +167,7 @@ defmodule PhilomenaWeb.TagController do
:info,
"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
@ -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

View file

@ -28,12 +28,12 @@ defmodule PhilomenaWeb.Topic.HideController do
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))
|> 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
@ -45,12 +45,12 @@ defmodule PhilomenaWeb.Topic.HideController do
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))
|> 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
@ -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

View file

@ -27,12 +27,12 @@ defmodule PhilomenaWeb.Topic.LockController do
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))
|> 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
@ -44,12 +44,12 @@ defmodule PhilomenaWeb.Topic.LockController do
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))
|> 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
@ -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

View file

@ -30,19 +30,19 @@ 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))
|> 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
%{
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

View file

@ -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(: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
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

View file

@ -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)

View file

@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController do
|> moderation_log(details: &log_details/3, data: post)
|> redirect(
to:
Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <>
~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <>
"#post_#{post.id}"
)
@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController do
|> put_flash(:error, "Unable to approve post!")
|> redirect(
to:
Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <>
~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <>
"#post_#{post.id}"
)
end
@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController do
%{
body: "Approved forum post ##{post.id} in topic '#{post.topic.title}'",
subject_path:
Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <>
~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <>
"#post_#{post.id}"
}
end

Some files were not shown because too many files have changed in this diff Show more