From 624b1b595527fcbd7e5d243397100c26d7160289 Mon Sep 17 00:00:00 2001 From: Miguel Michelson Martinez Date: Mon, 26 Feb 2024 02:20:33 -0300 Subject: [PATCH 01/13] connected accounts --- app/controllers/application_controller.rb | 2 - app/mailers/application_mailer.rb | 2 +- app/models/user.rb | 65 +++++++++++++++++++++++ app/views/shared/_user_menu.html.erb | 13 +++++ app/views/user_settings/index.html.erb | 6 +++ app/views/users/show.html.erb | 18 +++++-- config/routes.rb | 6 +++ db/schema.rb | 14 ++++- 8 files changed, 119 insertions(+), 7 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4e2013f..d508f16 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,8 +1,6 @@ class ApplicationController < ActionController::Base before_action do ActiveStorage::Current.url_options = {protocol: request.protocol, host: request.host, port: request.port} - ActiveStorage::Current.host = request.url - # ActiveStorage::Current.url_options = { protocol: "http://", host: "localhost", port: "3000" } end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 3c34c81..43ae421 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: "from@example.com" + default from: ENV['EMAIL_ACCOUNT'] layout "mailer" end diff --git a/app/models/user.rb b/app/models/user.rb index 68288c0..9685a16 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,6 +19,12 @@ class User < ApplicationRecord has_many :hosted_events, through: :event_hosts has_many :purchases has_many :comments + + + has_many :connected_accounts, foreign_key: :parent_id + + has_many :child_accounts, through: :connected_accounts, source: :user + has_one_attached :profile_header has_one_attached :avatar @@ -141,7 +147,66 @@ def user_sales_for(kind = "Track") .where(tracks: {user_id: id}) end + + def active_connected_accounts(user) + ConnectedAccount.where(parent_id: user.id, state: 'active').includes(:user) + end + + def is_child_of?(child_user_id) + ConnectedAccount.exists?(parent_id: self.id, state: 'active', user_id: child_user_id) + end + # def password_required? # false # end end + + + +class ExistingArtist + include ActiveModel::Model + include ActiveModel::Attributes + include ActiveModel::Validations + + attribute :username, :string + attribute :ticket_id, :integer + attribute :email, :string # Assuming you intend to use it given the validate_email function + + validates :username, presence: true + validates :ticket_id, presence: true + validates :email, presence: true, format: { with: URI::MailTo::EMAIL_REGEXP }, length: { maximum: 160 } + + # Custom validation method if you have additional logic + # validate :custom_validation_method + + private + + # Example custom validation method + # def custom_validation_method + # errors.add(:base, "Custom validation error message") if some_condition + # end +end + + +class NewArtist + include ActiveModel::Model + include ActiveModel::Validations + include ActiveModel::Attributes + + attribute :username, :string + attribute :genre, :string + attribute :hidden, :string + + validates :username, presence: true + validate :validate_email + + def validate_email + # Similar assumption about the `email` attribute + if email.present? && !email.match?(/\A[^\s]+@[^\s]+\z/) + errors.add(:email, "must have the @ sign and no spaces") + end + if email.length > 160 + errors.add(:email, "is too long (maximum is 160 characters)") + end + end +end \ No newline at end of file diff --git a/app/views/shared/_user_menu.html.erb b/app/views/shared/_user_menu.html.erb index e752c1a..e375dcc 100644 --- a/app/views/shared/_user_menu.html.erb +++ b/app/views/shared/_user_menu.html.erb @@ -100,6 +100,17 @@ + +
+ <% if user_id = session[:parent_user] %> + <% if user = Accounts.get_user!(user_id) %> + <%= link_to onbehalf_parent_path(username: user.username), class: "fixed p-2 text-xs bg-black hover:bg-white hover:text-black left-[-1px] border top-[45px] z-[200]" do %> + back to
<%= user.username %> + <% end %> + <% end %> + <% end %> +
+
<% if track.private %> diff --git a/config/routes.rb b/config/routes.rb index b5ff220..9762383 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -133,6 +133,8 @@ end end + resources :labels + constraints(Constraints::UsernameRouteConstrainer.new) do # Same route as before, only within the constraints block resources :users, path: "" do From c6579f3ee87a68570e2637992fae3f3da01166f9 Mon Sep 17 00:00:00 2001 From: Miguel Michelson Martinez Date: Sat, 11 May 2024 21:55:15 -0400 Subject: [PATCH 10/13] impersonation, label checkbox --- .../account_connections_controller.rb | 2 + app/controllers/application_controller.rb | 12 + app/controllers/label_artists_controller.rb | 2 +- app/controllers/labels_controller.rb | 6 + app/controllers/playlists_controller.rb | 18 +- app/controllers/tracks_controller.rb | 16 +- app/controllers/users_controller.rb | 24 +- app/helpers/labels_helper.rb | 2 + .../controllers/audio_upload_controller.js | 1 - app/models/current.rb | 12 + app/models/playlist.rb | 11 + app/models/track.rb | 7 + app/models/track_bulk_creator.rb | 2 +- app/models/user.rb | 74 +---- app/views/label_artists/index.html.erb | 47 +-- app/views/labels/show.html.erb | 294 ++++++++++++++++++ app/views/playlists/_basic_info_tab.html.erb | 6 + app/views/playlists/_cards.html.erb | 2 +- app/views/playlists/_form.html.erb | 10 + app/views/playlists/create.turbo_stream.erb | 2 +- app/views/shared/_user_menu.html.erb | 8 +- app/views/tracks/_form.html.erb | 6 + app/views/tracks/_track_item.html.erb | 6 +- app/views/tracks/create.turbo_stream.erb | 2 +- app/views/users/about.html.erb | 5 +- app/views/users/show.html.erb | 34 ++ config/routes.rb | 4 + .../20240506041324_add_label_to_models.rb | 9 + db/schema.rb | 6 +- spec/helpers/labels_helper_spec.rb | 15 + spec/models/connected_account_spec.rb | 20 +- spec/requests/labels_spec.rb | 7 + 32 files changed, 543 insertions(+), 129 deletions(-) create mode 100644 app/controllers/labels_controller.rb create mode 100644 app/helpers/labels_helper.rb create mode 100644 app/models/current.rb create mode 100644 app/views/labels/show.html.erb create mode 100644 db/migrate/20240506041324_add_label_to_models.rb create mode 100644 spec/helpers/labels_helper_spec.rb create mode 100644 spec/requests/labels_spec.rb diff --git a/app/controllers/account_connections_controller.rb b/app/controllers/account_connections_controller.rb index ae83ec5..3457a8a 100644 --- a/app/controllers/account_connections_controller.rb +++ b/app/controllers/account_connections_controller.rb @@ -67,6 +67,7 @@ def impersonate user = User.find_by(username: params[:username]) if current_user.child_accounts.find(user.id) session[:parent_user] = current_user.id + Current.label_user = current_user flash[:notice] = "signed as #{user.username}" sign_in(:user, user) redirect_to user_path(user.username) @@ -75,6 +76,7 @@ def impersonate if session[:parent_user].present? user = User.find(session[:parent_user]) session[:parent_user] = nil + Current.label_user = nil flash[:notice] = "signed as #{user.username}" sign_in(:user, user) redirect_to user_path(user.username) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ef9f4f7..cba0733 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,6 +2,7 @@ class ApplicationController < ActionController::Base before_action do ActiveStorage::Current.url_options = {protocol: request.protocol, host: request.host, port: request.port} # ActiveStorage::Current.url_options = { protocol: "http://", host: "localhost", port: "3000" } + Current.label_user = User.find(session[:parent_user]) if session[:parent_user].present? end before_action :set_locale @@ -12,6 +13,11 @@ def flash_stream turbo_stream.replace("flash", partial: "shared/flash", locals: { flash: flash }) end + helper_method :impersonating? + def impersonating?(user) + label_user.present? && current_user&.id == user&.id + end + def set_locale if params[:locale].present? cookies[:locale] = params[:locale] @@ -23,6 +29,12 @@ def set_locale end end + helper_method :label_user + def label_user + return if session[:parent_user].blank? + @label_user ||= User.find session[:parent_user] + end + def become if current_user.is_admin? user = User.find_by(username: params[:id]) diff --git a/app/controllers/label_artists_controller.rb b/app/controllers/label_artists_controller.rb index fc69cd4..f4006ce 100644 --- a/app/controllers/label_artists_controller.rb +++ b/app/controllers/label_artists_controller.rb @@ -2,6 +2,6 @@ class LabelArtistsController < ApplicationController def index - @label = User.where(role: "artist", label: true).find_by(username: params[:user_id]) + @label = User.where(role: ["artist", "admin"], label: true).find_by(username: params[:user_id]) end end diff --git a/app/controllers/labels_controller.rb b/app/controllers/labels_controller.rb new file mode 100644 index 0000000..fc6eeb1 --- /dev/null +++ b/app/controllers/labels_controller.rb @@ -0,0 +1,6 @@ +class LabelsController < ApplicationController + + before_action :find_user, except: [:index] + before_action :check_user_role, except: [:index] + +end diff --git a/app/controllers/playlists_controller.rb b/app/controllers/playlists_controller.rb index 375574b..a122184 100644 --- a/app/controllers/playlists_controller.rb +++ b/app/controllers/playlists_controller.rb @@ -44,6 +44,7 @@ def show def edit @tab = params[:tab] || "basic-info-tab" @playlist = current_user.playlists.friendly.find(params[:id]) + @playlist.enable_label = @playlist.label_id.present? end def new @@ -56,8 +57,10 @@ def new def create @tab = params[:tab] || "basic-info-tab" @playlist = current_user.playlists.create(playlist_params) - if @playlist.errors.blank? - flash[:now] = "successfully created" + if @playlist + flash.now[:notice] = "successfully created" + else + flash.now[:error] = "error in creating" end end @@ -65,10 +68,14 @@ def update @tab = params[:tab] || "basic-info-tab" @playlist = current_user.playlists.friendly.find(params[:id]) - if !params[:nonpersist] && @playlist.update(playlist_params) - flash[:now] = "successfully updated" - end + @playlist.assign_attributes(playlist_params) + if !params[:nonpersist] && @playlist.save + flash.now[:notice] = "successfully updated" + else + flash.now[:error] = "error updating playlist" + end + if params[:nonpersist] @playlist.assign_attributes(playlist_params) end @@ -83,6 +90,7 @@ def playlist_params :title, :description, :private, :price, :playlist_type, :release_date, :cover, :record_label, :buy_link, + :enable_label, :copyright, :attribution, :noncommercial, :non_derivative_works, :copies, track_playlists_attributes: [ diff --git a/app/controllers/tracks_controller.rb b/app/controllers/tracks_controller.rb index 443906d..ee30e92 100644 --- a/app/controllers/tracks_controller.rb +++ b/app/controllers/tracks_controller.rb @@ -23,6 +23,7 @@ def create audios = track_bulk_params["audio"].select { |o| o.is_a?(String) }.reject(&:empty?) # @track = current_user.tracks.new(track_params) @track_form.user = current_user + @track_form.private = track_bulk_params[:private] @track_form.tracks_attributes = audios.map { |o| {audio: o} } @track_form.step = "info" else @@ -44,12 +45,16 @@ def edit def update @track = current_user.tracks.friendly.find(params[:id]) @tab = params[:track][:tab] || "basic-info-tab" + @track.assign_attributes(track_params) if params[:nonpersist] - @track.assign_attributes(track_params) @track.valid? else - flash.now[:notice] = "Track was successfully updated." - @track.update(track_params) + @track.label_id = label_user.id if !label_user.blank? && @track.enable_label + if @track.save + flash.now[:notice] = "Track was successfully updated." + else + flash.now[:error] = @track.errors.full_messages + end end # puts @track.errors.as_json @track.tab = @tab @@ -103,6 +108,7 @@ def get_meta_tags def track_params params.require(:track).permit( :private, + :enable_label, :audio, :title, :step, :description, :tab, :genre, :contains_music, :artist, :publisher, :isrc, :composer, :release_title, :buy_link, :album_title, @@ -124,7 +130,9 @@ def check_activated_account def track_bulk_params params.require(:track_bulk_creator).permit( - :make_playlist, :private, + :make_playlist, + :private, + :enable_label, :step, audio: [], tracks_attributes: [ :audio, :cover, :title, :tags, :description diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 42aec64..c71e3a8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -37,9 +37,10 @@ def playlists_filter @kind = params[:kind].present? ? params[:kind].split(",") : Category.playlist_types - @playlists = @user.playlists + @playlists = Playlist .where(playlist_type: @kind) - .where(user_id: @user.id) + .where(user_id: @user.id).or(Playlist.where(label_id: @user.id)) + .where(private: false) .with_attached_cover .includes(user: {avatar_attachment: :blob}) .includes(tracks: {cover_attachment: :blob}) @@ -68,6 +69,8 @@ def playlists @collection = @collection.where(private: false) end + @collection.or(Playlist.where(label_id: @user.id)) if @user.label? + @collection = @collection.references(:tracks) .page(params[:page]) @@ -152,19 +155,18 @@ def get_meta_tags def get_tracks # @collection = @user.tracks.page(params[:page]).per(2) @collection = if current_user && @user.id == current_user&.id - User.track_preloaded_by_user(current_user&.id) + User.track_preloaded_by_user(current_user_id: current_user&.id, user: @user ) #.where(user_id: @user.id) - .with_attached_cover - .includes(user: {avatar_attachment: :blob}) - .order("id desc") - .page(params[:page]).per(6) else - User.track_preloaded_by_user_n(@user&.id) + User.track_preloaded_by_user_n(user: @user) + #.where(user_id: @user.id) #@user.tracks.published - .with_attached_cover - .includes(user: {avatar_attachment: :blob}) - .order("id desc").page(params[:page]).per(6) end + + @collection = @collection + .with_attached_cover + .includes(user: {avatar_attachment: :blob}) + .order("id desc").page(params[:page]).per(6) end def find_user diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb new file mode 100644 index 0000000..9802e31 --- /dev/null +++ b/app/helpers/labels_helper.rb @@ -0,0 +1,2 @@ +module LabelsHelper +end diff --git a/app/javascript/controllers/audio_upload_controller.js b/app/javascript/controllers/audio_upload_controller.js index ac1da6d..ab366f4 100644 --- a/app/javascript/controllers/audio_upload_controller.js +++ b/app/javascript/controllers/audio_upload_controller.js @@ -148,7 +148,6 @@ export default class extends Controller { this.preventDefaults(e); let files = e.dataTransfer.files; this.inputTarget.files = files; - debugger this.uploadFile(); } } \ No newline at end of file diff --git a/app/models/current.rb b/app/models/current.rb new file mode 100644 index 0000000..ffeeb32 --- /dev/null +++ b/app/models/current.rb @@ -0,0 +1,12 @@ +class Current < ActiveSupport::CurrentAttributes + attribute :label_user, :user + attribute :request_id, :user_agent, :ip_address + + resets { Time.zone = nil } + + def user=(user) + super + #self.label_user = user.account + #Time.zone = user.time_zone + end +end diff --git a/app/models/playlist.rb b/app/models/playlist.rb index 931c7fc..d115ba7 100644 --- a/app/models/playlist.rb +++ b/app/models/playlist.rb @@ -16,11 +16,14 @@ def self.plain friendly_id :title, use: :slugged belongs_to :user + belongs_to :label, class_name: "User", optional: true + has_many :track_playlists has_many :tracks, through: :track_playlists has_many :listening_events has_many :comments, as: :commentable has_many :likes, as: :likeable + has_one_attached :cover has_one_attached :zip @@ -28,6 +31,14 @@ def self.plain accepts_nested_attributes_for :track_playlists, allow_destroy: true + belongs_to :label, class_name: "User", optional: true + attr_accessor :enable_label + before_save :check_label + + def check_label + self.label_id = Current.label_user.id if enable_label && Current.label_user + end + scope :latests, -> { order("id desc") } scope :published, -> { where(private: false) } diff --git a/app/models/track.rb b/app/models/track.rb index 8c9e8d5..529a536 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -15,6 +15,13 @@ class Track < ApplicationRecord has_many :spotlights, as: :spotlightable # has_many :spotlighted_tracks, through: :spotlight_tracks + belongs_to :label, class_name: "User", optional: true + attr_accessor :enable_label + before_save :check_label + + def check_label + self.label_id = Current.label_user.id if enable_label && Current.label_user + end has_one_attached :cover has_one_attached :audio diff --git a/app/models/track_bulk_creator.rb b/app/models/track_bulk_creator.rb index d763f81..2087f1f 100644 --- a/app/models/track_bulk_creator.rb +++ b/app/models/track_bulk_creator.rb @@ -10,7 +10,7 @@ class TrackBulkCreator # Initialize the tracks_attributes with an empty array def initialize(attributes = {}) - self.private = true + self.private = attributes[:private] self.tracks_attributes ||= [] end diff --git a/app/models/user.rb b/app/models/user.rb index 394902a..2bacbde 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -83,11 +83,11 @@ def avatar_url(size = :medium) url || "daniel-schludi-mbGxz7pt0jM-unsplash-sqr-s-bn.png" end - def self.track_preloaded_by_user(id) + def self.track_preloaded_by_user(current_user_id:, user: ) # Track.left_outer_joins(:reposts, :likes) # .where("reposts.user_id = :id OR likes.liker_id = :id OR reposts.user_id IS NULL OR likes.liker_id IS NULL", id: id) # .includes(:audio_blob, :cover_blob, user: :avatar_attachment) - user = User.find(id) + # user = User.find(id) tracks = Track.arel_table users = User.arel_table reposts_alias = Repost.arel_table.alias("r") @@ -96,60 +96,58 @@ def self.track_preloaded_by_user(id) reposts_join = tracks .join(reposts_alias, Arel::Nodes::OuterJoin) .on(reposts_alias[:track_id].eq(tracks[:id]) - .and(reposts_alias[:user_id].eq(id))) + .and(reposts_alias[:user_id].eq(current_user_id))) .join_sources likes_join = tracks .join(likes_alias, Arel::Nodes::OuterJoin) .on(likes_alias[:likeable_id].eq(tracks[:id]) .and(likes_alias[:likeable_type].eq("Track")) - .and(likes_alias[:liker_id].eq(id)) + .and(likes_alias[:liker_id].eq(current_user_id)) .and(likes_alias[:liker_type].eq("User"))) .join_sources if !user.label result = Track.includes(:audio_blob, :cover_blob, user: :avatar_attachment) .joins(reposts_join, likes_join) + .where(tracks[:user_id].eq(user.id)) .select("tracks.*, r.id as repost_id, l.id as like_id") .references(:r, :l) return result else # Gather child account IDs - child_ids = User.find(id).child_accounts.pluck(:id) + # child_ids = User.find(id).child_accounts.pluck(:id) # Adjust where clause to include tracks from child accounts result = Track.includes(:audio_blob, :cover_blob, user: :avatar_attachment) .joins(reposts_join, likes_join) - .where(tracks[:user_id].eq(id).or(tracks[:user_id].in(child_ids))) + .where(tracks[:user_id].eq(user.id).or(tracks[:label_id].in(user.id))) .select("tracks.*, r.id as repost_id, l.id as like_id") .references(:r, :l) end end - def self.track_preloaded_by_user_n(id) - user = User.find(id) + def self.track_preloaded_by_user_n(user:) tracks = Track.arel_table users = User.arel_table if !user.label result = Track.includes(:audio_blob, :cover_blob, user: :avatar_attachment) + .where(tracks[:user_id].in(user.id)) return result else # Gather child account IDs - child_ids = User.find(id).child_accounts.pluck(:id) # Adjust where clause to include tracks from child accounts result = Track.includes(:audio_blob, :cover_blob, user: :avatar_attachment) - .where(tracks[:user_id].eq(id).or(tracks[:user_id].in(child_ids))) + .where(tracks[:user_id].in(user.id).or(tracks[:label_id].in(user.id))) end end def reposts_preloaded - User.track_preloaded_by_user(id) - .joins(:reposts) - .where("reposts.user_id =?", id) + User.track_preloaded_by_user(id).joins(:reposts).where("reposts.user_id =?", id) end def is_publisher? @@ -223,54 +221,4 @@ def find_artists_excluding_children(q = nil) # def password_required? # false # end -end - - - -class ExistingArtist - include ActiveModel::Model - include ActiveModel::Attributes - include ActiveModel::Validations - - attribute :username, :string - attribute :ticket_id, :integer - attribute :email, :string # Assuming you intend to use it given the validate_email function - - validates :username, presence: true - validates :ticket_id, presence: true - validates :email, presence: true, format: { with: URI::MailTo::EMAIL_REGEXP }, length: { maximum: 160 } - - # Custom validation method if you have additional logic - # validate :custom_validation_method - - private - - # Example custom validation method - # def custom_validation_method - # errors.add(:base, "Custom validation error message") if some_condition - # end -end - - -class NewArtist - include ActiveModel::Model - include ActiveModel::Validations - include ActiveModel::Attributes - - attribute :username, :string - attribute :genre, :string - attribute :hidden, :string - - validates :username, presence: true - validate :validate_email - - def validate_email - # Similar assumption about the `email` attribute - if email.present? && !email.match?(/\A[^\s]+@[^\s]+\z/) - errors.add(:email, "must have the @ sign and no spaces") - end - if email.length > 160 - errors.add(:email, "is too long (maximum is 160 characters)") - end - end end \ No newline at end of file diff --git a/app/views/label_artists/index.html.erb b/app/views/label_artists/index.html.erb index d95986f..fce6e87 100644 --- a/app/views/label_artists/index.html.erb +++ b/app/views/label_artists/index.html.erb @@ -1,4 +1,4 @@ - <% admin = current_user.id == @label&.id %> + <% admin = current_user && current_user.id == @label&.id %>
@@ -23,32 +23,33 @@ <% @label.child_accounts.each do |artist| %>
-
- <%= image_tag(artist.avatar_url, class: "h-full w-full object-cover object-center") %> -
+ <%= link_to user_path(artist.username) do %> +
+ <%= image_tag(artist.avatar_url, class: "h-full w-full object-cover object-center") %> +
-

