mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
format
This commit is contained in:
parent
21c17855f8
commit
d8f04fe922
6 changed files with 56 additions and 13 deletions
|
@ -32,7 +32,10 @@ defmodule Philomena.ArtistLinks do
|
||||||
recheck_query
|
recheck_query
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|> Enum.map(fn link ->
|
|> 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)
|
end)
|
||||||
|> Enum.map(&Repo.update!/1)
|
|> Enum.map(&Repo.update!/1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -263,7 +263,11 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do
|
||||||
do: true
|
do: true
|
||||||
|
|
||||||
# Artist link assistant actions
|
# Artist link assistant actions
|
||||||
def can?(%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, _action, %ArtistLink{}),
|
def can?(
|
||||||
|
%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}},
|
||||||
|
_action,
|
||||||
|
%ArtistLink{}
|
||||||
|
),
|
||||||
do: true
|
do: true
|
||||||
|
|
||||||
def can?(
|
def can?(
|
||||||
|
@ -273,13 +277,25 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do
|
||||||
),
|
),
|
||||||
do: true
|
do: true
|
||||||
|
|
||||||
def can?(%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, :edit, %ArtistLink{}),
|
def can?(
|
||||||
|
%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}},
|
||||||
|
:edit,
|
||||||
|
%ArtistLink{}
|
||||||
|
),
|
||||||
do: true
|
do: true
|
||||||
|
|
||||||
def can?(%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, :edit_links, %User{}),
|
def can?(
|
||||||
|
%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}},
|
||||||
|
:edit_links,
|
||||||
|
%User{}
|
||||||
|
),
|
||||||
do: true
|
do: true
|
||||||
|
|
||||||
def can?(%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}}, :index, %ArtistLink{}),
|
def can?(
|
||||||
|
%User{role: "assistant", role_map: %{"ArtistLink" => "moderator"}},
|
||||||
|
:index,
|
||||||
|
%ArtistLink{}
|
||||||
|
),
|
||||||
do: true
|
do: true
|
||||||
|
|
||||||
# View forums
|
# View forums
|
||||||
|
|
|
@ -13,7 +13,8 @@ defmodule PhilomenaWeb.Admin.ArtistLink.ContactController do
|
||||||
preload: [:user]
|
preload: [:user]
|
||||||
|
|
||||||
def create(conn, _params) do
|
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
|
conn
|
||||||
|> put_flash(:info, "Artist successfully marked as contacted.")
|
|> put_flash(:info, "Artist successfully marked as contacted.")
|
||||||
|
|
|
@ -52,7 +52,9 @@ defmodule PhilomenaWeb.Profile.ArtistLinkController do
|
||||||
:info,
|
:info,
|
||||||
"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(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} ->
|
{:error, %Ecto.Changeset{} = changeset} ->
|
||||||
render(conn, "new.html", changeset: changeset)
|
render(conn, "new.html", changeset: changeset)
|
||||||
|
@ -75,7 +77,9 @@ 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(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} ->
|
{:error, changeset} ->
|
||||||
render(conn, "edit.html", changeset: changeset)
|
render(conn, "edit.html", changeset: changeset)
|
||||||
|
|
|
@ -148,7 +148,10 @@ defmodule PhilomenaWeb.Profile.CommissionController do
|
||||||
|
|
||||||
false ->
|
false ->
|
||||||
conn
|
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))
|
|> redirect(to: Routes.commission_path(conn, :index))
|
||||||
|> halt()
|
|> halt()
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,13 +4,21 @@ defmodule Philomena.Repo.Migrations.RenameUserLinksTable do
|
||||||
def up do
|
def up do
|
||||||
rename table("user_links"), to: table("artist_links")
|
rename table("user_links"), to: table("artist_links")
|
||||||
execute "ALTER SEQUENCE user_links_id_seq RENAME TO artist_links_id_seq"
|
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_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_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_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_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_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_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 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 "ALTER TABLE artist_links RENAME CONSTRAINT user_links_pkey TO artist_links_pkey"
|
||||||
execute "UPDATE roles SET resource_type='ArtistLink' WHERE resource_type='UserLink'"
|
execute "UPDATE roles SET resource_type='ArtistLink' WHERE resource_type='UserLink'"
|
||||||
end
|
end
|
||||||
|
@ -18,13 +26,21 @@ defmodule Philomena.Repo.Migrations.RenameUserLinksTable do
|
||||||
def down do
|
def down do
|
||||||
rename table("artist_links"), to: table("user_links")
|
rename table("artist_links"), to: table("user_links")
|
||||||
execute "ALTER SEQUENCE artist_links_id_seq RENAME TO user_links_id_seq"
|
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_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_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_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_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_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_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 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 "ALTER TABLE user_links RENAME CONSTRAINT artist_links_pkey TO user_links_pkey"
|
||||||
execute "UPDATE roles SET resource_type='UserLink' WHERE resource_type='ArtistLink'"
|
execute "UPDATE roles SET resource_type='UserLink' WHERE resource_type='ArtistLink'"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue