Scope model methods by account
This commit is contained in:
committed by
Mike Dalessio
parent
a0251255a7
commit
15eeba82f5
@@ -18,8 +18,8 @@ class Account < ApplicationRecord
|
||||
class << self
|
||||
def create_with_admin_user(account:, owner:)
|
||||
create!(**account).tap do |account|
|
||||
User.create!(account: account, role: :system, name: "System")
|
||||
User.create!(**owner.reverse_merge(role: "admin", account: account))
|
||||
account.users.create!(role: :system, name: "System")
|
||||
account.users.create!(**owner.reverse_merge(role: "admin"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
module Ai
|
||||
def self.table_name_prefix
|
||||
"ai_"
|
||||
end
|
||||
end
|
||||
+1
-1
@@ -64,7 +64,7 @@ class Card < ApplicationRecord
|
||||
end
|
||||
|
||||
def handle_board_change
|
||||
old_board = Board.find_by(id: board_id_before_last_save)
|
||||
old_board = account.boards.find_by(id: board_id_before_last_save)
|
||||
|
||||
transaction do
|
||||
update! column: nil
|
||||
|
||||
@@ -3,6 +3,12 @@ class Push::Subscription < ApplicationRecord
|
||||
belongs_to :user
|
||||
|
||||
def notification(**params)
|
||||
WebPush::Notification.new(**params, badge: user.notifications.unread.count, endpoint: endpoint, p256dh_key: p256dh_key, auth_key: auth_key)
|
||||
WebPush::Notification.new(
|
||||
**params,
|
||||
badge: user.notifications.unread.count,
|
||||
endpoint: endpoint,
|
||||
p256dh_key: p256dh_key,
|
||||
auth_key: auth_key
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,15 +21,15 @@ class User::Filtering
|
||||
end
|
||||
|
||||
def tags
|
||||
@tags ||= Tag.all.alphabetically
|
||||
@tags ||= account.tags.all.alphabetically
|
||||
end
|
||||
|
||||
def users
|
||||
@users ||= Current.account.users.active.alphabetically
|
||||
@users ||= account.users.active.alphabetically
|
||||
end
|
||||
|
||||
def filters
|
||||
@filters ||= Current.user.filters.all
|
||||
@filters ||= user.filters.all
|
||||
end
|
||||
|
||||
def expanded?
|
||||
@@ -77,4 +77,9 @@ class User::Filtering
|
||||
def cache_key
|
||||
ActiveSupport::Cache.expand_cache_key([ user, filter, expanded?, boards, tags, users, filters ], "user-filtering")
|
||||
end
|
||||
|
||||
private
|
||||
def account
|
||||
user.account
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,7 +49,7 @@ class Webhook < ApplicationRecord
|
||||
end
|
||||
|
||||
def renderer
|
||||
@renderer ||= ApplicationController.renderer.new(script_name: "/#{account.external_account_id}", https: !Rails.env.local?)
|
||||
@renderer ||= ApplicationController.renderer.new(script_name: account.slug, https: !Rails.env.local?)
|
||||
end
|
||||
|
||||
def for_basecamp?
|
||||
|
||||
Reference in New Issue
Block a user