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/14] 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/14] 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 From 8ca50c4bded944abbfdd6794e42a79ac16aecfd5 Mon Sep 17 00:00:00 2001 From: Miguel Michelson Martinez Date: Tue, 14 May 2024 22:49:56 -0400 Subject: [PATCH 14/14] user menu, toggle theme + normalizes --- Gemfile | 10 +- Gemfile.lock | 236 ++++++++++-------- app/controllers/event_hosts_controller.rb | 6 +- .../event_recordings_controller.rb | 6 +- app/controllers/events_controller.rb | 6 +- app/controllers/playlists_controller.rb | 2 +- app/controllers/reposts_controller.rb | 2 +- app/controllers/user_follows_controller.rb | 2 +- .../user_integrations_controller.rb | 2 +- .../user_invitations_controller.rb | 2 +- app/controllers/user_settings_controller.rb | 2 +- app/models/user.rb | 3 + app/views/shared/_user_menu.html.erb | 17 +- 13 files changed, 171 insertions(+), 125 deletions(-) diff --git a/Gemfile b/Gemfile index 436cc39..6479b3f 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.2.2" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 7.0.7" +gem "rails", "~> 7.1.3.2" # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] gem "sprockets-rails" @@ -13,7 +13,8 @@ gem "sprockets-rails" gem "pg", "~> 1.1" # Use the Puma web server [https://github.com/puma/puma] -gem "puma", "~> 5.0" +gem "puma" +# gem "falcon" # Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails] gem "jsbundling-rails" @@ -66,7 +67,8 @@ gem "image_processing", "~> 1.2" gem "acts_as_list", "~> 0.9.19" gem "rails_heroicon" gem "aasm", "~> 5.2" -gem "acts-as-taggable-on", "~> 9.0" +gem "acts-as-taggable-on", github: "mbleigh/acts-as-taggable-on" # branch: "support_rails_7-1" + gem "aws-sdk-rails" gem "aws-sdk-s3", "~> 1.48" gem "friendly_id", "~> 5.4" @@ -144,7 +146,7 @@ gem "transbank-sdk", "~> 3.0" gem "stripe", "~> 8.6" gem "mercadopago", "~> 2.3" -gem "meta-tags", "~> 2.18" +gem "meta-tags", github: "kpumuk/meta-tags", branch: :main gem "http", "~> 5.1" diff --git a/Gemfile.lock b/Gemfile.lock index ebe2c26..9fe550c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,6 +38,21 @@ GIT stimulus-rails (>= 1.2) turbo-rails (>= 1.2) +GIT + remote: https://github.com/kpumuk/meta-tags.git + revision: a1bcfdeb54d2daa0706d1fe6cc0890cc25ebfdb1 + branch: main + specs: + meta-tags (2.21.0) + actionpack (>= 6.0.0, < 7.2) + +GIT + remote: https://github.com/mbleigh/acts-as-taggable-on.git + revision: 46c4e2d4b73a49b2e60ecf15a6ea4f6304a55672 + specs: + acts-as-taggable-on (10.0.0) + activerecord (>= 6.1, < 7.2) + GIT remote: https://github.com/rspec/rspec-core.git revision: 81589709e88db1ec2537faee3a7f4a43c7d9aac1 @@ -90,96 +105,103 @@ GEM specs: aasm (5.5.0) concurrent-ruby (~> 1.0) - actioncable (7.0.8.1) - actionpack (= 7.0.8.1) - activesupport (= 7.0.8.1) + actioncable (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.1) - actionpack (= 7.0.8.1) - activejob (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.1) - actionpack (= 7.0.8.1) - actionview (= 7.0.8.1) - activejob (= 7.0.8.1) - activesupport (= 7.0.8.1) + actionmailer (7.1.3.2) + actionpack (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8.1) - actionview (= 7.0.8.1) - activesupport (= 7.0.8.1) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.3.2) + actionview (= 7.1.3.2) + activesupport (= 7.1.3.2) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.1) - actionpack (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.2) + actionpack (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.1) - activesupport (= 7.0.8.1) + actionview (7.1.3.2) + activesupport (= 7.1.3.2) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8.1) - activesupport (= 7.0.8.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.3.6) - activemodel (7.0.8.1) - activesupport (= 7.0.8.1) - activerecord (7.0.8.1) - activemodel (= 7.0.8.1) - activesupport (= 7.0.8.1) - activestorage (7.0.8.1) - actionpack (= 7.0.8.1) - activejob (= 7.0.8.1) - activerecord (= 7.0.8.1) - activesupport (= 7.0.8.1) + activemodel (7.1.3.2) + activesupport (= 7.1.3.2) + activerecord (7.1.3.2) + activemodel (= 7.1.3.2) + activesupport (= 7.1.3.2) + timeout (>= 0.4.0) + activestorage (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activesupport (= 7.1.3.2) marcel (~> 1.0) - mini_mime (>= 1.1.0) activestorage-validator (0.4.0) rails (>= 6.1.0) - activesupport (7.0.8.1) + activesupport (7.1.3.2) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) - acts-as-taggable-on (9.0.1) - activerecord (>= 6.0, < 7.1) acts_as_list (0.9.19) activerecord (>= 3.0) addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - aws-eventstream (1.2.0) - aws-partitions (1.791.0) - aws-record (2.11.0) + aws-eventstream (1.3.0) + aws-partitions (1.929.0) + aws-record (2.13.0) aws-sdk-dynamodb (~> 1, >= 1.85.0) - aws-sdk-core (3.178.0) - aws-eventstream (~> 1, >= 1.0.2) + aws-sdk-core (3.196.1) + aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) - aws-sigv4 (~> 1.5) + aws-sigv4 (~> 1.8) jmespath (~> 1, >= 1.6.1) - aws-sdk-dynamodb (1.92.0) - aws-sdk-core (~> 3, >= 3.177.0) + aws-sdk-dynamodb (1.109.0) + aws-sdk-core (~> 3, >= 3.193.0) aws-sigv4 (~> 1.1) - aws-sdk-kms (1.71.0) - aws-sdk-core (~> 3, >= 3.177.0) + aws-sdk-kms (1.81.0) + aws-sdk-core (~> 3, >= 3.193.0) aws-sigv4 (~> 1.1) - aws-sdk-rails (3.8.0) + aws-sdk-rails (3.12.0) aws-record (~> 2) aws-sdk-ses (~> 1, >= 1.50.0) aws-sdk-sesv2 (~> 1, >= 1.34.0) @@ -187,27 +209,30 @@ GEM aws-sessionstore-dynamodb (~> 2) concurrent-ruby (~> 1) railties (>= 5.2.0) - aws-sdk-s3 (1.131.0) - aws-sdk-core (~> 3, >= 3.177.0) + aws-sdk-s3 (1.151.0) + aws-sdk-core (~> 3, >= 3.194.0) aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.6) - aws-sdk-ses (1.54.0) - aws-sdk-core (~> 3, >= 3.177.0) + aws-sigv4 (~> 1.8) + aws-sdk-ses (1.62.0) + aws-sdk-core (~> 3, >= 3.193.0) aws-sigv4 (~> 1.1) - aws-sdk-sesv2 (1.38.0) - aws-sdk-core (~> 3, >= 3.177.0) + aws-sdk-sesv2 (1.49.0) + aws-sdk-core (~> 3, >= 3.193.0) aws-sigv4 (~> 1.1) - aws-sdk-sqs (1.61.0) - aws-sdk-core (~> 3, >= 3.177.0) + aws-sdk-sqs (1.74.0) + aws-sdk-core (~> 3, >= 3.193.0) aws-sigv4 (~> 1.1) - aws-sessionstore-dynamodb (2.1.0) + aws-sessionstore-dynamodb (2.2.0) aws-sdk-dynamodb (~> 1, >= 1.85.0) - rack (~> 2) - aws-sigv4 (1.6.0) + rack (>= 2, < 4) + rack-session (>= 1, < 3) + aws-sigv4 (1.8.0) aws-eventstream (~> 1, >= 1.0.2) baran (0.1.7) + base64 (0.2.0) bcrypt (3.1.19) bcrypt_pbkdf (1.1.0) + bigdecimal (3.1.8) bindex (0.8.1) bootsnap (1.16.0) msgpack (~> 1.2) @@ -250,6 +275,7 @@ GEM dotenv-rails (2.8.1) dotenv (= 2.8.1) railties (>= 3.2) + drb (2.2.1) ed25519 (1.3.0) erubi (1.12.0) factory_bot (6.2.1) @@ -286,7 +312,7 @@ GEM http-cookie (1.0.5) domain_name (~> 0.5) http-form_data (2.3.0) - i18n (1.14.4) + i18n (1.14.5) concurrent-ruby (~> 1.0) image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) @@ -344,8 +370,6 @@ GEM mercadopago (2.3.0) faraday (>= 0.9.0) json (>= 1.4.6) - meta-tags (2.18.0) - actionpack (>= 3.2.0, < 7.1) method_source (1.1.0) mini_magick (4.12.0) mini_mime (1.1.5) @@ -362,7 +386,8 @@ GEM msgpack (1.7.2) multi_xml (0.6.0) multipart-post (2.3.0) - net-imap (0.4.10) + mutex_m (0.2.0) + net-imap (0.4.11) date net-protocol net-pop (0.1.2) @@ -374,10 +399,10 @@ GEM net-smtp (0.5.0) net-protocol net-ssh (7.2.0) - nio4r (2.7.1) - nokogiri (1.16.4-arm64-darwin) + nio4r (2.7.3) + nokogiri (1.16.5-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.4-x86_64-linux) + nokogiri (1.16.5-x86_64-linux) racc (~> 1.4) oauth (1.1.0) oauth-tty (~> 1.0, >= 1.0.1) @@ -423,30 +448,35 @@ GEM coderay (~> 1.1) method_source (~> 1.0) public_suffix (5.0.3) - puma (5.6.6) + puma (6.4.2) nio4r (~> 2.0) qdrant-ruby (0.9.3) faraday (>= 2.0.1, < 3) racc (1.7.3) - rack (2.2.9) + rack (3.0.11) rack-protection (3.0.6) rack + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8.1) - actioncable (= 7.0.8.1) - actionmailbox (= 7.0.8.1) - actionmailer (= 7.0.8.1) - actionpack (= 7.0.8.1) - actiontext (= 7.0.8.1) - actionview (= 7.0.8.1) - activejob (= 7.0.8.1) - activemodel (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.3.2) + actioncable (= 7.1.3.2) + actionmailbox (= 7.1.3.2) + actionmailer (= 7.1.3.2) + actionpack (= 7.1.3.2) + actiontext (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activemodel (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) bundler (>= 1.15.0) - railties (= 7.0.8.1) + railties (= 7.1.3.2) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -461,13 +491,14 @@ GEM rails_heroicon (2.2.0) actionview railties - railties (7.0.8.1) - actionpack (= 7.0.8.1) - activesupport (= 7.0.8.1) - method_source + railties (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.2.1) redcarpet (2.3.0) @@ -593,6 +624,7 @@ GEM nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (~> 4.0) + webrick (1.8.1) websocket (1.2.9) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) @@ -609,7 +641,7 @@ PLATFORMS DEPENDENCIES aasm (~> 5.2) activestorage-validator - acts-as-taggable-on (~> 9.0) + acts-as-taggable-on! acts_as_list (~> 0.9.19) aws-sdk-rails aws-sdk-s3 (~> 1.48) @@ -634,7 +666,7 @@ DEPENDENCIES kaminari kredis (~> 1.5) mercadopago (~> 2.3) - meta-tags (~> 2.18) + meta-tags! mrsk (~> 0.15.1) omniauth (~> 2.0) omniauth-discord @@ -644,9 +676,9 @@ DEPENDENCIES pg (~> 1.1) plain-rails! pry - puma (~> 5.0) + puma qdrant-ruby (~> 0.9.2) - rails (~> 7.0.7) + rails (~> 7.1.3.2) rails_autolink (~> 1.1) rails_heroicon rqrcode (~> 2.0) diff --git a/app/controllers/event_hosts_controller.rb b/app/controllers/event_hosts_controller.rb index 15a7bce..ed72260 100644 --- a/app/controllers/event_hosts_controller.rb +++ b/app/controllers/event_hosts_controller.rb @@ -11,7 +11,7 @@ def create @event_host = @event.event_hosts.new(event_host_params) @event_host.invite_user if @event_host.save - flash[:now] = "host created" + flash.now[:notice] = "host created" end end @@ -24,7 +24,7 @@ def destroy @event = current_user.events.friendly.find(params[:event_id]) @event_host = @event.event_hosts.find(params[:id]) if @event_host.destroy - flash[:now] = "host removed" + flash.now[:notice] = "host removed" end end @@ -32,7 +32,7 @@ def update @event = current_user.events.friendly.find(params[:event_id]) @event_host = @event.event_hosts.find(params[:id]) if @event_host.update(event_host_params) - flash[:now] = "host updated" + flash.now[:notice] = "host updated" end end diff --git a/app/controllers/event_recordings_controller.rb b/app/controllers/event_recordings_controller.rb index bfc61b5..d7ea13d 100644 --- a/app/controllers/event_recordings_controller.rb +++ b/app/controllers/event_recordings_controller.rb @@ -10,7 +10,7 @@ def create @event = current_user.events.friendly.find(params[:event_id]) @event_recording = @event.event_recordings.new(event_recording_params) if @event_recording.save - flash[:now] = "recording created" + flash.now[:notice] = "recording created" end end @@ -23,7 +23,7 @@ def destroy @event = current_user.events.friendly.find(params[:event_id]) @event_recording = @event.event_recordings.find(params[:id]) if @event_recording.destroy - flash[:now] = "recording removed" + flash.now[:notice] = "recording removed" end end @@ -31,7 +31,7 @@ def update @event = current_user.events.friendly.find(params[:event_id]) @event_recording = @event.event_recordings.find(params[:id]) if @event_recording.update(event_recording_params) - flash[:now] = "recording updated" + flash.now[:notice] = "recording updated" end end diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 6bd9349..ffef5ec 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -22,7 +22,7 @@ def edit def create @event = current_user.events.new(event_params) if @event.save - flash[:now] = "yes!" + flash.now[:notice] = "yes!" redirect_to edit_event_path(@event) end end @@ -33,12 +33,12 @@ def update if params[:toggle_published].present? @event.toggle_published! - flash[:now] = "event #{@event.state}" + flash.now[:notice] = "event #{@event.state}" render "toggle_published" and return end if @event.update(event_params) - flash[:now] = "yes!" + flash.now[:notice] = "yes!" # redirect_to edit_event_path(@event, section: @section) end end diff --git a/app/controllers/playlists_controller.rb b/app/controllers/playlists_controller.rb index 90a0b9a..af2d0c1 100644 --- a/app/controllers/playlists_controller.rb +++ b/app/controllers/playlists_controller.rb @@ -110,7 +110,7 @@ def sort collection = @playlist.track_playlists.find(id) collection.insert_at(position) - flash[:now] = "successfully updated" + flash.now[:notice] = "successfully updated" render "update" diff --git a/app/controllers/reposts_controller.rb b/app/controllers/reposts_controller.rb index f8f893c..816f32f 100644 --- a/app/controllers/reposts_controller.rb +++ b/app/controllers/reposts_controller.rb @@ -10,7 +10,7 @@ def create @button_class = "button-active" @repost = current_user.reposts.create(track: @track) if @repost.errors.blank? - flash[:now] = "Reposted ok!" + flash.now[:notice] = "Reposted ok!" end end end diff --git a/app/controllers/user_follows_controller.rb b/app/controllers/user_follows_controller.rb index 96da65f..305a459 100644 --- a/app/controllers/user_follows_controller.rb +++ b/app/controllers/user_follows_controller.rb @@ -15,7 +15,7 @@ def followers def create @user = User.find_by(username: params[:user_id]) - flash[:now] = if current_user.toggle_follow!(@user) + flash.now[:notice] = if current_user.toggle_follow!(@user) "Followed" else "Unfollowed" diff --git a/app/controllers/user_integrations_controller.rb b/app/controllers/user_integrations_controller.rb index 302fdf0..89f0065 100644 --- a/app/controllers/user_integrations_controller.rb +++ b/app/controllers/user_integrations_controller.rb @@ -5,7 +5,7 @@ def destroy identity = current_user.identities.find(params[:id]) if identity.destroy # user.update(role: "artist") - flash[:now] = "Integration removed" + flash.now[:notice] = "Integration removed" end @user = current_user @section = "integrations" diff --git a/app/controllers/user_invitations_controller.rb b/app/controllers/user_invitations_controller.rb index ed6638e..d0bf222 100644 --- a/app/controllers/user_invitations_controller.rb +++ b/app/controllers/user_invitations_controller.rb @@ -8,7 +8,7 @@ def create # user.update(role: "artist") current_user.decrement(:invitations_count) current_user.save - flash[:now] = "User invited" + flash.now[:notice] = "User invited" end @user = current_user @section = "invitations" diff --git a/app/controllers/user_settings_controller.rb b/app/controllers/user_settings_controller.rb index e03f028..5053c63 100644 --- a/app/controllers/user_settings_controller.rb +++ b/app/controllers/user_settings_controller.rb @@ -16,7 +16,7 @@ def update @user = User.find_by(username: params[:user_id]) @section = params[:section] if @user.update(user_attributes) - flash[:now] = "#{params[:section]} updated" + flash.now[:notice] = "#{params[:section]} updated" end end diff --git a/app/models/user.rb b/app/models/user.rb index d87557f..46eeeeb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -36,6 +36,9 @@ class User < ApplicationRecord acts_as_liker acts_as_mentionable + + normalizes :username, with: -> username { username.parameterize } + include User::OmniAuthExtension store_attribute :notification_settings, :new_follower_email, :boolean diff --git a/app/views/shared/_user_menu.html.erb b/app/views/shared/_user_menu.html.erb index 514758e..8dd031f 100644 --- a/app/views/shared/_user_menu.html.erb +++ b/app/views/shared/_user_menu.html.erb @@ -80,6 +80,19 @@
+ + + <%= link_to "#", class: "hidden sm:block text-brand-600 block- px-4 py-2 text-sm", data: { + action: 'click->dark-mode#toggle' + } do %> + + + <%= heroicon "sun", variant: :mini %> + + <% end %> + <%= link_to "/tracks/new", class: "inline-flex items-center justify-center space-x-1 rounded-md py-2 px-3 text-sm font-medium text-default hover:bg-brand-600" do %> <% end %> - <%= link_to "Toggle Theme", "#", class: "text-brand-600 block- px-4 py-2 text-sm", data: { - action: 'click->dark-mode#toggle' - } %> -
<%= link_to "English", url_for(locale: :en), class: "#{I18n.locale == :en ? 'text-brand-600' : 'text-gray-700 dark:text-gray-300' } block- px-4 py-2 text-sm" %> <%= link_to "Español", url_for(locale: :es), class: "#{I18n.locale == :es ? 'text-brand-600' : 'text-gray-700 dark:text-gray-300'} block- px-4 py-2 text-sm" %>