diff --git a/app/assets/javascripts/osem-datepickers.js b/app/assets/javascripts/osem-datepickers.js index b907aa0c..22604449 100644 --- a/app/assets/javascripts/osem-datepickers.js +++ b/app/assets/javascripts/osem-datepickers.js @@ -32,6 +32,12 @@ $(function () { minDate : $("#registration-arrival-datepicker").attr('start_date') }); + $('#invitation-end-date').datetimepicker({ + format: 'YYYY-MM-DD', + maxDate : $("#invitation-end-date").attr('end_date'), + minDate : today + }); + $("#registration-arrival-datepicker").on("dp.change",function (e) { // departure_date > start_date,arrival_date if ((new Date(e.date).getTime()) > (new Date($("#registration-arrival-datepicker").attr('start_date')).getTime())){ diff --git a/app/controllers/admin/invites_controller.rb b/app/controllers/admin/invites_controller.rb new file mode 100644 index 00000000..02bb4706 --- /dev/null +++ b/app/controllers/admin/invites_controller.rb @@ -0,0 +1,11 @@ +module Admin + class InvitesController < Admin::BaseController + load_and_authorize_resource :conference, find_by: :short_title + + def new + @invite = @conference.invites.new + end + + def create; end + end +end diff --git a/app/models/conference.rb b/app/models/conference.rb index be3c36ad..9272dab8 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -33,6 +33,7 @@ class Conference < ApplicationRecord has_many :resources, dependent: :destroy has_many :booths, dependent: :destroy has_many :confirmed_booths, -> { where(state: 'confirmed') }, class_name: 'Booth' + has_many :invites, dependent: :destroy has_many :lodgings, dependent: :destroy has_many :registrations, dependent: :destroy diff --git a/app/models/invite.rb b/app/models/invite.rb new file mode 100644 index 00000000..3ebb0d04 --- /dev/null +++ b/app/models/invite.rb @@ -0,0 +1,8 @@ +class Invite < ApplicationRecord + attr_accessor :emails + belongs_to :conference + + validates :end_date, presence: true + validates :invite_for, presence: true + validates :user_id, presence: true, uniqueness: { scope: [:invite_for, :conference_id] } +end diff --git a/app/views/admin/invites/new.html.haml b/app/views/admin/invites/new.html.haml new file mode 100644 index 00000000..a921d532 --- /dev/null +++ b/app/views/admin/invites/new.html.haml @@ -0,0 +1,28 @@ +.row + .col-md-offset-1.col-md-8 + %h1.text-center Late Submission Invitation + = semantic_form_for(@invite, url: admin_conference_invites_path, html: { multipart: true }) do |f| + = f.input :emails, class: 'form-control', required: true, + hint: 'Add emails to invite people to join the app and submit requests after the cfps deadline.' + = f.input :invite_for, as: :select, collection: ['Track', (t 'booth').capitalize] + = f.input :end_date, as: :string, input_html: { id: 'invitation-end-date', end_date: @conference.end_date } + %p.text-right + = f.submit 'Submit', class: 'btn btn-success' + + :javascript + $(document).ready(function() { + $('#invite_emails').selectize({ + plugins: ['remove_button'], + delimiter: ',', + persist: false, + create: function(input) { + if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(input)){ + return {} + } + return { + value: input, + text: input + } + } + } ) + }); diff --git a/config/routes.rb b/config/routes.rb index 57bfa630..6a5df73c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -45,7 +45,7 @@ Osem::Application.routes.draw do get '/volunteers_list' => 'volunteers#show' get '/volunteers' => 'volunteers#index', as: 'volunteers_info' patch '/volunteers' => 'volunteers#update', as: 'volunteers_update' - + resources :invites resources :booths do member do patch :accept diff --git a/db/migrate/20190810082925_create_invites.rb b/db/migrate/20190810082925_create_invites.rb new file mode 100644 index 00000000..56b4203e --- /dev/null +++ b/db/migrate/20190810082925_create_invites.rb @@ -0,0 +1,12 @@ +class CreateInvites < ActiveRecord::Migration[5.2] + def change + create_table :invites do |t| + t.integer :conference_id + t.integer :user_id + t.date :end_date + t.text :invite_for + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 683eb437..36cad41b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_06_12_161235) do +ActiveRecord::Schema.define(version: 2019_08_10_082925) do create_table "answers", force: :cascade do |t| t.string "title" @@ -264,6 +264,15 @@ ActiveRecord::Schema.define(version: 2019_06_12_161235) do t.datetime "created_at" end + create_table "invites", force: :cascade do |t| + t.integer "conference_id" + t.integer "user_id" + t.date "end_date" + t.text "invite_for" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "lodgings", force: :cascade do |t| t.string "name" t.text "description"