1
0
mirror of https://github.com/fspc/BikeShed-1.git synced 2025-04-04 05:33:22 -04:00

Compare commits

..

176 Commits

Author SHA1 Message Date
Jonathan Rosenbaum
50732ce07b Previous doc change not necessary, was running two instances on the same port. 2017-07-06 09:35:16 +00:00
Jonathan Rosenbaum
9bad2bf73d Improved documentation to include restart for db. 2017-07-06 09:03:56 +00:00
Jonathan Rosenbaum
c9af3d4897 Enhance Dockerfile / Fix missing extjs file bug
1. Speed-up nokogiri install significantly by turning off lib compilation
2. File at http://my.jasondenney.com/extjs-4.1.1.zip can't be found, but
it has been used for a long time.  Now just including it in the
repository.
3. Added helping documentation in Dockerfile
2017-07-04 04:50:59 +00:00
Jason Denney
4a30bc5efd Merge pull request #122 from ilya-konanykhin/csv-import
CSV import
2017-03-27 20:53:28 -10:00
Ilya Konanykhin
0f1dab1ad1 BikeCsvImporter: add import of brands as a separate step 2017-03-27 10:59:07 +06:00
Ilya Konanykhin
b7729ae29a BikeCsvImporter: add comments 2017-03-20 22:49:45 +06:00
Ilya Konanykhin
a6a616cf6d BikeCsvImporter: add status logs 2017-03-20 22:38:14 +06:00
Ilya Konanykhin
ae79a34652 BikeCsvImporter: colorize importer output to highlight individual row statuses 2017-03-20 21:44:27 +06:00
Ilya Konanykhin
072f303c65 BikeCsvImporter: refactor importer to output log messages to stdoud 2017-03-20 21:41:07 +06:00
Ilya Konanykhin
c1ca501204 BikeCsvImporter: fix incorrect method signatures 2017-03-20 21:25:24 +06:00
Ilya Konanykhin
0a338a2485 BikeCsvImporter: refactor BikeAttrs for methods to receive a single value, not the whole hash 2017-03-20 00:55:26 +06:00
Ilya Konanykhin
b5e8aa554f BikeCsvImporter: refactor by splitting into parts 2017-03-20 00:48:37 +06:00
Ilya Konanykhin
cfe81d6e65 BikeCsvImporter: add dummy field values for "bike_condition_id", "bike_wheel_size_id", "bike_style_id", "serial_number", "seat_tube_height" 2017-03-20 00:38:24 +06:00
Ilya Konanykhin
802db2ba34 BikeCsvImporter: print successfull matches & fix "unknown" model 2017-03-20 00:26:47 +06:00
Ilya Konanykhin
0083dd9bca BikeCsvImporter: add dry run 2017-03-20 00:18:32 +06:00
Ilya Konanykhin
95dbe162f7 BikeCsvImporter: make Bike#bike_model_id field accessible and specify it as a foreign key explicitly 2017-03-20 00:09:01 +06:00
Ilya Konanykhin
c171598354 BikeCsvImporter: add "bike_brand_id", "bike_model_id", "model" 2017-03-20 00:08:16 +06:00
Ilya Konanykhin
ae8b5cccd0 BikeCsvImporter: add "value" 2017-03-17 15:22:37 +06:00
Ilya Konanykhin
c79ec57684 BikeCsvImporter: add "purpose_id", temporary remove "gone" 2017-03-17 15:15:23 +06:00
Ilya Konanykhin
5564a1931f BikeCsvImporter: import bikes, first step (main code, shop_id) 2017-03-16 15:17:14 +06:00
Ilya Konanykhin
904b824c8b Create rake task (import:bikes:csv, import:bikes:analyze_csv) & importing class 2017-03-15 15:17:40 +06:00
Jason Denney
21fba7251f Merge pull request #121 from ilya-konanykhin/issue-120
Issue #120: user email is nullable now. Closes #121.
2017-02-02 11:15:09 -08:00
Ilya Konanykhin
2e29fb7ed1 Updated specs to reflect new user email & username behavior 2017-02-01 00:02:41 +06:00
Ilya Konanykhin
87e4124f48 Update Poltergeist: the version 1.5 requires PhantomJS 1.8 which isn't even available in Homebrew now 2017-01-31 23:47:44 +06:00
Ilya Konanykhin
45e14a1070 Fix: user email should be null instead of empty string 2017-01-31 23:46:10 +06:00
Jason Denney
b8ba64ab93 Merge pull request #118 from ilya-konanykhin/issue-105-106
Issue #105, #106: photo upload for User & Bike
2017-01-26 08:22:19 -08:00
Ilya Konanykhin
66fee66db0 Fix: validate username presence & uniqueness 2017-01-26 15:56:28 +06:00
Ilya Konanykhin
ed2f3f6e61 Fix: alert "Fine" only once 2017-01-26 15:50:47 +06:00
Ilya Konanykhin
ca72edb7e0 Client side validation on sign up page 2017-01-26 15:50:24 +06:00
Jason Denney
9df4aa38d9 Merge pull request #116 from ilya-konanykhin/issue-115
Issue #115: New top menu for desktop & mobile.
2017-01-22 16:35:02 -08:00
Jason Denney
6786bf3eff Merge pull request #117 from ilya-konanykhin/issue-114
Issue #114: Can't delete time entries in mobile UI
2017-01-22 08:43:38 -08:00
Jason Denney
1b72fdcc0b Merge pull request #119 from ilya-konanykhin/issue-109
Issue #109: db:seed failing
2017-01-21 23:20:23 -08:00
Ilya Konanykhin
e9b5a6ab7c Fix: file storage to .gitignore 2017-01-19 17:35:02 +06:00
Ilya Konanykhin
02a6442299 Fix: db:setup instead of :create/:migrate/:seed 2017-01-19 17:10:49 +06:00
Ilya Konanykhin
f7b1d8fd5e Fix: move database seeding from migrations to db:seed 2017-01-19 15:40:19 +06:00
Ilya Konanykhin
6794fc899c Show bike photo in a task list 2017-01-18 18:40:22 +06:00
Ilya Konanykhin
5f7eb43f63 Bike photo upload 2017-01-18 18:38:29 +06:00
Ilya Konanykhin
a68e7eca56 User avatar upload at sign up 2017-01-18 17:18:32 +06:00
Ilya Konanykhin
4dcce60fb8 Fix: HTML injection 2017-01-18 14:59:48 +06:00
Ilya Konanykhin
76980a8903 Fix: more explicit (and correct) time entries delete URL 2017-01-18 14:58:14 +06:00
Ilya Konanykhin
2c6a58206a Fix: incorrect variable scoping in task_lists.js & time_entries.js 2017-01-18 14:54:48 +06:00
Ilya Konanykhin
56ca135e80 New top menu for desktop & mobile: correct color for logo 2017-01-18 00:33:42 +06:00
Ilya Konanykhin
327ec462d1 New top menu for desktop & mobile. 2017-01-18 00:27:16 +06:00
Jason Denney
8a8c82f5b7 Merge pull request #113 from ilya-konanykhin/master
Bootstrap 2 to 3
2016-12-27 12:45:30 -05:00
Ilya Konanykhin
551676a5b3 Cleanup: removed now obsolete jquery-date-format 2016-12-27 10:18:41 +06:00
Ilya Konanykhin
3713e0a450 BS3: tests are up-to-date now 2016-12-27 10:05:35 +06:00
Ilya Konanykhin
b503ec6fbd BS3: cleanup 2016-12-27 09:53:47 +06:00
Ilya Konanykhin
9bb5190c4d Fix: dashboard buttons span the whole screen width 2016-12-27 09:42:47 +06:00
Ilya Konanykhin
be97729eef Fix: do not hide link to Desktop View on mobiles 2016-12-27 09:28:58 +06:00
Ilya Konanykhin
8a6a2b6cd1 Cleanup: removed unused views and controller. 2016-12-25 01:08:57 +06:00
Ilya Konanykhin
9faa92a8e6 Fix: stick to the .ruby-version will ya? 2016-12-25 01:00:35 +06:00
Ilya Konanykhin
1880f91c15 BS3: removed bootstrap-timepicker in favor of universal bootstrap-datetimepicker. 2016-12-25 00:37:36 +06:00
Ilya Konanykhin
3fc812bd7a Fix: '', '' -> nil, nil in input generation. 2016-12-23 00:20:03 +06:00
Ilya Konanykhin
58bc6b1a83 BS3: add bike. 2016-12-22 23:58:48 +06:00
Ilya Konanykhin
1106e08098 BS3: show bike. 2016-12-22 23:47:11 +06:00
Ilya Konanykhin
e8506f6fbc BS3: top menu. 2016-12-22 23:35:26 +06:00
Ilya Konanykhin
1774a6ad34 BS3: body padding. 2016-12-22 23:33:14 +06:00
Ilya Konanykhin
3c521eba15 BS3: js validation errors. 2016-12-22 23:23:48 +06:00
Ilya Konanykhin
c58c039e3c BS3: edit task list. 2016-12-22 23:21:41 +06:00
Ilya Konanykhin
462cf8b5d5 Fix: timepicker error messages vertical align. 2016-12-22 23:08:13 +06:00
Ilya Konanykhin
37acc35921 BS3: timesheet. 2016-12-22 23:06:26 +06:00
Ilya Konanykhin
1b3d115161 BS3: replaced old datepicker with modern datetimepicker. 2016-12-22 22:17:15 +06:00
Ilya Konanykhin
e775c97fd1 BS3: new time entry. 2016-12-22 21:45:21 +06:00
Ilya Konanykhin
2dd48c5b65 BS3: dashboard. 2016-12-22 20:57:42 +06:00
Ilya Konanykhin
7fbb40e9f9 Fix: any user sign in dev env is possible again 2016-12-22 20:02:42 +06:00
Ilya Konanykhin
ec6b58680b BS3: devise & flash messaging. 2016-12-21 17:17:54 +06:00
Ilya Konanykhin
508a1d8d06 Bootstrap 3 setup. 2016-12-20 17:09:56 +06:00
Ilya Konanykhin
40a22e8b78 .powrc for Pow + RVM. 2016-12-19 18:47:34 +06:00
Ilya Konanykhin
10870d0961 Get rid of twitter-bootstrap-rails gem, update others accordingly. 2016-12-19 18:42:38 +06:00
Jason Denney
1191f4448f Add demo and alternate dockerfile branch links 2016-03-06 08:31:05 -08:00
Jason Denney
ff3ec4f443 Update README.md 2016-02-26 18:52:59 -08:00
Jason Denney
98a51f51d2 Merge pull request #108 from spacemunkay/denney-docker
dockerize!
2016-02-26 18:09:56 -08:00
Jason Denney
bc6802e5fb Adding famfamfam icons for docker w/ symlink 2016-02-26 18:00:48 -08:00
Jason Denney
e48924a228 Fixed bug where rando 401 causes signin redirect 2016-02-26 17:55:24 -08:00
Jason Denney
1887840507 Fix port in dev guide 2016-02-26 16:19:29 -08:00
Jason Denney
0629972dca Update docs again 2016-02-26 16:11:22 -08:00
Jason Denney
6daff093eb Remove comment 2016-02-26 16:10:59 -08:00
Jason Denney
43faa79f60 Update the readme & docs 2016-02-26 16:10:47 -08:00
Jason Denney
9e282eda7c Need symlink for Docker to link extjs 2016-02-25 13:54:10 -08:00
Jason Denney
02fba62499 Fix bug in seed_bike factory 2016-02-25 13:36:18 -08:00
Jason Denney
4fe8865aca Dockerize! Startup with docker-compose up
Make sure to docker-compose build first
2016-02-25 13:36:01 -08:00
Jason Denney
fd5d4798b0 Merge pull request #103 from spacemunkay/denney-fix-user-add-bike
Fix User being able to add bikes
2014-06-12 22:26:30 -04:00
Jason Denney
3e480981c7 Fix User being able to add bikes 2014-06-12 22:24:00 -04:00
Jason Denney
523135ed9f Merge pull request #102 from spacemunkay/denney-fix-edit-redirect
root path to user edit
2014-06-12 21:25:29 -04:00
Jason Denney
5e95ce542c root path to user edit 2014-06-12 21:24:02 -04:00
Jason Denney
a8e0c87d37 Merge pull request #101 from spacemunkay/mobile-ui
Mobile UI
2014-05-04 20:55:41 -04:00
Jason Denney
1b2c0fa378 Submit dates in locale format for time being
Added jquery date format plugin
2014-05-04 20:43:46 -04:00
Jason Denney
785e096aea Giving up on checkin tests for now 2014-05-04 11:26:37 -04:00
Jason Denney
5c4007a1be Show add another bike link after creating bike 2014-05-04 11:14:50 -04:00
Jason Denney
b9b6ed5ca0 Remove stray puts in spec 2014-05-04 10:56:29 -04:00
Jason Denney
0605d0f0d9 Fixed creating bike work time entry & added spec 2014-05-04 10:56:14 -04:00
Jason Denney
071815b9fd Fix app layout for mobile devices 2014-05-04 10:34:55 -04:00
Jason Denney
ca3026e7c5 Added delete time entry feature spec 2014-05-03 22:53:27 -04:00
Jason Denney
5e0d678ea1 Finish time entry delete JS/html 2014-05-03 22:08:23 -04:00
Jason Denney
d94c436ba5 Added api/time_entry/delete method 2014-05-03 22:06:56 -04:00
Jason Denney
24facd4dee Time entry actions had the wrong IDs... 2014-05-03 21:48:35 -04:00
Jason Denney
894423e66f Fixed bug in user credits available
Personal work was counting toward credits, now it’s possible to add a
column to user actions to denote if a user action can count to credits.
2014-05-03 21:41:33 -04:00
Jason Denney
4ce4bd6597 WIP, rigged up JS/html to delete work entries 2014-05-03 19:29:57 -04:00
Jason Denney
2e21e327ca Home page link to time entries 2014-05-03 19:29:22 -04:00
Jason Denney
57d72c04a7 Fix TimeEntry scope 2014-05-03 19:28:56 -04:00
Jason Denney
4224f0de40 Added Time entries index page 2014-04-27 18:59:50 -04:00
Jason Denney
3d71add637 WIP, adding time entry index page 2014-04-27 15:46:42 -04:00
Jason Denney
7dd556d718 Fixed forwarding on time entry creation 2014-04-27 15:46:13 -04:00
Jason Denney
338905878e feature spec for adding new time entry 2014-04-27 15:07:21 -04:00
Jason Denney
7897795e8b Correct spec description 2014-04-27 14:39:32 -04:00
Jason Denney
00511c5b64 Finish Api/TimeEntries spec, fix bike_id handling 2014-04-27 14:39:11 -04:00
Jason Denney
1191014471 WIP, cleaned up api/time_entries, added TimeEntry
* Added scoped TimeEntry model
* Removed setting defaults in TimeEntry controller
* Still working on tests…
2014-04-26 20:06:47 -04:00
Jason Denney
c0a9d8c1e5 Return time entry on successful create 2014-04-20 22:56:48 -04:00
Jason Denney
82f38fe35c Actually merge time_entry defaults 2014-04-20 22:56:26 -04:00
Jason Denney
2321197973 If bike selected, forward to bike checklist 2014-04-20 22:56:04 -04:00
Jason Denney
069a11f480 WIP, adding JS and api time entry create 2014-04-19 21:06:29 -04:00
Jason Denney
b30203b750 Allow user select bike worked when adding time 2014-04-19 16:48:10 -04:00
Jason Denney
3e56f2eb19 Updating edit task list page w/ home & bike link 2014-04-19 16:25:15 -04:00
Jason Denney
2d65ebb45f JS Formatting 2014-04-19 16:22:54 -04:00
Jason Denney
80b2b7ff60 Added New Time Entry Front End 2014-04-19 16:20:14 -04:00
Jason Denney
98b136e4f4 Add link to view bike check list when showing bike 2014-03-16 13:50:13 -04:00
Jason Denney
9527725e07 Adding makeshift home button, Added view your bike link 2014-03-16 13:34:56 -04:00
Jason Denney
8f637348cf Fix check in/ check out 2014-03-12 23:35:09 -04:00
Jason Denney
062ed9c2d1 Added tests for user checkin/checkout on index 2014-03-12 21:52:37 -04:00
Jason Denney
124ce5901d Update spec tests for registration page 2014-03-12 21:29:01 -04:00
Jason Denney
1f9322ff3d Fixed weird spec sign_in issues, and render json 2014-03-09 22:49:30 -04:00
Jason Denney
b1ddcfb867 Redirect correctly after creating a bike 2014-03-09 22:48:59 -04:00
Jason Denney
64e907b6f7 Should authenticate by user username, not email 2014-03-09 22:48:35 -04:00
Jason Denney
e2f442889e Added tasks controller, spec, JS, apitesthelper
Had an issue with calling render_views in the specs to render the
jbuilder json templates and also getting the devise sign_in method to
work, ended up adding a helper to add the username/password for a user
2014-03-09 22:30:41 -04:00
Jason Denney
3b904f95f2 Adding api task_lists#show and spec, edit.haml updates 2014-03-09 19:20:00 -04:00
Jason Denney
656f0f12e4 WIP, creating TaskList Controller and edit action & view 2014-03-08 15:34:58 -05:00
Jason Denney
30d818ac87 Draft of the task list api controller 2014-03-08 15:04:27 -05:00
Jason Denney
dc0a567a27 Added bike show api method 2014-03-08 15:03:52 -05:00
Jason Denney
523046b042 Add create jbuilder template 2014-03-01 14:15:49 -05:00
Jason Denney
9231c91e6c Update README.md 2014-03-01 11:12:10 -05:00
Jason Denney
14869cf8b6 Modifed bikes create to use jbuilder & follow jsonapi.org 2014-02-26 00:06:25 -05:00
Jason Denney
b88bf545d2 Added jbuilder to gemfile 2014-02-26 00:05:02 -05:00
Jason Denney
20964eb268 Update feature for new bike view to pass 2014-02-10 00:09:11 -05:00
Jason Denney
b90e101d69 Whoops! copypasta in seed yml 2014-02-09 22:01:57 -05:00
Jason Denney
7b11da9583 Forward url on add bike/ don't display value if nil 2014-02-09 22:01:42 -05:00
Jason Denney
64d4186b57 Bike show view styling
TBD add class for color block
2014-02-09 19:18:16 -05:00
Jason Denney
c6a3ed9991 Added bike show and show view 2014-02-09 19:11:08 -05:00
Jason Denney
d0c05a0244 Fix validations for creating a bike, view respond to errors 2014-02-09 18:23:35 -05:00
Jason Denney
55974feb4c Parse float for seat tube height 2014-02-09 18:22:33 -05:00
Jason Denney
e867366525 Made feature specs for creating a bike 2014-02-08 16:56:34 -05:00
Jason Denney
fb02646092 Moved registrations specs to features 2014-02-08 16:56:21 -05:00
Jason Denney
75832a3910 Add poltergeist to gem file, and limited version dependecies 2014-02-08 16:54:50 -05:00
Jason Denney
2d09aba26a Added submit js to bikes/new view
* Added displayFormErrors utility
* Added 4th option to bike styles “OTHER”
2014-02-08 14:21:20 -05:00
Jason Denney
e694dfbddd Don't clobber development database, durrrr 2014-02-08 14:17:09 -05:00
Jason Denney
e19b80faec Update README.md 2014-02-08 11:46:48 -05:00
Jason Denney
38a716b132 Added User password_reset spec and some refactor
*Make returned error in errors array
*Use constants
2014-02-04 23:47:30 -05:00
Jason Denney
8110baf255 Removing unnecessary render 2014-02-03 00:16:13 -05:00
Jason Denney
9fa0017d36 Fixed error response codes, finished bikes#create spec 2014-02-03 00:14:37 -05:00
Jason Denney
e0041662d3 WIP, adding api/bikes_controller#create 2014-02-02 17:11:13 -05:00
Jason Denney
c575fface9 Commenting out description on bike form for now 2014-02-02 17:10:32 -05:00
Jason Denney
83a4e4e9c1 Make bike color not required 2014-02-02 17:10:17 -05:00
Jason Denney
f17eba810e WTF? Is this needed? Commenting this out for now
users#checkout  copy pasta perhaps?
2014-02-02 17:09:49 -05:00
Jason Denney
4b5133fd02 Fix unauthorized return code 2014-02-02 17:09:13 -05:00
Jason Denney
9edb90203c Remove whitespace 2014-02-02 09:45:18 -05:00
Jason Denney
8e112ca936 Adding logs_controller_spec, finally test coverage!!!!! 2014-02-02 09:45:01 -05:00
Jason Denney
8c5ff986a2 Update spec, remove turnip, to get tests working 2014-02-02 09:44:18 -05:00
Jason Denney
f10b2adad6 Convert .rvmrc to ruby version and gemset 2014-02-02 09:43:22 -05:00
Jason Denney
bd6872413e Make year dynamically updated 2014-01-21 23:35:11 -05:00
Jason Denney
a8bdb52536 Improved Add Bike view
Worked out some bootstrap overrides issues
2014-01-19 19:32:18 -05:00
Jason Denney
0f890e12e9 Added bikes views
*Added new bike template
2014-01-18 18:25:21 -05:00
Jason Denney
61472e0fb6 Hide admin view button on small devices 2014-01-18 15:20:34 -05:00
Jason Denney
ecb5083f1c Created new dashboard index
*Added js for logging out button
*WIP
2014-01-18 15:16:23 -05:00
Jason Denney
a84b0e0fe7 Moving Netzke Admin view to Panel controller
*Moved custom_netzke_helpers code to panel.js
*Added panel controller and index and netzke layout
2014-01-18 15:14:19 -05:00
Jason Denney
2b863b8d8a Updated Forget Password, other minor changes 2014-01-18 12:11:43 -05:00
Jason Denney
a35bd2f22b make sign up mobile friendly 2014-01-15 00:33:32 -05:00
Jason Denney
c9d2da3e50 Make sign up links like buttons 2014-01-15 00:00:18 -05:00
Jason Denney
df3c29a899 Use twitter bootstrap classes on login 2014-01-12 14:24:57 -05:00
Jason Denney
a11f5a1b91 Needed to add task_list_id as attr_accessible
Also improved labels for adding task
2013-11-21 20:36:35 -05:00
Jason Denney
2a6e10ee9d Disabling by default was just annoying 2013-11-21 20:35:23 -05:00
Jason Denney
ed1f2e6be4 Update schema.rb to make last migration 2013-11-21 19:38:10 -05:00
Jason Denney
852a00881e Velocipede changed their wording to CLASS
Can't find purpose by name, will have to rely on default ID in case wording is changed.
2013-11-21 19:37:30 -05:00
Jason Denney
8cc72c9f48 Added link to "add a bike" video 2013-11-17 22:49:11 -05:00
Jason Denney
90b3043d67 wording 2013-11-17 16:57:29 -05:00
Jason Denney
2ad9fab243 Move some instructions to proper section 2013-11-17 16:55:00 -05:00
Jason Denney
43db139dc7 Adding information to the about section 2013-11-17 16:51:46 -05:00
Jason Denney
2b72094f00 Update read me with youtube video link 2013-11-16 18:42:23 -05:00
129 changed files with 4143 additions and 876 deletions

