initialize invites

Invites model,controller and views are initialized.

add datepicker and selectize in invites#new

calender is added for end date field and selectize is added for emails field to allow multiple emails in field
This commit is contained in:
Rahul 2019-08-10 14:07:48 +05:30
parent a96722b3c3
commit 654760c3fc
8 changed files with 77 additions and 2 deletions

View file

@ -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())){

View file

@ -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

View file

@ -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

8
app/models/invite.rb Normal file
View file

@ -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

View file

@ -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
}
}
} )
});

View file

@ -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

View file

@ -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

View file

@ -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"