Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carnival Creation #294

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
df1af4f
creates CsvUpdater as Ruby Object with controller
Mar 27, 2019
708e214
implements carnival creation for Organizations
Mar 28, 2019
2bba99d
implements seeding for participants + memberships
Mar 29, 2019
75d67b6
adds tool upload func. and fixes other uploads
Mar 29, 2019
d091159
adds shift seeding
Mar 29, 2019
4b8a0c5
finishes mandatory seeding
Mar 29, 2019
f25f648
makes initial frontend changes
Mar 29, 2019
29902c8
clears cache after commiting db changes
Mar 29, 2019
584dedb
Changed creation and editing wizard pages
Mar 29, 2019
2e182cf
updates carnival_creation_controller_test
Mar 29, 2019
512715e
Merge branch 'carnival-creation' of https://github.com/sc0v/binder-ap…
Mar 29, 2019
72c564e
Added required tag to fields
Mar 29, 2019
b561853
Minor frontend change
Mar 29, 2019
9ccd812
Changed participants to just numbers on diff page
Mar 29, 2019
2d53e68
Added active filtering
Mar 29, 2019
a157e6c
moves csv_updater.rb to helpers
Mar 31, 2019
ebf5037
adds authorization to CarnivalCreationController
Mar 31, 2019
82db41a
comments carnival creation controller tests
Apr 2, 2019
a5aed40
implements task and certification seeding
Apr 2, 2019
65859a9
adds active filtering to search
Apr 2, 2019
05575eb
Fixed application controller
Apr 3, 2019
f38ebae
further active filtering
Apr 3, 2019
960d9ce
Revert "Revert "Dashboards (#293)""
Apr 17, 2019
b663487
removes materialize gem
Apr 17, 2019
f6340a3
nils out waiver signatures on carnival creation
Apr 19, 2019
b2ba102
redirects to root after carnival creation
Apr 19, 2019
15056e1
adds ability to upload additional csv's from Edit Carnival page
Apr 19, 2019
d1fc67c
Changing nav bar
Apr 21, 2019
5c95ce4
reactivates inactive tools upon scanning
Apr 26, 2019
7295c3d
removes active filtering for tools
Apr 26, 2019
58d1965
Merge branch 'active-filtering' into carnival-creation
Apr 26, 2019
d28edcc
adds confirmation popups to create/edit carnival actions
Apr 26, 2019
bfcf942
adds active status to show pages
Apr 26, 2019
b4958b4
adds active fields to all forms
Apr 26, 2019
6f35858
reverts 65859a9b
Apr 26, 2019
72df810
Navbar stuff done
Apr 26, 2019
af385ef
requires active certification for tool checkout
Apr 26, 2019
2ea9a8d
Shifts changes
Apr 26, 2019
2e0fca0
Waiver stuff
Apr 26, 2019
a606160
Made search bar wider
May 3, 2019
98d2ffe
Store cart widget changed
May 3, 2019
56fce17
Got rid of sorting in tasks bar
May 3, 2019
dce2648
Merge branch 'dashboards2' into carnival-creation
May 3, 2019
db795a7
resolves merge conflicts with navbar
May 3, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'jquery-datatables'
gem 'jbuilder'
gem 'bootstrap-sass'
gem 'simple_form'
Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ GEM
jbuilder (2.4.1)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jquery-datatables (1.10.19.1)
jquery-rails (4.1.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand Down Expand Up @@ -358,6 +359,7 @@ DEPENDENCIES
factory_girl_rails
highline
jbuilder
jquery-datatables
jquery-rails
mysql2 (~> 0.4.10)
newrelic_rpm
Expand Down Expand Up @@ -396,4 +398,4 @@ RUBY VERSION
ruby 2.3.0p0

BUNDLED WITH
1.14.5
1.17.3
10 changes: 9 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require datatables
//= require_tree .

$(document).on("ready page:change", function(){
Expand Down Expand Up @@ -57,4 +58,11 @@ function _toggleText(el, opt1, opt2){
var $el = $(el);
if($el.html().trim() == opt1.trim()) $el.html(opt2);
else if($el.html().trim() == opt2.trim()) $el.html(opt1);
}
}

$(document).ready(function () {
$('#tasks').DataTable({
"ordering": false
});
});

3 changes: 3 additions & 0 deletions app/assets/javascripts/carnival_creation.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
65 changes: 65 additions & 0 deletions app/assets/javascripts/datatables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//= require datatables/jquery.dataTables

// optional change '//' --> '//=' to enable

// require datatables/extensions/AutoFill/dataTables.autoFill
// require datatables/extensions/Buttons/dataTables.buttons
// require datatables/extensions/Buttons/buttons.html5
// require datatables/extensions/Buttons/buttons.print
// require datatables/extensions/Buttons/buttons.colVis
// require datatables/extensions/Buttons/buttons.flash
// require datatables/extensions/ColReorder/dataTables.colReorder
// require datatables/extensions/FixedColumns/dataTables.fixedColumns
// require datatables/extensions/FixedHeader/dataTables.fixedHeader
// require datatables/extensions/KeyTable/dataTables.keyTable
// require datatables/extensions/Responsive/dataTables.responsive
// require datatables/extensions/RowGroup/dataTables.rowGroup
// require datatables/extensions/RowReorder/dataTables.rowReorder
// require datatables/extensions/Scroller/dataTables.scroller
// require datatables/extensions/Select/dataTables.select

//= require datatables/dataTables.bootstrap4
// require datatables/extensions/AutoFill/autoFill.bootstrap4
// require datatables/extensions/Buttons/buttons.bootstrap4
// require datatables/extensions/Responsive/responsive.bootstrap4


//Global setting and initializer

$.extend( $.fn.dataTable.defaults, {
responsive: true,
pagingType: 'full',
//dom:
// "<'row'<'col-sm-4 text-left'f><'right-action col-sm-8 text-right'<'buttons'B> <'select-info'> >>" +
// "<'row'<'dttb col-12 px-0'tr>>" +
// "<'row'<'col-sm-12 table-footer'lip>>"
});


$(document).on('preInit.dt', function(e, settings) {
var api, table_id, url;
api = new $.fn.dataTable.Api(settings);
table_id = "#" + api.table().node().id;
url = $(table_id).data('source');
if (url) {
return api.ajax.url(url);
}
});


// init on turbolinks load
$(document).on('turbolinks:load', function() {
if (!$.fn.DataTable.isDataTable("table[id^=dttb-]")) {
$("table[id^=dttb-]").DataTable();
}
});

// turbolinks cache fix
$(document).on('turbolinks:before-cache', function() {
var dataTable = $($.fn.dataTable.tables(true)).DataTable();
if (dataTable !== null) {
dataTable.clear();
dataTable.destroy();
return dataTable = null;
}
});
18 changes: 10 additions & 8 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,43 @@
*
*= require_self
*= require_tree .
*= require datatables
*/

@import "bootstrap";
@import 'bootstrap';
@import 'datatables';

body {
padding-bottom: 30px;
}

.alert-inline{
.alert-inline {
margin: 4px;
padding: 10px;
}

.full-width{
.full-width {
width: 100%;
}

.cart-item{
.cart-item {
padding: 8px 4px 8px 4px;
border-top: 1px solid lightgrey;
width: 100%;
margin: 0;
}

.cart-item div{
.cart-item div {
padding: 0;
}

.cart-warning{
.cart-warning {
background-color: #fcf3dd;
}

.cart-button{
.cart-button {
width: 33%;
white-space: normal;
height: 55px;
border-color: #1d4b97;
}
}
31 changes: 31 additions & 0 deletions app/assets/stylesheets/carnival_creation.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Place all the styles related to the CarnivalCreation controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

.card {
margin: auto;
width: 70%;
border: 2px solid #eeeeee;
border-radius: 7px;
padding: 10px 10px 50px;
background-color: #eeeeee;
text-align: center;
}

input[type='file'] {
margin: auto 35%;
}

.table-success {
background-color: #b5e2b9;
}

.table-danger {
background-color: #edb8b4;
}

.required:after {
content:"*";
color: red;
}

15 changes: 15 additions & 0 deletions app/assets/stylesheets/datatables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@import 'datatables/dataTables.bootstrap4';

// optional remove '//=' to enable

//@import 'datatables/extensions/AutoFill/autoFill.bootstrap4';
//@import 'datatables/extensions/Buttons/buttons.bootstrap4';
//@import 'datatables/extensions/ColReorder/colReorder.bootstrap4';
//@import 'datatables/extensions/FixedColumns/fixedColumns.bootstrap4';
//@import 'datatables/extensions/FixedHeader/fixedHeader.bootstrap4';
//@import 'datatables/extensions/KeyTable/keyTable.bootstrap4';
//@import 'datatables/extensions/Responsive/responsive.bootstrap4';
//@import 'datatables/extensions/RowGroup/rowGroup.bootstrap4';
//@import 'datatables/extensions/RowReorder/rowReorder.bootstrap4';
//@import 'datatables/extensions/Scroller/scroller.bootstrap4';
//@import 'datatables/extensions/Select/select.bootstrap4';
14 changes: 7 additions & 7 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def participant_already_in_system(participant)
end

def sidebar
@current_shifts_sidebar = Shift.current
@upcoming_shifts_sidebar = Shift.upcoming
@tasks_sidebar = Task.upcoming.is_incomplete
@structural_queue_sidebar = OrganizationTimelineEntry.structural.current
@electrical_queue_sidebar = OrganizationTimelineEntry.electrical.current
@events_sidebar = Event.displayable
@downtime_sidebar = OrganizationTimelineEntry.downtime.current
@current_shifts_sidebar = Shift.active.current
@upcoming_shifts_sidebar = Shift.active.upcoming
@tasks_sidebar = Task.active.upcoming.is_incomplete
@structural_queue_sidebar = OrganizationTimelineEntry.active.structural.current
@electrical_queue_sidebar = OrganizationTimelineEntry.active.electrical.current
@events_sidebar = Event.active.displayable
@downtime_sidebar = OrganizationTimelineEntry.active.downtime.current
session[:tool_cart] = session[:tool_cart] || []
@tool_cart = session[:tool_cart].map{|barcode| Tool.find_by_barcode(barcode)}.reverse
end
Expand Down
75 changes: 75 additions & 0 deletions app/controllers/carnival_creation_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
class CarnivalCreationController < ApplicationController
before_filter { authorize! :manage, :carnival_creation }

def show_uploader
end

def show_diff
@organization_adds = Rails.cache.read('organization_insertions') | Rails.cache.read('organization_reactivations')
@participant_adds = Rails.cache.read('participant_insertions') | Rails.cache.read('participant_reactivations')
@membership_adds = Rails.cache.read('membership_insertions') | Rails.cache.read('membership_reactivations')
@tool_adds = Rails.cache.read('tool_insertions') | Rails.cache.read('tool_reactivations')
@shift_adds = Rails.cache.read('shift_insertions')

@organization_deactivations = Rails.cache.read('organization_deactivations')
@participant_deactivations = Rails.cache.read('participant_deactivations')
@membership_deactivations = Rails.cache.read('membership_deactivations')
@tool_deactivations = Rails.cache.read('tool_deactivations')
end

def upload_csvs
c = CsvUpdater.new()

# find params that have .csv files and cache their data
params.each do |key, val|
if key.include?('_csv')
c.add_from_csv(val.tempfile, key.chomp('_csv'))
end
end

redirect_to :show_diff
end

def upload_optional_csvs
c = CsvUpdater.new()

# find params that have .csv files and cache their data
params.each do |key, val|
if key.include?('_csv')
c.add_from_csv(val.tempfile, key.chomp('_csv'))
end
end

# run seeds as optional, which prevents deactivation of rows
# not included in .csvs
c.run_seeds(true)

Rails.cache.clear

redirect_to :root
end

def commit_changes
# TODO: dump current DB state
c = CsvUpdater.new()

# run seeds as mandatory, which deactivates any rows
# not included in .csvs
c.run_seeds(false)

# set has_signed_waiver, has_signed_hardhat_waiver, and waiver_start vals
# of all participants to nil
c.reset_waiver_signatures()

# deactivates all rows of tables not included in csv uploads
c.deactivate_unseeded_tables()

# clear the cache, where all info about insertions/deletions was stored
Rails.cache.clear

redirect_to :root
end

def show_end_index
end
end
2 changes: 1 addition & 1 deletion app/controllers/certifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def check_all_certifications
end

def certification_params
params.require(:certification).permit(:participant_id, :certification_type_id)
params.require(:certification).permit(:participant_id, :certification_type_id, :active)
end

end
2 changes: 1 addition & 1 deletion app/controllers/charge_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ def destroy
private
# Never trust parameters from the scary internet, only allow the white list through.
def charge_type_params
params.require(:charge_type).permit(:name, :default_amount, :description, :requires_booth_chair_approval)
params.require(:charge_type).permit(:name, :default_amount, :description, :requires_booth_chair_approval, :active)
end
end
8 changes: 4 additions & 4 deletions app/controllers/charges_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ class ChargesController < ApplicationController
def index
unless ( params[:organization_id].blank? )
@organization = Organization.find(params[:organization_id])
@charges = @organization.charges
@charges = @organization.charges.active
else
@charges = Charge.all
@charges = Charge.active
end

@charges = @charges.paginate(:page => params[:page]).per_page(20)
end

def export
@charges = Charge.all
@charges = Charge.active
end

# GET /charges/1
Expand Down Expand Up @@ -108,7 +108,7 @@ def set_charge
end

def charge_params
params.require(:charge).permit(:amount, :description, :issuing_participant_id, :receiving_participant_id, :organization_id, :charge_type_id)
params.require(:charge).permit(:amount, :description, :issuing_participant_id, :receiving_participant_id, :organization_id, :charge_type_id, :active)
end
end

2 changes: 1 addition & 1 deletion app/controllers/checkouts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CheckoutsController < ApplicationController
# GET /checkouts.json
def index
@tool = Tool.find(params[:tool_id])
@checkouts = @tool.checkouts
@checkouts = @tool.checkouts.active
authorize! :read, @checkouts

respond_to do |format|
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/event_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class EventTypesController < ApplicationController
# GET /event_types
# GET /event_types.json
def index
@event_types = EventType.all
@event_types = EventType.active
end

# GET /event_types/1
Expand Down Expand Up @@ -90,6 +90,6 @@ def set_event_type

# Never trust parameters from the scary internet, only allow the white list through.
def event_type_params
params.require(:event_type).permit(:display, :name)
params.require(:event_type).permit(:display, :name, :active)
end
end
Loading