- <%= link_to user_path(artist.username) do %> +

<%= artist.username %> - <% end %> -

+ + <% end %> + + + <% if admin %> + + <% end %>
- <% if admin %> -
- - <%= link_to impersonate_account_connections_path(username: artist.username) do %> - Impersonate - <% end %> - - <%= link_to edit_account_connection_path(artist.id) do %> - Edit - <% end %> - <%= link_to account_connection_path(artist.id), data: {turbo_method: :destroy, turbo_confirm: "sure?"} do %> - Remove - <% end %> -
- <% end %>
<% end %>
diff --git a/app/views/labels/show.html.erb b/app/views/labels/show.html.erb new file mode 100644 index 0000000..759604c --- /dev/null +++ b/app/views/labels/show.html.erb @@ -0,0 +1,294 @@ +
+
+
+
+ <%= image_tag @user.avatar_url(:medium), class: "sm:w-48 sm:h-48 w-16 h-16 rounded-full" %> +
+
+

<%= @user.username %>

+

<%= @user.first_name %> <%= @user.last_name%>

+

<%= @user.country %> <%= @user.city %>

+
+
+ +
+
+ + +
+ +
+
+ +
+
+
+ + +
+ +
+ +
+
+ + <% if @title == "All" %> + +
+ + <%= turbo_frame_tag "playlist-cards", src: user_playlists_filter_path(@user.username) do %> + loading.... + <% end %> + +
+ + <%= render "spotlights/form" %> + + <% if @user.posts.published.any? %> + <%= render "article_side", articles: @user.posts.published.limit(3) %> + <% end %> + + <% end %> + +
+
+ + + +
+
+
+ +
+ + <%= turbo_frame_tag "paginated-list", class: 'flex flex-col-reverse' do %> + <%= render partial: @section, collection: @collection, as: @as %> + <% end %> + + +
+ + +
+
+
+
+ + + +
\ No newline at end of file diff --git a/app/views/playlists/_basic_info_tab.html.erb b/app/views/playlists/_basic_info_tab.html.erb index e210adb..dc2e49f 100644 --- a/app/views/playlists/_basic_info_tab.html.erb +++ b/app/views/playlists/_basic_info_tab.html.erb @@ -9,6 +9,12 @@ <%= form.text_field :title %>
+ <% if impersonating?(@playlist.user) %> +
+ <%= form.check_box :enable_label, hint: "Associate this playlist to the label" %> +
+ <% end %> +
<%= form.text_area :description %>
diff --git a/app/views/playlists/_cards.html.erb b/app/views/playlists/_cards.html.erb index 46d62d5..3bb0cfc 100644 --- a/app/views/playlists/_cards.html.erb +++ b/app/views/playlists/_cards.html.erb @@ -14,7 +14,7 @@ <% end %> - <%= link_to user_playlists_path(@user.username), class: "text-sm font-semibold leading-6 text-brand-600" do %> + <%= link_to user_playlists_path(@user.username), class: "text-sm font-semibold leading-6 text-brand-600", data: {turbo_frame: "_top"} do %> See all <% end %> diff --git a/app/views/playlists/_form.html.erb b/app/views/playlists/_form.html.erb index 1b11b8d..93b4c9d 100644 --- a/app/views/playlists/_form.html.erb +++ b/app/views/playlists/_form.html.erb @@ -12,10 +12,19 @@ + + <% if impersonating?(@playlist.user) %> +
+ <%= form.check_box :enable_label, hint: "Associate this playlist to the label" %> +
+ <% end %> +
<%= form.label :playlist_type %> <%= form.select :playlist_type, Playlist::Types.plain, label: "Playlist type" %>
+ +
@@ -31,6 +40,7 @@
<%= form.radio_button :private, false, label: "Acceso público", hint: "Todo el mundo con el enlace verá este artículo." %>
+
<%= form.radio_button :private, true, label: "Miembros privados al artículo", hint: "Sólo los miembros de este artículo podrían acceder." %>
diff --git a/app/views/playlists/create.turbo_stream.erb b/app/views/playlists/create.turbo_stream.erb index bf71144..91ed366 100644 --- a/app/views/playlists/create.turbo_stream.erb +++ b/app/views/playlists/create.turbo_stream.erb @@ -3,7 +3,7 @@ <%= @playlist.errors.to_json %> <%= render "form" %> <% else %> -

