From ebcbd6619eb2571c6c5fcc68708295757c6b7f55 Mon Sep 17 00:00:00 2001 From: Miguel michelson Date: Sat, 8 Jun 2024 14:03:18 -0400 Subject: [PATCH] track deletion, initial config handles --- Gemfile.lock | 4 ++++ app/controllers/player_controller.rb | 4 +++- app/controllers/users_controller.rb | 2 +- app/models/track.rb | 8 ++++---- app/views/users/show.html.erb | 18 +++++++++++++++--- db/schema.rb | 4 ++-- 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2ac1599..b01e4c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -408,6 +408,8 @@ GEM nio4r (2.7.3) nokogiri (1.16.5-arm64-darwin) racc (~> 1.4) + nokogiri (1.16.5-x86_64-darwin) + racc (~> 1.4) nokogiri (1.16.5-x86_64-linux) racc (~> 1.4) oauth (1.1.0) @@ -608,6 +610,7 @@ GEM stripe (8.6.0) thor (1.3.1) tiktoken_ruby (0.0.5-arm64-darwin) + tiktoken_ruby (0.0.5-x86_64-darwin) tiktoken_ruby (0.0.5-x86_64-linux) timeout (0.4.1) transbank-sdk (3.0.2) @@ -642,6 +645,7 @@ GEM PLATFORMS arm64-darwin-21 arm64-darwin-22 + x86_64-darwin-23 x86_64-linux DEPENDENCIES diff --git a/app/controllers/player_controller.rb b/app/controllers/player_controller.rb index 26deb56..d119361 100644 --- a/app/controllers/player_controller.rb +++ b/app/controllers/player_controller.rb @@ -7,7 +7,9 @@ def update def show id = params[:id] - @track = Track.friendly.find(id) + @track = Track.friendly.find_by(id) + + render status: :ok and return if @track.blank? # @next_track = next_track(@track.id) # @prev_track = previous(@track.id) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3ccd386..8a6bb8f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -148,7 +148,7 @@ def get_tracks User.track_preloaded_by_user(current_user_id: current_user&.id, user: @user ) #.where(user_id: @user.id) else - User.track_preloaded_by_user_n(user: @user) + User.track_preloaded_by_user_n(user: @user).where(private: [nil, false]) #.where(user_id: @user.id) #@user.tracks.published end diff --git a/app/models/track.rb b/app/models/track.rb index 529a536..5e7f17d 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -9,10 +9,10 @@ class Track < ApplicationRecord has_many :listening_events has_many :reposts has_many :purchased_items, as: :purchased_item - has_many :likes, as: :likeable - has_many :comments, as: :commentable - has_one :track_peak - has_many :spotlights, as: :spotlightable + has_many :likes, as: :likeable, dependent: :destroy + has_many :comments, as: :commentable, dependent: :destroy + has_one :track_peak, dependent: :destroy + has_many :spotlights, as: :spotlightable, dependent: :destroy # has_many :spotlighted_tracks, through: :spotlight_tracks belongs_to :label, class_name: "User", optional: true diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 8453c17..fc311c2 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -106,9 +106,21 @@

<%= @title %>

<% if @user.id == current_user&.id %> - <%= link_to @cta_url || new_account_connection_path, class: "button-sm-outline space-x-2", data: {turbo_frame: "modal"} do %> - <%= heroicon("plus") %> - <%= @cta_label || t("tracks.new_track") %> + + <% if !@cta_url %> + <%= link_to new_track_path, class: "button-sm-outline space-x-2" do %> + <%= heroicon("plus") %> + <%= t("tracks.new_track") %> + <% end %> + + <% else %> + + <%= link_to @cta_url, class: "button-sm-outline space-x-2", + data: {turbo_frame: "modal"} do %> + <%= heroicon("plus") %> + <%= @cta_label %> + <% end %> + <% end %> <% end %> diff --git a/db/schema.rb b/db/schema.rb index 29c37f0..abea656 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_05_06_041324) do +ActiveRecord::Schema[7.1].define(version: 2024_05_06_041324) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -160,7 +160,7 @@ t.jsonb "event_settings" t.jsonb "tickets" t.bigint "user_id", null: false - t.jsonb "streaming_service", default: {} + t.jsonb "streaming_service" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["user_id"], name: "index_events_on_user_id"