Add invite comments (#10465)
This commit is contained in:
@ -43,7 +43,7 @@ class InvitesController < ApplicationController
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.require(:invite).permit(:max_uses, :expires_in, :autofollow)
|
||||
params.require(:invite).permit(:max_uses, :expires_in, :autofollow, :comment)
|
||||
end
|
||||
|
||||
def set_body_classes
|
||||
|
@ -12,6 +12,7 @@
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# autofollow :boolean default(FALSE), not null
|
||||
# comment :text
|
||||
#
|
||||
|
||||
class Invite < ApplicationRecord
|
||||
@ -22,6 +23,8 @@ class Invite < ApplicationRecord
|
||||
|
||||
scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) }
|
||||
|
||||
validates :comment, length: { maximum: 420 }
|
||||
|
||||
before_validation :set_code
|
||||
|
||||
def valid_for_use?
|
||||
|
@ -10,5 +10,8 @@
|
||||
.fields-group
|
||||
= f.input :autofollow, wrapper: :with_label
|
||||
|
||||
.fields-group
|
||||
= f.input :comment, wrapper: :with_label, input_html: { maxlength: 420 }
|
||||
|
||||
.actions
|
||||
= f.button :button, t('invites.generate'), type: :submit
|
||||
|
@ -20,6 +20,9 @@
|
||||
%td{ colspan: 2 }
|
||||
= t('invites.expired')
|
||||
|
||||
%td
|
||||
= invite.comment
|
||||
|
||||
%td
|
||||
- if invite.valid_for_use? && policy(invite).destroy?
|
||||
= table_link_to 'times', t('invites.delete'), invite_path(invite), method: :delete
|
||||
|
@ -15,6 +15,7 @@
|
||||
%th
|
||||
%th= t('invites.table.uses')
|
||||
%th= t('invites.table.expires_at')
|
||||
%th= t('invites.table.comment')
|
||||
%th
|
||||
%tbody
|
||||
= render @invites
|
||||
|
Reference in New Issue
Block a user