<%= @playlist.type %> Created

+

<%= @playlist.playlist_type %> Created

<%= link_to "Go to playlist", playlist_path(@playlist), "data-turbo-frame": "_top" %>
diff --git a/app/views/shared/_user_menu.html.erb b/app/views/shared/_user_menu.html.erb index 61b9d88..514758e 100644 --- a/app/views/shared/_user_menu.html.erb +++ b/app/views/shared/_user_menu.html.erb @@ -1,12 +1,12 @@ -<% if session[:parent_user] %> +<% if label_user %> diff --git a/app/views/tracks/_form.html.erb b/app/views/tracks/_form.html.erb index e2df6b8..19030cd 100644 --- a/app/views/tracks/_form.html.erb +++ b/app/views/tracks/_form.html.erb @@ -58,6 +58,12 @@
+ <% if impersonating?(@track.user) %> +
+ <%= form.check_box :enable_label, hint: "Associate this Track to the label" %> +
+ <% end %> +
<%= form.label :tags %>
diff --git a/app/views/tracks/_track_item.html.erb b/app/views/tracks/_track_item.html.erb index da851b2..ef2e932 100644 --- a/app/views/tracks/_track_item.html.erb +++ b/app/views/tracks/_track_item.html.erb @@ -51,11 +51,13 @@

