about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-08-19 11:40:42 +0200
committerEugen Rochko <eugen@zeonfederated.com>2019-08-19 11:40:42 +0200
commitcb62a83a71a9679061f8daa468119124b5da5e76 (patch)
treede738499adbad4d4ebbd76401b3632946d0fa96e /app
parent9b6a5ed109e1986149c1f15a41d4f442ae8ae39c (diff)
Add invite comments (#10465)
Diffstat (limited to 'app')
-rw-r--r--app/controllers/invites_controller.rb2
-rw-r--r--app/models/invite.rb3
-rw-r--r--app/views/invites/_form.html.haml3
-rw-r--r--app/views/invites/_invite.html.haml3
-rw-r--r--app/views/invites/index.html.haml1
5 files changed, 11 insertions, 1 deletions
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb
index de5280305..8d92147e2 100644
--- a/app/controllers/invites_controller.rb
+++ b/app/controllers/invites_controller.rb
@@ -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
diff --git a/app/models/invite.rb b/app/models/invite.rb
index 02ab8e0b2..29d25eae8 100644
--- a/app/models/invite.rb
+++ b/app/models/invite.rb
@@ -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?
diff --git a/app/views/invites/_form.html.haml b/app/views/invites/_form.html.haml
index 3a2a5ef0e..b19f70539 100644
--- a/app/views/invites/_form.html.haml
+++ b/app/views/invites/_form.html.haml
@@ -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
diff --git a/app/views/invites/_invite.html.haml b/app/views/invites/_invite.html.haml
index 62799ca5b..03050c868 100644
--- a/app/views/invites/_invite.html.haml
+++ b/app/views/invites/_invite.html.haml
@@ -21,5 +21,8 @@
       = 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
diff --git a/app/views/invites/index.html.haml b/app/views/invites/index.html.haml
index 61420ab1e..62065d6ae 100644
--- a/app/views/invites/index.html.haml
+++ b/app/views/invites/index.html.haml
@@ -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