mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-15 20:54:03 +00:00
Merge pull request #2354 from Ana06/datepickers
Fix Datepickers in Call for Content
This commit is contained in:
commit
1e5558660f
4 changed files with 45 additions and 105 deletions
|
|
@ -66,22 +66,19 @@ $(function () {
|
|||
format: "YYYY-MM-DD",
|
||||
});
|
||||
|
||||
// end_date_conference >= registration-period-Start_date >= Current_date
|
||||
// registration-period-Start_date <= registration-period-End_date <= End_date (of conference)
|
||||
$("#registration-period-start-datepicker").datetimepicker({
|
||||
pickTime: false,
|
||||
useCurrent: false,
|
||||
format: "YYYY-MM-DD",
|
||||
// today <= start_registration <= end_registration <= end_conference
|
||||
var end_conference = $('form').data('end-conference');
|
||||
|
||||
$('#registration-period-start-datapicker').datetimepicker({
|
||||
format: 'YYYY-MM-DD',
|
||||
minDate : today,
|
||||
maxDate : $("#registration-period-start-datepicker").attr('end_date'),
|
||||
maxDate : end_conference
|
||||
});
|
||||
|
||||
$("#registration-period-end-datepicker").datetimepicker({
|
||||
pickTime: false,
|
||||
useCurrent: false,
|
||||
format: "YYYY-MM-DD",
|
||||
minDate: today,
|
||||
maxDate : $("#registration-period-start-datepicker").attr('end_date'),
|
||||
$('#registration-period-end-datapicker').datetimepicker({
|
||||
format: 'YYYY-MM-DD',
|
||||
minDate : today,
|
||||
maxDate : end_conference
|
||||
});
|
||||
|
||||
$("#conference-start-datepicker").on("dp.change",function (e) {
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@
|
|||
.row
|
||||
.col-md-8
|
||||
= semantic_form_for(cfp, url: cfp_form_url(cfp, conference),
|
||||
html: { multipart: true }) do |f|
|
||||
html: { multipart: true,
|
||||
data: { end_conference: conference.end_date.to_s } }) do |f|
|
||||
= f.input :cfp_type, as: :hidden
|
||||
= f.input :start_date, as: :string,
|
||||
input_html: { id: 'registration-period-start-datepicker',
|
||||
start_date: conference.start_date,
|
||||
end_date: conference.end_date, readonly: 'readonly' }
|
||||
input_html: { class: 'form-control',
|
||||
id: 'registration-period-start-datapicker' }
|
||||
= f.input :end_date, as: :string,
|
||||
input_html: { id: 'registration-period-end-datepicker',
|
||||
readonly: 'readonly' }
|
||||
input_html: { class: 'form-control',
|
||||
id: 'registration-period-end-datapicker' }
|
||||
= f.input :description, hint: markdown_hint,
|
||||
input_html: { rows: 2, data: { provide: 'markdown-editable' } }
|
||||
- if cfp.cfp_type == 'events'
|
||||
|
|
|
|||
29
spec/controllers/admin/cfps_controller_spec.rb
Normal file
29
spec/controllers/admin/cfps_controller_spec.rb
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
require 'pry'
|
||||
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Admin::CfpsController do
|
||||
let!(:today) { Date.today }
|
||||
let!(:conference) { create(:conference, start_date: today + 20.days, end_date: today + 30.days) }
|
||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let!(:organizer) { create(:user, role_ids: organizer_role.id) }
|
||||
let(:cfp) { create(:cfp, program: conference.program) }
|
||||
|
||||
before { sign_in(organizer) }
|
||||
|
||||
describe 'POST #create' do
|
||||
it 'successes' do
|
||||
post :create, conference_id: conference.short_title, cfp: { cfp_type: 'events', start_date: today, end_date: today + 6.days, description: 'We call for papers, or tabak, or you know what!' }
|
||||
expect(flash[:notice]).to match('Call for papers successfully created.')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #update' do
|
||||
it 'successes' do
|
||||
patch :update, conference_id: conference.short_title, id: cfp.id, cfp: { end_date: today + 10.days }
|
||||
expect(flash[:notice]).to match('Call for papers successfully updated.')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
feature Conference do
|
||||
|
||||
let!(:conference) { create(:conference) }
|
||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
|
||||
|
||||
shared_examples 'add and update cfp' do
|
||||
scenario 'adds a new cfp', feature: true, js: true do
|
||||
expected_count = Cfp.count + 1
|
||||
|
||||
sign_in organizer
|
||||
|
||||
visit new_admin_conference_program_cfp_path(conference.short_title)
|
||||
|
||||
click_button 'Create Cfp'
|
||||
|
||||
page.find('#flash')
|
||||
expect(flash)
|
||||
.to eq('Creating the call for papers failed. ' +
|
||||
"Start date can't be blank. End date can't be blank.")
|
||||
|
||||
today = Date.today - 1
|
||||
page.execute_script(
|
||||
"$('#registration-period-start-datepicker').val('#{today.strftime('%d/%m/%Y')}')")
|
||||
page.execute_script(
|
||||
"$('#registration-period-end-datepicker').val('#{(today + 6).strftime('%d/%m/%Y')}')")
|
||||
|
||||
click_button 'Create Cfp'
|
||||
|
||||
# Validations
|
||||
expect(flash)
|
||||
.to eq('Call for papers successfully created.')
|
||||
|
||||
visit admin_conference_program_cfp_path(conference.short_title, conference.program.cfp)
|
||||
expect(find('#start-date').text).to eq(today.strftime('%A, %B %-d. %Y'))
|
||||
expect(find('#end-date').text).to eq((today + 6).strftime('%A, %B %-d. %Y'))
|
||||
|
||||
expect(Cfp.count).to eq(expected_count)
|
||||
end
|
||||
|
||||
scenario 'update cfp', feature: true, js: true do
|
||||
create(:cfp, program: conference.program)
|
||||
expected_count = Cfp.count
|
||||
|
||||
sign_in organizer
|
||||
visit admin_conference_program_cfp_path(conference.short_title, conference.program.cfp)
|
||||
click_link 'Edit'
|
||||
|
||||
# Validate update with empty start date will not saved
|
||||
page.execute_script(
|
||||
"$('#registration-period-start-datepicker').val('')")
|
||||
click_button 'Update Cfp'
|
||||
page.find('#flash')
|
||||
expect(flash)
|
||||
.to eq('Updating call for papers failed. ' +
|
||||
"Start date can't be blank.")
|
||||
|
||||
# Fill in date
|
||||
today = Date.today - 9
|
||||
page.execute_script(
|
||||
"$('#registration-period-start-datepicker').val('#{today.strftime('%d/%m/%Y')}')")
|
||||
page.execute_script(
|
||||
"$('#registration-period-end-datepicker').val('#{(today + 14).strftime('%d/%m/%Y')}')")
|
||||
|
||||
click_button 'Update Cfp'
|
||||
|
||||
# Validations
|
||||
page.find('#flash')
|
||||
expect(flash)
|
||||
.to eq('Call for papers successfully updated.')
|
||||
|
||||
visit admin_conference_program_cfp_path(conference.short_title, conference.program.cfp)
|
||||
expect(find('#start-date').text).to eq(today.strftime('%A, %B %-d. %Y'))
|
||||
expect(find('#end-date').text).to eq((today + 14).strftime('%A, %B %-d. %Y'))
|
||||
expect(Cfp.count).to eq(expected_count)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'organizer' do
|
||||
it_behaves_like 'add and update cfp'
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue