mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
@streed is the literal best
This commit is contained in:
parent
69b5ab66ea
commit
059fc67ba2
@ -2,8 +2,10 @@ class PageUnlockPromoCode < ApplicationRecord
|
||||
has_many :promotions
|
||||
has_many :users, -> { distinct }, through: :promotions
|
||||
|
||||
def unlocked_page_types
|
||||
page_types.split('|') & Rails.application.config.content_types[:all].map(&:name)
|
||||
serialize :page_types, Array
|
||||
|
||||
def whitelisted_page_types
|
||||
page_types & Rails.application.config.content_types[:all].map(&:name)
|
||||
end
|
||||
|
||||
|
||||
@ -19,7 +21,7 @@ class PageUnlockPromoCode < ApplicationRecord
|
||||
# 1 use left, but this seems not worth it to fix
|
||||
update(uses_remaining: uses_remaining - 1)
|
||||
|
||||
unlocked_page_types.each do |page_type|
|
||||
whitelisted_page_types.each do |page_type|
|
||||
promotions.create(
|
||||
user: user,
|
||||
content_type: page_type,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user