- <%= link_to track_path(track), "data-turbo-frame": "_top" do %> + <%= link_to track_path(track), "data-turbo-frame": "_top", class: "hover:underline" do %> <%= track.title %> <% end %>

-
<%= track.user.username %> <%= track.id %>
+
+ <%= link_to track.user.username, user_path(track.user.username), data: {turbo_frame: "_top"}, class: "hover:underline" %> +
<% if track.private %> diff --git a/app/views/tracks/create.turbo_stream.erb b/app/views/tracks/create.turbo_stream.erb index 37760d5..81d453d 100644 --- a/app/views/tracks/create.turbo_stream.erb +++ b/app/views/tracks/create.turbo_stream.erb @@ -3,7 +3,7 @@ <% if @track_form.step == "info" %> <%= form_with model: @track_form, url: tracks_path(), class: 'direct-upload' do |form| %> -
+
<%= form.hidden_field :step %> <%= form.fields_for :tracks do |ff| %>
diff --git a/app/views/users/about.html.erb b/app/views/users/about.html.erb index 229080e..76053af 100644 --- a/app/views/users/about.html.erb +++ b/app/views/users/about.html.erb @@ -4,7 +4,6 @@
-
@@ -41,9 +40,9 @@

- <%= link_to @user.username, user_path(@user.username) %> + <%= link_to @user.username, user_path(@user.username) , class: "text-brand-500 hover:underline" %>

