Files
fizzy/app/models/account.rb
T
Kevin McConnell e16cc21b0a Add "data export" feature
- Adds a button in Account Settings where you can request a ZIP export of your
  Fizzy data
- Export files are created in the background. When ready, a link to
  download them is sent to the requester.
- Exports expire after 24 hours. And are limited to 10 per day.
2025-12-01 15:23:26 +00:00

46 lines
1.0 KiB
Ruby

class Account < ApplicationRecord
include Entropic, Seedeable
has_one :join_code
has_many :users, dependent: :destroy
has_many :boards, dependent: :destroy
has_many :cards, dependent: :destroy
has_many :webhooks, dependent: :destroy
has_many :tags, dependent: :destroy
has_many :columns, dependent: :destroy
has_many :exports, class_name: "Account::Export", dependent: :destroy
has_many_attached :uploads
before_create :assign_external_account_id
after_create :create_join_code
validates :name, presence: true
class << self
def create_with_owner(account:, owner:)
create!(**account).tap do |account|
account.users.create!(role: :system, name: "System")
account.users.create!(**owner.reverse_merge(role: "owner"))
end
end
end
def slug
"/#{external_account_id}"
end
def account
self
end
def system_user
users.where(role: :system).first!
end
private
def assign_external_account_id
self.external_account_id ||= ExternalIdSequence.next
end
end