Store and show the user that postpones cards

This commit is contained in:
Jorge Manrubia
2025-10-15 13:44:49 +02:00
parent 9f3b0755f1
commit 9263cff3d5
8 changed files with 38 additions and 5 deletions
+1
View File
@@ -1,3 +1,4 @@
class Card::NotNow < ApplicationRecord
belongs_to :card, class_name: "::Card", touch: true
belongs_to :user, optional: true
end
+2 -2
View File
@@ -24,12 +24,12 @@ module Card::Postponable
open? && published? && !postponed?
end
def postpone
def postpone(user: Current.user)
transaction do
send_back_to_triage
reopen
activity_spike&.destroy
create_not_now! unless postponed?
create_not_now!(user: user) unless postponed?
end
end
@@ -10,7 +10,7 @@
<div class="card__closed">
<span class="card__closed-title" data-text="Not Now">Not Now</span>
<strong class="card__closed-date"><%= card.postponed_at.strftime("%b %d, %Y") %></strong>
<span class="card__closed-by-line">by <span class="card__closed-by"><%# card.postponed_by.familiar_name %></span></span>
<span class="card__closed-by-line">by <span class="card__closed-by"><%= card.postponed_by.familiar_name %></span></span>
</div>
<% end %>
@@ -0,0 +1,5 @@
class AddCreatorToCardNotNows < ActiveRecord::Migration[8.1]
def change
add_reference :card_not_nows, :creator, null: false, foreign_key: { to_table: :users }
end
end
@@ -0,0 +1,5 @@
class RenameCreatorToUserInCardNotNows < ActiveRecord::Migration[8.1]
def change
rename_column :card_not_nows, :creator_id, :user_id
end
end
Generated
+4 -1
View File
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.1].define(version: 2025_10_07_084223) do
ActiveRecord::Schema[8.1].define(version: 2025_10_15_114014) do
create_table "accesses", force: :cascade do |t|
t.datetime "accessed_at"
t.integer "collection_id", null: false
@@ -135,7 +135,9 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_07_084223) do
t.integer "card_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id", null: false
t.index ["card_id"], name: "index_card_not_nows_on_card_id", unique: true
t.index ["user_id"], name: "index_card_not_nows_on_user_id"
end
create_table "cards", force: :cascade do |t|
@@ -508,6 +510,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_07_084223) do
add_foreign_key "card_activity_spikes", "cards"
add_foreign_key "card_goldnesses", "cards"
add_foreign_key "card_not_nows", "cards"
add_foreign_key "card_not_nows", "users"
add_foreign_key "cards", "columns"
add_foreign_key "closures", "cards"
add_foreign_key "closures", "users"
+18 -1
View File
@@ -438,6 +438,7 @@ columns:
- *5
- *6
- *9
- *18
cards:
- *24
- !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column
@@ -1963,6 +1964,22 @@ indexes:
nulls_not_distinct:
comment:
valid: true
- !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition
table: card_not_nows
name: index_card_not_nows_on_user_id
unique: false
columns:
- user_id
lengths: {}
orders: {}
opclasses: {}
where:
type:
using:
include:
nulls_not_distinct:
comment:
valid: true
cards:
- !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition
table: cards
@@ -3148,4 +3165,4 @@ indexes:
nulls_not_distinct:
comment:
valid: true
version: 20251007084223
version: 20251015114014
+2
View File
@@ -22,6 +22,8 @@ class Card::PostponableTest < ActiveSupport::TestCase
assert_changes -> { card.reload.postponed? }, to: true do
card.postpone
end
assert_equal users(:david), card.not_now.user
end
test "scopes" do