-

+

<%= @user.country %>, <%= @user.city %>

diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 4cd04ef..6e0c561 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -165,6 +165,40 @@ <%= link_to "more", "/#{@user.username}/about", class: "mr-2 btn-xs outline rounded-sm p-1" %>

+ + +
+
+ <% @user.photos.each do |image| %> +
+ <%= link_to photo_path(image, user_id: @user.id), + data: {turbo_frame: "modal"}, + class: "h-auto max-w-full rounded-lg" do %> + +
+
+ +
+
+ + <% end %> +
+ <% end %> +
+
+ +
diff --git a/app/views/account_connections/approve.erb b/app/views/account_connections/approve.erb new file mode 100644 index 0000000..0c55c2d --- /dev/null +++ b/app/views/account_connections/approve.erb @@ -0,0 +1,27 @@ + + + + +
+
+
+

+ Be part of <%= @label.username %> label. +

+

+ <%= @label.username %>, has extended an invitation to be part of their catalog. + If you are agree please click on accept button, if not, just ignore the message +

+
+ <%= button_to approve_account_connection_url(params[:id]), class: "button-sm-outline space-x-2" do %> + Get started + <% end %> + + + Learn more + + +
+
+
+
diff --git a/app/views/connected_account_mailer/invitation_email.erb b/app/views/connected_account_mailer/invitation_email.erb new file mode 100644 index 0000000..aaaf4e1 --- /dev/null +++ b/app/views/connected_account_mailer/invitation_email.erb @@ -0,0 +1,19 @@ + +Dear <%= @artist.full_name %>, +
+ +We are delighted to extend an exclusive invitation for you to join Label <%= @label.username %>, on Rauversion platform. +
+Please confirm your interest by clicking on the following link: +
+<%= approve_account_connection_url(@connected_account.signed_id ) %> + +
+As a member of Label <%= @label.username %>, you will have access to unique collaborative opportunities, +promotional support, and the chance to connect with a network of talented artists and industry professionals. +
+If you have any questions or wish to discuss this exciting opportunity further, please do not hesitate to contact us. +
+Warm regards, +
+Rauversion team \ No newline at end of file diff --git a/app/views/connected_account_mailer/new_account_notification_to_label.erb b/app/views/connected_account_mailer/new_account_notification_to_label.erb new file mode 100644 index 0000000..620afdb --- /dev/null +++ b/app/views/connected_account_mailer/new_account_notification_to_label.erb @@ -0,0 +1,28 @@ + +Dear <%= @label.username %>,
+ +We are excited to announce that a new artist account has been created on the your label, <%= @label.username%> on Rauversion. +
+This addition underscores our commitment to nurturing a diverse and vibrant artistic community. + +
+Artist Details: +
+ +
+Name: <%= @artist.full_name %> +
+ +Account Created On: <%= l @artist.created_at, format: :short %> +
+Please ensure that the artist’s onboarding process is seamless and engaging. +For more information or to review their profile, please visit the link below: +
+<%= user_url @artist.username %> +
+Thank you for your cooperation and enthusiasm as we welcome our newest artist to the Label <%= @label.full_name%> family. + +
+Best regards, +
+Rauversion Team \ No newline at end of file diff --git a/app/views/label_artists/_artist.erb b/app/views/label_artists/_artist.erb new file mode 100644 index 0000000..c8ebd88 --- /dev/null +++ b/app/views/label_artists/_artist.erb @@ -0,0 +1,35 @@ +
+
+ <%= link_to user_path(artist.username), data: {turbo_frame: "_top"} do %> +
+ <%= image_tag(artist.avatar_url, class: "h-full w-full object-cover object-center") %> +
+ +

