Add invite comments (#10465)
This commit is contained in:
parent
9b6a5ed109
commit
cb62a83a71
@ -43,7 +43,7 @@ class InvitesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def resource_params
|
def resource_params
|
||||||
params.require(:invite).permit(:max_uses, :expires_in, :autofollow)
|
params.require(:invite).permit(:max_uses, :expires_in, :autofollow, :comment)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_body_classes
|
def set_body_classes
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# autofollow :boolean default(FALSE), not null
|
# autofollow :boolean default(FALSE), not null
|
||||||
|
# comment :text
|
||||||
#
|
#
|
||||||
|
|
||||||
class Invite < ApplicationRecord
|
class Invite < ApplicationRecord
|
||||||
@ -22,6 +23,8 @@ class Invite < ApplicationRecord
|
|||||||
|
|
||||||
scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) }
|
scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) }
|
||||||
|
|
||||||
|
validates :comment, length: { maximum: 420 }
|
||||||
|
|
||||||
before_validation :set_code
|
before_validation :set_code
|
||||||
|
|
||||||
def valid_for_use?
|
def valid_for_use?
|
||||||
|
@ -10,5 +10,8 @@
|
|||||||
.fields-group
|
.fields-group
|
||||||
= f.input :autofollow, wrapper: :with_label
|
= f.input :autofollow, wrapper: :with_label
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= f.input :comment, wrapper: :with_label, input_html: { maxlength: 420 }
|
||||||
|
|
||||||
.actions
|
.actions
|
||||||
= f.button :button, t('invites.generate'), type: :submit
|
= f.button :button, t('invites.generate'), type: :submit
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
%td{ colspan: 2 }
|
%td{ colspan: 2 }
|
||||||
= t('invites.expired')
|
= t('invites.expired')
|
||||||
|
|
||||||
|
%td
|
||||||
|
= invite.comment
|
||||||
|
|
||||||
%td
|
%td
|
||||||
- if invite.valid_for_use? && policy(invite).destroy?
|
- if invite.valid_for_use? && policy(invite).destroy?
|
||||||
= table_link_to 'times', t('invites.delete'), invite_path(invite), method: :delete
|
= table_link_to 'times', t('invites.delete'), invite_path(invite), method: :delete
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
%th
|
%th
|
||||||
%th= t('invites.table.uses')
|
%th= t('invites.table.uses')
|
||||||
%th= t('invites.table.expires_at')
|
%th= t('invites.table.expires_at')
|
||||||
|
%th= t('invites.table.comment')
|
||||||
%th
|
%th
|
||||||
%tbody
|
%tbody
|
||||||
= render @invites
|
= render @invites
|
||||||
|
5
db/migrate/20190403141604_add_comment_to_invites.rb
Normal file
5
db/migrate/20190403141604_add_comment_to_invites.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddCommentToInvites < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :invites, :comment, :text
|
||||||
|
end
|
||||||
|
end
|
@ -344,6 +344,7 @@ ActiveRecord::Schema.define(version: 2019_08_15_225426) do
|
|||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.boolean "autofollow", default: false, null: false
|
t.boolean "autofollow", default: false, null: false
|
||||||
|
t.text "comment"
|
||||||
t.index ["code"], name: "index_invites_on_code", unique: true
|
t.index ["code"], name: "index_invites_on_code", unique: true
|
||||||
t.index ["user_id"], name: "index_invites_on_user_id"
|
t.index ["user_id"], name: "index_invites_on_user_id"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user