From d8f04fe92297c37b7a2aa963714f5661d7b63275 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Wed, 2 Dec 2020 14:18:25 -0500 Subject: [PATCH] format --- lib/philomena/artist_links.ex | 5 ++- lib/philomena/users/ability.ex | 32 ++++++++++++++----- .../admin/artist_link/contact_controller.ex | 3 +- .../profile/artist_link_controller.ex | 8 +++-- .../profile/commission_controller.ex | 5 ++- ...20201124224116_rename_user_links_table.exs | 16 ++++++++++ 6 files changed, 56 insertions(+), 13 deletions(-) diff --git a/lib/philomena/artist_links.ex b/lib/philomena/artist_links.ex index 48af30ca..eeddac65 100644 --- a/lib/philomena/artist_links.ex +++ b/lib/philomena/artist_links.ex @@ -32,7 +32,10 @@ defmodule Philomena.ArtistLinks do recheck_query |> Repo.all() |> Enum.map(fn link -> - ArtistLink.automatic_verify_changeset(link, AutomaticVerifier.check_link(link, recheck_time)) + ArtistLink.automatic_verify_changeset( + link, + AutomaticVerifier.check_link(link, recheck_time) + ) end) |> Enum.map(&Repo.update!/1) end diff --git a/lib/philomena/users/ability.ex b/lib/philomena/users/ability.ex index c755af6a..2e6b3fb2 100644 --- a/lib/philomena/users/ability.ex +++ b/lib/philomena/users/ability.ex @@ -263,8 +263,12 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do do: true # Artist link assistant actions - def can?(%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, _action, %ArtistLink{}), - do: true + def can?( + %User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, + _action, + %ArtistLink{} + ), + do: true def can?( %User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, @@ -273,14 +277,26 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do ), do: true - def can?(%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, :edit, %ArtistLink{}), - do: true + def can?( + %User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, + :edit, + %ArtistLink{} + ), + do: true - def can?(%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, :edit_links, %User{}), - do: true + def can?( + %User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, + :edit_links, + %User{} + ), + do: true - def can?(%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, :index, %ArtistLink{}), - do: true + def can?( + %User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, + :index, + %ArtistLink{} + ), + do: true # View forums def can?(%User{role: "assistant"}, :show, %Forum{access_level: level}) diff --git a/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex b/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex index ce7d87a1..c2ece9cb 100644 --- a/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex @@ -13,7 +13,8 @@ defmodule PhilomenaWeb.Admin.ArtistLink.ContactController do preload: [:user] def create(conn, _params) do - {:ok, _} = ArtistLinks.contact_artist_link(conn.assigns.artist_link, conn.assigns.current_user) + {:ok, _} = + ArtistLinks.contact_artist_link(conn.assigns.artist_link, conn.assigns.current_user) conn |> put_flash(:info, "Artist successfully marked as contacted.") diff --git a/lib/philomena_web/controllers/profile/artist_link_controller.ex b/lib/philomena_web/controllers/profile/artist_link_controller.ex index 682989fb..3d48c308 100644 --- a/lib/philomena_web/controllers/profile/artist_link_controller.ex +++ b/lib/philomena_web/controllers/profile/artist_link_controller.ex @@ -52,7 +52,9 @@ defmodule PhilomenaWeb.Profile.ArtistLinkController do :info, "Link submitted! Please put '#{artist_link.verification_code}' on your linked webpage now." ) - |> redirect(to: Routes.profile_artist_link_path(conn, :show, conn.assigns.user, artist_link)) + |> redirect( + to: Routes.profile_artist_link_path(conn, :show, conn.assigns.user, artist_link) + ) {:error, %Ecto.Changeset{} = changeset} -> render(conn, "new.html", changeset: changeset) @@ -75,7 +77,9 @@ defmodule PhilomenaWeb.Profile.ArtistLinkController do {:ok, artist_link} -> conn |> put_flash(:info, "Link successfully updated.") - |> redirect(to: Routes.profile_artist_link_path(conn, :show, conn.assigns.user, artist_link)) + |> redirect( + to: Routes.profile_artist_link_path(conn, :show, conn.assigns.user, artist_link) + ) {:error, changeset} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/profile/commission_controller.ex b/lib/philomena_web/controllers/profile/commission_controller.ex index 2254c8d1..528c51e3 100644 --- a/lib/philomena_web/controllers/profile/commission_controller.ex +++ b/lib/philomena_web/controllers/profile/commission_controller.ex @@ -148,7 +148,10 @@ defmodule PhilomenaWeb.Profile.CommissionController do false -> conn - |> put_flash(:error, "You must have a verified artist link to create a commission listing.") + |> put_flash( + :error, + "You must have a verified artist link to create a commission listing." + ) |> redirect(to: Routes.commission_path(conn, :index)) |> halt() end diff --git a/priv/repo/migrations/20201124224116_rename_user_links_table.exs b/priv/repo/migrations/20201124224116_rename_user_links_table.exs index 45eee580..db0c0525 100644 --- a/priv/repo/migrations/20201124224116_rename_user_links_table.exs +++ b/priv/repo/migrations/20201124224116_rename_user_links_table.exs @@ -4,13 +4,21 @@ defmodule Philomena.Repo.Migrations.RenameUserLinksTable do def up do rename table("user_links"), to: table("artist_links") execute "ALTER SEQUENCE user_links_id_seq RENAME TO artist_links_id_seq" + execute "ALTER INDEX index_user_links_on_aasm_state RENAME TO index_artist_links_on_aasm_state" + execute "ALTER INDEX index_user_links_on_contacted_by_user_id RENAME TO index_artist_links_on_contacted_by_user_id" + execute "ALTER INDEX index_user_links_on_next_check_at RENAME TO index_artist_links_on_next_check_at" + execute "ALTER INDEX index_user_links_on_tag_id RENAME TO index_artist_links_on_tag_id" + execute "ALTER INDEX index_user_links_on_uri_tag_id_user_id RENAME TO index_artist_links_on_uri_tag_id_user_id" + execute "ALTER INDEX index_user_links_on_user_id RENAME TO index_artist_links_on_user_id" + execute "ALTER INDEX index_user_links_on_verified_by_user_id RENAME TO index_artist_links_on_verified_by_user_id" + execute "ALTER TABLE artist_links RENAME CONSTRAINT user_links_pkey TO artist_links_pkey" execute "UPDATE roles SET resource_type='ArtistLink' WHERE resource_type='UserLink'" end @@ -18,13 +26,21 @@ defmodule Philomena.Repo.Migrations.RenameUserLinksTable do def down do rename table("artist_links"), to: table("user_links") execute "ALTER SEQUENCE artist_links_id_seq RENAME TO user_links_id_seq" + execute "ALTER INDEX index_artist_links_on_aasm_state RENAME TO index_user_links_on_aasm_state" + execute "ALTER INDEX index_artist_links_on_contacted_by_user_id RENAME TO index_user_links_on_contacted_by_user_id" + execute "ALTER INDEX index_artist_links_on_next_check_at RENAME TO index_user_links_on_next_check_at" + execute "ALTER INDEX index_artist_links_on_tag_id RENAME TO index_user_links_on_tag_id" + execute "ALTER INDEX index_artist_links_on_uri_tag_id_user_id RENAME TO index_user_links_on_uri_tag_id_user_id" + execute "ALTER INDEX index_artist_links_on_user_id RENAME TO index_user_links_on_user_id" + execute "ALTER INDEX index_artist_links_on_verified_by_user_id RENAME TO index_user_links_on_verified_by_user_id" + execute "ALTER TABLE user_links RENAME CONSTRAINT artist_links_pkey TO user_links_pkey" execute "UPDATE roles SET resource_type='UserLink' WHERE resource_type='ArtistLink'" end