4
.gitignore vendored
View File

@ -6,7 +6,7 @@ tmp/
.powrc
.rbenv-version
.DS_Store
public/extjs
public/assets
public/images/icons
public/system
config/database.yml
.idea/

15
.powrc Normal file
View File

@ -0,0 +1,15 @@
if [ -f "$rvm_path/scripts/rvm" ]; then
source "$rvm_path/scripts/rvm"
if [ -f ".rvmrc" ]; then
source ".rvmrc"
fi
if [ -f ".ruby-version" ]; then
rvm use `cat .ruby-version`
fi
if [ -f ".ruby-gemset" ]; then
rvm gemset use --create `cat .ruby-gemset`
fi
fi

1
.rspec
View File

@ -1,2 +1 @@
--colour
-rturnip

1
.ruby-gemset Normal file
View File

@ -0,0 +1 @@
velocipede

1
.ruby-version Normal file
View File

@ -0,0 +1 @@
ruby-2.1.1

55
.rvmrc
View File

@ -1,55 +0,0 @@
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
environment_id="ruby-1.9.3-p374@velocipede"
#
# Uncomment following line if you want options to be set only for given project.
#
# PROJECT_JRUBY_OPTS=( --1.9 )
#
# First we attempt to load the desired environment directly from the environment
# file. This is very fast and efficient compared to running through the entire
# CLI and selector. If you want feedback on which environment was used then
# insert the word 'use' after --create as this triggers verbose mode.
#
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
then
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
fi
else
# If the environment file has not yet been created, use the RVM CLI to select.
if ! rvm --create use "$environment_id"
then
echo "Failed to create RVM environment '${environment_id}'."
return 1
fi
fi
#
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
# it be automatically loaded. Uncomment the following and adjust the filename if
# necessary.
#
# filename=".gems"
# if [[ -s "$filename" ]]
# then
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
# fi
# If you use bundler, this might be useful to you:
# if command -v bundle && [[ -s Gemfile ]]
# then
# bundle install
# fi

31
Dockerfile Normal file
View File

