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