+ <%= artist.full_name.present? ? artist.full_name : artist.username %> +

+ <% end %> + + + <% if @admin %> + + <% end %> +
+ +
\ No newline at end of file diff --git a/app/views/users/label_artists.html.erb b/app/views/users/label_artists.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/spec/mailers/connected_account_mailer_spec.rb b/spec/mailers/connected_account_mailer_spec.rb new file mode 100644 index 0000000..ad2c04b --- /dev/null +++ b/spec/mailers/connected_account_mailer_spec.rb @@ -0,0 +1,5 @@ +require "rails_helper" + +RSpec.describe ConnectedAccountMailer, type: :mailer do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/mailers/previews/connected_account_mailer_preview.rb b/spec/mailers/previews/connected_account_mailer_preview.rb new file mode 100644 index 0000000..32c6ffd --- /dev/null +++ b/spec/mailers/previews/connected_account_mailer_preview.rb @@ -0,0 +1,14 @@ +# Preview all emails at http://localhost:3000/rails/mailers/connected_account_mailer +class ConnectedAccountMailerPreview < ActionMailer::Preview + + + def new_account_notification_to_label + connected_account = ConnectedAccount.last + ConnectedAccountMailer.with(connected_account).new_account_notification_to_label(connected_account) + end + + def invitation_email + connected_account = ConnectedAccount.last + ConnectedAccountMailer.with(connected_account).invitation_email(connected_account) + end +end