@ -0,0 +1,31 @@
FROM ruby:2.1
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
RUN apt-get update && apt-get install -y nodejs --no-install-recommends && \
apt-get install -y mysql-client postgresql-client sqlite3 --no-install-recommends && \
apt-get install -y zip unzip --no-install-recommends && \
rm -rf /var/lib/apt/lists/*
COPY Gemfile /usr/src/app/
COPY Gemfile.lock /usr/src/app/
RUN env NOKOGIRI_USE_SYSTEM_LIBRARIES=true bundle install
#COPY install_extjs.rb /usr/src/app/
#RUN /usr/src/app/install_extjs.rb
COPY extjs-4.1.1.zip /usr/lib/
RUN unzip -d /usr/lib /usr/lib/extjs-4.1.1.zip; \
mv /usr/lib/ext-4.1.1a /usr/lib/extjs
COPY install_famfamfam.rb /usr/src/app/
RUN /usr/src/app/install_famfamfam.rb
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]

43
Gemfile
View File

@ -1,6 +1,7 @@
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'rake', '< 11.0'
gem 'netzke-cancan'
gem 'netzke-core', '~>0.8.0'
@ -12,39 +13,39 @@ gem 'bootstrap-will_paginate', '~> 0.0.6'
gem 'cancan'
gem 'decent_exposure', '~> 1.0.1'
gem 'devise', '~> 2.0.4'
gem 'haml-rails', '~> 0.3.4'
gem 'haml-rails'
gem 'jquery-rails', '~> 2.0'
gem 'pg'
gem 'pg', '~> 0.17.1'
gem 'will_paginate', '~> 3.0.3'
gem 'jbuilder', '~> 2.0.3'
gem 'paperclip', '~> 4.3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'coffee-rails', '~> 3.2.1'
gem "twitter-bootstrap-rails", "~> 2.0.3"
# Assets
gem 'sass-rails', '~> 3.0'
gem 'coffee-rails', '~> 3.2.1'
gem 'bootstrap-sass', '~> 3.1.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'momentjs-rails', '>= 2.9.0'
gem 'bootstrap3-datetimepicker-rails', '~> 4.17.43'
gem 'uglifier', '>= 1.0.3'
end
gem 'uglifier', '>= 1.0.3'
group :development, :test do
gem 'rspec-rails', '~> 2.8.1'
gem 'rspec-rails', '~> 2.14.0'
gem 'factory_girl_rails', '~> 1.2'
gem 'pry', '~> 0.9.8'
gem 'faker'
gem 'faker', '~> 1.2.0'
gem 'colorize'
end
group :test do
gem 'shoulda-matchers', '~> 1.0.0'
gem 'capybara', '~> 1.1.2'
gem 'turnip', '~> 0.3.0'
gem 'database_cleaner'
gem 'launchy'
gem 'spork'
gem 'capybara', '~> 2.2.1'
gem 'poltergeist', '~> 1.10.0'
gem 'database_cleaner', '~> 1.2.0'
gem 'launchy', '~> 2.4.2'
gem 'spork', '~> 0.9.2'
#guard dependency for Mac OS 10
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
gem 'guard-spork'
gem 'guard-rspec'
gem 'guard-spork', '~> 1.5.1'
gem 'guard-rspec', '~> 4.2.6'
end

View File

@ -36,42 +36,50 @@ GEM
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
addressable (2.3.3)
arel (3.0.2)
bcrypt-ruby (3.0.1)
bootstrap-will_paginate (0.0.9)
addressable (2.4.0)
arel (3.0.3)
bcrypt (3.1.10)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
bootstrap-sass (3.1.1.1)
sass (~> 3.2)
bootstrap-will_paginate (0.0.10)
will_paginate
bootstrap3-datetimepicker-rails (4.17.43)
momentjs-rails (>= 2.8.1)
builder (3.0.4)
cancan (1.6.9)
capybara (1.1.4)
cancan (1.6.10)
capybara (2.2.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
childprocess (0.3.9)
xpath (~> 2.0)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
coderay (1.0.9)
climate_control (0.1.0)
cliver (0.3.2)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.1)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.6.2)
commonjs (0.2.6)
database_cleaner (0.9.1)
coffee-script-source (1.10.0)
colorize (0.8.1)
database_cleaner (1.2.0)
decent_exposure (1.0.2)
devise (2.0.5)
devise (2.0.6)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
railties (~> 3.1)
warden (~> 1.1.1)
diff-lcs (1.1.3)
diff-lcs (1.2.5)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
execjs (2.6.0)
factory_girl (2.6.4)
activesupport (>= 2.3.9)
factory_girl_rails (1.7.0)
@ -79,52 +87,58 @@ GEM
railties (>= 3.0.0)
faker (1.2.0)
i18n (~> 0.5)
ffi (1.6.0)
formatador (0.2.4)
gherkin (2.11.6)
json (>= 1.7.6)
guard (1.7.0)
ffi (1.9.10)
formatador (0.2.5)
guard (2.13.0)
formatador (>= 0.2.4)
listen (>= 0.6.0)
lumberjack (>= 1.0.2)
pry (>= 0.9.10)
thor (>= 0.14.6)
guard-rspec (1.2.1)
guard (>= 1.1)
guard-spork (1.5.0)
listen (>= 2.7, <= 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-rspec (4.2.10)
guard (~> 2.1)
rspec (>= 2.14, < 4.0)
guard-spork (1.5.1)
childprocess (>= 0.2.3)
guard (>= 1.1)
spork (>= 0.8.4)
haml (3.1.8)
haml-rails (0.3.5)
haml (4.0.7)
tilt
haml-rails (0.4)
actionpack (>= 3.1, < 4.1)
activesupport (>= 3.1, < 4.1)
haml (~> 3.1)
haml (>= 3.1, < 4.1)
railties (>= 3.1, < 4.1)
hike (1.2.1)
hike (1.2.3)
i18n (0.6.1)
jbuilder (2.0.8)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
journey (1.0.4)
jquery-rails (2.2.1)
jquery-rails (2.3.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.7.7)
launchy (2.2.0)
json (1.8.3)
launchy (2.4.3)
addressable (~> 2.3)
less (2.2.2)
commonjs (~> 0.2.6)
less-rails (2.2.6)
actionpack (>= 3.1)
less (~> 2.2.0)
libv8 (3.3.10.4)
listen (0.7.3)
lumberjack (1.0.3)
mail (2.5.3)
i18n (>= 0.4.0)
listen (3.0.6)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9.7)
lumberjack (1.0.10)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.8.1)
mime-types (1.22)
multi_json (1.8.2)
method_source (0.8.2)
mime-types (1.25.1)
mimemagic (0.3.0)
mini_portile2 (2.0.0)
momentjs-rails (2.15.1)
railties (>= 3.1)
multi_json (1.12.1)
nenv (0.3.0)
netzke-basepack (0.8.4)
netzke-core (~> 0.8.2)
netzke-cancan (0.8.2)
@ -133,20 +147,34 @@ GEM
netzke-core (0.8.4)
execjs
uglifier
nokogiri (1.5.9)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
notiffany (0.0.8)
nenv (~> 0.1)
shellany (~> 0.0)
orm_adapter (0.0.7)
pg (0.15.1)
polyglot (0.3.3)
pry (0.9.12)
coderay (~> 1.0.5)
paperclip (4.3.7)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
cocaine (~> 0.5.5)
mime-types
mimemagic (= 0.3.0)
pg (0.17.1)
poltergeist (1.10.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
polyglot (0.3.5)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
rack (1.4.5)
rack-cache (1.2)
rack (1.4.7)
rack-cache (1.6.1)
rack (>= 0.4)
rack-ssl (1.3.3)
rack-ssl (1.3.4)
rack
rack-test (0.6.2)
rack-test (0.6.3)
rack (>= 1.0)
rails (3.2.13)
actionmailer (= 3.2.13)
@ -163,61 +191,58 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.4)
rb-fsevent (0.9.3)
rake (10.5.0)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rdoc (3.12.2)
json (~> 1.4)
rspec (2.8.0)
rspec-core (~> 2.8.0)
rspec-expectations (~> 2.8.0)
rspec-mocks (~> 2.8.0)
rspec-core (2.8.0)
rspec-expectations (2.8.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.8.0)
rspec-rails (2.8.1)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.8.0)
rubyzip (0.9.9)
selenium-webdriver (2.31.0)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
rubyzip
websocket (~> 1.0.4)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
sass (3.4.22)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
shellany (0.0.1)
shoulda-matchers (1.0.0)
slop (3.4.4)
slop (3.6.0)
spork (0.9.2)
sprockets (2.2.2)
sprockets (2.2.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
therubyracer (0.10.2)
libv8 (~> 3.3.10)
thor (0.18.1)
tilt (1.3.6)
treetop (1.4.12)
thor (0.19.4)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
turnip (0.3.1)
gherkin (>= 2.5)
rspec (~> 2.0)
twitter-bootstrap-rails (2.0.9)
actionpack (>= 3.1)
less-rails (~> 2.2.2)
railties (>= 3.1)
therubyracer (~> 0.10.1)
tzinfo (0.3.38)
uglifier (2.1.2)
tzinfo (0.3.46)
uglifier (2.7.2)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
json (>= 1.8.0)
warden (1.1.1)
rack (>= 1.0)
websocket (1.0.7)
will_paginate (3.0.4)
xpath (0.1.4)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
will_paginate (3.0.7)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS
@ -225,31 +250,37 @@ PLATFORMS
DEPENDENCIES
acts_as_loggable!
bootstrap-sass (~> 3.1.1)
bootstrap-will_paginate (~> 0.0.6)
bootstrap3-datetimepicker-rails (~> 4.17.43)
cancan
capybara (~> 1.1.2)
capybara (~> 2.2.1)
coffee-rails (~> 3.2.1)
database_cleaner
colorize
database_cleaner (~> 1.2.0)
decent_exposure (~> 1.0.1)
devise (~> 2.0.4)
factory_girl_rails (~> 1.2)
faker
guard-rspec
guard-spork
haml-rails (~> 0.3.4)
faker (~> 1.2.0)
guard-rspec (~> 4.2.6)
guard-spork (~> 1.5.1)
haml-rails
jbuilder (~> 2.0.3)
jquery-rails (~> 2.0)
launchy
launchy (~> 2.4.2)
momentjs-rails (>= 2.9.0)
netzke-basepack (~> 0.8.0)
netzke-cancan
netzke-core (~> 0.8.0)
pg
paperclip (~> 4.3)
pg (~> 0.17.1)
poltergeist (~> 1.10.0)
pry (~> 0.9.8)
rails (= 3.2.13)
rb-fsevent
rspec-rails (~> 2.8.1)
rake (< 11.0)
rspec-rails (~> 2.14.0)
sass-rails (~> 3.0)
shoulda-matchers (~> 1.0.0)
spork
turnip (~> 0.3.0)
twitter-bootstrap-rails (~> 2.0.3)
spork (~> 0.9.2)
uglifier (>= 1.0.3)
will_paginate (~> 3.0.3)

View File

@ -1,32 +1,48 @@
# 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
See [guides](doc/guides.md)
# Developer Setup
1. use rvm
1. allow the .rvmrc file
1. `gem install bundler`
1. `bundle`
1. Install Postgres (Mac OSX instructions below)
1. `rake db:create db:migrate`
1. `rake db:seed`
1. Download extJS 4.1 (A version of 4.1 is hosted here: http://my.jasondenney.com/extjs-4.1.1.zip) Latest versions at http://www.sencha.com/products/extjs. Unzip and place where ever you like.
1. Link to your extJS folder path under `public/extjs`: (From app root) `ln -s /MY/PATH/extjs/ public/extjs`
1. `rails s`
## Running with Docker (recommended)
1. These instructions haven't been tested, please provide corrections!
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:setup`
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.
# Postgres 9.2 Mac OSX Install
1. Install homebrew `ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"`
1. `brew install postgres`
1. First time db initialization `initdb /usr/local/var/postgres -E utf8`
1. Start Postgres `pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start`
1. Create your PG user `createuser -d -P velocipede`
1. Create your database `createdb -U velocipede --owner=velocipede velocipede`
1. Copy over DB config: `cp config/database.yml.example config/database.yml`
1. Update config with your database (velocipede), user (velocipede), and password.
### Alternative Dockerfile
# Optional
Add icons
See <https://github.com/fspc/bikeshed> for an alternative docker setup.
1. Download icons from http://www.famfamfam.com/lab/icons/silk/
1. Link to the icons under `public/images/icons`: (From app root) `ln -s /MY/PATH/famfamfam_silk_icons/icons public/images/icons`
### 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`.
You'll likely want to add the following aliases:
```
alias dm='docker-machine'
alias dc='docker-compose'
alias dcrw='docker-compose run web'
```
That way your commands can be shortened to:
```
dcrw rake routes
dcrw rails console
dcrw rspec
```
If there's a better way, I'm all ears. Alternatively you could ssh into the machine with `dcrw bash`.
# License
Velocipede is released under the MIT license (http://opensource.org/licenses/MIT)

View File

@ -12,4 +12,9 @@
//
//= require jquery
//= require jquery_ujs
//= require custom_netzke_helpers
//= require bootstrap
//= require utils
//= require moment
//= require bootstrap-datetimepicker
//= require jquery.form

View File

@ -0,0 +1,11 @@
$('.btn').button();
$("#add_bike_form").ajaxForm({
dataType: "json",
success: function(data){
window.location = data.bikes[0].id + "?add_bike=1";
},
error: function(data){
displayFormErrors(data.responseJSON);
}
})

View File

@ -2,50 +2,79 @@ $(document).ready(function(){
var MIN_LEN = 3;
var MAX_SUBMITS = 3;
var submit_count = 0;
$("input[name=commit]").click( function(e){
console.log("clicked");
submit_count += 1;
//IDs of contact info
var contact_info_ids = [
"user_email",
"user_user_profiles_attributes_0_addrStreet1",
"user_user_profiles_attributes_0_addrCity",
"user_user_profiles_attributes_0_addrState",
"user_user_profiles_attributes_0_addrZip",
"user_user_profiles_attributes_0_phone"
];
var contact_vals = "";
var index = 0;
//see if any contact info exists
for( var index in contact_info_ids){
contact_vals += $("#"+contact_info_ids[index]).val();
}
if( contact_vals.length >= MIN_LEN || submit_count > MAX_SUBMITS){
if( submit_count > MAX_SUBMITS ){
alert("Fine.");
var checkContacts = function() {
submit_count += 1;
//IDs of contact info
var contact_info_ids = [
"user_email",
"user_user_profiles_attributes_0_addrStreet1",
"user_user_profiles_attributes_0_addrCity",
"user_user_profiles_attributes_0_addrState",
"user_user_profiles_attributes_0_addrZip",
"user_user_profiles_attributes_0_phone"
];
var contact_vals = "";
//see if any contact info exists
for( var index in contact_info_ids){
contact_vals += $("#"+contact_info_ids[index]).val();
}
return true;
if( contact_vals.length >= MIN_LEN || submit_count > MAX_SUBMITS){
}else{
if( submit_count == MAX_SUBMITS + 1 ){
alert("Fine.");
}
return true;
switch(submit_count){
case 1:
alert("It appears you have not entered any contact information. " +
"Please do.");
break;
case 2:
alert("It is highly recommended that you enter at least one form of" +
" contact information. It is in your best interest.");
break;
case 3:
alert("If something happens to your bicycle, we will not be able to" +
" notify you. Please enter at least one form of contact.");
break;
default:
alert("Please enter at least one form of contact.");
}else{
switch(submit_count){
case 1:
alert("It appears you have not entered any contact information. " +
"Please do.");
break;
case 2:
alert("It is highly recommended that you enter at least one form of" +
" contact information. It is in your best interest.");
break;
case 3:
alert("If something happens to your bicycle, we will not be able to" +
" notify you. Please enter at least one form of contact.");
break;
default:
alert("Please enter at least one form of contact.");
}
return false;
}
return false;
}
};
var checkValid = function() {
var errors = {};
var hasErrors = false;
["username", "first_name", "last_name"].forEach(function(requiredField) {
if(!$("#user_" + requiredField).val().trim()) {
errors["user_" + requiredField] = ["can't be blank"];
hasErrors = true;
}
});
if($("#user_password").val().length < 6) {
errors["user_password"] = ["is too short (minimum is 6 characters)"];
hasErrors = true;
}
if($("#user_password").val() != $("#user_password_confirmation").val()) {
errors["user_password_confirmation"] = ["confirmation doesn't match password"];
hasErrors = true;
}
displayFormErrors({errors: errors}, "#new_user");
return !hasErrors;
};
$("input[name=commit]").click(function(e){
return checkContacts() && checkValid();
});
});

View File

@ -1,7 +1,7 @@
$(document).ready(function(){
$("#checkin_menu").show();
$("#checkin").click( function(e){
var username = $("#user_email").val();
var username = $("#user_username").val();
var password = $("#user_password").val();
$.ajax({
type: 'POST',
@ -13,7 +13,7 @@ $(document).ready(function(){
complete: function() { },
success: function(data) {
alert("Checked IN!");
$("#user_email").val('');
$("#user_username").val('');
$("#user_password").val('');
},
error: function(data,textStatus) {
@ -22,7 +22,7 @@ $(document).ready(function(){
})
});
$("#checkout").click( function(e){
var username = $("#user_email").val();
var username = $("#user_username").val();
var password = $("#user_password").val();
$.ajax({
type: 'POST',
@ -34,7 +34,8 @@ $(document).ready(function(){
complete: function() { },
success: function(data) {
alert("Checked OUT!");
$("#user_email").val('');
$("#user_username").val('');
$("#user_password").val('');
},
error: function(data,textStatus) {

View File

@ -1,6 +1,6 @@
//when signed out, or session expires forward to sign in page
Ext.Ajax.on('requestexception', function(conn, response, options) {
if (response.status === 401) { window.location = '/users/sign_in'; }
if (response.status === 401 && response.statusText === "Unauthorized") { window.location = '/users/sign_in'; }
}, this);
//Override default netzke time entry field

View File

@ -0,0 +1,9 @@
$("#index_logout").click(function(){
$.ajax({
type: "DELETE",
url: $("#index_logout").data("url"),
complete: function(){
window.location.href="/";
}
});
});

View File

@ -0,0 +1,32 @@
$(".task_list_task").click(function(){
$("#update_tasks_submit").removeClass("disabled");
});
$("#update_tasks_submit").click(function(){
var tasks = [];
$(".task_list_task").each(function(){
tasks.push({
id: parseInt($(this).data("id")),
done: $(this).is(":checked")
});
});
var json_data = {tasks: tasks};
$.ajax({
url: $("#update_tasks_submit").data("url"),
type: "PUT",
data: JSON.stringify(json_data),
contentType: 'application/json',
dataType: "json",
success: function(data, status, xhr){
//should re-render via JS, but for now reload
location.reload();
},
error: function(data, status ){
alert("An error occured updating tasks");
//displayFormErrors(data.responseJSON);
}
});
});

View File

@ -0,0 +1,83 @@
$(document).ready(function () {
var $date_input = $("#date_id");
$date_input.datetimepicker({format: $date_input.data("format")});
var $start_time_input = $("#start_time_id");
var $end_time_input = $("#end_time_id");
[$start_time_input, $end_time_input].forEach(function($x) {
$x.datetimepicker({format: $x.data("format"), stepping: 15});
})
$("#add_time_entry_submit").click(function () {
var date = $date_input.val();
var start_date = new Date(date + " " + $start_time_input.val());
var end_date = new Date(date + " " + $end_time_input.val());
var forward = $("#add_time_entry_submit").data("forward");
// If a bike is selected, forward to the bike
// checklist.
var bike_id = parseInt($("#bike_id").val());
if (bike_id > 0) {
forward = "/task_lists/" + bike_id + "/edit";
}
//FIXME: Ideally, we'd submit the dates as ISO, but I can't figure out
// how to get Netzke to render UTC dates correctly (it calls to_json
// somewhere and drops off the timezone). For the time being, save dates
// in locale like Netzke.
var json_data = {
time_entries: [{
start_date: moment(start_date).format("DD-MM-YYYY h:mm A"),
end_date: moment(end_date).format("DD-MM-YYYY h:mm A"),
log_action_id: parseInt($('input[name=action_id]:checked').val()),
bike_id: bike_id,
description: $("#description_id").val(),
}]
};
$.ajax({
url: $("#add_time_entry_submit").data("url"),
type: "POST",
data: JSON.stringify(json_data),
contentType: 'application/json',
dataType: "json",
success: function (data, status, xhr) {
window.location = forward;
},
error: function (data, status) {
displayFormErrors(data.responseJSON);
}
});
});
$(".work_entry-delete-btn").click(function () {
var row = $(this).closest("tr");
var entry_id = row.data("id");
var start_date = row.data("start_date");
var duration = row.data("duration");
var description = row.data("description");
$("#work_entry_start_date").text(start_date);
$("#work_entry_duration").text(duration);
$("#work_entry_description").text(description);
$("#confirmation_delete").data("entry_id", entry_id);
});
$("#confirmation_delete").click(function () {
var entry_id = $(this).data("entry_id");
var url = $("#confirmation_delete").data("url-template").replace(/__ID__/, entry_id);
$.ajax({
url: url,
type: "delete",
contentType: 'application/json',
success: function (data, status, xhr) {
location.reload();
},
error: function (data, status) {
displayFormErrors(data.responseJSON);
}
});
});
});

View File

@ -0,0 +1,10 @@
function displayFormErrors(data, form){
if(form){
$(form).find(".form-group.has-error").removeClass("has-error").find(".help-block").html("");
}
if(data.errors != undefined ){
$.each(data.errors, function(field, errorMsg) {
$("#"+field).closest(".form-group").addClass("has-error").find(".help-block").html(errorMsg.join(", "));
});
}
}

View File

@ -1,13 +0,0 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/

View File

@ -0,0 +1,3 @@
@import "bootstrap";
@import "bootstrap-datetimepicker";
@import "frontend";

View File

@ -1,17 +0,0 @@
@import "twitter/bootstrap/bootstrap";
@import "twitter/bootstrap/responsive";
// Set the correct sprite paths
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
// Your custom LESS stylesheets goes here
//
// Since bootstrap was imported above you have access to its mixins which
// you may use and inherit here
//
// If you'd like to override bootstrap's own variables, you can do so here as well
// See http://twitter.github.com/bootstrap/less.html for their names and documentation
//
// Example:
// @linkColor: #ff0000;

View File

@ -0,0 +1,69 @@
body {
padding-top: $grid-gutter-width / 2;
}
.x-boundlist-item {
white-space: nowrap;
}
fieldset, .fieldset {
margin-top: $line-height-computed;
margin-bottom: $line-height-computed;
}
.timepickers {
.form-group {
vertical-align: top;
&.dash {
line-height: 2.4em;
}
}
.bootstrap-datetimepicker-widget.dropdown-menu {
width: auto;
}
.bootstrap-datetimepicker-widget .timepicker-hour,
.bootstrap-datetimepicker-widget .timepicker-minute,
.bootstrap-datetimepicker-widget .timepicker-second {
width: 40px;
}
.bootstrap-datetimepicker-widget table td {
height: 40px;
line-height: 40px;
width: 40px;
padding: 0 !important;
}
.bootstrap-datetimepicker-widget table td.separator {
width: 10px;
}
.bootstrap-datetimepicker-widget table td span {
width: 40px;
height: 40px;
line-height: 40px;
margin: 0;
}
.bootstrap-datetimepicker-widget a[data-action] {
padding: 0;
color: #000;
}
}
.bike-color {
display: inline-block;
padding-left: 6px;
padding-right: 6px;
}
.navbar-default {
.navbar-text {
width: 100%;
font-size: 150%;
margin-top: 10px;
margin-bottom: 10px;
}
}

View File

@ -19,6 +19,6 @@
});
},
onChangeAccountInfo: function(){
window.location.href="users/edit";
window.location.href="/users/edit";
}
}

View File

@ -2,8 +2,6 @@ class Tasks < Netzke::Basepack::Grid
def configure(c)
super
#disable by default, will be enabled once bike is clicked
c.disabled = true
task_list_id = nil
if session[:selected_bike_id]
task_list_id = Bike.find_by_id(session[:selected_bike_id]).task_list.id
@ -31,13 +29,14 @@ class Tasks < Netzke::Basepack::Grid
end
def default_fields_for_forms
fields = []
fields << { :no_binding => true, :xtype => 'displayfield', :fieldLabel => "No Bike Selected", :value => "Select a Bike First!"}
fields.concat( [
bike = Bike.find_by_id(session[:selected_bike_id])
bike = "Select a Bike First!" if bike.nil?
[
{ :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Bike Selected", :value => "#{bike.to_s}"},
:done,
:task,
:notes
])
:notes,
]
end
#override with nil to remove actions

View File

@ -33,7 +33,7 @@
Ext.Msg.alert("Success", "New Password: "+data.password);
},
error: function(data,textStatus) {
Ext.Msg.alert( "Error", JSON.parse(data.responseText)["error"]);
Ext.Msg.alert( "Error", JSON.parse(data.responseText)["errors"][0]);
}
});
}

View File

@ -6,12 +6,12 @@ class Api::V1::BaseController < ActionController::Base
private
def authenticate_user
if params[:username]
user = User.find_for_database_authentication( :email => params[:username] )
user = User.find_for_database_authentication( :username => params[:username] )
@current_user = user if user && user.valid_password?( params[:password] )
if @current_user.nil?
msg = "Username/Password/Token invalid"
render :json => {:error => msg }, :status => 403 and return
render :json => {:error => msg }, :status => 401 and return
end
else
authenticate_user!

View File

@ -0,0 +1,32 @@
class Api::V1::BikesController < Api::V1::BaseController
CANNOT_MANAGE = "You do not have permission to manage bikes."
EXPECTED_BIKE = "Expected bike in submitted data"
NOT_FOUND = "The bike could not be found."
before_filter :check_bike_permission, except: :show
def create
if params[:bikes] && bike = params[:bikes].first
@bike = Bike.new(bike)
if !@bike.save
render json: { errors: @bike.errors }, status: 422 and return
end
else
render json: { errors: [EXPECTED_BIKE]}, status: 422 and return
end
end
def show
@bike = Bike.find_by_id(params[:id])
if @bike.nil?
render json: { errors: [NOT_FOUND] }, status: 404 and return
end
end
private
def check_bike_permission
if cannot? :manage, Bike
render json: { errors: [CANNOT_MANAGE]}, status: 403 and return
end
end
end

View File

@ -0,0 +1,24 @@
class Api::V1::TaskListsController < Api::V1::BaseController
CANNOT_MANAGE = "You do not have permission to manage this task list."
NOT_FOUND = "The task list could not be found."
before_filter :get_task_list
before_filter :check_task_list_permission, except: :show
def show
end
private
def get_task_list
@task_list = TaskList.find_by_id(params[:id])
if @task_list.nil?
render json: { errors: [NOT_FOUND] }, status: 404 and return
end
end
def check_task_list_permission
if cannot? :manage, Bike and @task_list.item != current_user.bike
render json: { errors: [CANNOT_MANAGE]}, status: 403 and return
end
end
end

View File

@ -0,0 +1,64 @@
class Api::V1::TasksController < Api::V1::BaseController
EXPECTED_TASKS = "Expected a list of tasks in submitted data."
CANNOT_MANAGE = "You do not have permission to manage this task."
NOT_FOUND = "The task could not be found."
before_filter :validate_params
before_filter :get_tasks
before_filter :check_task_permission, except: :show
def update
errors = []
@tasks.each do |task_hash|
task = task_hash[:record]
attrs = task_hash[:new_attributes]
task.update_attributes(attrs)
if !task.errors.empty?
errors << { id: task.id, errors: task.errors }
end
end
if !errors.empty?
render json: { errors: errors }, status: 422 and return
end
end
private
def validate_params
if params[:tasks].nil? and not params[:tasks].kind_of?(Array)
render json: { errors: [EXPECTED_TASKS]}, status: 422 and return
end
end
def get_tasks
@tasks = []
errors = []
params[:tasks].each do |task|
t = Task.find_by_id(task[:id])
if t.nil?
errors << { id: task[:id], error: NOT_FOUND }
else
@tasks << { record: t, new_attributes: task }
end
end
if !errors.empty?
render json: { errors: errors }, status: 404 and return
end
end
def check_task_permission
errors = []
@tasks.each do |task_hash|
task = task_hash[:record]
if task.task_list.item != current_user.bike
errors << { id: task[:id], error: CANNOT_MANAGE }
end
end
if cannot? :manage, Bike and !errors.empty?
render json: { errors: errors}, status: 403 and return
end
end
end

View File

@ -0,0 +1,33 @@
class Api::V1::TimeEntriesController < Api::V1::BaseController
EXPECTED_TIME_ENTRY = "Expected time entry in submitted data"
NOT_FOUND = "Time entry not found"
def create
if params[:time_entries] && time_entry = params[:time_entries].first
time_entry.merge!({ loggable_id: current_user.id,
logger_id: current_user.id })
bike_id = time_entry[:bike_id].to_i
@time_entry = TimeEntry.new(time_entry.except(:bike_id))
if bike_id > 0
@time_entry.copy_to_bike_history(bike_id)
end
if !@time_entry.save
render json: { errors: @time_entry.errors }, status: 422 and return
end
else
render json: { errors: [EXPECTED_TIME_ENTRY]}, status: 422 and return
end
end
def delete
if time_entry = TimeEntry.find_by_id(params[:id])
time_entry.delete
render nothing: true, status: 204 and return
else
render json: { errors: [NOT_FOUND]}, status: 404 and return
end
end
end

View File

@ -1,21 +1,27 @@
require 'securerandom'
class Api::V1::UsersController < Api::V1::BaseController
CANNOT_MANAGE = "You do not have the permission to manager users"
NOT_FOUND = "User not found"
NOT_ALLOWED = "Not allowed to reset your own password in this fashion"
PASS_LENGTH = 8
def password_reset
if can? :manage, User
user = User.find_by_id(params[:user_id])
render :json => { "error" => "User not found"}, :status => 404 and return if user.nil?
render :json => { "error" => "Not allowed to reset your own password in this fashion."}, :status => 403 and return if user.id == current_user.id
render :json => { "errors" => [NOT_FOUND]}, :status => 404 and return if user.nil?
render :json => { "errors" => [NOT_ALLOWED]}, :status => 403 and return if user.id == current_user.id
new_pass = SecureRandom.hex[0,8]
new_pass = SecureRandom.hex[0,PASS_LENGTH]
user.password = new_pass
user.save
render :json => { "password" => new_pass}, :status => 200 and return
else
render :json => { "error" => "You do not have the permission"}, :status => 403 and return
render :json => { "errors" => [CANNOT_MANAGE]}, :status => 403 and return
end
end
=begin Is this here by accident? Commenting out for now (1/30/14)
def checkout
#must use @current_user since user may not have signed in
if !@current_user.checked_in?
@ -25,4 +31,5 @@ class Api::V1::UsersController < Api::V1::BaseController
render :nothing => true, :status => 204 and return
end
end
=end
end

View File

@ -0,0 +1,17 @@
class BikesController < AuthenticatedController
def new
@bike = Bike.new bike_purpose_id: 1
@brands = BikeBrand.all.map{ |b| [b.brand, b.id] }
@brands.unshift( ["Select a brand", -1] )
@wheel_sizes = BikeWheelSize.all.map{ |w| [w.display_string, w.id] }
@wheel_sizes.unshift( ["Select a wheel size", -1] )
end
def show
@bike = Bike.find_by_id(params[:id])
@task_list = @bike.task_list
@show_add_bike = true if params[:add_bike]
end
end

View File

@ -0,0 +1,7 @@
class PanelController < ApplicationController
def index
render :inline => "<%=netzke :app_view, :layout => true %>", :layout => "netzke"
end
end

View File

@ -1,7 +1,6 @@
class SiteController < ApplicationController
def index
render :inline => "<%= netzke :app_view, :layout => true %>", :layout => "application"
@bike = current_user.bike
end
end

View File

@ -0,0 +1,5 @@
class TaskListsController < AuthenticatedController
def edit
@task_list = TaskList.find_by_id(params[:id])
end
end

View File

@ -0,0 +1,16 @@
class TimeEntriesController < AuthenticatedController
def new
@bikes = Bike.all.map{ |b| [b.to_s , b.id] }
if bike = current_user.bike
@bikes.unshift( [bike.to_s, bike.id] )
end
@bikes.unshift( ["Non-bike work", -1] )
end
def index
@user_time_entries = TimeEntry.where(loggable_id: current_user.id)
@credits_available = current_user.total_credits
@hours_worked = current_user.total_hours
end
end

View File

@ -1,34 +0,0 @@
class UsersController < AuthenticatedController
expose(:user)
expose(:users) { User.order('id').paginate(:page => params[:page]) }
def index
end
def show
end
def new
end
def create
if user.save
redirect_to user
else
render :new
end
end
def update
if user.save
redirect_to user
else
render :edit
end
end
def destroy
user.destroy
redirect_to bikes_url
end
end

View File

@ -7,4 +7,28 @@ module ApplicationHelper
end
link_to(name, '#', id: "add_#{association.to_s.singularize}" , class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
end
def top_menu(right = nil)
content_tag :nav, class: 'navbar navbar-default' do
content_tag :div, class: 'container-fluid' do
content_tag :div, class: 'row' do
[
content_tag(:div, link_to_dashboard, class: 'col-xs-3'),
content_tag(:div, header_logo, class: 'col-xs-6'),
content_tag(:div, class: 'col-xs-3') { content_tag :div, right, class: 'pull-right' },
].join.html_safe
end
end
end
end
def link_to_dashboard
link_to root_path, class: 'navbar-brand', title: 'Back to dashboard' do
content_tag :i, '', class: "glyphicon glyphicon-home"
end
end
def header_logo
content_tag :div, 'Velocipede', class: 'navbar-text text-center'
end
end

View File

@ -1,21 +1,18 @@
module DeviseHelper
# A simple way to show error messages for the current devise resource. If you need
# to customize this method, you can either overwrite it in your application helpers or
# copy the views to your application.
#
# This method is intended to stay simple and it is unlikely that we are going to change
# it to add more behavior or options.
def devise_error_messages!
return "" if resource.errors.empty?
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:p, msg, :class => "alert") }.join
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }
sentence = I18n.t("errors.messages.not_saved",
:count => resource.errors.count,
:resource => resource.class.model_name.human.downcase)
html = <<-HTML
<p>#{sentence}</p>
#{messages}
<div class="alert alert-danger">#{sentence}
<ul>
#{messages.join}
</ul>
</div>
HTML
html.html_safe

View File

@ -23,7 +23,7 @@ class Ability
def user
can :read, :all
can :manage, Bike, :id => @current_user.bike_id unless @current_user.bike.nil?
can :manage, @current_user.bike unless @current_user.bike.nil?
can :manage, ::ActsAsLoggable::Log, :loggable_type => "Bike", :loggable_id => @current_user.bike_id
can :manage, ::ActsAsLoggable::Log, :loggable_type => "User", :loggable_id => @current_user.id
end

View File

@ -1,28 +1,34 @@
class Bike < ActiveRecord::Base
acts_as_loggable
attr_accessible :shop_id, :serial_number, :bike_brand_id, :model, :color, :bike_style_id, :seat_tube_height,
:top_tube_length, :bike_wheel_size_id, :value, :bike_condition_id, :bike_purpose_id
attr_accessible :shop_id, :serial_number, :bike_brand_id, :bike_model_id, :model, :color, :bike_style_id,
:seat_tube_height, :top_tube_length, :bike_wheel_size_id, :value, :bike_condition_id, :bike_purpose_id, :photo
has_many :transactions
has_one :owner, :class_name => 'User'
has_one :task_list, :as => :item, :dependent => :destroy
belongs_to :bike_brand
belongs_to :bike_model
belongs_to :bike_style
belongs_to :bike_condition
belongs_to :bike_purpose
belongs_to :bike_wheel_size
has_attached_file :photo, :styles => {:thumb => '100x100>'}
validates :shop_id, :presence => true, :uniqueness => true, :numericality => { :only_integer => true }
validates :serial_number, :length => { :minimum => 3 }
validates :model, :length => { :maximum => 50 }
validates :bike_brand_id, :presence => true
validates :color, :presence => true
validates :bike_style_id, :presence => true
validates :seat_tube_height, :presence => true
validates :bike_wheel_size_id, :presence => true
validates :bike_condition_id, :presence => true
validates :bike_purpose_id, :presence => true
validates :bike_brand_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid brand" }
#validates :color, :presence => true
validates :bike_style_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid style" }
validates :seat_tube_height, :presence => true, :numericality => true
validates :bike_wheel_size_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid wheel size" }
validates :bike_condition_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid condition" }
validates :bike_purpose_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid purpose" }
validates_attachment :photo, :content_type => {:content_type => %w{ image/jpeg image/gif image/png }},
:file_name => {:matches => [/png\Z/, /jpe?g\Z/, /gif\Z/]}
self.per_page = 15

View File

@ -0,0 +1,160 @@
require 'csv'
# Imports data from CSV file into the bikes database.
class BikeCsvImporter
include BikeCsvImporter::Cache
include BikeCsvImporter::Cleaner
include BikeCsvImporter::BikeAttrs
include BikeCsvImporter::Logs
attr_reader :file
# Default constructor
#
# @param [String] file Path to the CSV file
def initialize(file)
@file = file
end
# Runs the import. Will print out progress to stdout
#
# @param [Boolean] dry_run If true, does not save data, only shows the progress of validation
def run(dry_run)
imported_count, skipped_count = 0, 0
puts "Performing a #{dry_run ? 'DRY RUN' : 'LIVE RUN'} of import"
fetch do |bike_hash|
bike = new_bike bike_hash
check_method = dry_run ? :valid? : :save
if bike.try check_method
puts "Imported #{bike.shop_id}: #{bike}".green
logs = new_logs_entries bike, bike_hash
logs.each do |log|
if log.send check_method
puts "\tLog entry created: #{log.inspect}".green
else
puts "\tLog entry creation failed: #{log.errors.full_messages.join '; '}".red
end
end
imported_count += 1
else
puts "Skipped #{bike.try(:shop_id) || bike_hash.values.first}: #{bike.try(:errors).try(:full_messages).try :join, '; '}".red
skipped_count += 1
end
end
puts "#{imported_count} bikes imported, #{skipped_count} bikes skipped, total of #{imported_count + skipped_count} rows in the CSV"
end
# Analyzes and prints out the input CSV file values
#
# @param [Array<Strong>] fields If passed, analyze only the given fields (names are down cased)
def analyze(fields = [])
puts "Analyzing CSV values frequency for #{fields.any? ? fields.join(', ') + ' field' : 'all fields'}"
fields = fields.map &:downcase
grouped = {}
fetch do |bike_hash|
bike_hash.each do |key, value|
next if fields.any? && !fields.include?(key)
grouped[key] ||= {}
grouped[key][value] ||= 0
grouped[key][value] += 1
end
end
grouped.each do |field, values|
puts "#{field}:"
values.each do |value, count|
puts "\t#{value.inspect}: #{count}"
end
puts "\tTotal of #{values.count} distinct values"
end
end
# Imports new brands from CSV file (field 'make'). Will print out progress to stdout
#
# @param [Boolean] dry_run If true, does not save data, only shows the progress of validation
def brands(dry_run)
created_count, skipped_count = 0, 0
puts "Performing a #{dry_run ? 'DRY RUN' : 'LIVE RUN'} of brands import"
fetch do |bike_hash|
make = clean_value bike_hash['make']
brand = bike_attr_bike_brand make, true
check_method = dry_run ? :valid? : :save
if brand.try :persisted?
puts "Skipped already existing brand #{brand.brand}"
skipped_count +=1
elsif brand.try check_method
puts "Created brand #{brand.brand}".green
created_count += 1
else
puts "Skipped #{brand.try(:brand) || make}: #{brand.try(:errors).try(:full_messages).try(:join, '; ') || 'object not created'}".red
skipped_count += 1
end
end
puts "#{created_count} brand created, #{skipped_count} brand skipped, total of #{created_count + skipped_count} rows in the CSV"
end
private
# Parses the CSV header & rows, yielding a block for each row (except the header)
# Header is down cased!
#
# @param [Proc] &block The block to yield to
def fetch
CSV.foreach(file).each_with_index do |row, i|
if i.zero?
parse_header row
else
yield parse_bike(row)
end
end
end
# Parses & stores the input header, down casing by the way
#
# @param [Array<String>] row
def parse_header(row)
@header = row.map(&:downcase)
end
# Parses the input row into a hash with keys from the header, @see #parse_header
#
# @param [Array<String>] row
#
# @return [Hash]
def parse_bike(row)
@header.zip(row).to_h
end
# Constructs a new Bike instance from the given hash from a CSV row
#
# @param [Hash] bike_hash
#
# @return [Bike]
def new_bike(bike_hash)
Bike.new bike_attrs(bike_hash)
end
# Constructs new Bike Log Entries instances from the given hash from a CSV row
#
# @param [Bike] bike The Bike instance to construct log entries for
# @param [Hash] bike_hash The input hash from a CSV row
#
# @return [Array<ActsAsLoggable::Log>]
def new_logs_entries(bike, bike_hash)
%i{ acquired comment gone }.map { |x| send :"log_entry_#{x}", bike, bike_hash }.compact
end
end

View File

@ -0,0 +1,93 @@
# Helper module to create various Bike instanct fields from a CSV row hash
class BikeCsvImporter
module BikeAttrs
def bike_attr_fields
{
shop_id: 'velocipede number',
bike_purpose_id: 'program',
#gone: 'gone',
value: 'price',
bike_brand_id: 'make',
bike_model_id: 'model',
model: 'model',
bike_style_id: nil,
bike_condition_id: nil,
seat_tube_height: nil,
bike_wheel_size_id: nil,
serial_number: nil,
}
end
def bike_attrs(bike_hash)
bike_attr_fields.each_with_object({}) do |(model_field, csv_field), memo|
memo[model_field] = send :"bike_attr_#{model_field}", clean_value(bike_hash[csv_field])
end
end
def bike_attr_shop_id(value)
value.to_i
end
def bike_attr_bike_purpose_id(value)
map = {
'SALE' => /shop|as(-|\s+)is|safety\s*check/,
'BUILDBIKE' => /build|bikes.*world/,
'STORAGE' => nil,
'PARTS' => /part|frame/,
'SCRAP' => /scrap|strip/,
}
default = 'UNDETERMINED'
test_value = value.try :downcase
value = map.find { |_, regexp| regexp.try :match, test_value }.try :first
cached_bike_purpose(value || default).id
end
def bike_attr_gone(value)
%w{ yes yeah y }.include? value.try :downcase
end
def bike_attr_value(value)
value.try(:gsub, /[$]/, '').try :to_i
end
def bike_attr_bike_brand(value, new_if_empty = false)
value = 'Unknown' if !value || value =~ /\Aunknown/i
cached_bike_brand value, new_if_empty
end
def bike_attr_bike_brand_id(value)
bike_attr_bike_brand(value, false).try :id
end
def bike_attr_bike_model_id(value)
return unless value
cached_bike_model(value).try :id
end
def bike_attr_model(value)
value if value && value !~ /unknown/i
end
def bike_attr_bike_style_id(_)
@bike_style_other_cache ||= BikeStyle.find_by_style('OTHER').id
end
def bike_attr_bike_condition_id(_)
@bike_condition_undertermined_cache ||= BikeCondition.find_by_condition('UNDETERMINED').id
end
def bike_attr_seat_tube_height(_)
0
end
def bike_attr_bike_wheel_size_id(_)
@bike_condition_wheel_size_undertermined_cache ||= BikeWheelSize.find_by_description('UNDETERMINED').id
end
def bike_attr_serial_number(_)
'UNDETERMINED'
end
end
end

View File

@ -0,0 +1,35 @@
# Helper module to create various cached instances for bike CSV imports
class BikeCsvImporter
module Cache
def cached_bike_purpose(purpose)
@bike_purpose_cache ||= {}
@bike_purpose_cache[purpose] ||= BikePurpose.find_by_purpose purpose
end
def cached_bike_brand(brand, new_if_empty = false)
@bike_brand_cache ||= {}
if @bike_brand_cache.has_key? brand
@bike_brand_cache[brand]
else
bike_brand = BikeBrand.where('lower(brand) = ?', brand.downcase).first
bike_brand ||= BikeBrand.new(brand: brand) if new_if_empty
@bike_brand_cache[brand] = bike_brand
end
end
def cached_bike_model(model)
@bike_model_cache ||= {}
if @bike_model_cache.has_key? model
@bike_model_cache[model]
else
@bike_model_cache[model] = BikeModel.where('lower(model) = ?', model.downcase).first
end
end
def cached_log_bike_action(action)
@log_bike_action_id_cache ||= {}
@log_bike_action_id_cache[action] ||= ActsAsLoggable::BikeAction.find_by_action(action)
end
end
end

View File

@ -0,0 +1,16 @@
# Helper module to clean the incoming data from CSV fields
class BikeCsvImporter
module Cleaner
def clean_value(value)
value_or_nil strip_value(value)
end
def strip_value(value)
value.try(:strip).try(:gsub, /\n|\r/, '')
end
def value_or_nil(value)
return value unless ['?', 'n/a', 'missing', 'unknown', ''].include? value.try(:downcase)
end
end
end

View File

@ -0,0 +1,42 @@
# Helper module to create ActsAsLoggable log entries for a Bike instance from a CSV row hash
class BikeCsvImporter
module Logs
def log_entry_gone(bike, bike_hash)
if clean_value(bike_hash['gone']).to_s =~ /y/i
log_entry bike, log_entry_date(clean_value(bike_hash['date out'])), 'COMPLETED', 'Gone'
end
end
def log_entry_acquired(bike, bike_hash)
if clean_value(bike_hash['date in'])
log_entry bike, log_entry_date(clean_value(bike_hash['date in'])), 'ACQUIRED'
end
end
def log_entry_comment(bike, bike_hash)
if clean_value(bike_hash['comment']).present?
log_entry bike, nil, 'NOTE', clean_value(bike_hash['comment'])
end
end
def log_entry_date(value)
return unless value
Date.strptime value, '%m/%d/%y' rescue nil
end
def log_entry(bike, date, type, description = nil)
date ||= DateTime.now
bike_action = cached_log_bike_action(type)
ActsAsLoggable::Log.new(
loggable_type: bike.class.to_s,
loggable_id: bike.id || bike.shop_id.to_i, # for dry run
log_action_type: bike_action.class.to_s,
log_action_id: bike_action.id,
start_date: date,
end_date: date,
description: description,
)
end
end
end

View File

@ -1,5 +1,5 @@
class Task < ActiveRecord::Base
attr_accessible :task, :notes, :done
attr_accessible :task, :notes, :done, :task_list_id
belongs_to :task_list

View File

@ -4,7 +4,7 @@ class TaskList < ActiveRecord::Base
attr_accessible :item_id, :item_type, :name
belongs_to :item, :polymorphic => true
has_many :tasks
has_many :tasks, order: "id ASC"
after_save :create_default_bike_tasks

27
app/models/time_entry.rb Normal file
View File

@ -0,0 +1,27 @@
class TimeEntry < ActsAsLoggable::Log
default_scope where( loggable_type: "User",
logger_type: "User",
log_action_type: "ActsAsLoggable::UserAction").where("log_action_id != 4").order("start_date DESC")
def copy_to_bike_history(bike_id)
self.assign_attributes({
copy_log: true,
copy_type: 'Bike',
copy_id: bike_id,
copy_action_type: 'ActsAsLoggable::BikeAction',
copy_action_id: 4
})
end
def duration
end_date - start_date
end
def duration_in_hours
(duration / 1.hour).round(2)
end
def type
log_action.try(:action)
end
end

View File

@ -1,4 +1,6 @@
class User < ActiveRecord::Base
MAX_AVATAR_SIZE_KB = 1024
acts_as_loggable
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
@ -8,7 +10,7 @@ class User < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me,
:first_name, :last_name, :bike_id,
:user_profiles_attributes, :username
:user_profiles_attributes, :username, :avatar
has_many :transactions, as: :customer
has_many :transaction_logs, through: :transactions, source: :logs
@ -20,11 +22,19 @@ class User < ActiveRecord::Base
belongs_to :bike
has_attached_file :avatar, :styles => {:thumb => '100x100>'}
default_scope order('username ASC')
validates :username, :presence => true, uniqueness: true
validates :first_name, :presence => true
validates :last_name, :presence => true
validates_attachment :avatar, :content_type => {:content_type => %w{ image/jpeg image/gif image/png }},
:file_name => {:matches => [/png\Z/, /jpe?g\Z/, /gif\Z/]},
:size => {:in => 0..MAX_AVATAR_SIZE_KB.kilobytes}
def to_s
"#{first_name} #{last_name}"
end
@ -44,10 +54,16 @@ class User < ActiveRecord::Base
roles.include?(role)
end
# try keeping the email field in DB clear and consistent, without empty strings (NULLs instead)
def email=(other)
super(other.blank? ? nil : other)
end
### TODO methods below probably belong somewhere else
def completed_build_bikes
purpose_id = BikePurpose.find_by_purpose("BUILDBIKE").id
#default BUILDBIKE/CLASS ID is 5
purpose_id = 5
Bike.find_by_sql("
SELECT *
FROM bikes
@ -64,15 +80,16 @@ class User < ActiveRecord::Base
end
def total_credits_spent
log_action = ::ActsAsLoggable::TransactionAction.find_by_action("TIME")
log_action_id = 1 #TIME
transaction_logs.
where( "log_action_id = ? AND log_action_type = ?",
log_action.id, log_action.class.to_s).
log_action_id, ::ActsAsLoggable::TransactionAction.to_s).
sum{ |r| r.description.to_i }.round(2)
end
def total_earned_credits
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
volunteer_id = 1
staff_id = 3
# Find the first credit conversion which has a created_at date before the
# log's created_at date and join it to the log's row so we can calculate
@ -81,7 +98,7 @@ class User < ActiveRecord::Base
#
# The DISTINCT ON, and ORDER BY are important to getting the
# single conversion rate that applies to the respective log.
::ActsAsLoggable::Log.find_by_sql("
::ActsAsLoggable::Log.find_by_sql(["
SELECT DISTINCT ON (logs.created_at) start_date, end_date,
conversion.conversion, conversion.created_at
FROM logs
@ -89,23 +106,26 @@ class User < ActiveRecord::Base
SELECT conversion, created_at
FROM credit_conversions
) AS conversion ON logs.created_at > conversion.created_at
WHERE logs.loggable_id = #{self.id}
WHERE logs.loggable_id = :id
AND logs.loggable_type = 'User'
AND (log_action_id != #{log_action.id} AND log_action_type = '#{log_action.class.to_s}')
ORDER BY logs.created_at, conversion.created_at DESC").
AND (log_action_id IN (:credit_actions) AND log_action_type = :log_action_type)
ORDER BY logs.created_at, conversion.created_at DESC",
{id: self.id,
credit_actions: [volunteer_id, staff_id],
log_action_type: ::ActsAsLoggable::UserAction.to_s}]).
sum{ |l| ((l.end_date - l.start_date)/3600) * l.conversion.to_i}.round(2)
end
def total_hours
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
logs.where("log_action_id != ? AND log_action_type = ?", log_action.id, log_action.class.to_s).sum { |l| (l.end_date - l.start_date)/3600 }.round(2)
log_action_id = 4 #CHECKIN
logs.where("log_action_id != ? AND log_action_type = ?", log_action_id, ::ActsAsLoggable::UserAction.to_s).sum { |l| (l.end_date - l.start_date)/3600 }.round(2)
end
def current_month_hours
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
log_action_id = 4 #CHECKIN
#TODO need to prevent users from saving logs across months, force to create a new log if crossing month
current_month_range = (Time.now.beginning_of_month..Time.now.end_of_month)
logs.where("log_action_id != ? AND log_action_type = ?", log_action.id, log_action.class.to_s)
logs.where("log_action_id != ? AND log_action_type = ?", log_action_id, ::ActsAsLoggable::UserAction.to_s)
.where( :start_date => current_month_range)
.where( :end_date => current_month_range)
.sum { |l| (l.end_date - l.start_date)/3600 }
@ -113,28 +133,31 @@ class User < ActiveRecord::Base
end
def checked_in?
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
checked = logs.where( log_action_id: log_action.id).
#default CHECKIN log action is id, yea yea should be a constant
log_action_id = 4
checked = logs.where( log_action_id: log_action_id).
where("start_date >= ?", Time.zone.now.beginning_of_day).
where("start_date = end_date")
!checked.empty?
end
def checkin
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
#default CHECKIN log action is id, yea yea should be a constant
log_action_id = 4
time = Time.now
logs.create( logger_id: self.id,
logger_type: self.class.to_s,
start_date: time,
end_date: time,
log_action_id: log_action.id,
log_action_type: log_action.class.to_s)
log_action_id: log_action_id,
log_action_type: ::ActsAsLoggable::UserAction.to_s)
save
end
def checkout
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
checked = logs.where( log_action_id: log_action.id).
#default CHECKIN log action is id, yea yea should be a constant
log_action_id = 4
checked = logs.where( log_action_id: log_action_id).
where("start_date >= ?", Time.zone.now.beginning_of_day).
where("start_date = end_date").first
checked.end_date = Time.now

View File

@ -0,0 +1,4 @@
json.bikes [@bike] do |bike|
json.array! bike
json.set! :href, api_bike_path(bike)
end

View File

@ -0,0 +1,3 @@
json.bikes [@bike] do |bike|
json.array! bike
end

View File

@ -0,0 +1,15 @@
json.task_lists [@task_list] do |tl|
json.array! tl
json.links do
json.bike do
json.href api_bike_path(tl.item)
json.id tl.item_id
end
json.tasks tl.tasks do |task|
json.id task.id
json.done task.done
json.notes task.notes
json.task task.task
end
end
end

View File

@ -0,0 +1,3 @@
json.tasks [@tasks.map{|x| x[:record]}] do |task|
json.array! task
end

View File

@ -0,0 +1,4 @@
json.time_entries [@time_entry] do |time_entry|
json.array! time_entry
#json.set! :href, api_time_entry_path(time_entry)
end

View File

@ -0,0 +1,80 @@
= top_menu
%h1 Add Bike
.row
.col-xs-12.col-sm-6.col-lg-4
= form_for @bike, as: 'bikes', index: '', url: api_create_bike_path, method: :post, enctype: 'multipart/form-data', html: {id: 'add_bike_form'} do |f|
= f.hidden_field 'bike_purpose_id'
%fieldset
.form-group
= f.number_field 'shop_id', placeholder: 'Shop ID', min: 0, class: 'form-control', id: 'shop_id'
.help-block
.form-group
= f.select 'bike_brand_id', options_for_select(@brands), {}, class: 'form-control', id: 'bike_brand_id'
.help-block
.form-group
= f.text_field 'model', placeholder: 'Model', class: 'form-control', id: 'model'
.help-block
.form-group
= f.text_field 'serial_number', placeholder: 'Serial Number', class: 'form-control', id: 'serial_number'
.help-block
.form-group
.btn-group(data-toggle="buttons")
%label.btn.btn-default
= f.radio_button 'bike_style_id', 3
RD
%label.btn.btn-default
= f.radio_button 'bike_style_id', 1
MTN
%label.btn.btn-default
= f.radio_button 'bike_style_id', 2
HYB
%label.btn.btn-default
= f.radio_button 'bike_style_id', 4
OTHER
= hidden_field_tag nil, nil, id: 'bike_style_id'
.help-block
.form-group
= f.select 'bike_wheel_size_id', options_for_select(@wheel_sizes), {}, class: 'form-control', id: 'bike_wheel_size_id'
.help-block
.form-group
.btn-group(data-toggle="buttons")
%label.btn.btn-default
= f.radio_button 'bike_condition_id', 2
Poor
%label.btn.btn-default
= f.radio_button 'bike_condition_id', 3
Fair
%label.btn.btn-default
= f.radio_button 'bike_condition_id', 4
Good
%label.btn.btn-default
= f.radio_button 'bike_condition_id', 5
Excellent
= hidden_field_tag nil, nil, id: 'bike_condition_id'
.help-block
.form-group
.input-group
= f.number_field 'seat_tube_height', placeholder: 'Seat Tube', min: 0, max: 100, class: 'form-control', id: 'seat_tube_height'
.input-group-addon cm
.help-block
.form-group
%label Bike photo (optional)
= f.file_field 'photo', id: 'photo'
.help-block
-# Commenting this out until description is added to Bike
/.form-group
%input{id: "bike_description", placeholder: "Short description", type: "text", class: "input-lg" }
.form-group
= button_tag 'Add Bike', class: 'btn btn-primary'

View File

@ -0,0 +1,57 @@
- btn = if @show_add_bike
- capture do
= link_to 'Add Another Bike?', new_bike_path, class: 'btn btn-default navbar-btn hidden-xs'
= link_to new_bike_path, class: 'navbar-brand visible-xs', title: 'Add Another Bike?' do
%i.glyphicon.glyphicon-plus
= top_menu btn
%h1 #{@bike.shop_id}: #{@bike.bike_brand}
%h4= @bike.model
.form-horizontal
- if @bike.photo?
.form-group
%label.col-sm-2.control-label Photo
.col-sm-10
= link_to @bike.photo.url, target: '_blank' do
%img{src: @bike.photo.url(:thumb), class: 'img-thumbnail'}
.form-group
%label.col-sm-2.control-label Type
.col-sm-10.form-control-static= @bike.bike_style
.form-group
%label.col-sm-2.control-label Wheel Size
.col-sm-10.form-control-static= @bike.bike_wheel_size.display_string
.form-group
%label.col-sm-2.control-label Condition
.col-sm-10.form-control-static= @bike.bike_condition
.form-group
%label.col-sm-2.control-label Seat Tube (cm)
.col-sm-10.form-control-static= @bike.seat_tube_height
.form-group
%label.col-sm-2.control-label Purpose
.col-sm-10.form-control-static= @bike.bike_purpose
- unless @bike.value.nil?
.form-group
%label.col-sm-2.control-label Value
.col-sm-10.form-control-static= @bike.value
- unless @bike.color.nil?
.form-group
%label.col-sm-2.control-label Color
.col-sm-10.form-control-static
.bike-color(style="background-color: ##{@bike.color}")= @bike.color
- if @task_list
- tasks = @task_list.tasks.to_a
.form-group
%label.col-sm-2.control-label Task list
.col-sm-10.form-control-static
= link_to edit_task_list_path(@task_list.id) do
#{tasks.select(&:done).count}/#{tasks.count}

View File

@ -1,25 +0,0 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Sign in", new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>

View File

@ -0,0 +1,20 @@
- links = []
- if controller_name != 'sessions'
- links << ['Sign in', new_session_path(resource_name)]
- if devise_mapping.registerable? && controller_name != 'registrations'
- links << ['Sign up', new_registration_path(resource_name)]
- if devise_mapping.recoverable? && controller_name != 'passwords'
- links << ['Forgot your password?', new_password_path(resource_name)]
- if devise_mapping.confirmable? && controller_name != 'confirmations'
- links << ['Didn\'t receive confirmation instructions?', new_confirmation_path(resource_name)]
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
- links << ["Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)]
- if links.any?
%p= links.map { |title, url| link_to title, url }.join(' &middot; ').html_safe

View File

@ -1,12 +0,0 @@
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.submit "Resend confirmation instructions" %></div>
<% end %>
<%= render "links" %>

View File

@ -1,16 +0,0 @@
<h2>Change your password</h2>
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<div><%= f.label :password, "New password" %><br />
<%= f.password_field :password %></div>
<div><%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.submit "Change my password" %></div>
<% end %>
<%= render "links" %>

View File

@ -0,0 +1,19 @@
%h1 Change your password
.row
.col-xs-12.col-sm-6.col-lg-4
= form_for resource, as: resource_name, url: password_path(resource_name), html: {method: :put} do |f|
= devise_error_messages!
= f.hidden_field :reset_password_token
%fieldset
.form-group
= f.password_field :password, placeholder: 'New password', class: 'form-control'
.form-group
= f.password_field :password_confirmation, placeholder: 'Confirm new password', class: 'form-control'
.form-group
= f.submit 'Change my password', class: 'btn btn-primary'
= render 'links'

View File

@ -1,12 +0,0 @@
<h2>Forgot your password?</h2>
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.submit "Send me reset password instructions" %></div>
<% end %>
<%= render "links" %>

View File

@ -0,0 +1,15 @@
%h1 Forgot your password?
.row
.col-xs-12.col-sm-6.col-lg-4
= form_for resource, as: resource_name, url: password_path(resource_name), html: {method: :post} do |f|
= devise_error_messages!
%fieldset
.form-group
= f.email_field :email, placeholder: 'Email', class: 'form-control'
.form-group
= f.submit 'Reset Password', class: 'btn btn-primary'
= render 'links'

View File

@ -1,25 +1,17 @@
%fieldset
.control-group
= f.label :addrStreet1, :class => "control-label"
.controls
= f.text_field :addrStreet1, :class => "control-label"
.control-group
= f.label :addrStreet2, :class => "control-label"
.controls
= f.text_field :addrStreet2, :class => "control-label"
.control-group
= f.label :addrCity, :class => "control-label"
.controls
= f.text_field :addrCity, :class => "control-label"
.control-group
= f.label :addrState, :class => "control-label"
.controls
= f.text_field :addrState, :class => "control-label"
.control-group
= f.label :addrZip, :class => "control-label"
.controls
= f.text_field :addrZip, :class => "control-label"
.control-group
= f.label :phone, :class => "control-label"
.controls
= f.text_field :phone, :class => "control-label"
.form-group
= f.text_field :addrStreet1, placeholder: 'Street Address Line 1', class: 'form-control'
.form-group
= f.text_field :addrStreet2, placeholder: 'Street Address Line 2',class: 'form-control'
.form-group
= f.text_field :addrCity, placeholder: 'City', class: 'form-control'
.form-group
= f.text_field :addrState, placeholder: 'State Abbreviation', class: 'form-control'
.form-group
= f.text_field :addrZip, placeholder: 'Zip Code', class: 'form-control'
.form-group
= f.text_field :phone, placeholder: 'Phone', class: 'form-control'

View File

@ -1,27 +0,0 @@
<%= stylesheet_link_tag "bootstrap_and_overrides", :media => "all" %>
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, :autocomplete => "off" %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password %></div>
<div><%= f.submit "Update" %></div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
<%= link_to "Back", :back %>

View File

@ -1,36 +1,47 @@
= stylesheet_link_tag "bootstrap_and_overrides", :media => "all"
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form-horizontal"}) do |f|
= devise_error_messages!
.controls
%h2 Sign up
.control-group
= f.label :username, :class => "control-label"
.controls
= f.text_field :username
.control-group
= f.label :first_name, :class => "control-label"
.controls
= f.text_field :first_name
.control-group
= f.label :last_name, :class => "control-label"
.controls
= f.text_field :last_name
.control-group
= f.label :email, :class => "control-label"
.controls
= f.email_field :email
- profile_builder = resource.user_profiles.empty? ? resource.user_profiles.build : resource.user_profiles
= f.fields_for :user_profiles, profile_builder do |builder|
= render 'user_profile_fields', f: builder
.control-group
= f.label :password, :class => "control-label"
.controls
= f.password_field :password
.control-group
= f.label :password_confirmation, :class => "control-label"
.controls
= f.password_field :password_confirmation
.control-group
.controls
= f.submit "Sign up"
= render "links"
%h1 Sign up
.row
.col-xs-12.col-sm-6.col-lg-4
= form_for resource, as: resource_name, url: registration_path(resource_name) do |f|
= devise_error_messages!
%fieldset
.form-group
= f.text_field :username, placeholder: 'Username', class: 'form-control', required: true
.help-block
.form-group
= f.text_field :first_name, placeholder: 'First Name', class: 'form-control', required: true
.help-block
.form-group
= f.text_field :last_name, placeholder: 'Last Name', class: 'form-control', required: true
.help-block
.form-group
= f.email_field :email, placeholder: 'E-mail', class: 'form-control'
%fieldset
- profile_builder = resource.user_profiles.empty? ? resource.user_profiles.build : resource.user_profiles
= f.fields_for :user_profiles, profile_builder do |builder|
= render 'user_profile_fields', f: builder
%fieldset
.form-group
%label You may upload your photo to be used as an avatar
= f.file_field :avatar
.help-block #{User::MAX_AVATAR_SIZE_KB} Kb max
%fieldset
.form-group
= f.password_field :password, placeholder: 'Password', class: 'form-control', required: true
.help-block
.form-group
= f.password_field :password_confirmation, placeholder: 'Password Confirmation', class: 'form-control', required: true
.help-block
.form-group
= f.submit 'Sign up', class: 'btn btn-primary'
= render 'links'

View File

@ -1,38 +0,0 @@
<%= stylesheet_link_tag "bootstrap_and_overrides", :media => "all" %>
<h2>Velocipede</h2>
<a href="http://madewithloveinbaltimore.org">Made with &hearts; in Baltimore</a>
<br>
<br>
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<div><%= f.label :username%><br />
<%= f.text_field :username%></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
<% if devise_mapping.rememberable? -%>
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
<% end -%>
<div><%= f.submit "Sign in" %></div>
<div id="checkin_menu"style="display:none;">
<input id="checkin" name="checkin" type="button" value="CHECK IN">
<input id="checkout" name="checkout" type="button" value="CHECK OUT">
</div>
<% end %>
<%= render "links" %>
<% if Rails.env.development? %>
<% User.all.each do |user| %>
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<%= f.hidden_field :username, :value => user.username%></div>
<%= f.hidden_field :password, :value => 'password' %></div>
<div><%= f.submit "Sign in as #{user.username}" %></div>
<% end %>
<% end %>
<% end %>

View File

@ -0,0 +1,41 @@
%h1 Velocipede
%p= link_to 'Made with &hearts; in Baltimore'.html_safe, 'http://madewithloveinbaltimore.org'
.row
.col-xs-12.col-sm-6.col-lg-4
= form_for resource, as: resource_name, url: session_path(resource_name) do |f|
%fieldset
.form-group
= f.text_field :username, placeholder: 'Username', class: 'form-control'
.form-group
= f.password_field :password, placeholder: 'Password', class: 'form-control'
- if devise_mapping.rememberable?
.form-group
.checkbox
= f.label :remember_me do
= f.check_box :remember_me
Remember Me
.form-group
.pull-left
= f.submit 'Sign in', class: 'btn btn-primary'
.pull-right
%span.btn-group
= f.button 'Check in', id: 'checkin', name: 'checkin', type: 'button', class: 'btn btn-success'
= f.button 'Check out', id: 'checkout', name: 'checkout', type: 'button', class: 'btn btn-danger'
.clearfix
= render 'links'
- if Rails.env.development?
%hr
- User.all.each do |user|
= form_for resource, as: resource_name, url: session_path(resource_name) do |f|
= f.hidden_field :username, value: user.username
= f.hidden_field :password, value: 'password'
%p= f.submit "Sign in as #{user.username}", class: 'btn btn-sm btn-info'

View File

@ -1,12 +0,0 @@
<h2>Resend unlock instructions</h2>
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.submit "Resend unlock instructions" %></div>
<% end %>
<%= render "links" %>

View File

@ -1,34 +1,27 @@
!!! 5
%html{:lang => "en"}
%html(lang="en")
%head
%meta{:charset => "utf-8"}/
%title= content_for?(:title) ? yield(:title) : "Velocipede"
= load_netzke
%meta(charset="utf-8")/
%meta(name="viewport" content="width=device-width" initial-scale="1.0")/
%title= content_for?(:title) ? yield(:title) : 'Velocipede'
= csrf_meta_tags
= stylesheet_link_tag 'application', media: 'all'
/[if lt IE 9]
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
:css
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
.x-boundlist-item {
white-space: nowrap;
}
= javascript_include_tag 'http://html5shim.googlecode.com/svn/trunk/html5.js'
%body
.container
.content
- if flash[:notice]
%p{:class => 'notice'}= flash[:notice]
%div.alert.alert-info= flash[:notice]
- if flash[:alert]
%p{:class => 'alert'}= flash[:alert]
.row
.span13
= yield
%div.alert.alert-danger= flash[:alert]
= yield
%footer
%p &copy; Velocipede 2013
%hr
%p.text-muted &copy; BikeShed #{Time.now.year}
= javascript_include_tag "application"
= javascript_include_tag 'application'
= javascript_include_tag params[:controller]

View File

@ -0,0 +1,11 @@
!!! 5
%html{:lang => "en"}
%head
%meta{:charset => "utf-8"}/
%title= content_for?(:title) ? yield(:title) : "Velocipede"
= load_netzke
= csrf_meta_tags
%body
= yield
= javascript_include_tag "application"
= javascript_include_tag params[:controller]

View File

@ -0,0 +1,31 @@
%h1 Dashboard
.row.fieldset
.col-xs-12.col-sm-3.col-lg-2
%p= link_to 'Add Time Entry', new_time_entry_path, class: 'btn btn-default btn-block'
.col-xs-12.col-sm-3.col-lg-2
%p= link_to 'View Timesheet', time_entries_path, class: 'btn btn-default btn-block'
- can_manage_bike = can? :manage, Bike
- has_bike = !@bike.nil?
- if can_manage_bike || has_bike
.row.fieldset
- if can_manage_bike
.col-xs-12.col-sm-3.col-lg-2
%p
= link_to 'Add Bike', new_bike_path, class: 'btn btn-default btn-block'
- if has_bike
.col-xs-12.col-sm-3.col-lg-2
%p
= link_to 'View Your Bike', bike_path(@bike), class: 'btn btn-default btn-block'
.row.fieldset
.col-xs-12.col-sm-3.col-lg-2
%p
= link_to 'Desktop View', admin_index_path, class: 'btn btn-default btn-block'
.row.fieldset
.col-xs-12.col-sm-3.col-lg-2
%p
= button_tag 'Logout', id: 'index_logout', class: 'btn btn-danger btn-block', data: {url: destroy_user_session_path}

View File

@ -0,0 +1,24 @@
= top_menu
%h1 Task List
%h3
= link_to bike_path(@task_list.item) do
#{@task_list.item.shop_id}: #{@task_list.item.bike_brand}
%h4= @task_list.item.model
- if @task_list.item.photo?
%p
%img{src: @task_list.item.photo.url(:thumb), class: 'img-thumbnail'}
%fieldset
.form-group
- @task_list.tasks.each do |task|
.checkbox
%label
= check_box_tag nil, nil, task.done, class: 'task_list_task', type: 'checkbox', data: {id: task.id}
= task.task
.form-group
= button_tag 'Save Changes', id: 'update_tasks_submit', class: 'btn btn-primary disabled', data: {url: api_update_task_path}

View File

@ -0,0 +1,47 @@
= top_menu
%h1 Your Timesheet
.row
.col-xs-12.col-sm-6.col-lg-3
%p
%span.badge= @hours_worked
Total Hours Worked
.col-xs-12.col-sm-6.col-lg-3
%p
%span.badge= @credits_available
Total Credits Available
%table.table
%tbody
- @user_time_entries.each do |entry|
-# data: {start_date: ..} gets transformed to data-start-date instead of data-start_date, we don't want this
%tr{data: {id: entry.id, description: entry.description, duration: entry.duration_in_hours},
'data-start_date' => entry.start_date.to_date.to_formatted_s(:rfc822)}
%td= entry.start_date.to_date.to_formatted_s(:rfc822)
%td= entry.duration_in_hours
%td= entry.type
%td= link_to truncate(entry.description).presence || '<em>No title</em>'.html_safe, edit_task_list_path(entry)
%td
= link_to '#modal', class: 'text-danger work_entry-delete-btn', role: 'button', data: {toggle: 'modal', target: '#confirmation'} do
%i.glyphicon.glyphicon-remove
= link_to 'Add Time Entry', new_time_entry_path, class: 'btn btn-primary'
.modal#confirmation(role="dialog" aria-labelledby="confirmation_title" aria-hidden="true" tabindex="-1")
.modal-dialog
.modal-content
.modal-header
%button.close(data-dismiss="modal" aria-hidden="true") &times;
%h4#confirmation_title Are you sure you want to delete?
.modal-body
#work_entry_start_date Start Date
#work_entry_duration Duration
#work_entry_description Description
.modal-footer
%button.btn.btn-default(data-dismiss="modal" aria-hidden="true") Cancel
%button.btn.btn-danger#confirmation_delete{data: {url_template: api_delete_time_entry_path('__ID__')}} Delete

View File

@ -0,0 +1,56 @@
= top_menu
%h1 Add Time Entry
- time = Time.now
- date_format, time_format = '%m/%d/%Y', '%l:%M %p'
- mjs_date_format, mjs_time_format = 'MM/DD/YYYY', 'h:mm A'
.row
.col-xs-12.col-sm-6.col-lg-4
%fieldset
.form-group.form-inline
= text_field_tag nil, time.strftime(date_format), id: 'date_id', placeholder: 'Date', class: 'form-control',
size: 12, data: {format: mjs_date_format}
.help-block
.form-group.timepickers.form-inline
.form-group
%label.visible-xs Start time
= text_field_tag nil, time.strftime(time_format), id: 'start_time_id', placeholder: 'Start time',
class: 'form-control', size: 8, data: {format: mjs_time_format}
.hidden#start_date
.help-block
.form-group.dash.hidden-xs
&mdash;
.form-group
%label.visible-xs End time
= text_field_tag nil, time.strftime(time_format), id: 'end_time_id', placeholder: 'End time',
class: 'form-control', size: 8, data: {format: mjs_time_format}
.hidden#end_date
.help-block
.form-group
.btn-group(data-toggle="buttons")
%label.btn.btn-default
= radio_button_tag 'action_id', 1, false, autocomplete: 'off'
Volunteer
%label.btn.btn-default
= radio_button_tag 'action_id', 2, false, autocomplete: 'off'
Personal
%label.btn.btn-default
= radio_button_tag 'action_id', 3, false, autocomplete: 'off'
Staff
.hidden#log_action_id
.help-block
.form-group
= select_tag :bike_id, options_for_select(@bikes), class: 'form-control'
.form-group
= text_area_tag nil, nil, id: 'description_id', placeholder: 'Work description', class: 'form-control', rows: 5
.control-group
.controls
= button_tag 'Add Time Entry', id: 'add_time_entry_submit', class: 'btn btn-primary', data: {url: api_create_time_entry_path, forward: '.'}

View File

@ -1,68 +0,0 @@
= form_for @user, :html => { :class => 'form-horizontal' } do |f|
.control-group
= f.label :email, :class => 'control-label'
.controls
= f.text_field :email, :class => 'text_field'
.control-group
= f.label :encrypted_password, :class => 'control-label'
.controls
= f.text_field :encrypted_password, :class => 'text_field'
.control-group
= f.label :reset_password_token, :class => 'control-label'
.controls
= f.text_field :reset_password_token, :class => 'text_field'
.control-group
= f.label :reset_password_sent_at, :class => 'control-label'
.controls
= f.datetime_select :reset_password_sent_at, :class => 'datetime_select'
.control-group
= f.label :remember_created_at, :class => 'control-label'
.controls
= f.datetime_select :remember_created_at, :class => 'datetime_select'
.control-group
= f.label :sign_in_count, :class => 'control-label'
.controls
= f.number_field :sign_in_count, :class => 'number_field'
.control-group
= f.label :current_sign_in_at, :class => 'control-label'
.controls
= f.datetime_select :current_sign_in_at, :class => 'datetime_select'
.control-group
= f.label :last_sign_in_at, :class => 'control-label'
.controls
= f.datetime_select :last_sign_in_at, :class => 'datetime_select'
.control-group
= f.label :current_sign_in_ip, :class => 'control-label'
.controls
= f.text_field :current_sign_in_ip, :class => 'text_field'
.control-group
= f.label :last_sign_in_ip, :class => 'control-label'
.controls
= f.text_field :last_sign_in_ip, :class => 'text_field'
.control-group
= f.label :failed_attempts, :class => 'control-label'
.controls
= f.number_field :failed_attempts, :class => 'number_field'
.control-group
= f.label :unlock_token, :class => 'control-label'
.controls
= f.text_field :unlock_token, :class => 'text_field'
.control-group
= f.label :locked_at, :class => 'control-label'
.controls
= f.datetime_select :locked_at, :class => 'datetime_select'
.control-group
= f.label :first_name, :class => 'control-label'
.controls
= f.text_field :first_name, :class => 'text_field'
.control-group
= f.label :last_name, :class => 'control-label'
.controls
= f.text_field :last_name, :class => 'text_field'
.control-group
= f.label :nickname, :class => 'control-label'
.controls
= f.text_field :nickname, :class => 'text_field'
.form-actions
= f.submit nil, :class => 'btn btn-primary'
= link_to t('.cancel', :default => t("helpers.links.cancel")), users_path, :class => 'btn'

View File

@ -1,4 +0,0 @@
- model_class = user.class
.page-header
%h1=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human, :default => "Edit #{model_class.model_name.human}")
= render :partial => "form"

View File

@ -1,28 +0,0 @@
- model_class = User.new.class
.page-header
%h1=t '.title', :default => model_class.model_name.human.pluralize
%table.table.table-striped
%thead
%tr
%th= model_class.human_attribute_name(:id)
%th= model_class.human_attribute_name(:email)
%th= model_class.human_attribute_name(:first_name)
%th= model_class.human_attribute_name(:last_name)
%th= model_class.human_attribute_name(:nickname)
%th= model_class.human_attribute_name(:created_at)
%th=t '.actions', :default => t("helpers.actions")
%tbody
- users.each do |user|
%tr
%td= link_to user.id, user_path(user)
%td= link_to user.email, user_path(user)
%td= user.first_name
%td= user.last_name
%td= user.nickname
%td=l user.created_at
%td
= link_to t('.edit', :default => t("helpers.links.edit")), edit_user_path(user), :class => 'btn btn-mini'
= link_to t('.destroy', :default => t("helpers.links.destroy")), user_path(user), :method => :delete, :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')), :class => 'btn btn-mini btn-danger'
= will_paginate users
= link_to t('.new', :default => t("helpers.links.new")), new_user_path, :class => 'btn btn-primary'

View File

@ -1,4 +0,0 @@
- model_class = user.class
.page-header
%h1=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}")
= render :partial => "form"

View File

@ -1,73 +0,0 @@
- model_class = user.class
.page-header
%h1=t '.title', :default => model_class.model_name.human
%p
%strong= model_class.human_attribute_name(:email) + ':'
%br
= user.email
%p
%strong= model_class.human_attribute_name(:encrypted_password) + ':'
%br
= user.encrypted_password
%p
%strong= model_class.human_attribute_name(:reset_password_token) + ':'
%br
= user.reset_password_token
%p
%strong= model_class.human_attribute_name(:reset_password_sent_at) + ':'
%br
= user.reset_password_sent_at
%p
%strong= model_class.human_attribute_name(:remember_created_at) + ':'
%br
= user.remember_created_at
%p
%strong= model_class.human_attribute_name(:sign_in_count) + ':'
%br
= user.sign_in_count
%p
%strong= model_class.human_attribute_name(:current_sign_in_at) + ':'
%br
= user.current_sign_in_at
%p
%strong= model_class.human_attribute_name(:last_sign_in_at) + ':'
%br
= user.last_sign_in_at
%p
%strong= model_class.human_attribute_name(:current_sign_in_ip) + ':'
%br
= user.current_sign_in_ip
%p
%strong= model_class.human_attribute_name(:last_sign_in_ip) + ':'
%br
= user.last_sign_in_ip
%p
%strong= model_class.human_attribute_name(:failed_attempts) + ':'
%br
= user.failed_attempts
%p
%strong= model_class.human_attribute_name(:unlock_token) + ':'
%br
= user.unlock_token
%p
%strong= model_class.human_attribute_name(:locked_at) + ':'
%br
= user.locked_at
%p
%strong= model_class.human_attribute_name(:first_name) + ':'
%br
= user.first_name
%p
%strong= model_class.human_attribute_name(:last_name) + ':'
%br
= user.last_name
%p
%strong= model_class.human_attribute_name(:nickname) + ':'
%br
= user.nickname
.form-actions
= link_to t('.back', :default => t("helpers.links.back")), users_path, :class => 'btn'
= link_to t('.edit', :default => t("helpers.links.edit")), edit_user_path(user), :class => 'btn'
= link_to t('.destroy', :default => t("helpers.links.destroy")), user_path(user), :method => "delete", :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')), :class => 'btn btn-danger'

View File

@ -62,5 +62,8 @@ module Velocipede
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
# Enabled for bootstrap-sass gem
config.assets.initialize_on_precompile
end
end

View File

@ -1,23 +1,19 @@
development:
development: &default
adapter: postgresql
database: velocipede
username: velocipede
password:
host: 127.0.0.1
encoding: unicode
pool: 5
database: <%= ENV['RDS_DB_NAME'] || 'postgres' %>
username: <%= ENV['RDS_USERNAME'] || 'postgres' %>
password: <%= ENV['RDS_PASSWORD'] %>
host: <%= ENV['RDS_HOSTNAME'] || 'db' %>
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
database: velocipede
username: velocipede
password:
host: 127.0.0.1
<<: *default
database: velocipede_test
production:
adapter: postgresql
database: velocipede
username: velocipede
password:
host: 127.0.0.1
<<: *default
database: velocipede_production

View File

@ -222,11 +222,12 @@ Devise.setup do |config|
# end
end
#Check in the user if they sign in. (Devise uses Warden)
Warden::Manager.after_set_user do |user,auth,opts|
# this essentially gets called after every netzke request, but alas,
# only using the after_authenticaion callback doesn't get fired after
# user creation.
user.checkin unless user.checked_in?
unless Rails.env.test?
#Check in the user if they sign in. (Devise uses Warden)
Warden::Manager.after_set_user do |user,auth,opts|
# this essentially gets called after every netzke request, but alas,
# only using the after_authenticaion callback doesn't get fired after
# user creation.
user.checkin unless user.checked_in?
end
end

View File

@ -4,13 +4,34 @@ Velocipede::Application.routes.draw do
netzke
root :to => 'site#index'
get 'admin/index', to: 'panel#index', as: "admin_index"
get 'bikes/new', to: 'bikes#new', as: "new_bike"
get 'bikes/:id', to: 'bikes#show', as: "bike"
get 'task_lists/:id/edit' => "task_lists#edit", as: "edit_task_list"
get 'time_entries' => "time_entries#index", as: "time_entries"
get 'time_entries/new' => "time_entries#new", as: "new_time_entry"
###########################
# API Routes
scope 'api', :module => :api do
scope 'api', :module => :api, defaults: {format: :json} do
scope 'v1', :module => :v1 do
post 'checkin' => "logs#checkin", :as => "api_checkin"
post 'checkin' => "logs#checkin", :as => "api_checkin"
post 'checkout' => "logs#checkout", :as => "api_checkout"
post 'reset' => "users#password_reset", :as => "api_password_reset"
post 'reset' => "users#password_reset", :as => "api_password_reset"
get 'bikes/:id' => "bikes#show", as: "api_bike"
post 'bikes/create' => "bikes#create", as: "api_create_bike"
get 'task_lists/:id' => "task_lists#show", as: "api_task_list"
put 'tasks/update' => "tasks#update", as: "api_update_task"
post 'time_entries/create' => "time_entries#create", as: "api_create_time_entry"
delete 'time_entries/:id' => "time_entries#delete", as: "api_delete_time_entry"
end
end

View File

@ -10,10 +10,6 @@ class CreateBikeWheelSizes < ActiveRecord::Migration
t.string :description
t.string :tire_common_score
end
#create the default undetermined wheel size record
BikeWheelSize.create( twmm: 0, rdmm: 0, rdin: 0, twin: 0, rdfr: 0, twfr: 0, description: "UNDETERMINED", tire_common_score: 0)
ActiveRecord::Base.connection.execute(IO.read(File.join(Rails.root, "db", "seed", "sql", "common_wheel_sizes.sql")))
end
def down

View File

@ -0,0 +1,11 @@
class AddAttachmentAvatarToUsers < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.attachment :avatar
end
end
def self.down
remove_attachment :users, :avatar
end
end

View File

@ -0,0 +1,11 @@
class AddAttachmentPhotoToBikes < ActiveRecord::Migration
def self.up
change_table :bikes do |t|
t.attachment :photo
end
end
def self.down
remove_attachment :bikes, :photo
end
end

View File

@ -0,0 +1,15 @@
class UserEmailCanBeNull < ActiveRecord::Migration
def up
change_table :users do |t|
t.change :email, :string, default: nil, null: true
end
User.where(email: '').update_all(email: nil)
end
def down
change_table :users do |t|
t.change :email, :string, default: '', null: false
end
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20131019170248) do
ActiveRecord::Schema.define(:version => 20170131164224) do
create_table "bike_actions", :force => true do |t|
t.string "action", :limit => 128, :null => false
@ -47,14 +47,14 @@ ActiveRecord::Schema.define(:version => 20131019170248) do
end
create_table "bike_wheel_sizes", :force => true do |t|
t.string "twmm"
t.string "rdmm"
t.string "twin"
t.string "rdin"
t.string "twfr"
t.string "rdfr"
t.string "description"
t.string "tire_common_score"
t.integer "twmm"
t.integer "rdmm"
t.string "twin"
t.string "rdin"
t.string "twfr"
t.string "rdfr"
t.string "description"
t.string "tire_common_score"
end
create_table "bikes", :force => true do |t|
@ -73,6 +73,10 @@ ActiveRecord::Schema.define(:version => 20131019170248) do
t.string "model"
t.integer "shop_id"
t.integer "bike_wheel_size_id"
t.string "photo_file_name"
t.string "photo_content_type"
t.integer "photo_file_size"
t.datetime "photo_updated_at"
end
create_table "credit_conversions", :force => true do |t|
@ -179,7 +183,7 @@ ActiveRecord::Schema.define(:version => 20131019170248) do
end
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "email"
t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
@ -198,6 +202,10 @@ ActiveRecord::Schema.define(:version => 20131019170248) do
t.string "first_name", :default => "", :null => false
t.string "last_name", :default => "", :null => false
t.string "username"
t.string "avatar_file_name"
t.string "avatar_content_type"
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
end
add_index "users", ["bike_id"], :name => "index_users_on_bike_id", :unique => true

View File

@ -7,3 +7,6 @@ hybrid:
road:
id: 3
style: ROAD
other:
id: 4
style: OTHER

View File

@ -1,3 +1,6 @@
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
INSERT INTO bike_wheel_sizes (TWMM, RDMM,RDIN,TWIN,RDFR,TWFR,DESCRIPTION,tire_common_score) values (0,0,0,0,0,0,'UNDETERMINED',0);
INSERT INTO bike_wheel_sizes (TWMM, RDMM,RDIN,TWIN,RDFR,TWFR,DESCRIPTION,tire_common_score) values (54,110,'8 1/2','2','','','',1);
INSERT INTO bike_wheel_sizes (TWMM, RDMM,RDIN,TWIN,RDFR,TWFR,DESCRIPTION,tire_common_score) values (62,203,'12','1/2 x 2 1/4','320 ','57','',1);
INSERT INTO bike_wheel_sizes (TWMM, RDMM,RDIN,TWIN,RDFR,TWFR,DESCRIPTION,tire_common_score) values (47,305,'16','1,75 [x 2]','','','',1);
@ -35,3 +38,4 @@ INSERT INTO bike_wheel_sizes (TWMM, RDMM,RDIN,TWIN,RDFR,TWFR,DESCRIPTION,tire_co
INSERT INTO bike_wheel_sizes (TWMM, RDMM,RDIN,TWIN,RDFR,TWFR,DESCRIPTION,tire_common_score) values (28,630,'27','1 1/8 [1 1/4 fifty]','','','',1);
INSERT INTO bike_wheel_sizes (TWMM, RDMM,RDIN,TWIN,RDFR,TWFR,DESCRIPTION,tire_common_score) values (32,630,'27','1 1/4','','','',1);
INSERT INTO bike_wheel_sizes (TWMM, RDMM,RDIN,TWIN,RDFR,TWFR,DESCRIPTION,tire_common_score) values (40,635,'28','1 1/2 [1 3/8]','700 ','38B [35B]','',1);
COMMIT;

View File

@ -18,10 +18,12 @@ if BikeBrand.all.empty? and BikeModel.all.empty?
# so that the PG table ID sequence is incremented
#
# Note the drop(1) which assumes we have a junk PRAGMA line at the top
load_statements = File.readlines(File.join(Rails.root, 'db', 'seed', 'sql', 'bike_brands_and_models.sql')).drop(1).map do |statement|
statement.sub(/VALUES\(\d+,/, 'VALUES(DEFAULT,')
['common_wheel_sizes.sql', 'bike_brands_and_models.sql'].each do |sql|
load_statements = File.readlines(File.join(Rails.root, 'db', 'seed', 'sql', sql)).drop(1).map do |statement|
statement.sub(/VALUES\(\d+,/, 'VALUES(DEFAULT,')
end
ActiveRecord::Base.connection.execute(load_statements.join)
end
ActiveRecord::Base.connection.execute(load_statements.join)
end
if Rails.env.development?
@ -41,7 +43,7 @@ if Rails.env.development?
#create fake bikes
if Bike.all.empty?
42.times do |n|
FactoryGirl.create(:bike)
FactoryGirl.create(:seed_bike)
end
end
elsif Rails.env.production?

View File

@ -1 +0,0 @@
# No API yet

20
doc/guides.md Normal file
View File

@ -0,0 +1,20 @@
# Overview
## Guides
### Adding a User
To add a user, a user must sign themselves up from the initial login screen. An admin can later log in to grant that user admin privileges afterward, if desired.
### Adding a Bike
How to add a bike to the database via the desktop view: <https://www.youtube.com/watch?v=1IchWUdMQ90>.
## Views
The app has two different views. One for "core" volunteers which I consider admins, and another for "customer" volunteers which I consider users. Because of the Netzke/ExtJS framework I used, the current UI is non-intuitive and I feel like is only adequate for admins who can take the time to learn the system. I'm in the process of designing a simpler mobile friendly UI with the essential functionality that's intended for users.
## Deployment
Currently, at the Velocipede collective we have it running on a computer in the shop on the local network. The reason for this, is so that it's only accessible from within the shop. I'm weighing out different methods for ensuring that users can only log in from within the shop (and not from home), such as a shop password that only admins can see and would make visible from within the physical bike shop. I also don't have to worry about security issues while the app is in development. In the future, I'd like to see the app hosted much like <http://freehub.bikekitchen.org/>.
## Ideas
At Velocipede, with a mobile friendly UI for users, I'm hoping we can get donations of old, unused smart phones, connected via local wifi, that can be used as stations to log a volunteer's work and hours. They can be secured by gluing cables into the earphone jacks to deter theft if necessary. This might be another way that the collective can promote reuse of materials.

34
doc/local_dev_setup.md Normal file
View File

@ -0,0 +1,34 @@
# Local Developer Setup
1. use rvm
1. allow the .rvmrc file
1. `gem install bundler`
1. `bundle`
1. Install Postgres (Mac OSX instructions below)
1. Copy over DB config: `cp config/database.yml.example config/database.yml`
1. Update config with your database (velocipede), user (velocipede), and password.
1. `rake db:setup`
1. Download extJS 4.1 (A version of 4.1 is hosted here: http://my.jasondenney.com/extjs-4.1.1.zip) Latest versions at http://www.sencha.com/products/extjs. Unzip and place where ever you like.
1. Link to your extJS folder path under `public/extjs`: (From app root) `ln -s /MY/PATH/extjs/ public/extjs`
1. `rails s`
# Postgres 9.2 Mac OSX Install
1. Install homebrew `ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"`
1. `brew install postgres`
1. First time db initialization `initdb /usr/local/var/postgres -E utf8`
1. Start Postgres `pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start`
1. Create your PG user `createuser -d -P velocipede`
1. Create your database `createdb -U velocipede --owner=velocipede velocipede`
1. Create your test database `createdb -U velocipede --owner=velocipede velocipede_test`
# Testing
1. Install phantomjs `brew install phantomjs`
1. Run tests with `rspec`
# Optional
Add icons
1. Download icons from http://www.famfamfam.com/lab/icons/silk/
1. Link to the icons under `public/images/icons`: (From app root) `ln -s /MY/PATH/famfamfam_silk_icons/icons public/images/icons`

21
docker-compose.yml Normal file
View File

@ -0,0 +1,21 @@
# BikeShed
#
# cp config/database.yml.example config/database.yml
#
# docker-compose -f docker-compose.demo.yml build
# docker-compose -f docker-compose.demo.yml up -d db
# docker-compose -f docker-compose.demo.yml run bikeshed rake db:setup
# docker-compose -f docker-compose.demo.yml up -d bikeshed
db:
image: postgres
ports:
- "5432"
web:
volumes:
- .:/usr/src/app
build: .
ports:
- "8080:3000"
links:
- db

BIN
extjs-4.1.1.zip Normal file

Binary file not shown.

20
install_extjs.rb Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env ruby
require 'fileutils'
extjs_url = "http://my.jasondenney.com/extjs-4.1.1.zip"
download_dir = '/tmp'
dest_dir ='/usr/lib'
extjs_download_path = File.join(download_dir,'extjs-4.1.1.zip')
files = Dir.glob(File.join(dest_dir, 'extjs', '*'))
if files.empty? and Dir.glob(extjs_download_path).empty?
`wget -P #{download_dir} #{extjs_url}`
raise "Failed downloading #{extjs_url}" if Dir.glob(extjs_download_path).empty?
end
if files.empty?
puts `unzip #{extjs_download_path} -d #{dest_dir}/`
FileUtils.mv(File.join(dest_dir, 'ext-4.1.1a'), File.join(dest_dir, 'extjs'))
end
raise "Failed unzipping #{extjs_download_path}" if Dir.glob(File.join(dest_dir,'extjs', '*')).empty?

Some files were not shown because too many files have changed in this diff Show More