2 changed files with 116 additions and 1 deletions
+7 -1
View File
@@ -1,6 +1,8 @@
# About
A web application for bicycle collectives to track bicycles, bicycle work history, volunteer hours, volunteer work history, and volunteers currently in the shop.
See a live demo here: <http://bikeshed.wvcompletestreets.org/> Thanks @fspc for setting that up!
See an overview video of what the desktop view looks like and how it works here: https://www.youtube.com/watch?v=0-JjM6d9nK4.
## Overview/Instructions/Guides
@@ -15,11 +17,15 @@ See [guides](doc/guides.md)
1. Install Docker Toolbox <https://www.docker.com/toolbox>
1. Make sure you have a machine running: `docker-machine start default && eval "$(docker-machine env default)"`
1. Execute `docker-compose build`
1. Execute `docker-compose run web rake db:create db:migrate`
1. Execute `docker-compose run web rake db:create db:migrate db:seed`
1. Execute `docker-compose up`
1. If using Docker Toolbox, use `docker-machine ip default` to get the IP where the server is running.
1. Test the Rails server is running with by visiting `<INSERT IP>:8080` in your browser.
### Alternative Dockerfile
See <https://github.com/fspc/bikeshed> for an alternative docker setup.
### Developer Workflow
The project directory should already be mounted inside the container, so you should be able to make live changes. However, since the project is running in the 'web' container, you need to prepend commands with `docker-compose run web`.
+109
View File
@@ -0,0 +1,109 @@
namespace :import do
desc "Import a CSV list of bikes. Call via 'rake import:bikes_csv['myFilename.csv']'"
task :bikes_csv, [:filename] => :environment do |t, args|
require 'csv'
# Expected Headers:
# Shop Specific ID Number, Program Type/Purpose, Gone (Is it in the shop?),Date In,Date Out,Price/Value,Make/Brand,Model,for Whom,for Whom Zip Code,Comment
#
# 2,Shop,Yes,Missing,2/17/2008,$90,Univega,Novo Sport Chronology,Darrell Forbes,Missing,,bikes for the World,
@loggable_type = 'Bike'
@log_action_type= 'ActsAsLoggable::BikeAction'
@logger_type = 'User'
@logger_id = User.find_by_username('admin')
@acquired_log_action_id = ActsAsLoggable::BikeAction.find_by_action('ACQUIRED')
@note_log_action_id = ActsAsLoggable::BikeAction.find_by_action('NOTE')
@completed_log_action_id = ActsAsLoggable::BikeAction.find_by_action('COMPLETED')
@sold_log_action_id = ActsAsLoggable::BikeAction.find_by_action('SOLD')
@build_bike_matchers = ["build-a-bike"]
@sale_matchers = ["as-is","shop"]
@parts_matchers = ["parts"]
def create_acquired_log(bike_id, date)
ActsAsLoggable::Log.new(
loggable_type: @loggable_type,
loggable_id: bike_id,
logger_type: @logger_type
logger_id: @logger_id
log_action_type: @log_action_type
log_aciton_id: @acquired_log_aciton_id,
start_date: date,
end_date: date,
)
end
def create_note_log(bike_id, date, note)
ActsAsLoggable::Log.new(
loggable_type: @loggable_type,
loggable_id: bike_id,
logger_type: @logger_type
logger_id: @logger_id
log_action_type: @log_action_type
log_aciton_id: @note_log_action_id,
start_date: date,
end_date: date,
description: note,
)
end
def create_sold_log(bike_id, date)
ActsAsLoggable::Log.new(
loggable_type: @loggable_type,
loggable_id: bike_id,
logger_type: @logger_type
logger_id: @logger_id
log_action_type: @log_action_type
log_aciton_id: @sold_log_action_id,
start_date: date,
end_date: date,
)
end
def create_completed_log(bike_id, date)
ActsAsLoggable::Log.new(
loggable_type: @loggable_type,
loggable_id: bike_id,
logger_type: @logger_type
logger_id: @logger_id
log_action_type: @log_action_type
log_aciton_id: @completed_log_action_id,
start_date: date,
end_date: date,
)
end
def get_bike_purpose_id(purpose)
case purpose.downcase
when *@build_bike_matchers
when *@sale_matchers
when *@parts_matchers
else
end
end
CSV.foreach(args[:filename], headers: true) do | row |
bike_id = row["Shop Specific ID Number"]
bike_purpose_id = get_bike_purpose_id(row["Program Type/Purpose"])
bike_value = get_bike_value(row["Price/Value"])
bike_brand_id = get_bike_brand(row["Make/Brand"])
bike_model = get_bike_model(row["Model"])
bike = Bike.find_or_create_by_shop_id_and_bike_purpose_id_and_value_and_bike_brand_id_and_model(
bike_id,
bike_purpose_id,
bike_value,
bike_brand_id,
bike_model
)
#Create aquired log
#
#Create For whom log
#
#Create note/comment log
#
#Create SOLD/completed log
#
end
end
end