diff --git a/assets/package-lock.json b/assets/package-lock.json
index 21780799..6f395a28 100644
--- a/assets/package-lock.json
+++ b/assets/package-lock.json
@@ -10,9 +10,9 @@
"chart.js": "^3.8.0",
"dante3": "^1.1.5",
"flatpickr": "^4.6.13",
- "phoenix": "^1.6.10",
- "phoenix_html": "^3.2.0",
- "phoenix_live_view": "^0.17.10",
+ "phoenix": "^1.7.1",
+ "phoenix_html": "^3.3.1",
+ "phoenix_live_view": "^0.19.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
@@ -2081,21 +2081,19 @@
}
},
"node_modules/phoenix": {
- "version": "1.6.10",
- "resolved": "https://registry.yarnpkg.com/phoenix/-/phoenix-1.6.10.tgz",
- "integrity": "sha512-KfYAJrrw95JGaOlvmZ+lFJZhSfQmo4SVOj6s175/V8YxqhYGO5EGacdrJxQmJ6uhaK4H3S6b0wkC1T33qU/d8Q==",
- "license": "MIT"
+ "version": "1.7.1",
+ "resolved": "https://registry.npmjs.org/phoenix/-/phoenix-1.7.1.tgz",
+ "integrity": "sha512-DORpAOHp8XdQDs6WT2yD65fhUQXhzrD+CTZCKqWQ9g0G/fyM8EKsSDhtOwl54Nr2DDBu8JARMR97OfLYCiKAoQ=="
},
"node_modules/phoenix_html": {
- "version": "3.2.0",
- "resolved": "https://registry.yarnpkg.com/phoenix_html/-/phoenix_html-3.2.0.tgz",
- "integrity": "sha512-zv7PIZk0MPkF0ax8n465Q6w86+sGAy5cTem6KcbkUbdgxGc0y3WZmzkM2bSlYdSGbLEZfjXxos1G72xXsha6xA=="
+ "version": "3.3.1",
+ "resolved": "https://registry.npmjs.org/phoenix_html/-/phoenix_html-3.3.1.tgz",
+ "integrity": "sha512-t/9Saqpe8vznZYHMDim7HS32Dd2/rKf3+uxuKKNRADLpGXVIDjselOY6pK8aNaLiY2gnlqsoz6yIpUBuoLT63w=="
},
"node_modules/phoenix_live_view": {
- "version": "0.17.10",
- "resolved": "https://registry.yarnpkg.com/phoenix_live_view/-/phoenix_live_view-0.17.10.tgz",
- "integrity": "sha512-oHSoH0IdJ1I5uAYjH2A1KlBmwra6LgcUrHlAP3EEorrZyMpbhBJjNNhXxhBu6dmcxqnaAbwsIXMQRLi6KjJZIg==",
- "license": "MIT"
+ "version": "0.19.0",
+ "resolved": "https://registry.npmjs.org/phoenix_live_view/-/phoenix_live_view-0.19.0.tgz",
+ "integrity": "sha512-A5csAJh8wHqhconanS2BI/5vhCSRKvdrEqLc+FF8BaKGm1xu00f3rC/mENT7Aen+jeKP9jjy028fDMMYWk4F+w=="
},
"node_modules/picocolors": {
"version": "1.0.0",
@@ -4429,19 +4427,19 @@
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw=="
},
"phoenix": {
- "version": "1.6.10",
- "resolved": "https://registry.yarnpkg.com/phoenix/-/phoenix-1.6.10.tgz",
- "integrity": "sha512-KfYAJrrw95JGaOlvmZ+lFJZhSfQmo4SVOj6s175/V8YxqhYGO5EGacdrJxQmJ6uhaK4H3S6b0wkC1T33qU/d8Q=="
+ "version": "1.7.1",
+ "resolved": "https://registry.npmjs.org/phoenix/-/phoenix-1.7.1.tgz",
+ "integrity": "sha512-DORpAOHp8XdQDs6WT2yD65fhUQXhzrD+CTZCKqWQ9g0G/fyM8EKsSDhtOwl54Nr2DDBu8JARMR97OfLYCiKAoQ=="
},
"phoenix_html": {
- "version": "3.2.0",
- "resolved": "https://registry.yarnpkg.com/phoenix_html/-/phoenix_html-3.2.0.tgz",
- "integrity": "sha512-zv7PIZk0MPkF0ax8n465Q6w86+sGAy5cTem6KcbkUbdgxGc0y3WZmzkM2bSlYdSGbLEZfjXxos1G72xXsha6xA=="
+ "version": "3.3.1",
+ "resolved": "https://registry.npmjs.org/phoenix_html/-/phoenix_html-3.3.1.tgz",
+ "integrity": "sha512-t/9Saqpe8vznZYHMDim7HS32Dd2/rKf3+uxuKKNRADLpGXVIDjselOY6pK8aNaLiY2gnlqsoz6yIpUBuoLT63w=="
},
"phoenix_live_view": {
- "version": "0.17.10",
- "resolved": "https://registry.yarnpkg.com/phoenix_live_view/-/phoenix_live_view-0.17.10.tgz",
- "integrity": "sha512-oHSoH0IdJ1I5uAYjH2A1KlBmwra6LgcUrHlAP3EEorrZyMpbhBJjNNhXxhBu6dmcxqnaAbwsIXMQRLi6KjJZIg=="
+ "version": "0.19.0",
+ "resolved": "https://registry.npmjs.org/phoenix_live_view/-/phoenix_live_view-0.19.0.tgz",
+ "integrity": "sha512-A5csAJh8wHqhconanS2BI/5vhCSRKvdrEqLc+FF8BaKGm1xu00f3rC/mENT7Aen+jeKP9jjy028fDMMYWk4F+w=="
},
"picocolors": {
"version": "1.0.0",
diff --git a/assets/package.json b/assets/package.json
index 678cb8be..9cea7acb 100644
--- a/assets/package.json
+++ b/assets/package.json
@@ -7,7 +7,7 @@
"flatpickr": "^4.6.13",
"phoenix": "^1.7.1",
"phoenix_html": "^3.3.1",
- "phoenix_live_view": "^0.18.17",
+ "phoenix_live_view": "^0.19.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
diff --git a/assets/yarn.lock b/assets/yarn.lock
index ecd9235e..7f9de412 100644
--- a/assets/yarn.lock
+++ b/assets/yarn.lock
@@ -984,18 +984,18 @@ path-type@^4.0.0:
phoenix@^1.7.1:
version "1.7.1"
- resolved "https://registry.yarnpkg.com/phoenix/-/phoenix-1.7.1.tgz#99a2f697eb8e0a95c64e5756829621c52966069c"
+ resolved "https://registry.npmjs.org/phoenix/-/phoenix-1.7.1.tgz"
integrity sha512-DORpAOHp8XdQDs6WT2yD65fhUQXhzrD+CTZCKqWQ9g0G/fyM8EKsSDhtOwl54Nr2DDBu8JARMR97OfLYCiKAoQ==
phoenix_html@^3.3.1:
version "3.3.1"
- resolved "https://registry.yarnpkg.com/phoenix_html/-/phoenix_html-3.3.1.tgz#87461c879a075cad6a7340e434e40f69a815f11b"
+ resolved "https://registry.npmjs.org/phoenix_html/-/phoenix_html-3.3.1.tgz"
integrity sha512-t/9Saqpe8vznZYHMDim7HS32Dd2/rKf3+uxuKKNRADLpGXVIDjselOY6pK8aNaLiY2gnlqsoz6yIpUBuoLT63w==
-phoenix_live_view@^0.18.17:
- version "0.18.17"
- resolved "https://registry.yarnpkg.com/phoenix_live_view/-/phoenix_live_view-0.18.17.tgz#978bf017e8b250f9e70e276e09ea271fedf6662d"
- integrity sha512-ORVy7K1Fihn8sxhwpJRfPZTINsq0DQhtWbiCz6t8h5D/uwURDUUWV1KBFeB+2HhyjqdnWF9DqqAYlt7luNSp1g==
+phoenix_live_view@^0.19.0:
+ version "0.19.0"
+ resolved "https://registry.npmjs.org/phoenix_live_view/-/phoenix_live_view-0.19.0.tgz"
+ integrity sha512-A5csAJh8wHqhconanS2BI/5vhCSRKvdrEqLc+FF8BaKGm1xu00f3rC/mENT7Aen+jeKP9jjy028fDMMYWk4F+w==
pify@^2.3.0:
version "2.3.0"
diff --git a/config/cy.exs b/config/cy.exs
index c5a206c9..b41afba8 100644
--- a/config/cy.exs
+++ b/config/cy.exs
@@ -116,6 +116,8 @@ config :active_storage, :secret_key_base, "xxxxxxxxxxx"
config :active_job, repo: Rauversion.Repo
config :active_storage, repo: Rauversion.Repo
+config :rauversion, :domain, "http://localhost:4002"
+
config :mogrify,
mogrify_command: [
path: "mogrify",
diff --git a/config/runtime.exs b/config/runtime.exs
index 8aa41163..01069dd1 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -72,6 +72,9 @@ config :rauversion, google_analytics_id: System.get_env("GA_ID")
config :rauversion, disabled_registrations: System.get_env("DISABLED_REGISTRATIONS", "false")
+config :rauversion,
+ disabled_label_registrations: System.get_env("LABEL_REGISTRATION_CLOSED", "false")
+
config :ueberauth, Ueberauth.Strategy.Zoom.OAuth,
client_id: System.get_env("ZOOM_CLIENT_ID"),
client_secret: System.get_env("ZOOM_CLIENT_SECRET")
diff --git a/lib/rauversion/accounts.ex b/lib/rauversion/accounts.ex
index 79f3739a..8d6bd6c7 100644
--- a/lib/rauversion/accounts.ex
+++ b/lib/rauversion/accounts.ex
@@ -70,6 +70,10 @@ defmodule Rauversion.Accounts do
|> where([u], not is_nil(u.username))
end
+ def search_by_username(query, term) do
+ query |> where([u], like(u.username, ^"#{term}%"))
+ end
+
def artists() do
from(u in User,
where: [type: ^"artist"],
@@ -146,6 +150,11 @@ defmodule Rauversion.Accounts do
"""
def get_user!(id), do: Repo.get!(User, id)
+ def not_in(query, id) do
+ query
+ |> where([u], u.id != ^id)
+ end
+
## User registration
@doc """
@@ -207,6 +216,15 @@ defmodule Rauversion.Accounts do
|> Repo.update()
end
+ def is_label?(user) do
+ user.label
+ end
+
+ def update_label(user, attrs \\ %{}) do
+ User.label_changeset(user, attrs)
+ |> Repo.update()
+ end
+
def update_notifications(user, attrs \\ %{}) do
User.notifications_changeset(user, attrs)
|> Repo.update()
@@ -593,11 +611,12 @@ defmodule Rauversion.Accounts do
end
def user_host_events(user) do
- from p in Rauversion.Events.Event,
+ from(p in Rauversion.Events.Event,
join: c in assoc(p, :event_hosts),
where: c.user_id == ^user.id,
preload: [:user],
select: p
+ )
end
def find_managed_event(user, event_id) do
@@ -718,8 +737,9 @@ defmodule Rauversion.Accounts do
q = track_orders_query(current_user)
query =
- from [p, c] in q,
+ from([p, c] in q,
where: c.state == "paid" or c.state == "free_access"
+ )
query
|> Repo.all()
@@ -740,8 +760,9 @@ defmodule Rauversion.Accounts do
q = album_orders_query(current_user)
query =
- from [p, c] in q,
+ from([p, c] in q,
where: c.state == "paid" or c.state == "free_access"
+ )
query
|> Repo.all()
@@ -751,8 +772,9 @@ defmodule Rauversion.Accounts do
q = album_orders_query(current_user)
query =
- from [p, c] in q,
+ from([p, c] in q,
where: c.state == "pending"
+ )
query
|> Repo.all()
@@ -780,8 +802,9 @@ defmodule Rauversion.Accounts do
|> order_by([c], desc: c.id)
query =
- from [p, c] in q,
+ from([p, c] in q,
where: c.state == "paid"
+ )
query
end
@@ -799,9 +822,28 @@ defmodule Rauversion.Accounts do
|> order_by([c], desc: c.id)
query =
- from [p, c] in q,
+ from([p, c] in q,
where: c.state == "paid"
+ )
query
end
+
+ ### connected accounts
+
+ def active_connected_accounts(user) do
+ from(p in Rauversion.ConnectedAccounts.ConnectedAccount)
+ |> where(parent_id: ^user.id)
+ |> where(state: "active")
+ |> Rauversion.Repo.all()
+ |> Repo.preload(:user)
+ end
+
+ def is_child_of?(user, child_user_id) do
+ from(p in Rauversion.ConnectedAccounts.ConnectedAccount)
+ |> where(parent_id: ^user.id)
+ |> where(state: "active")
+ |> where([c], ^child_user_id == c.user_id)
+ |> Rauversion.Repo.one()
+ end
end
diff --git a/lib/rauversion/accounts/user.ex b/lib/rauversion/accounts/user.ex
index 75048b44..d99a9dff 100644
--- a/lib/rauversion/accounts/user.ex
+++ b/lib/rauversion/accounts/user.ex
@@ -19,6 +19,7 @@ defmodule Rauversion.Accounts.User do
field :city, :string
field :bio, :string
field :invitations_count, :integer, default: 10
+ field :label, :boolean
belongs_to :invited_by_user, Rauversion.Accounts.User, foreign_key: :invited_by
@@ -62,6 +63,13 @@ defmodule Rauversion.Accounts.User do
has_many :purchased_tickets, Rauversion.PurchasedTickets.PurchasedTicket,
on_delete: :delete_all
+ has_many :connected_accounts,
+ Rauversion.ConnectedAccounts.ConnectedAccount,
+ on_delete: :delete_all,
+ foreign_key: :parent_id
+
+ has_many :child_accounts, through: [:connected_accounts, :user]
+
has_one(:avatar_attachment, ActiveStorage.Attachment,
where: [record_type: "User", name: "avatar"],
foreign_key: :record_id
@@ -178,6 +186,10 @@ defmodule Rauversion.Accounts.User do
|> unique_constraint(:username)
end
+ def label_changeset(user, attrs, _opts \\ []) do
+ user |> cast(attrs, [:label])
+ end
+
defp validate_contact_fields(changeset, attrs) do
changeset
|> cast(attrs, [:username, :first_name, :last_name, :country, :bio, :city])
diff --git a/lib/rauversion/album_purchase_orders/album_purchase_order.ex b/lib/rauversion/album_purchase_orders/album_purchase_order.ex
index 052ccfe3..4ee19c79 100644
--- a/lib/rauversion/album_purchase_orders/album_purchase_order.ex
+++ b/lib/rauversion/album_purchase_orders/album_purchase_order.ex
@@ -38,20 +38,20 @@ defmodule Rauversion.AlbumPurchaseOrders.AlbumPurchaseOrder do
Rauversion.Playlists.get_playlist!(order.playlist_id)
|> Rauversion.Repo.preload([:user, :cover_blob, [track_playlists: [track: [:audio_blob]]]])
- # {:ok, fd, file_path} = Temp.open("my-file")
- #
- # text = """
- #
#{playlist.title}
- # #{playlist.description}
- # Visit: #{playlist.title} on #{Application.get_env(:rauversion, :domain)}
- # """
- #
- # IO.write(fd, text)
- # charlist = String.to_charlist(text)
- # IO.write(fd, charlist)
- ## File.close(fd) ## close file?
- #
- # file_entry = [source: {:file, file_path}, path: "/#{playlist.slug}/#{playlist.slug}.html"]
+ {:ok, fd, file_path} = Temp.open("my-file")
+
+ text = """
+ #{playlist.title}
+
+ #{playlist.description}
+
+ Visit: #{playlist.title} on #{Application.get_env(:rauversion, :domain)}
+ """
+
+ IO.write(fd, text)
+ # File.close(fd) ## close file?
+
+ file_entry = [source: {:file, file_path}, path: "/#{playlist.slug}/#{playlist.slug}.html"]
entries =
Enum.map(playlist.track_playlists, fn item ->
@@ -65,7 +65,7 @@ defmodule Rauversion.AlbumPurchaseOrders.AlbumPurchaseOrder do
]
end)
- # entries = entries ++ [file_entry]
+ entries = entries ++ [file_entry]
cover = Rauversion.BlobUtils.blob_proxy_url(playlist, :cover)
diff --git a/lib/rauversion/auto_context.ex b/lib/rauversion/auto_context.ex
new file mode 100644
index 00000000..f98b0f91
--- /dev/null
+++ b/lib/rauversion/auto_context.ex
@@ -0,0 +1,39 @@
+defmodule Rauversion.AutoContext do
+ defmacro __using__(opts) do
+ quote bind_quoted: [opts: opts] do
+ import Ecto.Query, warn: false
+ alias Rauversion.Repo
+
+ def list do
+ Repo.all(unquote(opts))
+ end
+
+ def get!(id), do: Repo.get!(unquote(opts), id)
+
+ def create(attrs \\ %{}) do
+ %unquote(opts){}
+ |> unquote(opts).changeset(attrs)
+ |> Repo.insert()
+ end
+
+ def update(%unquote(opts){} = connected_account, attrs) do
+ connected_account
+ |> unquote(opts).changeset(attrs)
+ |> Repo.update()
+ end
+
+ def delete(%unquote(opts){} = connected_account) do
+ Repo.delete(connected_account)
+ end
+
+ def change(
+ %unquote(opts){} = connected_account,
+ attrs \\ %{}
+ ) do
+ unquote(opts).changeset(connected_account, attrs)
+ end
+
+ defoverridable list: 0, get!: 1, create: 1, update: 2, delete: 1, change: 1
+ end
+ end
+end
diff --git a/lib/rauversion/connected_accounts.ex b/lib/rauversion/connected_accounts.ex
new file mode 100644
index 00000000..3fb0bb4b
--- /dev/null
+++ b/lib/rauversion/connected_accounts.ex
@@ -0,0 +1,131 @@
+defmodule Rauversion.ConnectedAccounts do
+ @moduledoc """
+ The ConnectedAccounts context.
+ """
+
+ # import Ecto.Query, warn: false
+ # alias Rauversion.Repo
+
+ # alias Rauversion.ConnectedAccounts.ConnectedAccount
+
+ use Rauversion.AutoContext, Rauversion.ConnectedAccounts.ConnectedAccount
+
+ def attach_existing_account(from, username) do
+ case Rauversion.Accounts.get_user_by_username(username) do
+ %Rauversion.Accounts.User{} = user ->
+ __MODULE__.create(%{inviter_id: from.id, user_id: user})
+
+ _ ->
+ IO.puts("non")
+ end
+ end
+
+ def attach_new_account(from, user_params) do
+ case Rauversion.Accounts.create_user(user_params) do
+ user ->
+ __MODULE__.create(%{inviter_id: from.id, user_id: user})
+
+ nil ->
+ nil
+ end
+ end
+
+ @doc """
+ Returns the list of connected_account.
+
+ ## Examples
+
+ iex> list_connected_account()
+ [%ConnectedAccount{}, ...]
+
+ """
+
+ # def list_connected_account do
+ # Repo.all(ConnectedAccount)
+ # end
+
+ @doc """
+ Gets a single connected_account.
+
+ Raises `Ecto.NoResultsError` if the Connected account does not exist.
+
+ ## Examples
+
+ iex> get_connected_account!(123)
+ %ConnectedAccount{}
+
+ iex> get_connected_account!(456)
+ ** (Ecto.NoResultsError)
+
+ """
+
+ # def get_connected_account!(id), do: Repo.get!(ConnectedAccount, id)
+
+ @doc """
+ Creates a connected_account.
+
+ ## Examples
+
+ iex> create_connected_account(%{field: value})
+ {:ok, %ConnectedAccount{}}
+
+ iex> create_connected_account(%{field: bad_value})
+ {:error, %Ecto.Changeset{}}
+
+ """
+
+ # def create_connected_account(attrs \\ %{}) do
+ # %ConnectedAccount{}
+ # |> ConnectedAccount.changeset(attrs)
+ # |> Repo.insert()
+ # end
+
+ @doc """
+ Updates a connected_account.
+
+ ## Examples
+
+ iex> update_connected_account(connected_account, %{field: new_value})
+ {:ok, %ConnectedAccount{}}
+
+ iex> update_connected_account(connected_account, %{field: bad_value})
+ {:error, %Ecto.Changeset{}}
+
+ """
+
+ # def update_connected_account(%ConnectedAccount{} = connected_account, attrs) do
+ # connected_account
+ # |> ConnectedAccount.changeset(attrs)
+ # |> Repo.update()
+ # end
+
+ @doc """
+ Deletes a connected_account.
+
+ ## Examples
+
+ iex> delete_connected_account(connected_account)
+ {:ok, %ConnectedAccount{}}
+
+ iex> delete_connected_account(connected_account)
+ {:error, %Ecto.Changeset{}}
+
+ """
+
+ # def delete_connected_account(%ConnectedAccount{} = connected_account) do
+ # Repo.delete(connected_account)
+ # end
+
+ @doc """
+ Returns an `%Ecto.Changeset{}` for tracking connected_account changes.
+
+ ## Examples
+
+ iex> change_connected_account(connected_account)
+ %Ecto.Changeset{data: %ConnectedAccount{}}
+
+ """
+ # def change_connected_account(%ConnectedAccount{} = connected_account, attrs \\ %{}) do
+ # ConnectedAccount.changeset(connected_account, attrs)
+ # end
+end
diff --git a/lib/rauversion/connected_accounts/connected_account.ex b/lib/rauversion/connected_accounts/connected_account.ex
new file mode 100644
index 00000000..f52beeea
--- /dev/null
+++ b/lib/rauversion/connected_accounts/connected_account.ex
@@ -0,0 +1,23 @@
+defmodule Rauversion.ConnectedAccounts.ConnectedAccount do
+ use Ecto.Schema
+ import Ecto.Changeset
+
+ schema "connected_accounts" do
+ field :state, :string, default: "pending"
+ # field :parent_id, :id
+ # field :user_id, :id
+
+ belongs_to :inviter, Rauversion.Accounts.User, foreign_key: :parent_id
+ belongs_to :user, Rauversion.Accounts.User, foreign_key: :user_id
+
+ timestamps()
+ end
+
+ @doc false
+ def changeset(connected_account, attrs) do
+ connected_account
+ |> cast(attrs, [:state, :parent_id, :user_id])
+ |> validate_required([:state])
+ |> unsafe_validate_unique([:parent_id, :user_id], Rauversion.Repo)
+ end
+end
diff --git a/lib/rauversion/connected_accounts/existing_artist.ex b/lib/rauversion/connected_accounts/existing_artist.ex
new file mode 100644
index 00000000..754f2001
--- /dev/null
+++ b/lib/rauversion/connected_accounts/existing_artist.ex
@@ -0,0 +1,24 @@
+defmodule Rauversion.ConnectedAccounts.ExistingArtist do
+ use Ecto.Schema
+ import Ecto.Changeset
+
+ embedded_schema do
+ field :username, :string
+ field :ticket_id, :id
+ end
+
+ def changeset(struct, attrs) do
+ struct
+ |> cast(attrs, [:username, :ticket_id])
+ |> validate_required([:username, :ticket_id])
+
+ # |> validate_email()
+ end
+
+ defp validate_email(changeset) do
+ changeset
+ |> validate_required([:email])
+ |> validate_format(:email, ~r/^[^\s]+@[^\s]+$/, message: "must have the @ sign and no spaces")
+ |> validate_length(:email, max: 160)
+ end
+end
diff --git a/lib/rauversion/connected_accounts/new_artist.ex b/lib/rauversion/connected_accounts/new_artist.ex
new file mode 100644
index 00000000..0aad8640
--- /dev/null
+++ b/lib/rauversion/connected_accounts/new_artist.ex
@@ -0,0 +1,41 @@
+defmodule Rauversion.ConnectedAccounts.NewArtist do
+ use Ecto.Schema
+ import Ecto.Changeset
+
+ embedded_schema do
+ field :username, :string
+ field :genre, :string
+ field :hidden, :string
+ end
+
+ # Artist name
+ # Location
+ # e.g. Seattle, WA
+ # Genre
+ # select one
+ # Your genre selection determines where your music appears in Bandcamp Discover. It’s OK if you don’t fit perfectly within one of these – just use the genre tag field, below, to provide more granularity.
+
+ # Genre tags
+ # URL http://
+ # .com
+ # You can point your own URL/custom domain here later.
+
+ # Hide artist
+ # You can hide and unhide artists later, too.
+ # Photo
+
+ def changeset(struct, attrs) do
+ struct
+ |> cast(attrs, [:username, :genre, :hidden])
+ |> validate_required([:username])
+
+ # |> validate_email()
+ end
+
+ defp validate_email(changeset) do
+ changeset
+ |> validate_required([:email])
+ |> validate_format(:email, ~r/^[^\s]+@[^\s]+$/, message: "must have the @ sign and no spaces")
+ |> validate_length(:email, max: 160)
+ end
+end
diff --git a/lib/rauversion/track_purchase_orders/track_purchase_order.ex b/lib/rauversion/track_purchase_orders/track_purchase_order.ex
index 14917de1..74f893f0 100644
--- a/lib/rauversion/track_purchase_orders/track_purchase_order.ex
+++ b/lib/rauversion/track_purchase_orders/track_purchase_order.ex
@@ -68,21 +68,22 @@ defmodule Rauversion.TrackPurchaseOrders.TrackPurchaseOrder do
]
end
- # {:ok, fd, file_path} = Temp.open("my-file")
- #
- # text = """
- # #{track.title}
- # #{track.description}
- # Visit: #{track.title} on #{Application.get_env(:rauversion, :domain)}
- # """
- #
- # charlist = String.to_charlist(text)
- # IO.write(fd, charlist)
- ## File.close(fd) ## close file?
- #
- # file_entry = [source: {:file, file_path}, path: "/#{track.slug}/track.slug.html"]
- #
- # entries_group = entries_group ++ [file_entry]
+ {:ok, fd, file_path} = Temp.open("my-file")
+
+ text = """
+ #{track.title}
+
+ #{track.description}
+
+ Visit: #{track.title} on #{Application.get_env(:rauversion, :domain)}
+ """
+
+ IO.write(fd, text)
+ # File.close(fd) ## close file?
+
+ file_entry = [source: {:file, file_path}, path: "/#{track.slug}/track.slug.html"]
+
+ entries_group = entries_group ++ [file_entry]
IO.inspect(entries_group)
entries_group
end
diff --git a/lib/rauversion_web.ex b/lib/rauversion_web.ex
index d7c98715..db3b9dd2 100644
--- a/lib/rauversion_web.ex
+++ b/lib/rauversion_web.ex
@@ -55,7 +55,7 @@ defmodule RauversionWeb do
use PhoenixMetaTags.TagView
- on_mount RauversionWeb.RestoreLocale
+ on_mount(RauversionWeb.RestoreLocale)
alias RauversionWeb.Router.Helpers, as: Routes
unquote(view_helpers())
diff --git a/lib/rauversion_web/active_storage/representations/proxy_controller.ex b/lib/rauversion_web/active_storage/representations/proxy_controller.ex
index 1d296887..25c2dd92 100644
--- a/lib/rauversion_web/active_storage/representations/proxy_controller.ex
+++ b/lib/rauversion_web/active_storage/representations/proxy_controller.ex
@@ -15,7 +15,7 @@
defmodule RauversionWeb.ActiveStorage.Representations.ProxyController do
use RauversionWeb, :controller
- action_fallback RauversionWeb.FallbackController
+ action_fallback(RauversionWeb.FallbackController)
# def show
# http_cache_forever public: true do
@@ -64,7 +64,13 @@ defmodule RauversionWeb.ActiveStorage.Representations.ProxyController do
chunk(conn, chunk_data)
end)
- {:ok, conn} = downloaded_stream
- conn
+ case downloaded_stream do
+ {:ok, conn} ->
+ conn
+
+ e ->
+ IO.inspect(e)
+ conn
+ end
end
end
diff --git a/lib/rauversion_web/controllers/label_auth_controller.ex b/lib/rauversion_web/controllers/label_auth_controller.ex
new file mode 100644
index 00000000..fef060aa
--- /dev/null
+++ b/lib/rauversion_web/controllers/label_auth_controller.ex
@@ -0,0 +1,57 @@
+defmodule RauversionWeb.LabelAuthController do
+ use RauversionWeb, :controller
+ alias Rauversion.Accounts
+
+ def add(conn, %{"username" => username}) do
+ user = Accounts.get_user_by_username(username)
+
+ case RauversionWeb.UserAuth.fetch_current_user(conn, []) do
+ %{assigns: %{current_user: current_user}} ->
+ case Rauversion.Accounts.is_child_of?(current_user, user.id) do
+ %Rauversion.ConnectedAccounts.ConnectedAccount{} = connected_account ->
+ connected_account = connected_account |> Rauversion.Repo.preload(:user)
+
+ conn
+ |> RauversionWeb.UserAuth.log_in_user_conn(connected_account.user)
+ |> put_session(:parent_user, current_user.id)
+ |> redirect(to: "/#{user.username}")
+
+ _a ->
+ conn
+ |> put_flash(:error, gettext("not allowed"))
+ |> redirect(to: "/#{current_user.username}")
+ end
+
+ _ ->
+ conn
+ |> put_flash(:error, gettext("not allowed"))
+ |> RauversionWeb.UserAuth.log_in_user(user)
+ end
+ end
+
+ # back to parent
+ def back(conn, %{"username" => username}) do
+ user = Accounts.get_user_by_username(username)
+
+ case RauversionWeb.UserAuth.fetch_current_user(conn, []) do
+ %{assigns: %{current_user: current_user}} ->
+ case Rauversion.Accounts.is_child_of?(user, current_user.id) do
+ %Rauversion.ConnectedAccounts.ConnectedAccount{} = _connected_account ->
+ conn
+ |> RauversionWeb.UserAuth.log_in_user_conn(user)
+ |> put_session(:parent_user, nil)
+ |> redirect(to: "/#{user.username}")
+
+ _ ->
+ conn
+ |> put_flash(:error, gettext("not allowed"))
+ |> redirect(to: "/#{current_user.username}")
+ end
+
+ _ ->
+ conn
+ |> put_flash(:error, gettext("not allowed"))
+ |> redirect(to: "/#{user.username}")
+ end
+ end
+end
diff --git a/lib/rauversion_web/controllers/user_auth.ex b/lib/rauversion_web/controllers/user_auth.ex
index 4b1a5365..59e26732 100644
--- a/lib/rauversion_web/controllers/user_auth.ex
+++ b/lib/rauversion_web/controllers/user_auth.ex
@@ -38,6 +38,19 @@ defmodule RauversionWeb.UserAuth do
|> redirect(to: user_return_to || signed_in_path(conn))
end
+ def log_in_user_conn(conn, user, params \\ %{}) do
+ token = Accounts.generate_user_session_token(user)
+ user_return_to = get_session(conn, :user_return_to)
+
+ conn
+ |> renew_session()
+ |> put_session(:user_token, token)
+ |> put_session(:live_socket_id, "users_sessions:#{Base.url_encode64(token)}")
+ |> maybe_write_remember_me_cookie(token, params)
+ |> fetch_flash()
+ |> put_flash(:info, "Logged in successfully.")
+ end
+
defp maybe_write_remember_me_cookie(conn, token, %{"remember_me" => "true"}) do
put_resp_cookie(conn, @remember_me_cookie, token, @remember_me_options)
end
diff --git a/lib/rauversion_web/live/account_connect_live/existing_user.ex b/lib/rauversion_web/live/account_connect_live/existing_user.ex
new file mode 100644
index 00000000..91dc7e34
--- /dev/null
+++ b/lib/rauversion_web/live/account_connect_live/existing_user.ex
@@ -0,0 +1,136 @@
+defmodule RauversionWeb.AccountConnectLive.ExistingUser do
+ use RauversionWeb, :live_component
+ alias Rauversion.{Accounts, Repo}
+
+ @impl true
+ def handle_event("search", params, socket) do
+ page = 0
+
+ artists =
+ Accounts.artists()
+ |> Accounts.latests()
+ |> Accounts.search_by_username(params["search"])
+ |> Accounts.not_in(socket.assigns.current_user.id)
+ |> Repo.paginate(page: page, page_size: 12)
+
+ {:noreply, socket |> assign(:collection, artists)}
+ end
+
+ @impl true
+ def handle_event("select-artist", %{"artist" => artist}, socket) do
+ selected_artist = Rauversion.Accounts.get_user!(artist)
+
+ {:noreply,
+ socket
+ |> assign(:selected_artist, selected_artist)
+ |> assign(:collection, [])}
+ end
+
+ @impl true
+ def handle_event("confirm", _, socket) do
+ # TODO: do the theng
+ case Rauversion.ConnectedAccounts.create(%{
+ parent_id: socket.assigns.current_user.id,
+ user_id: socket.assigns.selected_artist.id
+ }) do
+ {:ok, _ac} ->
+ {:noreply,
+ socket
+ |> put_flash(:info, "Artist linked successfully")
+ |> push_patch(to: "/#{socket.assigns.current_user.username}/artists")}
+
+ {:error, changeset} ->
+ errors = convert_changeset_errors(changeset)
+ {:noreply, socket |> assign(:errors, errors)}
+ end
+ end
+
+ @impl true
+ def handle_event("cancel", _, socket) do
+ {:noreply, socket |> assign(:errors, nil) |> assign(:selected_artist, nil)}
+ end
+
+ def convert_changeset_errors(_changeset) do
+ out = "errors connecting the account"
+
+ out
+ end
+
+ @impl true
+ def render(assigns) do
+ ~H"""
+
+ <%= if !@selected_artist do %>
+
+ <%= gettext("Existing artist") %>
+
+
+
Please search for an existing artist.
+
+
+
+ <%= for artist <- @collection do %>
+
+
+ <%= artist.username %>
+
+
+
+ <%= gettext("select") %>
+
+
+
+ <% end %>
+ <% end %>
+
+
+
+ <%= gettext("%{name} is selected", name: @selected_artist.username) %>
+
+
+
+ <%= gettext("Please confirm in order to send the connect invitation request to the artist.") %>
+
+
+
+
+ <%= gettext("Send connect request") %>
+
+
+
+ <%= gettext("cancel") %>
+
+
+
+
<%= @errors %>
+
+
+ """
+ end
+end
diff --git a/lib/rauversion_web/live/account_connect_live/new.ex b/lib/rauversion_web/live/account_connect_live/new.ex
new file mode 100644
index 00000000..07f72bcd
--- /dev/null
+++ b/lib/rauversion_web/live/account_connect_live/new.ex
@@ -0,0 +1,93 @@
+defmodule RauversionWeb.AccountConnectLive.New do
+ use RauversionWeb, :live_view
+ on_mount RauversionWeb.UserLiveAuth
+
+ @impl true
+ def mount(_params, _session, socket) do
+ socket =
+ socket
+ |> assign(:op, nil)
+
+ {:ok, socket}
+ end
+
+ @impl true
+ def handle_event("add-existing", _, socket) do
+ {:noreply, socket |> assign(:op, "existing")}
+ end
+
+ @impl true
+ def handle_event("add-new", _, socket) do
+ changeset = Rauversion.Accounts.change_user_profile(%Rauversion.Accounts.User{}, %{})
+ {:noreply, socket |> assign(:op, "new") |> assign(:changeset, changeset)}
+ end
+
+ def default_class do
+ "pointer-events-auto w-[21rem] rounded-lg bg-white dark:bg-gray-900 p-4 text-[0.8125rem] leading-5 shadow-xl shadow-black/5 hover:bg-slate-50 ring-1 ring-slate-700/10"
+ end
+
+ def selected_class do
+ "pointer-events-auto w-[21rem] rounded-lg bg-white dark:bg-gray-900 p-4 text-[0.8125rem] leading-5 shadow-xl shadow-black/5 hover:bg-slate-50 ring-2 ring-indigo-600"
+ end
+
+ def option(assigns) do
+ ~H"""
+
+
+
+ <%= @label %>
+
+
+
+
+
+
+
Last message sent an hour ago
+
1200 users
+
+ """
+ end
+
+ @impl true
+ def render(assigns) do
+ ~H"""
+
+
+
+
+ <.option label={gettext("New artist")} action="add-new" selected={@op == "new"} />
+ <.option
+ label={gettext("Existing Artist")}
+ action="add-existing"
+ selected={@op == "existing"}
+ />
+
+
+
+ <%= live_component(RauversionWeb.AccountConnectLive.NewUser,
+ id: "new-user-connect",
+ changeset: @changeset,
+ current_user: @current_user
+ ) %>
+
+
+
+ <%= live_component(RauversionWeb.AccountConnectLive.ExistingUser,
+ id: "existing-user-connect",
+ current_user: @current_user,
+ collection: [],
+ selected_artist: nil,
+ errors: ""
+ ) %>
+
+
+
+
+ """
+ end
+end
diff --git a/lib/rauversion_web/live/account_connect_live/new_user.ex b/lib/rauversion_web/live/account_connect_live/new_user.ex
new file mode 100644
index 00000000..922bbf36
--- /dev/null
+++ b/lib/rauversion_web/live/account_connect_live/new_user.ex
@@ -0,0 +1,118 @@
+defmodule RauversionWeb.AccountConnectLive.NewUser do
+ use RauversionWeb, :live_component
+
+ def handle_event("validate", %{"user" => user_params}, socket) do
+ # socket.assigns.changeset
+ changeset =
+ %Rauversion.Accounts.User{}
+ |> Rauversion.Accounts.change_user_profile(user_params)
+ |> Map.put(:action, :validate)
+
+ IO.inspect(user_params)
+ IO.inspect(changeset)
+
+ {:noreply, assign(socket, :changeset, changeset)}
+ end
+
+ def handle_event("save", %{"user" => user_params}, socket) do
+ rand = SecureRandom.uuid()
+
+ user_params =
+ Map.merge(user_params, %{
+ "email" => "internal+#{rand}@xxx.com",
+ "password" => SecureRandom.urlsafe_base64(10),
+ "type" => "artist"
+ })
+
+ # will auto atictivate the assoc (state: "active")
+ case Rauversion.Accounts.register_user(user_params) do
+ {:ok, user} ->
+ case Rauversion.ConnectedAccounts.create(%{
+ user_id: user.id,
+ parent_id: socket.assigns.current_user.id,
+ state: "active"
+ }) do
+ {:ok, _connected} ->
+ Rauversion.Accounts.update_user_type(user, "artist")
+
+ {:noreply,
+ socket
+ |> put_flash(:info, "Artist created successfully")
+ |> push_navigate(to: "/#{socket.assigns.current_user.username}/artists")}
+
+ _ ->
+ {:noreply, socket}
+ end
+
+ e ->
+ {:noreply, socket |> assign(changeset: e)}
+ end
+ end
+
+ def render(assigns) do
+ ~H"""
+
+
+ <.form
+ :let={f}
+ for={@changeset}
+ phx-target={@myself}
+ id="hosts-managers-form"
+ phx-change="validate"
+ phx-submit="save"
+ >
+
+ <%= gettext("New artist") %>
+
+
+
Please specify an account to add.
+
+
+
+
+ <%= Application.get_env(:rauversion, :domain) %>/
+
+ <%= text_input(f, :username,
+ required: true,
+ autocomplete: "off",
+ class:
+ "autofill:!bg-yellow-200 dark:bg-gray-900 appearance-none block w-full px-3 py-2 border border-gray-300 dark:border-gray-700 flex-1 block w-full min-w-0 border-blue-gray-300 rounded-none rounded-r-md shadow-sm placeholder-gray-400 dark:placeholder-gray-600 focus:outline-none focus:ring-brand-500 focus:border-brand-500 sm:text-sm"
+ ) %>
+
+ <%= error_tag(f, :username) %>
+
+
+
+
+ <%= form_input_renderer(
+ f,
+ %{
+ type: :text_input,
+ name: :first_name,
+ wrapper_class: "sm:col-span-6"
+ }
+ ) %>
+
+ <%= form_input_renderer(
+ f,
+ %{
+ type: :text_input,
+ name: :last_name,
+ wrapper_class: "sm:col-span-6"
+ }
+ ) %>
+
+
+ <%= submit(gettext("Save"),
+ phx_disable_with: gettext("Saving..."),
+ class:
+ "inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-brand-600 hover:bg-brand-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand-500"
+ ) %>
+
+
+
+
+
+ """
+ end
+end
diff --git a/lib/rauversion_web/live/articles_live/components/sidebar_form_component.ex b/lib/rauversion_web/live/articles_live/components/sidebar_form_component.ex
index f2dafd62..a986d6de 100644
--- a/lib/rauversion_web/live/articles_live/components/sidebar_form_component.ex
+++ b/lib/rauversion_web/live/articles_live/components/sidebar_form_component.ex
@@ -181,7 +181,9 @@ defmodule RauversionWeb.ArticlesLive.SidebarFormComponent do
<% end %>
<%= for {_ref, msg, } <- @uploads.cover.errors do %>
- <%= Phoenix.Naming.humanize(msg) %>
+
+ <%= Phoenix.Naming.humanize(msg) %>
+
<% end %>
diff --git a/lib/rauversion_web/live/event_streaming/show.ex b/lib/rauversion_web/live/event_streaming/show.ex
index e6672c2d..fea161e9 100644
--- a/lib/rauversion_web/live/event_streaming/show.ex
+++ b/lib/rauversion_web/live/event_streaming/show.ex
@@ -41,7 +41,7 @@ defmodule RauversionWeb.EventsStreamingLive.Show do
_ ->
socket
|> put_flash(:error, "Event not found")
- |> push_redirect(to: "/")
+ |> push_navigate(to: "/")
end
end
diff --git a/lib/rauversion_web/live/events_live/components/forms/attendees_component.ex b/lib/rauversion_web/live/events_live/components/forms/attendees_component.ex
index f9a0f312..3c3d85f9 100644
--- a/lib/rauversion_web/live/events_live/components/forms/attendees_component.ex
+++ b/lib/rauversion_web/live/events_live/components/forms/attendees_component.ex
@@ -13,16 +13,6 @@ defmodule RauversionWeb.Live.EventsLive.Components.AttendeesComponent do
|> assign(:open_modal, false)}
end
- defp list_posts(event) do
- Rauversion.Events.list_tickets(event)
- # Events.list_event() |> Repo.preload(user: :avatar_blob)
- end
-
- def new_invitation_changeset(%InviteTicketForm{} = invitation, attrs \\ %{}) do
- invitation
- |> InviteTicketForm.changeset(attrs)
- end
-
@impl true
def handle_event("validate", %{"invite_ticket_form" => event_params}, socket) do
changeset =
@@ -33,16 +23,19 @@ defmodule RauversionWeb.Live.EventsLive.Components.AttendeesComponent do
{:noreply, assign(socket, :changeset, changeset)}
end
+ @impl true
def handle_event("open_modal", %{"value" => ""}, socket) do
{:noreply,
assign(socket, :open_modal, true)
|> assign(:invitation_changeset, new_invitation_changeset(%InviteTicketForm{}))}
end
+ @impl true
def handle_event("close-modal", _, socket) do
{:noreply, assign(socket, :open_modal, false)}
end
+ @impl true
def handle_event(
"save",
%{
@@ -67,13 +60,15 @@ defmodule RauversionWeb.Live.EventsLive.Components.AttendeesComponent do
gettext("Invitation for event: %{title}", %{title: socket.assigns.event.title}),
event: socket.assigns.event
) do
- # IO.inspect(result)
+ IO.inspect("REDIRECT TOOOOO: /events/#{socket.assigns.event.slug}/edit/attendees ")
+ IO.inspect(gettext("Invitation sent"))
+
{:noreply,
socket
|> assign(:open_modal, false)
|> assign(:status, :success)
|> put_flash(:info, gettext("Invitation sent"))
- |> push_redirect(to: "/events/#{socket.assigns.event.slug}/edit/attendees")}
+ |> push_patch(to: ~p"/events/#{socket.assigns.event.slug}/edit/attendees")}
# |> assign(:attendees, list_posts(socket.assigns.event))}
else
@@ -82,18 +77,22 @@ defmodule RauversionWeb.Live.EventsLive.Components.AttendeesComponent do
socket
|> put_flash(:error, "Fail to create chchc.")
|> assign(:changeset, changeset)
- |> assign(:status, :error)}
+ |> assign(:status, :error)
+ |> push_patch(to: ~p"/events/#{socket.assigns.event.slug}/edit/attendees")}
{:error, _} ->
{:noreply,
socket
|> put_flash(:error, "Failed to authenticate.")
- |> assign(:status, :error)}
+ |> assign(:status, :error)
+ |> push_patch(to: ~p"/events/#{socket.assigns.event.slug}/edit/attendees")}
_any ->
{:noreply,
socket
- |> assign(:status, :error)}
+ |> put_flash(:error, "Error sending invitation.")
+ |> assign(:status, :error)
+ |> push_patch(to: ~p"/events/#{socket.assigns.event.slug}/edit/attendees")}
end
# save_repost(socket, socket.assigns.action, repost_params)
@@ -112,6 +111,16 @@ defmodule RauversionWeb.Live.EventsLive.Components.AttendeesComponent do
end
end
+ defp list_posts(event) do
+ Rauversion.Events.list_tickets(event)
+ # Events.list_event() |> Repo.preload(user: :avatar_blob)
+ end
+
+ def new_invitation_changeset(%InviteTicketForm{} = invitation, attrs \\ %{}) do
+ invitation
+ |> InviteTicketForm.changeset(attrs)
+ end
+
@impl true
def render(assigns) do
~H"""
diff --git a/lib/rauversion_web/live/events_live/components/forms/hosts_uploader_component.ex b/lib/rauversion_web/live/events_live/components/forms/hosts_uploader_component.ex
index 323c7793..29cee620 100644
--- a/lib/rauversion_web/live/events_live/components/forms/hosts_uploader_component.ex
+++ b/lib/rauversion_web/live/events_live/components/forms/hosts_uploader_component.ex
@@ -41,7 +41,7 @@ defmodule RauversionWeb.EventsLive.Components.HostsUploaderComponent do
:noreply,
socket
|> put_flash(:info, "Host updated successfully")
- |> push_navigate(to: ~p"/events/#{socket.assigns.event.slug}/edit/hosts")
+ |> push_patch(to: ~p"/events/#{socket.assigns.event.slug}/edit/hosts")
}
{:error, %Ecto.Changeset{} = changeset} ->
diff --git a/lib/rauversion_web/live/events_live/components/forms/recordings_component.ex b/lib/rauversion_web/live/events_live/components/forms/recordings_component.ex
index 91ede639..9dfd9eca 100644
--- a/lib/rauversion_web/live/events_live/components/forms/recordings_component.ex
+++ b/lib/rauversion_web/live/events_live/components/forms/recordings_component.ex
@@ -90,7 +90,7 @@ defmodule RauversionWeb.Live.EventsLive.Components.RecordingsComponent do
{
:noreply,
socket
- |> put_flash(:info, "Event created successfully")
+ |> put_flash(:info, "Event recording created successfully")
|> assign(:event_recordings, list_recordings(socket.assigns.event))
|> assign(:display_form, false)
# |> push_redirect(to: "/events/#{event.slug}/edit")
diff --git a/lib/rauversion_web/live/events_live/components/forms/scheduling_form_component.ex b/lib/rauversion_web/live/events_live/components/forms/scheduling_form_component.ex
index 9bd8dc03..2b3326fa 100644
--- a/lib/rauversion_web/live/events_live/components/forms/scheduling_form_component.ex
+++ b/lib/rauversion_web/live/events_live/components/forms/scheduling_form_component.ex
@@ -99,7 +99,7 @@ defmodule RauversionWeb.Live.EventsLive.Components.SchedulingFormComponent do
:noreply,
socket
|> put_flash(:info, "Event updated successfully")
- # |> push_redirect(to: socket.assigns.return_to)
+ |> push_patch(to: "/events/#{socket.assigns.event.slug}/edit/schedule")
}
{:error, %Ecto.Changeset{} = changeset} ->
diff --git a/lib/rauversion_web/live/events_live/components/forms/streaming_component.ex b/lib/rauversion_web/live/events_live/components/forms/streaming_component.ex
index be452b93..b148e9ad 100644
--- a/lib/rauversion_web/live/events_live/components/forms/streaming_component.ex
+++ b/lib/rauversion_web/live/events_live/components/forms/streaming_component.ex
@@ -34,7 +34,7 @@ defmodule RauversionWeb.Live.EventsLive.Components.StreamingComponent do
:noreply,
socket
|> put_flash(:info, "Event updated successfully")
- |> push_redirect(to: "/events/#{event.slug}/edit/streaming")
+ |> push_navigate(to: "/events/#{event.slug}/edit/streaming")
}
{:error, %Ecto.Changeset{} = changeset} ->
diff --git a/lib/rauversion_web/live/events_live/components/hosts_component.ex b/lib/rauversion_web/live/events_live/components/hosts_component.ex
index 94ef325c..b855bd86 100644
--- a/lib/rauversion_web/live/events_live/components/hosts_component.ex
+++ b/lib/rauversion_web/live/events_live/components/hosts_component.ex
@@ -208,6 +208,9 @@ defmodule RauversionWeb.Live.EventsLive.Components.HostsComponent do
event_params
|> Map.put("avatar", files_for(socket, :avatar))
+ require IEx
+ IEx.pry()
+
case EventHosts.update_event_host(socket.assigns.changeset.data, event_params) do
{:ok, _event} ->
{
diff --git a/lib/rauversion_web/live/events_live/new.ex b/lib/rauversion_web/live/events_live/new.ex
index dcb4406c..f82fff35 100644
--- a/lib/rauversion_web/live/events_live/new.ex
+++ b/lib/rauversion_web/live/events_live/new.ex
@@ -1,6 +1,6 @@
defmodule RauversionWeb.EventsLive.New do
use RauversionWeb, :live_view
- on_mount RauversionWeb.UserLiveAuth
+ on_mount(RauversionWeb.UserLiveAuth)
alias Rauversion.{Events}
@@ -83,7 +83,7 @@ defmodule RauversionWeb.EventsLive.New do
{:noreply,
socket
|> put_flash(:info, "Event created successfully")
- |> push_redirect(to: "/events/#{event.slug}/edit")}
+ |> push_patch(to: ~p"/events/#{event.slug}/edit")}
{:error, %Ecto.Changeset{} = changeset} ->
# IO.inspect(changeset)
@@ -163,7 +163,7 @@ defmodule RauversionWeb.EventsLive.New do
nil ->
socket
|> put_flash(:error, "Resource not available")
- |> push_redirect(to: "/events")
+ |> push_navigate(to: "/events")
end
end
end
diff --git a/lib/rauversion_web/live/live_helpers.ex b/lib/rauversion_web/live/live_helpers.ex
index 47b8fa0d..4d0ecbc6 100644
--- a/lib/rauversion_web/live/live_helpers.ex
+++ b/lib/rauversion_web/live/live_helpers.ex
@@ -633,7 +633,9 @@ defmodule RauversionWeb.LiveHelpers do
<% end %>
<%= for {_ref, msg, } <- @field.uploads[@name].errors do %>
- <%= Phoenix.Naming.humanize(msg) %>
+
+ <%= Phoenix.Naming.humanize(msg) %>
+
<% end %>
@@ -741,4 +743,12 @@ defmodule RauversionWeb.LiveHelpers do
_ -> date
end
end
+
+ def my_music_label(current_user) do
+ if Rauversion.Accounts.is_label?(current_user) do
+ gettext("My label")
+ else
+ gettext("My Music")
+ end
+ end
end
diff --git a/lib/rauversion_web/live/playlist_live/form_component.ex b/lib/rauversion_web/live/playlist_live/form_component.ex
index b8d4ddf5..970d549b 100644
--- a/lib/rauversion_web/live/playlist_live/form_component.ex
+++ b/lib/rauversion_web/live/playlist_live/form_component.ex
@@ -121,7 +121,7 @@ defmodule RauversionWeb.PlaylistLive.FormComponent do
{:noreply,
socket
|> put_flash(:info, "Playlist updated successfully")
- |> push_redirect(to: socket.assigns.return_to)}
+ |> push_patch(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, :changeset, changeset)}
diff --git a/lib/rauversion_web/live/profile_live/components/artists_list.ex b/lib/rauversion_web/live/profile_live/components/artists_list.ex
new file mode 100644
index 00000000..84d4c63a
--- /dev/null
+++ b/lib/rauversion_web/live/profile_live/components/artists_list.ex
@@ -0,0 +1,72 @@
+defmodule RauversionWeb.ProfileLive.Components.ArtistsList do
+ use RauversionWeb, :live_component
+
+ def get_artists(user) do
+ Rauversion.Accounts.active_connected_accounts(user)
+ end
+
+ def render(assigns) do
+ ~H"""
+
+
+
+
+ Artists
+
+
+ <%= if @current_user.id == @profile.id do %>
+ <.link
+ patch="/accounts/connect"
+ class="inline-flex justify-between dark:border-2 dark:border-white rounded-lg py-3 px-5 bg-black text-white block font-medium"
+ >
+
+
+
+
Add artist
+
+ <% end %>
+
+
+
+ <%= for account <- get_artists(@current_user) do %>
+
+
+ <%= img_tag(
+ Rauversion.Accounts.avatar_url(account.user, :small),
+ class: "h-full w-full object-cover object-center"
+ ) %>
+
+
+
+ <%= live_redirect(
+ to: Routes.profile_index_path(@socket, :index, account.user.username)
+ ) do %>
+ <%= account.user.username %>
+ <% end %>
+
+
+ <% end %>
+
+
+
+
+
+ """
+ end
+end
diff --git a/lib/rauversion_web/live/profile_live/components/menu_component.ex b/lib/rauversion_web/live/profile_live/components/menu_component.ex
index 31c407b2..2aa3e56b 100644
--- a/lib/rauversion_web/live/profile_live/components/menu_component.ex
+++ b/lib/rauversion_web/live/profile_live/components/menu_component.ex
@@ -30,36 +30,47 @@ defmodule RauversionWeb.ProfileLive.MenuComponent do
<%= if @current_user && @current_user.id != @profile.id do %>
-
- <%= if @user_follow do %>
- <%= link to: "#", phx_click: "unfollow-user", class: "inline-flex items-center px-4 py-2 border border-brand-300 shadow-sm text-base font-medium rounded-md text-brand-700 bg-white hover:bg-brand-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" do %>
-
-
-
-
<%= gettext("Following") %>
- <% end %>
- <% else %>
- <%= link to: "#", phx_click: "follow-user", class: "inline-flex items-center px-4 py-2 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-brand-600 hover:bg-brand-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand-500" do %>
-
-
-
-
<%= gettext("Follow") %>
- <% end %>
+
+ <%= if Rauversion.Accounts.is_child_of?(@current_user, @profile.id) do %>
+
+ <%= gettext("act on behalf") %>
+
<% end %>
+
+
+ <%= if @user_follow do %>
+ <%= link to: "#", phx_click: "unfollow-user", class: "inline-flex items-center px-4 py-2 border border-brand-300 shadow-sm text-base font-medium rounded-md text-brand-700 bg-white hover:bg-brand-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" do %>
+
+
+
+
<%= gettext("Following") %>
+ <% end %>
+ <% else %>
+ <%= link to: "#", phx_click: "follow-user", class: "inline-flex items-center px-4 py-2 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-brand-600 hover:bg-brand-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand-500" do %>
+
+
+
+
<%= gettext("Follow") %>
+ <% end %>
+ <% end %>
+
<% end %>
diff --git a/lib/rauversion_web/live/profile_live/index.ex b/lib/rauversion_web/live/profile_live/index.ex
index 34b6e492..3cdec43c 100644
--- a/lib/rauversion_web/live/profile_live/index.ex
+++ b/lib/rauversion_web/live/profile_live/index.ex
@@ -1,6 +1,6 @@
defmodule RauversionWeb.ProfileLive.Index do
use RauversionWeb, :live_view
- on_mount RauversionWeb.UserLiveAuth
+ on_mount(RauversionWeb.UserLiveAuth)
alias Rauversion.{Accounts, Tracks, UserFollows}
@@ -30,12 +30,6 @@ defmodule RauversionWeb.ProfileLive.Index do
nil
end
- # @impl true
- # def handle_info({Tracks, [:tracks, _], _}, socket) do
- # IO.puts("OLIII")
- # {:noreply, assign(socket, :tracks, Tracks.list_tracks())}
- # end
-
@impl true
def handle_event("follow-user", %{}, socket) do
UserFollows.create_user_follow(%{
@@ -166,7 +160,18 @@ defmodule RauversionWeb.ProfileLive.Index do
|> assign(:data, menu(socket, id, "insights"))
end
- defp menu(socket, id, kind) do
+ defp apply_action(socket, :artists, %{"username" => id}) do
+ socket
+ |> assign(:title, "artists")
+ |> assign(:page_title, gettext("%{id}'s artists on Rauversion", id: id))
+ |> assign(:data, menu(socket, id, "insights"))
+ end
+
+ # TODO: we should do a menu for FAN?
+
+ # menu for artists
+ defp menu(socket = %{assigns: %{profile: %Rauversion.Accounts.User{label: label}}}, id, kind)
+ when is_nil(label) or label == false do
[
%{
name: "All",
@@ -206,4 +211,27 @@ defmodule RauversionWeb.ProfileLive.Index do
}
]
end
+
+ # menu for labels
+ defp menu(
+ socket = %{assigns: %{profile: %Rauversion.Accounts.User{label: label}}},
+ id,
+ kind
+ )
+ when not is_nil(label) do
+ [
+ %{
+ name: "Artists",
+ selected: kind == "artists",
+ url: Routes.profile_index_path(socket, :artists, id),
+ kind: kind
+ },
+ %{
+ name: "Music",
+ url: Routes.profile_index_path(socket, :albums, id),
+ selected: kind == "albums",
+ kind: kind
+ }
+ ]
+ end
end
diff --git a/lib/rauversion_web/live/profile_live/index.html.heex b/lib/rauversion_web/live/profile_live/index.html.heex
index 855d8020..83f55d37 100644
--- a/lib/rauversion_web/live/profile_live/index.html.heex
+++ b/lib/rauversion_web/live/profile_live/index.html.heex
@@ -20,16 +20,30 @@
<%= case @title do
# TODO: this is the same as all, but eventually will list all only the pinned ones
"all" ->
- live_component(
- RauversionWeb.TrackLive.TrackListComponent,
- id: "all-track-#{@profile.id}",
- profile: @profile,
- title: @title,
- tracks: [],
- track_meta: %{},
- page: 1,
- current_user: assigns[:current_user]
- )
+ if Rauversion.Accounts.is_label?(@profile) do
+ live_component(
+ RauversionWeb.ProfileLive.Components.ArtistsList,
+ id: "profile-insights-#{@profile.id}",
+ profile: @profile,
+ title: @title,
+ page: 1,
+ playlists: [],
+ track_meta: %{},
+ page: 1,
+ current_user: @current_user
+ )
+ else
+ live_component(
+ RauversionWeb.TrackLive.TrackListComponent,
+ id: "all-track-#{@profile.id}",
+ profile: @profile,
+ title: @title,
+ tracks: [],
+ track_meta: %{},
+ page: 1,
+ current_user: assigns[:current_user]
+ )
+ end
"tracks_all" ->
live_component(
@@ -96,6 +110,19 @@
current_user: @current_user
)
+ "artists" ->
+ live_component(
+ RauversionWeb.ProfileLive.Components.ArtistsList,
+ id: "profile-insights-#{@profile.id}",
+ profile: @profile,
+ title: @title,
+ page: 1,
+ playlists: [],
+ track_meta: %{},
+ page: 1,
+ current_user: @current_user
+ )
+
_ ->
"no match on #{@title}"
end %>
diff --git a/lib/rauversion_web/live/repost_live/form_component.ex b/lib/rauversion_web/live/repost_live/form_component.ex
index d041aa48..5e3b429b 100644
--- a/lib/rauversion_web/live/repost_live/form_component.ex
+++ b/lib/rauversion_web/live/repost_live/form_component.ex
@@ -33,7 +33,7 @@ defmodule RauversionWeb.RepostLive.FormComponent do
{:noreply,
socket
|> put_flash(:info, "Repost updated successfully")
- |> push_redirect(to: socket.assigns.return_to)}
+ |> push_patch(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, :changeset, changeset)}
@@ -46,7 +46,7 @@ defmodule RauversionWeb.RepostLive.FormComponent do
{:noreply,
socket
|> put_flash(:info, "Repost created successfully")
- |> push_redirect(to: socket.assigns.return_to)}
+ |> push_navigate(to: socket.assigns.return_to)}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign(socket, changeset: changeset)}
diff --git a/lib/rauversion_web/live/track_live/components/edit_form_component.ex b/lib/rauversion_web/live/track_live/components/edit_form_component.ex
index 06816235..5012d1ad 100644
--- a/lib/rauversion_web/live/track_live/components/edit_form_component.ex
+++ b/lib/rauversion_web/live/track_live/components/edit_form_component.ex
@@ -63,7 +63,7 @@ defmodule RauversionWeb.TrackLive.EditFormComponent do
{:noreply,
socket
|> put_flash(:info, "Cover updated successfully")
- |> push_redirect(to: "/tracks/#{socket.assigns.track.id}")}
+ |> push_patch(to: "/tracks/#{socket.assigns.track.id}")}
# {:noreply, assign(socket, :prompt, value)}
end
diff --git a/lib/rauversion_web/live/track_live/components/supporters.ex b/lib/rauversion_web/live/track_live/components/supporters.ex
index f48c65a1..d5dca2ea 100644
--- a/lib/rauversion_web/live/track_live/components/supporters.ex
+++ b/lib/rauversion_web/live/track_live/components/supporters.ex
@@ -4,9 +4,10 @@ defmodule RauversionWeb.TrackLive.Components.Supporters do
def render(assigns = %{kind: "albums", supporters: _supporters}) do
~H"""
- <%= if Enum.any?(@supporters) do %>
-
Supporters
- <% end %>
+
+
+ <%= gettext("Supporters") %>
+
<%= for supporter <- @supporters do %>
@@ -28,7 +29,9 @@ defmodule RauversionWeb.TrackLive.Components.Supporters do
def render(assigns = %{kind: "tracks", supporters: _supporters}) do
~H"""
-
<%= gettext("Supporters") %>
+
+ <%= gettext("Supporters") %>
+
<%= for supporter <- @supporters do %>
<%= live_redirect to: Routes.profile_index_path(@socket, :index, supporter.track_order.purchase_order.user.username) do %>
diff --git a/lib/rauversion_web/live/track_live/components/upload_form_component.ex b/lib/rauversion_web/live/track_live/components/upload_form_component.ex
index d15f2404..e919ee9c 100644
--- a/lib/rauversion_web/live/track_live/components/upload_form_component.ex
+++ b/lib/rauversion_web/live/track_live/components/upload_form_component.ex
@@ -36,7 +36,9 @@ defmodule RauversionWeb.TrackLive.UploadFormComponent do
-
+
@@ -59,7 +61,7 @@ defmodule RauversionWeb.TrackLive.UploadFormComponent do
<%= gettext("Upload a Audio file") %>
- <.live_file_input upload={@uploads.audio} class="hidden" />
+ <.live_file_input upload={@uploads.audio} class="invisible" />
<% # = live_file_input @uploads.audio, class: "hidden" %>
<%= gettext("or drag and drop") %>
@@ -76,8 +78,10 @@ defmodule RauversionWeb.TrackLive.UploadFormComponent do
<% end %>
<%= for {_ref, msg, } <- @uploads.audio.errors do %>
- <%= Phoenix.Naming.humanize(msg) %>
- <% end %>
+
+ <%= Phoenix.Naming.humanize(msg) %>
+
+ <% end %>
diff --git a/lib/rauversion_web/live/track_live/form_component.ex b/lib/rauversion_web/live/track_live/form_component.ex
index 1adc34aa..0c2b9839 100644
--- a/lib/rauversion_web/live/track_live/form_component.ex
+++ b/lib/rauversion_web/live/track_live/form_component.ex
@@ -101,7 +101,7 @@ defmodule RauversionWeb.TrackLive.FormComponent do
{:noreply,
response
|> put_flash(:info, "Track updated successfully")
- |> push_redirect(to: socket.assigns.return_to)}
+ |> push_patch(to: socket.assigns.return_to)}
{:error, response} ->
{:noreply, response}
diff --git a/lib/rauversion_web/live/usersettings_live/components/email_form.ex b/lib/rauversion_web/live/user_settings_live/components/email_form.ex
similarity index 98%
rename from lib/rauversion_web/live/usersettings_live/components/email_form.ex
rename to lib/rauversion_web/live/user_settings_live/components/email_form.ex
index 56b2a479..6110f1b9 100644
--- a/lib/rauversion_web/live/usersettings_live/components/email_form.ex
+++ b/lib/rauversion_web/live/user_settings_live/components/email_form.ex
@@ -1,4 +1,4 @@
-defmodule RauversionWeb.UsersettingsLive.EmailForm do
+defmodule RauversionWeb.UserSettingsLive.EmailForm do
use RauversionWeb, :live_component
def render(%{changeset: _changeset} = assigns) do
diff --git a/lib/rauversion_web/live/usersettings_live/components/integrations_form.ex b/lib/rauversion_web/live/user_settings_live/components/integrations_form.ex
similarity index 98%
rename from lib/rauversion_web/live/usersettings_live/components/integrations_form.ex
rename to lib/rauversion_web/live/user_settings_live/components/integrations_form.ex
index 8f173e31..27bb558b 100644
--- a/lib/rauversion_web/live/usersettings_live/components/integrations_form.ex
+++ b/lib/rauversion_web/live/user_settings_live/components/integrations_form.ex
@@ -1,4 +1,4 @@
-defmodule RauversionWeb.UsersettingsLive.IntegrationsForm do
+defmodule RauversionWeb.UserSettingsLive.IntegrationsForm do
use RauversionWeb, :live_component
alias Rauversion.Repo
diff --git a/lib/rauversion_web/live/usersettings_live/components/invitations.ex b/lib/rauversion_web/live/user_settings_live/components/invitations.ex
similarity index 94%
rename from lib/rauversion_web/live/usersettings_live/components/invitations.ex
rename to lib/rauversion_web/live/user_settings_live/components/invitations.ex
index dbe0b717..0dad0712 100644
--- a/lib/rauversion_web/live/usersettings_live/components/invitations.ex
+++ b/lib/rauversion_web/live/user_settings_live/components/invitations.ex
@@ -1,4 +1,4 @@
-defmodule RauversionWeb.UsersettingsLive.Invitations do
+defmodule RauversionWeb.UserSettingsLive.Invitations do
use RauversionWeb, :live_component
alias Rauversion.Accounts
@@ -28,26 +28,26 @@ defmodule RauversionWeb.UsersettingsLive.Invitations do
{:noreply,
socket
|> put_flash(:info, gettext("Invitation sent successfully"))
- |> push_redirect(to: "/users/settings/invitations")}
+ |> push_navigate(to: "/users/settings/invitations")}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply,
assign(socket, :changeset, changeset)
|> put_flash(:error, gettext("Error, Invitation was not sent"))
- |> push_redirect(to: "/users/settings/invitations")}
+ |> push_navigate(to: "/users/settings/invitations")}
_ ->
{:noreply,
socket
|> put_flash(:error, gettext("There was something wrong sending this invitation"))
- |> push_redirect(to: "/users/settings/invitations")}
+ |> push_navigate(to: "/users/settings/invitations")}
end
_user ->
{:noreply,
socket
|> put_flash(:error, gettext("Invitation not sent, this person already exists"))
- |> push_redirect(to: "/users/settings/invitations")}
+ |> push_navigate(to: "/users/settings/invitations")}
end
end
diff --git a/lib/rauversion_web/live/user_settings_live/components/label_form.ex b/lib/rauversion_web/live/user_settings_live/components/label_form.ex
new file mode 100644
index 00000000..7257b66f
--- /dev/null
+++ b/lib/rauversion_web/live/user_settings_live/components/label_form.ex
@@ -0,0 +1,82 @@
+defmodule RauversionWeb.UserSettingsLive.LabelForm do
+ use RauversionWeb, :live_component
+
+ def render(%{changeset: _changeset} = assigns) do
+ ~H"""
+
+
+
+ <%= if Application.get_env(:rauversion, :disabled_label_registrations) == "false" do %>
+ <.form
+ :let={f}
+ for={@changeset}
+ id="update_profile"
+ phx-target={@target}
+ phx-change="validate"
+ phx-submit="save"
+ multipart={true}
+ class="space-y-8 divide-y divide-gray-200 dark:divide-gray-800"
+ >
+ <%= if @changeset.action do %>
+
+
<%= gettext("Oops, something went wrong! Please check the errors below.") %>
+
+ <% end %>
+
+ <%= hidden_input(f, :action, name: "action", value: "update_label") %>
+
+
+
+
+ <%= gettext("Activate label") %>
+
+
+ <%= gettext("When enabled the account will became a label.") %>
+
+
+
+
+ <%= checkbox(f, :label,
+ class: "h-4 w-4 border-gray-300 text-brand-600 focus:ring-brand-500"
+ ) %>
+
+
+
+
+ <%= submit(gettext("Change profile information"),
+ phx_disable_with: gettext("Saving..."),
+ class:
+ "bg-white py-2 px-4 border border-gray-300 dark:text-blue-gray-100 dark:bg-gray-900 rounded-md shadow-sm text-sm font-medium text-blue-gray-900 hover:bg-blue-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
+ ) %>
+
+
+ <% else %>
+
+ Welcome to Rauversion, a music streaming platform that offers a unique opportunity for music labels to showcase their artists and connect with a global audience.
+ If you're interested in becoming a label on Rauversion, we invite you to apply for a label account.
+
+
+
+
+
+ As a label on Rauversion, you'll have access to a range of tools and features that allow you to promote your artists,
+ track their performance, and connect with fans around the world. Our platform is designed to make it easy for labels to reach new audiences and build their brands online.
+
+ To apply for a label account, please fill out our application form and provide some basic information about your label and the artists you represent. We'll review your application and
+ get back to you as soon as possible with next steps.
+
+
+ Thank you for your interest in Rauversion, and we look forward to working with you to bring great music to the world!
+
+ <% end %>
+
+ """
+ end
+end
diff --git a/lib/rauversion_web/live/usersettings_live/components/nav_bar.ex b/lib/rauversion_web/live/user_settings_live/components/nav_bar.ex
similarity index 89%
rename from lib/rauversion_web/live/usersettings_live/components/nav_bar.ex
rename to lib/rauversion_web/live/user_settings_live/components/nav_bar.ex
index 39cddc61..8ddbd6b7 100644
--- a/lib/rauversion_web/live/usersettings_live/components/nav_bar.ex
+++ b/lib/rauversion_web/live/user_settings_live/components/nav_bar.ex
@@ -16,6 +16,12 @@ defmodule RauversionWeb.UserSettingsLive.NavBar do
title: gettext("Change Email"),
sub: gettext("Change Email information.")
},
+ %{
+ to: "/users/settings/labels",
+ namespace: :labels,
+ title: gettext("Rauversion for Labels"),
+ sub: gettext("Manage your label details.")
+ },
%{
to: "/users/settings/security",
namespace: :security,
@@ -202,6 +208,24 @@ defmodule RauversionWeb.UserSettingsLive.NavBar do
"""
+ :labels ->
+ ~H"""
+
+
+
+ """
+
_ ->
nil
end
diff --git a/lib/rauversion_web/live/usersettings_live/components/notifications_form.ex b/lib/rauversion_web/live/user_settings_live/components/notifications_form.ex
similarity index 98%
rename from lib/rauversion_web/live/usersettings_live/components/notifications_form.ex
rename to lib/rauversion_web/live/user_settings_live/components/notifications_form.ex
index 30b759a5..1d8f55e1 100644
--- a/lib/rauversion_web/live/usersettings_live/components/notifications_form.ex
+++ b/lib/rauversion_web/live/user_settings_live/components/notifications_form.ex
@@ -1,4 +1,4 @@
-defmodule RauversionWeb.UsersettingsLive.NotificationsForm do
+defmodule RauversionWeb.UserSettingsLive.NotificationsForm do
use RauversionWeb, :live_component
def notification_inputs() do
diff --git a/lib/rauversion_web/live/usersettings_live/components/profile_form.ex b/lib/rauversion_web/live/user_settings_live/components/profile_form.ex
similarity index 99%
rename from lib/rauversion_web/live/usersettings_live/components/profile_form.ex
rename to lib/rauversion_web/live/user_settings_live/components/profile_form.ex
index 8e413e15..b61ff0fc 100644
--- a/lib/rauversion_web/live/usersettings_live/components/profile_form.ex
+++ b/lib/rauversion_web/live/user_settings_live/components/profile_form.ex
@@ -1,4 +1,4 @@
-defmodule RauversionWeb.UsersettingsLive.ProfileForm do
+defmodule RauversionWeb.UserSettingsLive.ProfileForm do
use RauversionWeb, :live_component
def render(%{changeset: _changeset} = assigns) do
diff --git a/lib/rauversion_web/live/usersettings_live/components/security_form.ex b/lib/rauversion_web/live/user_settings_live/components/security_form.ex
similarity index 98%
rename from lib/rauversion_web/live/usersettings_live/components/security_form.ex
rename to lib/rauversion_web/live/user_settings_live/components/security_form.ex
index 686dc2ec..f7d60481 100644
--- a/lib/rauversion_web/live/usersettings_live/components/security_form.ex
+++ b/lib/rauversion_web/live/user_settings_live/components/security_form.ex
@@ -1,4 +1,4 @@
-defmodule RauversionWeb.UsersettingsLive.SecurityForm do
+defmodule RauversionWeb.UserSettingsLive.SecurityForm do
use RauversionWeb, :live_component
@impl true
diff --git a/lib/rauversion_web/live/usersettings_live/components/transbank_form.ex b/lib/rauversion_web/live/user_settings_live/components/transbank_form.ex
similarity index 98%
rename from lib/rauversion_web/live/usersettings_live/components/transbank_form.ex
rename to lib/rauversion_web/live/user_settings_live/components/transbank_form.ex
index 60c94000..704d024c 100644
--- a/lib/rauversion_web/live/usersettings_live/components/transbank_form.ex
+++ b/lib/rauversion_web/live/user_settings_live/components/transbank_form.ex
@@ -1,4 +1,4 @@
-defmodule RauversionWeb.UsersettingsLive.TransbankForm do
+defmodule RauversionWeb.UserSettingsLive.TransbankForm do
use RauversionWeb, :live_component
def render(%{changeset: _changeset} = assigns) do
diff --git a/lib/rauversion_web/live/usersettings_live/form_component.ex b/lib/rauversion_web/live/user_settings_live/form_component.ex
similarity index 77%
rename from lib/rauversion_web/live/usersettings_live/form_component.ex
rename to lib/rauversion_web/live/user_settings_live/form_component.ex
index 7f4269e8..a9acb11b 100644
--- a/lib/rauversion_web/live/usersettings_live/form_component.ex
+++ b/lib/rauversion_web/live/user_settings_live/form_component.ex
@@ -1,4 +1,4 @@
-defmodule RauversionWeb.UsersettingsLive.FormComponent do
+defmodule RauversionWeb.UserSettingsLive.FormComponent do
use RauversionWeb, :live_component
alias Rauversion.Accounts
@@ -34,6 +34,21 @@ defmodule RauversionWeb.UsersettingsLive.FormComponent do
)
end
+ defp get_change_set(:labels, socket, user) do
+ socket
+ |> assign(:changeset, Accounts.change_user_email(user))
+ |> allow_upload(:avatar,
+ accept: ~w(.jpg .jpeg .png),
+ max_entries: 1,
+ max_file_size: 15_000_000
+ )
+ |> allow_upload(:profile_header,
+ accept: ~w(.jpg .jpeg .png),
+ max_entries: 1,
+ max_file_size: 15_000_000
+ )
+ end
+
defp get_change_set(:email, socket, user) do
socket
|> assign(:changeset, Accounts.change_user_email(user))
@@ -120,6 +135,19 @@ defmodule RauversionWeb.UsersettingsLive.FormComponent do
save_profile(socket, socket.assigns.action, params)
end
+ @impl true
+ def handle_event(
+ "save",
+ %{"action" => "update_label"} = params,
+ socket = %{
+ assigns: %{
+ action: :labels
+ }
+ }
+ ) do
+ save_label(socket, socket.assigns.action, params)
+ end
+
defp save_email(socket, :email, %{"current_password" => password, "user" => user_params}) do
user = socket.assigns.current_user
@@ -137,7 +165,28 @@ defmodule RauversionWeb.UsersettingsLive.FormComponent do
:info,
"A link to confirm your email change has been sent to the new address."
)
- |> push_redirect(to: socket.assigns.return_to)
+ |> push_navigate(to: socket.assigns.return_to)
+
+ {:error, changeset} ->
+ socket |> assign(:changeset, changeset)
+ end
+
+ {:noreply, socket}
+ end
+
+ defp save_label(socket, :labels, params) do
+ %{"user" => user_params} = params
+
+ user = socket.assigns.current_user
+
+ socket =
+ case Accounts.update_label(user, user_params) do
+ {:ok, _user} ->
+ socket
+ |> put_flash(:info, "Label config updated successfully.")
+ |> push_navigate(to: "/users/settings/labels")
+
+ # |> PhoenixLiveSession.put_session(:user_return_to, "/user/settings/security")
{:error, changeset} ->
socket |> assign(:changeset, changeset)
@@ -175,20 +224,18 @@ defmodule RauversionWeb.UsersettingsLive.FormComponent do
|> Map.put("avatar", files_for(socket, :avatar))
|> Map.put("profile_header", files_for(socket, :profile_header))
- IO.inspect(user_params)
-
- socket =
- case Accounts.update_user_profile(user, user_params) do
- {:ok, _user} ->
- socket
- |> put_flash(:info, "User profile updated successfully.")
- |> push_redirect(to: "/users/settings")
+ case Accounts.update_user_profile(user, user_params) do
+ {:ok, _user} ->
+ {:noreply,
+ socket
+ |> put_flash(:info, "User profile updated successfully.")
+ # |> put_session(:flash, %{info: "Event created successfully"})
- {:error, changeset} ->
- socket |> assign(:changeset, changeset)
- end
+ |> push_patch(to: "/users/settings")}
- {:noreply, socket}
+ {:error, changeset} ->
+ {:noreply, socket |> assign(:changeset, changeset)}
+ end
end
defp save_profile(socket, :notifications, %{"user" => user_params}) do
@@ -199,7 +246,7 @@ defmodule RauversionWeb.UsersettingsLive.FormComponent do
{:ok, _user} ->
socket
|> put_flash(:info, "User profile updated successfully.")
- |> redirect(to: "/users/settings")
+ |> push_navigate(to: "/users/settings")
{:error, changeset} ->
socket |> assign(:changeset, changeset)
@@ -216,7 +263,7 @@ defmodule RauversionWeb.UsersettingsLive.FormComponent do
{:ok, _user} ->
socket
|> put_flash(:info, "User profile updated successfully.")
- |> redirect(to: "/users/settings/notifications")
+ |> push_navigate(to: "/users/settings/notifications")
{:error, changeset} ->
socket |> assign(:changeset, changeset)
@@ -233,7 +280,7 @@ defmodule RauversionWeb.UsersettingsLive.FormComponent do
{:ok, _user} ->
socket
|> put_flash(:info, "User profile updated successfully.")
- |> redirect(to: "/users/settings/transbank")
+ |> push_navigate(to: "/users/settings/transbank")
{:error, changeset} ->
socket |> assign(:changeset, changeset)
diff --git a/lib/rauversion_web/live/usersettings_live/form_component.html.heex b/lib/rauversion_web/live/user_settings_live/form_component.html.heex
similarity index 66%
rename from lib/rauversion_web/live/usersettings_live/form_component.html.heex
rename to lib/rauversion_web/live/user_settings_live/form_component.html.heex
index 25dfca32..8ae2e599 100644
--- a/lib/rauversion_web/live/usersettings_live/form_component.html.heex
+++ b/lib/rauversion_web/live/user_settings_live/form_component.html.heex
@@ -1,7 +1,18 @@
<%= if @action == :profile do %>
<.live_component
- module={RauversionWeb.UsersettingsLive.ProfileForm}
+ module={RauversionWeb.UserSettingsLive.ProfileForm}
+ id="contact-form"
+ target={@myself}
+ changeset={@changeset}
+ return_to={@return_to}
+ uploads={@uploads}
+ />
+ <% end %>
+
+ <%= if @action == :labels do %>
+ <.live_component
+ module={RauversionWeb.UserSettingsLive.LabelForm}
id="contact-form"
target={@myself}
changeset={@changeset}
@@ -12,7 +23,7 @@
<%= if @action == :email do %>
<.live_component
- module={RauversionWeb.UsersettingsLive.EmailForm}
+ module={RauversionWeb.UserSettingsLive.EmailForm}
id="email-form"
target={@myself}
changeset={@changeset}
@@ -22,7 +33,7 @@
<%= if @action == :security do %>
<.live_component
- module={RauversionWeb.UsersettingsLive.SecurityForm}
+ module={RauversionWeb.UserSettingsLive.SecurityForm}
id="security-form"
target={@myself}
changeset={@changeset}
@@ -32,7 +43,7 @@
<%= if @action == :notifications do %>
<.live_component
- module={RauversionWeb.UsersettingsLive.NotificationsForm}
+ module={RauversionWeb.UserSettingsLive.NotificationsForm}
id="security-form"
target={@myself}
changeset={@changeset}
@@ -42,7 +53,7 @@
<%= if @action == :integrations do %>
<.live_component
- module={RauversionWeb.UsersettingsLive.IntegrationsForm}
+ module={RauversionWeb.UserSettingsLive.IntegrationsForm}
id="integrations"
target={@myself}
current_user={@current_user}
@@ -52,7 +63,7 @@
<%= if @action == :transbank do %>
<.live_component
- module={RauversionWeb.UsersettingsLive.TransbankForm}
+ module={RauversionWeb.UserSettingsLive.TransbankForm}
id="security-form"
target={@myself}
changeset={@changeset}
@@ -62,7 +73,7 @@
<%= if @action == :invitations do %>
<.live_component
- module={RauversionWeb.UsersettingsLive.Invitations}
+ module={RauversionWeb.UserSettingsLive.Invitations}
id="invitations-form"
target={@myself}
current_user={@current_user}
diff --git a/lib/rauversion_web/live/usersettings_live/index.ex b/lib/rauversion_web/live/user_settings_live/index.ex
similarity index 100%
rename from lib/rauversion_web/live/usersettings_live/index.ex
rename to lib/rauversion_web/live/user_settings_live/index.ex
diff --git a/lib/rauversion_web/live/usersettings_live/index.html.heex b/lib/rauversion_web/live/user_settings_live/index.html.heex
similarity index 85%
rename from lib/rauversion_web/live/usersettings_live/index.html.heex
rename to lib/rauversion_web/live/user_settings_live/index.html.heex
index e250a8e4..afe85b34 100644
--- a/lib/rauversion_web/live/usersettings_live/index.html.heex
+++ b/lib/rauversion_web/live/user_settings_live/index.html.heex
@@ -7,7 +7,7 @@
/>
<.live_component
- module={RauversionWeb.UsersettingsLive.FormComponent}
+ module={RauversionWeb.UserSettingsLive.FormComponent}
id={@current_user.id || "profile-form"}
action={@live_action}
current_user={@current_user}
diff --git a/lib/rauversion_web/router.ex b/lib/rauversion_web/router.ex
index 693c8a91..c920ecec 100644
--- a/lib/rauversion_web/router.ex
+++ b/lib/rauversion_web/router.ex
@@ -156,6 +156,9 @@ defmodule RauversionWeb.Router do
get "/users/invite", UserInvitationController, :new
post "/users/invite", UserInvitationController, :create
+ get "/onbehalf/parent/:username", LabelAuthController, :back
+ get "/onbehalf/:username", LabelAuthController, :add
+
get "/webpayplus/mall/create", TbkController, :mall_create
post "/webpayplus/mall/create", TbkController, :send_mall_create
post "/webpayplus/mall/return_url", TbkController, :mall_commit
@@ -168,6 +171,8 @@ defmodule RauversionWeb.Router do
get "/webpayplus/mall/status/:token", TbkController, :mall_status
post "/webpayplus/mall/refund", TbkController, :mall_refund
+ live "/accounts/connect", AccountConnectLive.New, :new
+
live "/streams/:id", StreamsLive.Show, :show
live "/tickets/qr/:signed_id", QrLive.Index, :index
@@ -179,6 +184,7 @@ defmodule RauversionWeb.Router do
live "/users/settings/integrations", UserSettingsLive.Index, :integrations
live "/users/settings/transbank", UserSettingsLive.Index, :transbank
live "/users/settings/invitations", UserSettingsLive.Index, :invitations
+ live "/users/settings/labels", UserSettingsLive.Index, :labels
get "/oembed", OEmbedController, :create
@@ -355,6 +361,7 @@ defmodule RauversionWeb.Router do
live "/:username/following", FollowsLive.Index, :followings
live "/:username/comments", FollowsLive.Index, :comments
live "/:username/likes", FollowsLive.Index, :likes
+ live "/:username/artists", ProfileLive.Index, :artists
live "/:username/tracks/all", ProfileLive.Index, :tracks_all
live "/:username/tracks/reposts", ProfileLive.Index, :reposts
live "/:username/tracks/albums", ProfileLive.Index, :albums
diff --git a/lib/rauversion_web/templates/layout/_user_menu.html.heex b/lib/rauversion_web/templates/layout/_user_menu.html.heex
index 6d09efd7..efb81633 100644
--- a/lib/rauversion_web/templates/layout/_user_menu.html.heex
+++ b/lib/rauversion_web/templates/layout/_user_menu.html.heex
@@ -1,7 +1,17 @@
-
+
-
+
+ <%= if user_id = Plug.Conn.get_session(@conn, "parent_user") do %>
+ <%= if user = Rauversion.Accounts.get_user!(user_id) do %>
+
+ ← back to <%= user.username %>
+
+ <% end %>
+ <% end %>
<%= live_redirect to: "/", class: "flex items-center space-x-3 text-white sm:text-2xl text-sm font-extrabold" do %>
@@ -181,7 +191,8 @@
>
<%= if is_creator?(@current_user) && @current_user.username do %>
- <%= live_redirect(gettext("My Music"),
+ <%= live_redirect(
+ my_music_label(@current_user),
to: Routes.profile_index_path(@conn, :index, @current_user.username),
class: "block px-4 py-2 text-sm text-gray-700 dark:text-gray-300"
) %>
@@ -199,7 +210,6 @@
) %>
<% end %>
-
<%= if is_creator?(@current_user) do %>
<%= live_redirect(gettext("My Purchases"),
to: "/purchases",
@@ -218,12 +228,15 @@
) %>
-
- Support
-
-
- License
+
+
+ <%= gettext("Support") %>
+
<%= link(gettext("Log out"),
to: Routes.user_session_path(@conn, :delete),
method: :delete,
@@ -345,7 +358,7 @@
<% # = link gettext("Log out"), to: Routes.user_session_path(@conn, :delete), method: :delete, class: "block rounded-md py-2 px-3 text-base font-medium text-gray-200 hover:text-white hover:bg-gray-800" %>
<%= if is_creator?(@current_user) && @current_user.username do %>
- <%= live_redirect(gettext("My Music"),
+ <%= live_redirect(my_music_label(@current_user),
to: Routes.profile_index_path(@conn, :index, @current_user.username),
class: "block px-4 py-2 text-sm text-gray-700 dark:text-gray-300"
) %>
@@ -373,8 +386,15 @@
) %>
-
Support
-
License
+
+
+ <%= gettext("Support") %>
+
+
<%= link(gettext("Log out"),
to: Routes.user_session_path(@conn, :delete),
method: :delete,
diff --git a/lib/rauversion_web/templates/layout/live.html.heex b/lib/rauversion_web/templates/layout/live.html.heex
index e2acfc5e..46b556fb 100644
--- a/lib/rauversion_web/templates/layout/live.html.heex
+++ b/lib/rauversion_web/templates/layout/live.html.heex
@@ -1,6 +1,6 @@
-
<%= live_flash(@flash, :info) %>
+
<%= Phoenix.Flash.get(@flash, :info) %>
-
<%= live_flash(@flash, :error) %>
+
<%= Phoenix.Flash.get(@flash, :error) %>
<%= @inner_content %>
diff --git a/lib/rauversion_web/templates/user_registration/new.html.heex b/lib/rauversion_web/templates/user_registration/new.html.heex
index cb79e211..40594bc3 100644
--- a/lib/rauversion_web/templates/user_registration/new.html.heex
+++ b/lib/rauversion_web/templates/user_registration/new.html.heex
@@ -93,7 +93,7 @@
<% end %>
-
+
<%= Application.get_env(:rauversion, :domain) %>/
<%= text_input(f, :username,
diff --git a/mix.exs b/mix.exs
index 5b291730..55c404e7 100644
--- a/mix.exs
+++ b/mix.exs
@@ -41,7 +41,7 @@ defmodule Rauversion.MixProject do
defp deps do
[
{:bcrypt_elixir, "~> 3.0"},
- {:phoenix, "~> 1.7.0-rc.2", override: true},
+ {:phoenix, "~> 1.7.0", override: true},
{:phoenix_ecto, "~> 4.4"},
{:ecto_sql, "~> 3.9"},
{:ecto_nested_changeset, "~> 0.2.0"},
diff --git a/priv/repo/migrations/20230216230412_add_is_label_to_users.exs b/priv/repo/migrations/20230216230412_add_is_label_to_users.exs
new file mode 100644
index 00000000..f2706b66
--- /dev/null
+++ b/priv/repo/migrations/20230216230412_add_is_label_to_users.exs
@@ -0,0 +1,9 @@
+defmodule Rauversion.Repo.Migrations.AddIsLabelToUsers do
+ use Ecto.Migration
+
+ def change do
+ alter table(:users) do
+ add :label, :boolean
+ end
+ end
+end
diff --git a/priv/repo/migrations/20230217013852_create_connected_account.exs b/priv/repo/migrations/20230217013852_create_connected_account.exs
new file mode 100644
index 00000000..2beb2ba9
--- /dev/null
+++ b/priv/repo/migrations/20230217013852_create_connected_account.exs
@@ -0,0 +1,16 @@
+defmodule Rauversion.Repo.Migrations.CreateConnectedAccount do
+ use Ecto.Migration
+
+ def change do
+ create table(:connected_accounts) do
+ add :state, :string
+ add :parent_id, references(:users, on_delete: :nothing)
+ add :user_id, references(:users, on_delete: :nothing)
+
+ timestamps()
+ end
+
+ create index(:connected_accounts, [:parent_id])
+ create index(:connected_accounts, [:user_id])
+ end
+end
diff --git a/test/cypress/integration/tracks/tracks_spec.js b/test/cypress/integration/tracks/tracks_spec.js
index 4b5b468a..c1ec359d 100644
--- a/test/cypress/integration/tracks/tracks_spec.js
+++ b/test/cypress/integration/tracks/tracks_spec.js
@@ -19,12 +19,30 @@ describe('Tracks Spec', function () {
cy.contains("Playlists")
cy.wait(2000)
cy.contains("New Track").click()
- cy.get('input[type=file]').selectFile('test/cypress/fixtures/example.json', {force: true})
+ cy.get('input[type=file]')
+ //cy.get('[data-cy="upload-track"]')
+ .selectFile('test/cypress/fixtures/example.json', {
+ force: true,
+ action: 'drag-drop'
+ })
+ //.trigger('drop')
+ //cy.get('input[type=file]').trigger("change", {force: true})
+
cy.contains("Not accepted")
- cy.get('input[type=file]').selectFile('test/cypress/fixtures/sample-3s.mp3', {force: true})
+ cy.get('input[type=file]')
+
+ //cy.get('[data-cy="upload-track"]')
+ cy.get('input[type=file]')
+ .selectFile('test/cypress/fixtures/sample-3s.mp3', {
+ force: true,
+ action: 'drag-drop'
+ }).trigger('change', {force: true})
+
+ cy.get('input[type=file]').trigger("change", {force: true})
+
cy.contains("Continue").click()
cy.contains("Save").click()
- cy.wait(16000)
+ cy.wait(6000)
cy.contains("Go to your track").click()
cy.contains("sample-3s.mp3")
cy.get('[data-audio-target="play"]').click()
@@ -51,7 +69,7 @@ describe('User Tracks access', function () {
cy.appScenario('basic', {email: "test@test.cl", password: "12345678", username: "test"});
})
- it('Draft event My events', function () {
+ it('Upload not allowed, non artists', function () {
login()
cy.visit("/tracks/new")
cy.contains("Tracks uploads are not allowed on your account type")
diff --git a/test/rauversion/connected_accounts_test.exs b/test/rauversion/connected_accounts_test.exs
new file mode 100644
index 00000000..da96eb68
--- /dev/null
+++ b/test/rauversion/connected_accounts_test.exs
@@ -0,0 +1,70 @@
+defmodule Rauversion.ConnectedAccountsTest do
+ use Rauversion.DataCase
+
+ alias Rauversion.ConnectedAccounts
+
+ describe "connected_account" do
+ alias Rauversion.ConnectedAccounts.ConnectedAccount
+
+ import Rauversion.ConnectedAccountsFixtures
+
+ @invalid_attrs %{state: nil}
+
+ test "list/0 returns all connected_account" do
+ connected_account = connected_account_fixture()
+ assert ConnectedAccounts.list() == [connected_account]
+ end
+
+ test "get!/1 returns the connected_account with given id" do
+ connected_account = connected_account_fixture()
+ assert ConnectedAccounts.get!(connected_account.id) == connected_account
+ end
+
+ test "create/1 with valid data creates a connected_account" do
+ valid_attrs = %{state: "some state"}
+
+ assert {:ok, %ConnectedAccount{} = connected_account} =
+ ConnectedAccounts.create(valid_attrs)
+
+ assert connected_account.state == "some state"
+ end
+
+ test "create/1 with invalid data returns error changeset" do
+ assert {:error, %Ecto.Changeset{}} = ConnectedAccounts.create(@invalid_attrs)
+ end
+
+ test "update/2 with valid data updates the connected_account" do
+ connected_account = connected_account_fixture()
+ update_attrs = %{state: "some updated state"}
+
+ assert {:ok, %ConnectedAccount{} = connected_account} =
+ ConnectedAccounts.update(connected_account, update_attrs)
+
+ assert connected_account.state == "some updated state"
+ end
+
+ test "update/2 with invalid data returns error changeset" do
+ connected_account = connected_account_fixture()
+
+ assert {:error, %Ecto.Changeset{}} =
+ ConnectedAccounts.update(connected_account, @invalid_attrs)
+
+ assert connected_account == ConnectedAccounts.get!(connected_account.id)
+ end
+
+ test "delete/1 deletes the connected_account" do
+ connected_account = connected_account_fixture()
+
+ assert {:ok, %ConnectedAccount{}} = ConnectedAccounts.delete(connected_account)
+
+ assert_raise Ecto.NoResultsError, fn ->
+ ConnectedAccounts.get!(connected_account.id)
+ end
+ end
+
+ test "change/1 returns a connected_account changeset" do
+ connected_account = connected_account_fixture()
+ assert %Ecto.Changeset{} = ConnectedAccounts.change(connected_account)
+ end
+ end
+end
diff --git a/test/support/fixtures/connected_accounts_fixtures.ex b/test/support/fixtures/connected_accounts_fixtures.ex
new file mode 100644
index 00000000..99e5999e
--- /dev/null
+++ b/test/support/fixtures/connected_accounts_fixtures.ex
@@ -0,0 +1,20 @@
+defmodule Rauversion.ConnectedAccountsFixtures do
+ @moduledoc """
+ This module defines test helpers for creating
+ entities via the `Rauversion.ConnectedAccounts` context.
+ """
+
+ @doc """
+ Generate a connected_account.
+ """
+ def connected_account_fixture(attrs \\ %{}) do
+ {:ok, connected_account} =
+ attrs
+ |> Enum.into(%{
+ state: "some state"
+ })
+ |> Rauversion.ConnectedAccounts.create()
+
+ connected_account
+ end
+end