mirror of
https://github.com/fspc/BikeShed-1.git
synced 2026-09-17 00:41:38 -04:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01d1dcdcf1 |
@@ -8,4 +8,3 @@ tmp/
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
public/extjs
|
public/extjs
|
||||||
public/images/icons
|
public/images/icons
|
||||||
config/database.yml
|
|
||||||
|
|||||||
@@ -14,12 +14,13 @@ gem 'decent_exposure', '~> 1.0.1'
|
|||||||
gem 'devise', '~> 2.0.4'
|
gem 'devise', '~> 2.0.4'
|
||||||
gem 'haml-rails', '~> 0.3.4'
|
gem 'haml-rails', '~> 0.3.4'
|
||||||
gem 'jquery-rails', '~> 2.0'
|
gem 'jquery-rails', '~> 2.0'
|
||||||
gem 'pg'
|
gem 'sqlite3', '~> 1.3.5'
|
||||||
gem 'will_paginate', '~> 3.0.3'
|
gem 'will_paginate', '~> 3.0.3'
|
||||||
|
|
||||||
# Gems used only for assets and not required
|
# Gems used only for assets and not required
|
||||||
# in production environments by default.
|
# in production environments by default.
|
||||||
group :assets do
|
group :assets do
|
||||||
|
gem 'sass-rails', '~> 3.2.3'
|
||||||
gem 'coffee-rails', '~> 3.2.1'
|
gem 'coffee-rails', '~> 3.2.1'
|
||||||
gem "twitter-bootstrap-rails", "~> 2.0.3"
|
gem "twitter-bootstrap-rails", "~> 2.0.3"
|
||||||
|
|
||||||
|
|||||||
+9
-5
@@ -1,6 +1,6 @@
|
|||||||
GIT
|
GIT
|
||||||
remote: https://github.com/spacemunkay/acts_as_loggable.git
|
remote: https://github.com/spacemunkay/acts_as_loggable.git
|
||||||
revision: 49e264849ed9018445fb999cacfc55e1e28d7faa
|
revision: 6033fe5a44878bb374f73fe473fed9a3396ddc74
|
||||||
specs:
|
specs:
|
||||||
acts_as_loggable (0.0.7)
|
acts_as_loggable (0.0.7)
|
||||||
activerecord (>= 3.0)
|
activerecord (>= 3.0)
|
||||||
@@ -133,7 +133,6 @@ GEM
|
|||||||
uglifier
|
uglifier
|
||||||
nokogiri (1.5.9)
|
nokogiri (1.5.9)
|
||||||
orm_adapter (0.0.7)
|
orm_adapter (0.0.7)
|
||||||
pg (0.15.1)
|
|
||||||
polyglot (0.3.3)
|
polyglot (0.3.3)
|
||||||
pry (0.9.12)
|
pry (0.9.12)
|
||||||
coderay (~> 1.0.5)
|
coderay (~> 1.0.5)
|
||||||
@@ -162,7 +161,6 @@ GEM
|
|||||||
rdoc (~> 3.4)
|
rdoc (~> 3.4)
|
||||||
thor (>= 0.14.6, < 2.0)
|
thor (>= 0.14.6, < 2.0)
|
||||||
rake (10.0.4)
|
rake (10.0.4)
|
||||||
rb-fsevent (0.9.3)
|
|
||||||
rdoc (3.12.2)
|
rdoc (3.12.2)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
rspec (2.8.0)
|
rspec (2.8.0)
|
||||||
@@ -179,6 +177,11 @@ GEM
|
|||||||
railties (>= 3.0)
|
railties (>= 3.0)
|
||||||
rspec (~> 2.8.0)
|
rspec (~> 2.8.0)
|
||||||
rubyzip (0.9.9)
|
rubyzip (0.9.9)
|
||||||
|
sass (3.2.7)
|
||||||
|
sass-rails (3.2.6)
|
||||||
|
railties (~> 3.2.0)
|
||||||
|
sass (>= 3.1.10)
|
||||||
|
tilt (~> 1.3)
|
||||||
selenium-webdriver (2.31.0)
|
selenium-webdriver (2.31.0)
|
||||||
childprocess (>= 0.2.5)
|
childprocess (>= 0.2.5)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
@@ -192,6 +195,7 @@ GEM
|
|||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
rack (~> 1.0)
|
rack (~> 1.0)
|
||||||
tilt (~> 1.1, != 1.3.0)
|
tilt (~> 1.1, != 1.3.0)
|
||||||
|
sqlite3 (1.3.7)
|
||||||
therubyracer (0.10.2)
|
therubyracer (0.10.2)
|
||||||
libv8 (~> 3.3.10)
|
libv8 (~> 3.3.10)
|
||||||
thor (0.18.1)
|
thor (0.18.1)
|
||||||
@@ -239,13 +243,13 @@ DEPENDENCIES
|
|||||||
netzke-basepack (~> 0.8.0)
|
netzke-basepack (~> 0.8.0)
|
||||||
netzke-cancan
|
netzke-cancan
|
||||||
netzke-core (~> 0.8.0)
|
netzke-core (~> 0.8.0)
|
||||||
pg
|
|
||||||
pry (~> 0.9.8)
|
pry (~> 0.9.8)
|
||||||
rails (= 3.2.13)
|
rails (= 3.2.13)
|
||||||
rb-fsevent
|
|
||||||
rspec-rails (~> 2.8.1)
|
rspec-rails (~> 2.8.1)
|
||||||
|
sass-rails (~> 3.2.3)
|
||||||
shoulda-matchers (~> 1.0.0)
|
shoulda-matchers (~> 1.0.0)
|
||||||
spork
|
spork
|
||||||
|
sqlite3 (~> 1.3.5)
|
||||||
turnip (~> 0.3.0)
|
turnip (~> 0.3.0)
|
||||||
twitter-bootstrap-rails (~> 2.0.3)
|
twitter-bootstrap-rails (~> 2.0.3)
|
||||||
uglifier (>= 1.0.3)
|
uglifier (>= 1.0.3)
|
||||||
|
|||||||
@@ -4,36 +4,19 @@
|
|||||||
1. allow the .rvmrc file
|
1. allow the .rvmrc file
|
||||||
1. `gem install bundler`
|
1. `gem install bundler`
|
||||||
1. `bundle`
|
1. `bundle`
|
||||||
1. Install Postgres (Mac OSX instructions below)
|
1. `rake db:create db:migrate db:seed`
|
||||||
1. `rake db:create db:migrate`
|
1. Download extJS (http://www.sencha.com/products/extjs), unzip, and place where ever you like.
|
||||||
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. Link to your extJS folder path under `public/extjs`: (From app root) `ln -s /MY/PATH/extjs/ public/extjs`
|
||||||
1. `rails s`
|
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. Copy over DB config: `cp config/database.yml.example config/database.yml`
|
|
||||||
1. Update config with your database (velocipede), user (velocipede), and password.
|
|
||||||
|
|
||||||
# Optional
|
# Optional
|
||||||
Add icons
|
Add icons
|
||||||
|
|
||||||
1. Download icons from http://www.famfamfam.com/lab/icons/silk/
|
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`
|
1. Link to the icons under `public/images/icons`: (From app root) `ln -s /MY/PATH/famfamfam_silk_icons/icons public/images/icons`
|
||||||
|
|
||||||
|
|
||||||
## Mailcatcher
|
## Mailcatcher
|
||||||
|
|
||||||
Use mailcatcher to see what emails look like in development.
|
Use mailcatcher to see what emails look like in development.
|
||||||
Follow the instructions from http://mailcatcher.me/ to create an rvm wrapper so you don't install it all over your gemsets
|
Follow the instructions from http://mailcatcher.me/ to create an rvm wrapper so you don't install it all over your gemsets
|
||||||
|
|
||||||
# License
|
|
||||||
Velocipede is released under the MIT license (http://opensource.org/licenses/MIT)
|
|
||||||
|
|
||||||
<a href="http://madewithloveinbaltimore.org">Made with ♥ in Baltimore</a>
|
|
||||||
|
|||||||
@@ -12,20 +12,16 @@ require File.expand_path('../config/application', __FILE__)
|
|||||||
|
|
||||||
Velocipede::Application.load_tasks
|
Velocipede::Application.load_tasks
|
||||||
|
|
||||||
unless Rails.env.production?
|
namespace :spec do
|
||||||
|
desc 'Run all acceptance specs'
|
||||||
namespace :spec do
|
RSpec::Core::RakeTask.new(:acceptance => 'db:test:prepare') do |t|
|
||||||
desc 'Run all acceptance specs'
|
t.pattern = '**/*.feature'
|
||||||
RSpec::Core::RakeTask.new(:acceptance => 'db:test:prepare') do |t|
|
|
||||||
t.pattern = '**/*.feature'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Rake.application.remove_task 'spec'
|
Rake.application.remove_task 'spec'
|
||||||
|
|
||||||
desc 'Run all specs'
|
desc 'Run all specs'
|
||||||
RSpec::Core::RakeTask.new(:spec => 'db:test:prepare') do |t|
|
RSpec::Core::RakeTask.new(:spec => 'db:test:prepare') do |t|
|
||||||
t.pattern = '**/*{_spec.rb,.feature}'
|
t.pattern = '**/*{_spec.rb,.feature}'
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,4 +12,5 @@
|
|||||||
//
|
//
|
||||||
//= require jquery
|
//= require jquery
|
||||||
//= require jquery_ujs
|
//= require jquery_ujs
|
||||||
//= require custom_netzke_helpers
|
//= require twitter/bootstrap
|
||||||
|
//= require_tree .
|
||||||
|
|||||||
@@ -3,148 +3,3 @@ Ext.Ajax.on('requestexception', function(conn, response, options) {
|
|||||||
if (response.status === 401) { window.location = '/users/sign_in'; }
|
if (response.status === 401) { window.location = '/users/sign_in'; }
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
Ext.define('Ext.ux.form.field.ColorCombo', {
|
|
||||||
extend:'Ext.form.FieldContainer',
|
|
||||||
mixins:{
|
|
||||||
field:'Ext.form.field.Field'
|
|
||||||
},
|
|
||||||
alias: 'widget.xcolorcombo',
|
|
||||||
|
|
||||||
//configurables
|
|
||||||
combineErrors: true,
|
|
||||||
msgTarget: 'under',
|
|
||||||
layout: 'hbox',
|
|
||||||
readOnly: false,
|
|
||||||
|
|
||||||
// properties
|
|
||||||
colorValue: null,
|
|
||||||
/**
|
|
||||||
* @property dateField
|
|
||||||
* @type Ext.form.field.Date
|
|
||||||
*/
|
|
||||||
colorField: null,
|
|
||||||
|
|
||||||
initComponent: function(){
|
|
||||||
var me = this
|
|
||||||
,i = 0
|
|
||||||
,key
|
|
||||||
,tab;
|
|
||||||
|
|
||||||
me.items = me.items || [];
|
|
||||||
|
|
||||||
me.colorField = Ext.create('Ext.form.field.Trigger', {
|
|
||||||
flex:1,
|
|
||||||
isFormField:false, //exclude from field query's
|
|
||||||
submitValue:false,
|
|
||||||
readOnly: me.readOnly,
|
|
||||||
onTriggerClick: function() {
|
|
||||||
//show renders, so put first
|
|
||||||
me.picker.show();
|
|
||||||
me.picker.alignTo(me.colorField.inputEl);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
me.items.push(me.colorField);
|
|
||||||
|
|
||||||
me.picker = Ext.create('Ext.picker.Color', {
|
|
||||||
renderTo: document.body,
|
|
||||||
floating: true,
|
|
||||||
hidden: true,
|
|
||||||
style: {
|
|
||||||
backgroundColor: "#fff"
|
|
||||||
},
|
|
||||||
listeners: {
|
|
||||||
scope:this,
|
|
||||||
select: function(field, value, opts){
|
|
||||||
me.setValue(value);
|
|
||||||
me.picker.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
me.items.push(me.picker);
|
|
||||||
|
|
||||||
for (; i < me.items.length; i++) {
|
|
||||||
me.items[i].on('focus', Ext.bind(me.onItemFocus, me));
|
|
||||||
me.items[i].on('blur', Ext.bind(me.onItemBlur, me));
|
|
||||||
me.items[i].on('specialkey', function(field, event){
|
|
||||||
key = event.getKey();
|
|
||||||
tab = key == event.TAB;
|
|
||||||
|
|
||||||
if (tab && me.focussedItem == me.dateField) {
|
|
||||||
event.stopEvent();
|
|
||||||
me.timeField.focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
me.fireEvent('specialkey', field, event);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
me.callParent();
|
|
||||||
|
|
||||||
// this dummy is necessary because Ext.Editor will not check whether an inputEl is present or not
|
|
||||||
this.inputEl = {
|
|
||||||
dom: document.createElement('div'),
|
|
||||||
swallowEvent:function(){}
|
|
||||||
};
|
|
||||||
|
|
||||||
me.initField();
|
|
||||||
},
|
|
||||||
focus:function(){
|
|
||||||
this.callParent(arguments);
|
|
||||||
this.colorField.focus();
|
|
||||||
var me = this;
|
|
||||||
},
|
|
||||||
|
|
||||||
onItemFocus:function(item){
|
|
||||||
if (this.blurTask){
|
|
||||||
this.blurTask.cancel();
|
|
||||||
}
|
|
||||||
this.focussedItem = item;
|
|
||||||
},
|
|
||||||
|
|
||||||
onItemBlur:function(item, e){
|
|
||||||
var me = this;
|
|
||||||
if (item != me.focussedItem){ return; }
|
|
||||||
// 100ms to focus a new item that belongs to us, otherwise we will assume the user left the field
|
|
||||||
me.blurTask = new Ext.util.DelayedTask(function(){
|
|
||||||
me.picker.hide();
|
|
||||||
me.fireEvent('blur', me, e);
|
|
||||||
});
|
|
||||||
me.blurTask.delay(100);
|
|
||||||
},
|
|
||||||
|
|
||||||
getValue: function(){
|
|
||||||
var value = null
|
|
||||||
,color = this.colorField.getSubmitValue();
|
|
||||||
|
|
||||||
if (color){
|
|
||||||
value = this.colorField.getValue();
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
},
|
|
||||||
|
|
||||||
getSubmitValue: function(){
|
|
||||||
// var value = this.getValue();
|
|
||||||
// return value ? Ext.Date.format(value, this.dateTimeFormat) : null;
|
|
||||||
|
|
||||||
var me = this
|
|
||||||
,value = me.getValue();
|
|
||||||
|
|
||||||
return value;
|
|
||||||
},
|
|
||||||
|
|
||||||
setValue: function(value){
|
|
||||||
this.colorField.setValue(value);
|
|
||||||
},
|
|
||||||
// Bug? A field-mixin submits the data from getValue, not getSubmitValue
|
|
||||||
getSubmitData: function(){
|
|
||||||
var me = this
|
|
||||||
,data = null;
|
|
||||||
|
|
||||||
if (!me.disabled && me.submitValue && !me.isFileUpload()) {
|
|
||||||
data = {};
|
|
||||||
data[me.getName()] = '' + me.getSubmitValue();
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
$(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.");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
$(document).ready(function(){
|
|
||||||
$("#checkin_menu").show();
|
|
||||||
$("#checkin").click( function(e){
|
|
||||||
var username = $("#user_email").val();
|
|
||||||
var password = $("#user_password").val();
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: '/api/v1/checkin',
|
|
||||||
dataType: 'json',
|
|
||||||
contentType: 'application/json',
|
|
||||||
processData: false,
|
|
||||||
data: JSON.stringify({"username": username, "password": password }),
|
|
||||||
complete: function() { },
|
|
||||||
success: function(data) {
|
|
||||||
alert("Checked IN!");
|
|
||||||
$("#user_email").val('');
|
|
||||||
$("#user_password").val('');
|
|
||||||
},
|
|
||||||
error: function(data,textStatus) {
|
|
||||||
alert( "Error: " + JSON.parse(data.responseText)["error"]);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
$("#checkout").click( function(e){
|
|
||||||
var username = $("#user_email").val();
|
|
||||||
var password = $("#user_password").val();
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: '/api/v1/checkout',
|
|
||||||
dataType: 'json',
|
|
||||||
contentType: 'application/json',
|
|
||||||
processData: false,
|
|
||||||
data: JSON.stringify({"username": username, "password": password }),
|
|
||||||
complete: function() { },
|
|
||||||
success: function(data) {
|
|
||||||
alert("Checked OUT!");
|
|
||||||
$("#user_email").val('');
|
|
||||||
$("#user_password").val('');
|
|
||||||
},
|
|
||||||
error: function(data,textStatus) {
|
|
||||||
alert( "Error: " + JSON.parse(data.responseText)["error"]);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,18 +1,9 @@
|
|||||||
class AppTabPanel < Netzke::Basepack::TabPanel
|
class AppTabPanel < Netzke::Basepack::TabPanel
|
||||||
|
|
||||||
|
|
||||||
action :sign_out do |c|
|
action :sign_out do |c|
|
||||||
c.icon = :door_out
|
c.icon = :door_out
|
||||||
c.text = "Exit"
|
c.text = "Sign out #{controller.current_user.email}" if controller.current_user
|
||||||
end
|
|
||||||
|
|
||||||
action :check_out do |c|
|
|
||||||
c.icon = :door_out
|
|
||||||
c.text = "CHECK OUT" if controller.current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
action :change_account_info do |c|
|
|
||||||
c.icon = :user_edit
|
|
||||||
c.text = "Change Email/Password"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure(c)
|
def configure(c)
|
||||||
@@ -25,36 +16,30 @@ class AppTabPanel < Netzke::Basepack::TabPanel
|
|||||||
title: "Brands/Models"}
|
title: "Brands/Models"}
|
||||||
]
|
]
|
||||||
|
|
||||||
#for users only
|
#for users
|
||||||
if not controller.current_user.role?(:admin)
|
if controller.current_user.role?(:user)
|
||||||
|
# (had to use hash for borders to get the title to display properly)
|
||||||
@@app_tab_panel_items.concat [{ layout: :fit,
|
@@app_tab_panel_items.concat [{ layout: :fit,
|
||||||
wrappedComponent: :user_profile_border,
|
wrappedComponent: :user_profile_border,
|
||||||
title: "My Profile"},
|
title: "Profile"},
|
||||||
{ layout: :fit,
|
{ layout: :fit,
|
||||||
wrappedComponent: :user_transactions_border,
|
wrappedComponent: :user_transactions_border,
|
||||||
title: "My Transactions"}
|
title: "Transactions"}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
#for admins
|
#for admins
|
||||||
if can? :manage, User
|
if controller.current_user.role?(:admin)
|
||||||
|
# (had to use hash for borders to get the title to display properly)
|
||||||
@@app_tab_panel_items.concat [{ layout: :fit,
|
@@app_tab_panel_items.concat [{ layout: :fit,
|
||||||
wrappedComponent: :users_and_profiles_border,
|
wrappedComponent: :users_and_profiles_border,
|
||||||
title: "Users/Profiles"}]
|
title: "Users/Profiles"},
|
||||||
end
|
{ layout: :fit,
|
||||||
if can? :manage, Transaction
|
|
||||||
@@app_tab_panel_items.concat [{ layout: :fit,
|
|
||||||
wrappedComponent: :transactions_border,
|
wrappedComponent: :transactions_border,
|
||||||
title: "Users/Transactions"}]
|
title: "Transactions"},
|
||||||
end
|
:logs,
|
||||||
if can? :manage, Role
|
:user_roles]
|
||||||
@@app_tab_panel_items.concat [{ layout: :fit,
|
|
||||||
wrappedComponent: :user_role_joins,
|
|
||||||
title: "User Roles"},
|
|
||||||
]
|
|
||||||
end
|
|
||||||
if can? :manage, ::ActsAsLoggable::Log.all
|
|
||||||
@@app_tab_panel_items.concat [:check_ins, :logs]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@app_tab_panel_items.each do |item|
|
@@app_tab_panel_items.each do |item|
|
||||||
if item.kind_of?(Symbol)
|
if item.kind_of?(Symbol)
|
||||||
self.class.component item
|
self.class.component item
|
||||||
@@ -62,8 +47,9 @@ class AppTabPanel < Netzke::Basepack::TabPanel
|
|||||||
self.class.component item[:wrappedComponent]
|
self.class.component item[:wrappedComponent]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
c.prevent_header = true
|
c.prevent_header = true
|
||||||
c.tbar = [:sign_out, :check_out, :change_account_info]
|
c.tbar = [:sign_out]
|
||||||
c.items = @@app_tab_panel_items
|
c.items = @@app_tab_panel_items
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@@ -72,5 +58,6 @@ class AppTabPanel < Netzke::Basepack::TabPanel
|
|||||||
#gets js from app_tab_panel/javascripts/sign_out.js
|
#gets js from app_tab_panel/javascripts/sign_out.js
|
||||||
c.mixin :sign_out
|
c.mixin :sign_out
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,20 +5,5 @@
|
|||||||
url: '/users/sign_out',
|
url: '/users/sign_out',
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
});
|
});
|
||||||
},
|
|
||||||
onCheckOut: function(){
|
|
||||||
Ext.Ajax.request({
|
|
||||||
url: '/api/v1/checkout',
|
|
||||||
method: 'POST',
|
|
||||||
success: function(response, opts) {
|
|
||||||
Ext.Ajax.request({
|
|
||||||
url: '/users/sign_out',
|
|
||||||
method: 'DELETE'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onChangeAccountInfo: function(){
|
|
||||||
window.location.href="users/edit";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-10
@@ -30,21 +30,38 @@ class BikeLogs < Netzke::Basepack::Grid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@bike_logs = ::ActsAsLoggable::Log.where(:loggable_type => "Bike").all
|
|
||||||
c.prohibit_update = true if cannot? :update, @bike_logs
|
|
||||||
c.prohibit_create = true if cannot? :create, @bike_logs
|
|
||||||
c.prohibit_delete = true if cannot? :delete, @bike_logs
|
|
||||||
=begin
|
=begin
|
||||||
#TODO: fix GUI so it actually respects this
|
#TODO: fix GUI so it actually respects this
|
||||||
current_bike = Bike.find_by_id(session[:selected_bike_id])
|
current_bike = Bike.find_by_id(session[:selected_bike_id])
|
||||||
if cannot? :update, current_bike
|
if can? :manage, current_bike
|
||||||
|
puts "\n\n\nCAN MANAGE!\n\n\n"
|
||||||
|
c.bbar = default_bbar
|
||||||
|
else
|
||||||
|
puts "\n\n\nCANNNOT MANAGE!\n\n\n"
|
||||||
# if you can't update the bike, you can't do anything to the log
|
# if you can't update the bike, you can't do anything to the log
|
||||||
c.prohibit_update = c.prohibit_create = c.prohibit_delete = true
|
#c.prohibit_update = c.prohibit_create = c.prohibit_delete = true
|
||||||
|
c.bbar = [ :search ]
|
||||||
end
|
end
|
||||||
=end
|
=end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
endpoint :set_read_only do |params, this|
|
||||||
|
current_bike = Bike.find_by_id(session[:selected_bike_id])
|
||||||
|
puts "\n\n\nREAD!\n\n\n"
|
||||||
|
if can? :manage, current_bike
|
||||||
|
puts "\n\n\nCAN MANAGE!\n\n\n"
|
||||||
|
#calls this.setDisabled()
|
||||||
|
this.set_disabled(false)
|
||||||
|
#sets the return value of this function
|
||||||
|
#this.netzke_set_result(true)
|
||||||
|
else
|
||||||
|
puts "\n\n\nCANNNOT MANAGE!\n\n\n"
|
||||||
|
#sets the return value of this function
|
||||||
|
#this.netzke_set_result(true)
|
||||||
|
this.set_disabled(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def default_fields_for_forms
|
def default_fields_for_forms
|
||||||
[
|
[
|
||||||
{ :name => :start_date},
|
{ :name => :start_date},
|
||||||
@@ -59,9 +76,8 @@ class BikeLogs < Netzke::Basepack::Grid
|
|||||||
#override with nil to remove actions
|
#override with nil to remove actions
|
||||||
def default_bbar
|
def default_bbar
|
||||||
bbar = [ :search ]
|
bbar = [ :search ]
|
||||||
bbar.concat [ :apply ] if can? :update, ::ActsAsLoggable::Log
|
bbar.concat [ :apply ] #if can? :update, ::ActsAsLoggable::Log
|
||||||
bbar.concat [ :add_in_form ] if can? :create, ::ActsAsLoggable::Log
|
bbar.concat [ :add_in_form ] #if can? :create, ::ActsAsLoggable::Log
|
||||||
bbar
|
bbar
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
+6
-26
@@ -2,6 +2,7 @@ class Bikes < Netzke::Basepack::Grid
|
|||||||
def configure(c)
|
def configure(c)
|
||||||
super
|
super
|
||||||
c.model = "Bike"
|
c.model = "Bike"
|
||||||
|
|
||||||
c.columns = [
|
c.columns = [
|
||||||
{ :name => :shop_id, :text => 'Shop ID'},
|
{ :name => :shop_id, :text => 'Shop ID'},
|
||||||
:serial_number,
|
:serial_number,
|
||||||
@@ -15,12 +16,11 @@ class Bikes < Netzke::Basepack::Grid
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
#needs to have type :action or else won't work in grid, because... netzke
|
:color,
|
||||||
{ :name => "color", :text => "Frame Color", :type => :action, :editor => { :xtype => "xcolorcombo"}, :renderer => :color_block},
|
|
||||||
{ :name => :bike_style__style, :text => 'Style' },
|
{ :name => :bike_style__style, :text => 'Style' },
|
||||||
{ :name => :seat_tube_height, :text => 'Seat Tube (in)'},
|
:seat_tube_height,
|
||||||
{ :name => :top_tube_length, :text => 'Top Tube (in)'},
|
:top_tube_length,
|
||||||
{ :name => :wheel_size, :text => 'Wheel Size (in)'},
|
:wheel_size,
|
||||||
:value,
|
:value,
|
||||||
{ :name => :bike_condition__condition, :text => 'Condition'},
|
{ :name => :bike_condition__condition, :text => 'Condition'},
|
||||||
{ :name => :bike_status__status, :text => 'Status'},
|
{ :name => :bike_status__status, :text => 'Status'},
|
||||||
@@ -30,28 +30,8 @@ class Bikes < Netzke::Basepack::Grid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@bike = Bike.all
|
|
||||||
c.prohibit_update = true if cannot? :update, @bike
|
|
||||||
c.prohibit_create = true if cannot? :create, @bike
|
|
||||||
c.prohibit_delete = true if cannot? :delete, @bike
|
|
||||||
end
|
|
||||||
def default_fields_for_forms
|
|
||||||
# :field_label MUST be defined in order for search to work
|
|
||||||
[
|
|
||||||
{ :name => :shop_id, :field_label => 'Shop ID'},
|
|
||||||
{ :name => :serial_number, :field_label => 'Serial Number'},
|
|
||||||
{ :name => :bike_brand__brand, :field_label => 'Brand' },
|
|
||||||
{ :name => :bike_model__model, :field_label => 'Model'},
|
|
||||||
{ :name => "color", :xtype => "xcolorcombo"},
|
|
||||||
{ :name => :bike_style__style, :field_label => 'Style' },
|
|
||||||
{ :name => :seat_tube_height, :field_label => 'Seat Tube (in)'},
|
|
||||||
{ :name => :top_tube_length, :field_label => 'Top Tube (in)'},
|
|
||||||
{ :name => :wheel_size, :field_label => 'Wheel Size (in)'},
|
|
||||||
{ :name => :value, :field_label => 'Value'},
|
|
||||||
{ :name => :bike_condition__condition, :field_label => 'Condition'},
|
|
||||||
{ :name => :bike_status__status, :field_label => 'Status'}
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#override with nil to remove actions
|
#override with nil to remove actions
|
||||||
def default_bbar
|
def default_bbar
|
||||||
[ :apply, :add_in_form, :search ]
|
[ :apply, :add_in_form, :search ]
|
||||||
|
|||||||
@@ -9,8 +9,5 @@
|
|||||||
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
||||||
this.selectBikeBrand({bike_brand_id: record.get('bike_brand__brand')});
|
this.selectBikeBrand({bike_brand_id: record.get('bike_brand__brand')});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
|
||||||
colorBlock: function(value){
|
|
||||||
return Ext.String.format('<div style="display:inline-block">{1}</div><div style="background-color:#{0};width:50px;height:10px;display:inline-block;margin:0 5px 0 5px;border:solid;border-color:gray;border-width:1px;"></div>', value, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,11 @@
|
|||||||
this.selectBike({bike_id: record.get('id')});
|
this.selectBike({bike_id: record.get('id')});
|
||||||
if( this.queryById('bike_logs') ){
|
if( this.queryById('bike_logs') ){
|
||||||
this.queryById('bike_logs').getStore().load();
|
this.queryById('bike_logs').getStore().load();
|
||||||
|
this.queryById('bike_logs').setReadOnly({}, function(arg, arg1, arg2){
|
||||||
|
console.log(arg);
|
||||||
|
console.log(this.getDockedItems());
|
||||||
|
});
|
||||||
|
this.queryById('bike_logs').setDisabled(true);
|
||||||
}
|
}
|
||||||
if( this.queryById('tasks') ){
|
if( this.queryById('tasks') ){
|
||||||
this.queryById('tasks').getStore().load();
|
this.queryById('tasks').getStore().load();
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
class CheckIns < Netzke::Basepack::Grid
|
|
||||||
|
|
||||||
def configure(c)
|
|
||||||
super
|
|
||||||
c.header = false
|
|
||||||
c.model = "ActsAsLoggable::Log"
|
|
||||||
c.scope = lambda { |rel| rel.where(:log_action_type => ::ActsAsLoggable::UserAction).
|
|
||||||
where(:loggable_type => "User").
|
|
||||||
where(:log_action_id => ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")).
|
|
||||||
where("start_date >= ?", Time.zone.now.beginning_of_day);
|
|
||||||
}
|
|
||||||
c.columns = [
|
|
||||||
{ :name => :name, :getter => lambda{ |rec|
|
|
||||||
user = User.find_by_id(rec.loggable_id)
|
|
||||||
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ :name => "Status", :getter => lambda{ |rec| rec.start_date == rec.end_date ? "Checked In" : "Checked Out" } },
|
|
||||||
:start_date,
|
|
||||||
:end_date,
|
|
||||||
]
|
|
||||||
c.prohibit_update = true
|
|
||||||
c.prohibit_create = true
|
|
||||||
c.prohibit_delete = true
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_bbar
|
|
||||||
[ :search ]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -22,25 +22,4 @@ class Logs < Netzke::Basepack::Grid
|
|||||||
{ :name => :hours, :getter => lambda { |rec| (rec.end_date - rec.start_date)/3600 }, :sorting_scope => :sort_by_duration}
|
{ :name => :hours, :getter => lambda { |rec| (rec.end_date - rec.start_date)/3600 }, :sorting_scope => :sort_by_duration}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_fields_for_forms
|
|
||||||
[
|
|
||||||
:loggable_id,
|
|
||||||
:loggable_type,
|
|
||||||
:logger_id,
|
|
||||||
:logger_type,
|
|
||||||
:context,
|
|
||||||
:start_date,
|
|
||||||
:end_date,
|
|
||||||
:description,
|
|
||||||
:log_action_id,
|
|
||||||
:log_action_type,
|
|
||||||
:created_at,
|
|
||||||
:updated_at
|
|
||||||
].map{ |x| { :name => x, :field_label => x.to_s.humanize} }
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_bbar
|
|
||||||
[ :apply, :add_in_form, :search ]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,21 +29,22 @@ class TransactionLogs < Netzke::Basepack::Grid
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@transaction_logs = ::ActsAsLoggable::Log.where(:loggable_type => "Transaction").all
|
c.prohibit_update = true if cannot? :update, ::ActsAsLoggable::Log
|
||||||
c.prohibit_update = true if cannot? :update, @transaction_logs
|
c.prohibit_create = true if cannot? :create, ::ActsAsLoggable::Log
|
||||||
c.prohibit_create = true if cannot? :create, @transaction_logs
|
c.prohibit_delete = true if cannot? :delete, ::ActsAsLoggable::Log
|
||||||
c.prohibit_delete = true if cannot? :delete, @transaction_logs
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_fields_for_forms
|
def default_fields_for_forms
|
||||||
customer = "No Customer Selected"
|
customer = nil
|
||||||
item = "No Item Selected"
|
item = nil
|
||||||
trans = Transaction.find_by_id(session[:selected_transaction_id])
|
if session[:selected_transaction_id]
|
||||||
if trans
|
trans = Transaction.find_by_id(session[:selected_transaction_id])
|
||||||
customer = trans.customer
|
customer = trans.customer
|
||||||
item = trans.item
|
item = trans.item
|
||||||
end
|
end
|
||||||
|
customer = "No Customer Selected" if customer.nil?
|
||||||
|
item = "No Item Selected" if item.nil?
|
||||||
[
|
[
|
||||||
{ :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Payment from:", :value => "#{customer.to_s}"},
|
{ :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Payment from:", :value => "#{customer.to_s}"},
|
||||||
{ :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Payment for:", :value => "#{item.to_s}"},
|
{ :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Payment for:", :value => "#{item.to_s}"},
|
||||||
@@ -57,8 +58,8 @@ class TransactionLogs < Netzke::Basepack::Grid
|
|||||||
#override with nil to remove actions
|
#override with nil to remove actions
|
||||||
def default_bbar
|
def default_bbar
|
||||||
bbar = [ :search ]
|
bbar = [ :search ]
|
||||||
bbar.concat [ :apply ] if can? :update, @transaction_logs
|
bbar.concat [ :apply ] if can? :update, ::ActsAsLoggable::Log
|
||||||
bbar.concat [:add_in_form ] if can? :create, @transaction_logs
|
bbar.concat [:add_in_form ] if can? :create, ::ActsAsLoggable::Log
|
||||||
bbar
|
bbar
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,16 +14,10 @@ class UserLogs < Netzke::Basepack::Grid
|
|||||||
:copy_action_id => 4
|
:copy_action_id => 4
|
||||||
}
|
}
|
||||||
|
|
||||||
#this seems inefficient
|
if can? :manage, ::ActsAsLoggable::Log
|
||||||
if can? :manage, ::ActsAsLoggable::Log.where(:loggable_type => "User").all
|
|
||||||
#admins and staff
|
#admins and staff
|
||||||
|
user_log_scope = lambda { |rel| rel.where(:loggable_type => 'User',:loggable_id => session[:selected_user_id]);}
|
||||||
#if selected user nil, then the admin is viewing their own profile
|
user_log_strong_default_attrs.merge!( { :loggable_id => session[:selected_user_id] } )
|
||||||
selected_user = User.find_by_id(session[:selected_user_id])
|
|
||||||
selected_user = controller.current_user if selected_user.nil?
|
|
||||||
|
|
||||||
user_log_scope = lambda { |rel| rel.where(:loggable_type => 'User',:loggable_id => selected_user.id );}
|
|
||||||
user_log_strong_default_attrs.merge!( { :loggable_id => selected_user.id } )
|
|
||||||
user_log_data_store = {auto_load: true }
|
user_log_data_store = {auto_load: true }
|
||||||
else
|
else
|
||||||
#just users
|
#just users
|
||||||
@@ -33,7 +27,7 @@ class UserLogs < Netzke::Basepack::Grid
|
|||||||
end
|
end
|
||||||
|
|
||||||
c.model = "ActsAsLoggable::Log"
|
c.model = "ActsAsLoggable::Log"
|
||||||
c.title = "User Timesheet"
|
c.title = "User History"
|
||||||
c.data_store = user_log_data_store
|
c.data_store = user_log_data_store
|
||||||
c.scope = user_log_scope
|
c.scope = user_log_scope
|
||||||
c.strong_default_attrs = user_log_strong_default_attrs
|
c.strong_default_attrs = user_log_strong_default_attrs
|
||||||
@@ -43,7 +37,7 @@ class UserLogs < Netzke::Basepack::Grid
|
|||||||
{ :name => :end_date, :hidden => true, :default_value => Time.now.to_formatted_s(:db) },
|
{ :name => :end_date, :hidden => true, :default_value => Time.now.to_formatted_s(:db) },
|
||||||
{ :name => :hours, :getter => lambda { |rec| (rec.end_date - rec.start_date)/3600 }, :sorting_scope => :sort_by_duration},
|
{ :name => :hours, :getter => lambda { |rec| (rec.end_date - rec.start_date)/3600 }, :sorting_scope => :sort_by_duration},
|
||||||
:description,
|
:description,
|
||||||
{ :name => :user_action__action, :text => 'Action', :default_value => ::ActsAsLoggable::UserAction.all.first.id },
|
{ :name => :user_action__action, :text => 'Action' },
|
||||||
:created_at,
|
:created_at,
|
||||||
:updated_at,
|
:updated_at,
|
||||||
{ :name => :logged_by, :getter => lambda{ |rec|
|
{ :name => :logged_by, :getter => lambda{ |rec|
|
||||||
@@ -59,13 +53,13 @@ class UserLogs < Netzke::Basepack::Grid
|
|||||||
bike_store = Bike.all.map { |b| [b.id, b.shop_id] }
|
bike_store = Bike.all.map { |b| [b.id, b.shop_id] }
|
||||||
current_user ||= User.find_by_id(session[:selected_user_id]) || controller.current_user
|
current_user ||= User.find_by_id(session[:selected_user_id]) || controller.current_user
|
||||||
bike_id = current_user.bike.nil? ? nil : current_user.bike.id
|
bike_id = current_user.bike.nil? ? nil : current_user.bike.id
|
||||||
|
action_id = current_user.user_role.id
|
||||||
[
|
[
|
||||||
{ :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Log for:", :value => "#{current_user.to_s}"},
|
|
||||||
{ :name => :start_date},
|
{ :name => :start_date},
|
||||||
{ :name => :end_date},
|
{ :name => :end_date},
|
||||||
{ :name => :description},
|
{ :name => :description},
|
||||||
#had to hack acts_as_loggable/log.rb to get this to work
|
#had to hack acts_as_loggable/log.rb to get this to work
|
||||||
{ :name => :user_action__action, :field_label => 'Action'},
|
{ :name => :user_action__action, :field_label => 'Action', :value => action_id},
|
||||||
{ :name => :for_bike, :checkboxName => :copy_log, :inputValue => true, :title => "Copy description to a Bike's History?", :xtype => 'fieldset', :checkboxToggle => true, :collapsed => true, :items => [
|
{ :name => :for_bike, :checkboxName => :copy_log, :inputValue => true, :title => "Copy description to a Bike's History?", :xtype => 'fieldset', :checkboxToggle => true, :collapsed => true, :items => [
|
||||||
{:xtype => 'combo', :no_binding => true, :name => :copy_id, :title => 'Bike', :fieldLabel => 'Bike', :store => bike_store, :value => bike_id}
|
{:xtype => 'combo', :no_binding => true, :name => :copy_id, :title => 'Bike', :fieldLabel => 'Bike', :store => bike_store, :value => bike_id}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
class UserRoleJoins < Netzke::Basepack::Grid
|
|
||||||
def configure(c)
|
|
||||||
super
|
|
||||||
c.model = "UserRoleJoin"
|
|
||||||
c.header = false
|
|
||||||
c.title = "User Roles"
|
|
||||||
c.columns = [
|
|
||||||
{ :name => :user__username, :text => "Username"},
|
|
||||||
{ :name => :name, :getter => lambda{ |rec|
|
|
||||||
user = User.find_by_id(rec.user_id)
|
|
||||||
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ :name => :role__role, :text => "Role"},
|
|
||||||
:created_at,
|
|
||||||
:updated_at,
|
|
||||||
:ends ]
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_fields_for_forms
|
|
||||||
[
|
|
||||||
{ :name => :user__username, :field_label => 'Username' },
|
|
||||||
{ :name => :role__role, :field_label => 'Role' },
|
|
||||||
{ :name => :ends }
|
|
||||||
]
|
|
||||||
end
|
|
||||||
|
|
||||||
#override with nil to remove actions
|
|
||||||
def default_bbar
|
|
||||||
[ :apply, :add_in_form, :search ]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
class UserRoles < Netzke::Basepack::Grid
|
||||||
|
|
||||||
|
def configure(c)
|
||||||
|
super
|
||||||
|
c.model = "UserRole"
|
||||||
|
c.title = "User Roles"
|
||||||
|
c.columns = [ :role, :created_at, :updated_at, :ends ]
|
||||||
|
end
|
||||||
|
|
||||||
|
#override with nil to remove actions
|
||||||
|
def default_bbar
|
||||||
|
[ :apply, :add_in_form, :search ]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -2,29 +2,14 @@ class UserStats < Netzke::Base
|
|||||||
|
|
||||||
def body_content(user)
|
def body_content(user)
|
||||||
bike = user.bike
|
bike = user.bike
|
||||||
completed = user.completed_build_bikes
|
%Q(
|
||||||
#TODO I think it's time to switch to a template
|
<div id="user_stats_page">
|
||||||
body = ""
|
|
||||||
body += %Q(<div id="user_stats_page">)
|
|
||||||
body += %Q(
|
|
||||||
<p>Username: #{user.username}</p>
|
|
||||||
<p>Total Credits Earned: #{user.total_earned_credits}</p>
|
|
||||||
<p>Credits Available: #{user.total_credits}</p>
|
|
||||||
<p>Credits Spent: #{user.total_credits_spent}</p>
|
|
||||||
<p>Total Hours Worked: #{user.total_hours}</p>
|
<p>Total Hours Worked: #{user.total_hours}</p>
|
||||||
<p>Hours worked in #{Time.now.strftime('%B')}: #{user.current_month_hours}</p>
|
<p>Hours worked in #{Time.now.strftime('%B')}: #{user.current_month_hours}</p>
|
||||||
<p>Current bike Shop ID: #{bike.shop_id if bike}</p>
|
<p>Current bike Shop ID: #{bike.shop_id if bike}</p>
|
||||||
<p>Current bike S/N: #{bike.serial_number if bike}</p>
|
<p>Current bike S/N: #{bike.serial_number if bike}</p>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
unless completed.empty?
|
|
||||||
body += %Q(<p>Previously built bikes (#{completed.count}):</p>)
|
|
||||||
body += %Q(<ul>)
|
|
||||||
completed.each do |b|
|
|
||||||
body += %Q(<li>#{b.shop_id}</li>)
|
|
||||||
end
|
|
||||||
body += %Q(</ul>)
|
|
||||||
end
|
|
||||||
body += %Q(</div>)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
js_configure do |c|
|
js_configure do |c|
|
||||||
|
|||||||
+2
-12
@@ -1,27 +1,17 @@
|
|||||||
class Users < Netzke::Basepack::Grid
|
class Users < Netzke::Basepack::Grid
|
||||||
include Netzke::Basepack::ActionColumn
|
|
||||||
|
|
||||||
column :reset do |c|
|
|
||||||
c.type = :action
|
|
||||||
c.actions = [{name: :reset_password, icon: :lock_break}]
|
|
||||||
c.header = ""
|
|
||||||
c.width = 20
|
|
||||||
end
|
|
||||||
|
|
||||||
def configure(c)
|
def configure(c)
|
||||||
super
|
super
|
||||||
c.header = false
|
c.header = false
|
||||||
c.model = "User"
|
c.model = "User"
|
||||||
|
|
||||||
c.columns = [
|
c.columns = [
|
||||||
:username,
|
|
||||||
:first_name,
|
:first_name,
|
||||||
:last_name,
|
:last_name,
|
||||||
|
:nickname,
|
||||||
:email,
|
:email,
|
||||||
|
:user_role__role,
|
||||||
:bike__shop_id
|
:bike__shop_id
|
||||||
]
|
]
|
||||||
|
|
||||||
c.columns << :reset if can? :manage, User
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#override with nil to remove actions
|
#override with nil to remove actions
|
||||||
|
|||||||
@@ -4,32 +4,8 @@
|
|||||||
this.callParent();
|
this.callParent();
|
||||||
this.getView().on('itemclick', function(view, record){
|
this.getView().on('itemclick', function(view, record){
|
||||||
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
|
||||||
|
console.log("user: " + record.get('id') );
|
||||||
this.selectCustomer({customer_id: record.get('id'), customer_type: 'User'});
|
this.selectCustomer({customer_id: record.get('id'), customer_type: 'User'});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
|
||||||
onResetPassword: function(record){
|
|
||||||
user = record.data;
|
|
||||||
Ext.Msg.confirm(
|
|
||||||
"Reset Password",
|
|
||||||
"Are you sure you want to reset "+user.first_name+" "+user.last_name+"'s password?",
|
|
||||||
function(butt_id){
|
|
||||||
if( butt_id === "yes" ){
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: '/api/v1/reset',
|
|
||||||
dataType: 'json',
|
|
||||||
contentType: 'application/json',
|
|
||||||
processData: false,
|
|
||||||
data: JSON.stringify({"user_id": user.id}),
|
|
||||||
complete: function() { },
|
|
||||||
success: function(data) {
|
|
||||||
Ext.Msg.alert("Success", "New Password: "+data.password);
|
|
||||||
},
|
|
||||||
error: function(data,textStatus) {
|
|
||||||
Ext.Msg.alert( "Error", JSON.parse(data.responseText)["error"]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class UsersAndProfilesBorder < Netzke::Base
|
|||||||
super
|
super
|
||||||
c.header = false
|
c.header = false
|
||||||
c.items = [
|
c.items = [
|
||||||
{ netzke_component: :users, header: "Users", region: :center, width: 350, split: true },
|
{ netzke_component: :users, header: "Users", region: :center, width: 300, split: true },
|
||||||
{ netzke_component: :user_profiles, region: :south, height: 150, split: true},
|
{ netzke_component: :user_profiles, region: :south, height: 150, split: true},
|
||||||
{ netzke_component: :user_logs, region: :east, split: true}
|
{ netzke_component: :user_logs, region: :east, split: true}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
class Api::V1::BaseController < ActionController::Base
|
|
||||||
respond_to :json
|
|
||||||
|
|
||||||
before_filter :authenticate_user
|
|
||||||
|
|
||||||
private
|
|
||||||
def authenticate_user
|
|
||||||
if params[:username]
|
|
||||||
user = User.find_for_database_authentication( :email => 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
|
|
||||||
end
|
|
||||||
else
|
|
||||||
authenticate_user!
|
|
||||||
@current_user = current_user
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
class Api::V1::LogsController < Api::V1::BaseController
|
|
||||||
|
|
||||||
def checkin
|
|
||||||
#must use @current_user since user may not have signed in
|
|
||||||
if @current_user.checked_in?
|
|
||||||
render :json => { "error" => "You are already checked in."}, :status => 404 and return
|
|
||||||
else
|
|
||||||
@current_user.checkin
|
|
||||||
render :nothing => true, :status => 204 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def checkout
|
|
||||||
#must use @current_user since user may not have signed in
|
|
||||||
if !@current_user.checked_in?
|
|
||||||
render :json => { "error" => "You were not even checked in."}, :status => 404 and return
|
|
||||||
else
|
|
||||||
@current_user.checkout
|
|
||||||
render :nothing => true, :status => 204 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
require 'securerandom'
|
|
||||||
class Api::V1::UsersController < Api::V1::BaseController
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
new_pass = SecureRandom.hex[0,8]
|
|
||||||
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
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def checkout
|
|
||||||
#must use @current_user since user may not have signed in
|
|
||||||
if !@current_user.checked_in?
|
|
||||||
render :json => { "error" => "You were not even checked in."}, :status => 404 and return
|
|
||||||
else
|
|
||||||
@current_user.checkout
|
|
||||||
render :nothing => true, :status => 204 and return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
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?
|
|
||||||
|
|
||||||
messages = resource.errors.full_messages.map { |msg| content_tag(:p, msg, :class => "alert") }.join
|
|
||||||
sentence = I18n.t("errors.messages.not_saved",
|
|
||||||
:count => resource.errors.count,
|
|
||||||
:resource => resource.class.model_name.human.downcase)
|
|
||||||
|
|
||||||
html = <<-HTML
|
|
||||||
<p>#{sentence}</p>
|
|
||||||
#{messages}
|
|
||||||
HTML
|
|
||||||
|
|
||||||
html.html_safe
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -3,9 +3,7 @@ class Ability
|
|||||||
|
|
||||||
def initialize(current_user)
|
def initialize(current_user)
|
||||||
@current_user = current_user
|
@current_user = current_user
|
||||||
current_user.roles.each do |role|
|
self.send(current_user.role.to_sym)
|
||||||
self.send(role.role.to_sym)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def admin
|
def admin
|
||||||
@@ -24,7 +22,7 @@ class Ability
|
|||||||
def user
|
def user
|
||||||
can :read, :all
|
can :read, :all
|
||||||
can :manage, Bike, :id => @current_user.bike_id unless @current_user.bike.nil?
|
can :manage, Bike, :id => @current_user.bike_id unless @current_user.bike.nil?
|
||||||
can :manage, ::ActsAsLoggable::Log, :loggable_type => "Bike", :loggable_id => @current_user.bike_id
|
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
|
can :manage, ::ActsAsLoggable::Log, { :loggable_type => "User", :loggable_id => @current_user.id }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
class CreditConversion < ActiveRecord::Base
|
|
||||||
attr_accessible :conversion
|
|
||||||
end
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
class Role < ActiveRecord::Base
|
|
||||||
attr_accessible :role
|
|
||||||
|
|
||||||
has_many :user_role_joins
|
|
||||||
has_many :users, through: :user_role_joins
|
|
||||||
validates_uniqueness_of :role
|
|
||||||
|
|
||||||
|
|
||||||
def to_s
|
|
||||||
self.role
|
|
||||||
end
|
|
||||||
|
|
||||||
def ==(other)
|
|
||||||
self.role == other.role
|
|
||||||
end
|
|
||||||
end
|
|
||||||
+11
-100
@@ -7,17 +7,14 @@ class User < ActiveRecord::Base
|
|||||||
|
|
||||||
# Setup accessible (or protected) attributes for your model
|
# Setup accessible (or protected) attributes for your model
|
||||||
attr_accessible :email, :password, :password_confirmation, :remember_me,
|
attr_accessible :email, :password, :password_confirmation, :remember_me,
|
||||||
:first_name, :last_name, :bike_id,
|
:first_name, :last_name, :nickname, :user_role_id, :bike_id,
|
||||||
:user_profiles_attributes, :username
|
:user_profiles_attributes
|
||||||
|
|
||||||
has_many :transactions, as: :customer
|
has_many :transactions
|
||||||
has_many :transaction_logs, through: :transactions, source: :logs
|
|
||||||
has_many :user_profiles
|
has_many :user_profiles
|
||||||
accepts_nested_attributes_for :user_profiles, allow_destroy: false
|
accepts_nested_attributes_for :user_profiles, allow_destroy: false
|
||||||
|
|
||||||
has_many :user_role_joins, :conditions => ["ends IS NULL OR ends > ?", Time.now]
|
has_one :user_role
|
||||||
has_many :roles, through: :user_role_joins
|
|
||||||
|
|
||||||
belongs_to :bike
|
belongs_to :bike
|
||||||
|
|
||||||
validates :first_name, :presence => true
|
validates :first_name, :presence => true
|
||||||
@@ -27,115 +24,29 @@ class User < ActiveRecord::Base
|
|||||||
"#{first_name} #{last_name}"
|
"#{first_name} #{last_name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def email_required?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
to_s
|
to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def role
|
||||||
|
user_role.role
|
||||||
|
end
|
||||||
|
|
||||||
def role?(role)
|
def role?(role)
|
||||||
if role.kind_of?(String) or role.kind_of?(Symbol)
|
user_role.to_s == role.to_s
|
||||||
role = Role.find_by_role(role.to_s)
|
|
||||||
end
|
|
||||||
roles.include?(role)
|
|
||||||
end
|
|
||||||
|
|
||||||
### TODO methods below probably belong somewhere else
|
|
||||||
|
|
||||||
def completed_build_bikes
|
|
||||||
status_id = BikeStatus.find_by_status("BUILDBIKE").id
|
|
||||||
Bike.find_by_sql("
|
|
||||||
SELECT *
|
|
||||||
FROM bikes
|
|
||||||
INNER JOIN(
|
|
||||||
SELECT *
|
|
||||||
FROM transactions
|
|
||||||
WHERE customer_id = #{self.id}
|
|
||||||
) AS transactions ON bikes.id = transactions.bike_id
|
|
||||||
WHERE bike_status_id = #{status_id}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def total_credits
|
|
||||||
total_earned_credits - total_credits_spent
|
|
||||||
end
|
|
||||||
|
|
||||||
def total_credits_spent
|
|
||||||
log_action = ::ActsAsLoggable::TransactionAction.find_by_action("TIME")
|
|
||||||
transaction_logs.
|
|
||||||
where( "log_action_id = ? AND log_action_type = ?",
|
|
||||||
log_action.id, log_action.class.to_s).
|
|
||||||
sum{ |r| r.description.to_i }.round(2)
|
|
||||||
end
|
|
||||||
|
|
||||||
def total_earned_credits
|
|
||||||
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
|
||||||
|
|
||||||
# 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
|
|
||||||
# the credits earned from that log entry (each log could have a different
|
|
||||||
# conversion rate)
|
|
||||||
#
|
|
||||||
# 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("
|
|
||||||
SELECT DISTINCT ON (logs.created_at) start_date, end_date,
|
|
||||||
conversion.conversion, conversion.created_at
|
|
||||||
FROM logs
|
|
||||||
INNER JOIN(
|
|
||||||
SELECT conversion, created_at
|
|
||||||
FROM credit_conversions
|
|
||||||
) AS conversion ON logs.created_at > conversion.created_at
|
|
||||||
WHERE logs.loggable_id = #{self.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").
|
|
||||||
sum{ |l| ((l.end_date - l.start_date)/3600) * l.conversion.to_i}.round(2)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_hours
|
def total_hours
|
||||||
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
ActsAsLoggable::Log.where( :loggable_type => self.class.to_s, :loggable_id => self.id).sum { |l| (l.end_date - l.start_date)/3600 }.round(2)
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_month_hours
|
def current_month_hours
|
||||||
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
|
||||||
#TODO need to prevent users from saving logs across months, force to create a new log if crossing month
|
#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)
|
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)
|
ActsAsLoggable::Log.where( :loggable_type => self.class.to_s, :loggable_id => self.id)
|
||||||
.where( :start_date => current_month_range)
|
.where( :start_date => current_month_range)
|
||||||
.where( :end_date => current_month_range)
|
.where( :end_date => current_month_range)
|
||||||
.sum { |l| (l.end_date - l.start_date)/3600 }
|
.sum { |l| (l.end_date - l.start_date)/3600 }
|
||||||
.round(2)
|
.round(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def checked_in?
|
|
||||||
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
|
||||||
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")
|
|
||||||
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)
|
|
||||||
save
|
|
||||||
end
|
|
||||||
|
|
||||||
def checkout
|
|
||||||
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
|
||||||
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
|
|
||||||
checked.save
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
class UserProfile < ActiveRecord::Base
|
class UserProfile < ActiveRecord::Base
|
||||||
|
# Setup accessible (or protected) attributes for your model
|
||||||
attr_accessible :user_id, :addrStreet1, :addrStreet2, :addrCity,
|
attr_accessible :user_id, :addrStreet1, :addrStreet2, :addrCity,
|
||||||
:addrState, :addrZip, :phone
|
:addrState, :addrZip, :phone
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :bike
|
belongs_to :bike
|
||||||
|
|
||||||
#validates :addrStreet1 , :presence => true
|
#validates :addrStreet1 , :presence => true
|
||||||
#validates :addrCity , :presence => true
|
#validates :addrCity , :presence => true
|
||||||
#validates :addrState , :presence => true
|
#validates :addrState , :presence => true
|
||||||
#validates :addrZip , :presence => true
|
#validates :addrZip , :presence => true
|
||||||
#validates :phone, :presence => true
|
validates :phone, :presence => true
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
[addrStreet1, addrStreet2, addrCity, addrState, addrZip, phone].join(" - ")
|
[addrStreet1, addrStreet2, addrCity, addrState, addrZip, phone].join(" - ")
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
class UserRole < ActiveRecord::Base
|
||||||
|
attr_accessible :role
|
||||||
|
|
||||||
|
belongs_to :user
|
||||||
|
|
||||||
|
self.per_page = 15
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
self.role
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
class UserRoleJoin < ActiveRecord::Base
|
|
||||||
self.table_name = :user_role_joins
|
|
||||||
attr_accessible :role_id, :user_id, :ends
|
|
||||||
|
|
||||||
belongs_to :user
|
|
||||||
belongs_to :role
|
|
||||||
|
|
||||||
validate :role_id, presence: true, numericality: true
|
|
||||||
validate :user_id, presence: true, numericality: true
|
|
||||||
validates_uniqueness_of :user_id, :scope => :role_id
|
|
||||||
|
|
||||||
self.per_page = 15
|
|
||||||
end
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
<%= stylesheet_link_tag "bootstrap_and_overrides", :media => "all" %>
|
|
||||||
|
|
||||||
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
||||||
|
|
||||||
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
= stylesheet_link_tag "bootstrap_and_overrides", :media => "all"
|
|
||||||
%h2 Sign up
|
%h2 Sign up
|
||||||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
|
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
|
||||||
= devise_error_messages!
|
= devise_error_messages!
|
||||||
%div
|
|
||||||
= f.label :username
|
|
||||||
%br/
|
|
||||||
= f.text_field :username
|
|
||||||
%div
|
%div
|
||||||
= f.label :first_name
|
= f.label :first_name
|
||||||
%br/
|
%br/
|
||||||
@@ -14,13 +9,16 @@
|
|||||||
= f.label :last_name
|
= f.label :last_name
|
||||||
%br/
|
%br/
|
||||||
= f.text_field :last_name
|
= f.text_field :last_name
|
||||||
|
%div
|
||||||
|
= f.label :nickname
|
||||||
|
%br/
|
||||||
|
= f.text_field :nickname
|
||||||
%div
|
%div
|
||||||
= f.label :email
|
= f.label :email
|
||||||
%br/
|
%br/
|
||||||
= f.email_field :email
|
= f.email_field :email
|
||||||
%div
|
%div
|
||||||
- profile_builder = resource.user_profiles.empty? ? resource.user_profiles.build : resource.user_profiles
|
= f.fields_for :user_profiles, UserProfile.new do |builder|
|
||||||
= f.fields_for :user_profiles, profile_builder do |builder|
|
|
||||||
= render 'user_profile_fields', f: builder
|
= render 'user_profile_fields', f: builder
|
||||||
%div
|
%div
|
||||||
= f.label :password
|
= f.label :password
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
<%= stylesheet_link_tag "bootstrap_and_overrides", :media => "all" %>
|
<h2>Sign in</h2>
|
||||||
|
|
||||||
<h2>Velocipede</h2>
|
|
||||||
<a href="http://madewithloveinbaltimore.org">Made with ♥ in Baltimore</a>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||||
<div><%= f.label :username%><br />
|
<div><%= f.label :email %><br />
|
||||||
<%= f.text_field :username%></div>
|
<%= f.email_field :email %></div>
|
||||||
|
|
||||||
<div><%= f.label :password %><br />
|
<div><%= f.label :password %><br />
|
||||||
<%= f.password_field :password %></div>
|
<%= f.password_field :password %></div>
|
||||||
@@ -16,23 +12,17 @@
|
|||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<div><%= f.submit "Sign in" %></div>
|
<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 %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<%= render "links" %>
|
<%= render "links" %>
|
||||||
|
|
||||||
<% if Rails.env.development? %>
|
<% if Rails.env.development? %>
|
||||||
<% User.all.each do |user| %>
|
<% User.all.each do |user| %>
|
||||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||||
<%= f.hidden_field :username, :value => user.username%></div>
|
<%= f.hidden_field :email, :value => user.email %></div>
|
||||||
<%= f.hidden_field :password, :value => 'password' %></div>
|
<%= f.hidden_field :password, :value => 'password' %></div>
|
||||||
<div><%= f.submit "Sign in as #{user.username}" %></div>
|
<div><%= f.submit "Sign in as #{user.email}" %></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -28,4 +28,3 @@
|
|||||||
%p © Velocipede 2013
|
%p © Velocipede 2013
|
||||||
|
|
||||||
= javascript_include_tag "application"
|
= javascript_include_tag "application"
|
||||||
= javascript_include_tag params[:controller]
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# SQLite version 3.x
|
||||||
|
# gem install sqlite3
|
||||||
|
#
|
||||||
|
# Ensure the SQLite 3 gem is defined in your Gemfile
|
||||||
|
# gem 'sqlite3'
|
||||||
|
development:
|
||||||
|
adapter: sqlite3
|
||||||
|
database: db/development.sqlite3
|
||||||
|
pool: 5
|
||||||
|
timeout: 5000
|
||||||
|
|
||||||
|
# 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: sqlite3
|
||||||
|
database: db/test.sqlite3
|
||||||
|
pool: 5
|
||||||
|
timeout: 5000
|
||||||
|
|
||||||
|
production:
|
||||||
|
adapter: sqlite3
|
||||||
|
database: db/production.sqlite3
|
||||||
|
pool: 5
|
||||||
|
timeout: 5000
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
development:
|
|
||||||
adapter: postgresql
|
|
||||||
database: velocipede
|
|
||||||
username: velocipede
|
|
||||||
password:
|
|
||||||
host: 127.0.0.1
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
production:
|
|
||||||
adapter: postgresql
|
|
||||||
database: velocipede
|
|
||||||
username: velocipede
|
|
||||||
password:
|
|
||||||
host: 127.0.0.1
|
|
||||||
@@ -5,15 +5,20 @@ Velocipede::Application.configure do
|
|||||||
config.cache_classes = true
|
config.cache_classes = true
|
||||||
|
|
||||||
# Full error reports are disabled and caching is turned on
|
# Full error reports are disabled and caching is turned on
|
||||||
config.consider_all_requests_local = true
|
config.consider_all_requests_local = false
|
||||||
config.action_controller.perform_caching = true
|
config.action_controller.perform_caching = true
|
||||||
|
|
||||||
# Disable Rails's static asset server (Apache or nginx will already do this)
|
# Disable Rails's static asset server (Apache or nginx will already do this)
|
||||||
config.serve_static_assets = true
|
config.serve_static_assets = false
|
||||||
|
|
||||||
# Compress JavaScripts and CSS
|
# Compress JavaScripts and CSS
|
||||||
config.assets.compress = false
|
config.assets.compress = true
|
||||||
config.assets.debug = true
|
|
||||||
|
# Don't fallback to assets pipeline if a precompiled asset is missed
|
||||||
|
config.assets.compile = false
|
||||||
|
|
||||||
|
# Generate digests for assets URLs
|
||||||
|
config.assets.digest = true
|
||||||
|
|
||||||
# Defaults to Rails.root.join("public/assets")
|
# Defaults to Rails.root.join("public/assets")
|
||||||
# config.assets.manifest = YOUR_PATH
|
# config.assets.manifest = YOUR_PATH
|
||||||
@@ -40,6 +45,9 @@ Velocipede::Application.configure do
|
|||||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
||||||
# config.action_controller.asset_host = "http://assets.example.com"
|
# config.action_controller.asset_host = "http://assets.example.com"
|
||||||
|
|
||||||
|
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||||
|
# config.assets.precompile += %w( search.js )
|
||||||
|
|
||||||
# TODO set to host
|
# TODO set to host
|
||||||
# Disable delivery errors, bad email addresses will be ignored
|
# Disable delivery errors, bad email addresses will be ignored
|
||||||
# config.action_mailer.raise_delivery_errors = false
|
# config.action_mailer.raise_delivery_errors = false
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ Devise.setup do |config|
|
|||||||
# session. If you need permissions, you should implement that in a before filter.
|
# session. If you need permissions, you should implement that in a before filter.
|
||||||
# You can also supply a hash where the value is a boolean determining whether
|
# You can also supply a hash where the value is a boolean determining whether
|
||||||
# or not authentication should be aborted when the value is not present.
|
# or not authentication should be aborted when the value is not present.
|
||||||
config.authentication_keys = [ :username ]
|
# config.authentication_keys = [ :email ]
|
||||||
|
|
||||||
# Configure parameters from the request object used for authentication. Each entry
|
# Configure parameters from the request object used for authentication. Each entry
|
||||||
# given should be a request method and it will automatically be passed to the
|
# given should be a request method and it will automatically be passed to the
|
||||||
@@ -38,12 +38,12 @@ Devise.setup do |config|
|
|||||||
# Configure which authentication keys should be case-insensitive.
|
# Configure which authentication keys should be case-insensitive.
|
||||||
# These keys will be downcased upon creating or modifying a user and when used
|
# These keys will be downcased upon creating or modifying a user and when used
|
||||||
# to authenticate or find a user. Default is :email.
|
# to authenticate or find a user. Default is :email.
|
||||||
config.case_insensitive_keys = [ :username ]
|
config.case_insensitive_keys = [ :email ]
|
||||||
|
|
||||||
# Configure which authentication keys should have whitespace stripped.
|
# Configure which authentication keys should have whitespace stripped.
|
||||||
# These keys will have whitespace before and after removed upon creating or
|
# These keys will have whitespace before and after removed upon creating or
|
||||||
# modifying a user and when used to authenticate or find a user. Default is :email.
|
# modifying a user and when used to authenticate or find a user. Default is :email.
|
||||||
config.strip_whitespace_keys = [ :username ]
|
config.strip_whitespace_keys = [ :email ]
|
||||||
|
|
||||||
# Tell if authentication through request.params is enabled. True by default.
|
# Tell if authentication through request.params is enabled. True by default.
|
||||||
# It can be set to an array that will enable params authentication only for the
|
# It can be set to an array that will enable params authentication only for the
|
||||||
@@ -221,9 +221,3 @@ Devise.setup do |config|
|
|||||||
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
#Check in the user if they sign in. (Devise uses Warden)
|
|
||||||
Warden::Manager.after_authentication do |user,auth,opts|
|
|
||||||
user.checkin unless user.checked_in?
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ en:
|
|||||||
devise:
|
devise:
|
||||||
failure:
|
failure:
|
||||||
already_authenticated: 'You are already signed in.'
|
already_authenticated: 'You are already signed in.'
|
||||||
unauthenticated: 'You need to provide your username and password or sign in/sign up before continuing.'
|
unauthenticated: 'You need to sign in or sign up before continuing.'
|
||||||
unconfirmed: 'You have to confirm your account before continuing.'
|
unconfirmed: 'You have to confirm your account before continuing.'
|
||||||
locked: 'Your account is locked.'
|
locked: 'Your account is locked.'
|
||||||
invalid: 'Invalid email or password.'
|
invalid: 'Invalid email or password.'
|
||||||
|
|||||||
@@ -4,14 +4,4 @@ Velocipede::Application.routes.draw do
|
|||||||
netzke
|
netzke
|
||||||
|
|
||||||
root :to => 'site#index'
|
root :to => 'site#index'
|
||||||
###########################
|
|
||||||
# API Routes
|
|
||||||
scope 'api', :module => :api do
|
|
||||||
scope 'v1', :module => :v1 do
|
|
||||||
post 'checkin' => "logs#checkin", :as => "api_checkin"
|
|
||||||
post 'checkout' => "logs#checkout", :as => "api_checkout"
|
|
||||||
post 'reset' => "users#password_reset", :as => "api_password_reset"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,5 +2,6 @@ class AddEndsToUserRoles < ActiveRecord::Migration
|
|||||||
def change
|
def change
|
||||||
add_column(:user_roles, :ends, :timestamp)
|
add_column(:user_roles, :ends, :timestamp)
|
||||||
add_column(:user_roles, :user_id, :integer)
|
add_column(:user_roles, :user_id, :integer)
|
||||||
|
remove_column(:users, :role_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
class AlterUserRoles < ActiveRecord::Migration
|
|
||||||
def up
|
|
||||||
rename_table :user_roles, :user_role_joins
|
|
||||||
change_table :user_role_joins do |t|
|
|
||||||
t.rename :role, :role_id
|
|
||||||
#t.change :role_id, :integer
|
|
||||||
end
|
|
||||||
#for Postgres
|
|
||||||
connection.execute(%q{
|
|
||||||
alter table user_role_joins
|
|
||||||
alter column role_id
|
|
||||||
type integer using cast(role_id as integer)
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
rename_table :user_role_joins, :user_roles
|
|
||||||
change_table :user_role_joins do |t|
|
|
||||||
t.rename :role_id, :role
|
|
||||||
t.change :role_id, :string
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
class AddRoles < ActiveRecord::Migration
|
|
||||||
def change
|
|
||||||
create_table(:roles) do |t|
|
|
||||||
t.string :role
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
class AlterUser < ActiveRecord::Migration
|
|
||||||
def change
|
|
||||||
remove_column :users, :user_role_id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
class AddUsernameToUser < ActiveRecord::Migration
|
|
||||||
def change
|
|
||||||
add_column :users, :username, :string
|
|
||||||
add_index :users, :username, :unique => true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
class RemoveNickname < ActiveRecord::Migration
|
|
||||||
def change
|
|
||||||
remove_column :users, :nickname
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
class CreateCreditConversions < ActiveRecord::Migration
|
|
||||||
def change
|
|
||||||
create_table(:credit_conversions) do |t|
|
|
||||||
t.integer :conversion, :default => 1
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
+5
-17
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20130629152047) do
|
ActiveRecord::Schema.define(:version => 20130419010051) do
|
||||||
|
|
||||||
create_table "bike_actions", :force => true do |t|
|
create_table "bike_actions", :force => true do |t|
|
||||||
t.string "action", :limit => 128, :null => false
|
t.string "action", :limit => 128, :null => false
|
||||||
@@ -65,12 +65,6 @@ ActiveRecord::Schema.define(:version => 20130629152047) do
|
|||||||
|
|
||||||
add_index "bikes", ["shop_id"], :name => "index_bikes_on_shop_id", :unique => true
|
add_index "bikes", ["shop_id"], :name => "index_bikes_on_shop_id", :unique => true
|
||||||
|
|
||||||
create_table "credit_conversions", :force => true do |t|
|
|
||||||
t.integer "conversion", :default => 1
|
|
||||||
t.datetime "created_at", :null => false
|
|
||||||
t.datetime "updated_at", :null => false
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "customers", :force => true do |t|
|
create_table "customers", :force => true do |t|
|
||||||
t.string "first_name", :null => false
|
t.string "first_name", :null => false
|
||||||
t.string "last_name", :null => false
|
t.string "last_name", :null => false
|
||||||
@@ -103,12 +97,6 @@ ActiveRecord::Schema.define(:version => 20130629152047) do
|
|||||||
|
|
||||||
add_index "logs", ["loggable_id", "loggable_type", "context"], :name => "index_logs_on_loggable_id_and_loggable_type_and_context"
|
add_index "logs", ["loggable_id", "loggable_type", "context"], :name => "index_logs_on_loggable_id_and_loggable_type_and_context"
|
||||||
|
|
||||||
create_table "roles", :force => true do |t|
|
|
||||||
t.string "role"
|
|
||||||
t.datetime "created_at", :null => false
|
|
||||||
t.datetime "updated_at", :null => false
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "task_lists", :force => true do |t|
|
create_table "task_lists", :force => true do |t|
|
||||||
t.integer "item_id", :null => false
|
t.integer "item_id", :null => false
|
||||||
t.string "item_type", :null => false
|
t.string "item_type", :null => false
|
||||||
@@ -160,8 +148,8 @@ ActiveRecord::Schema.define(:version => 20130629152047) do
|
|||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "user_role_joins", :force => true do |t|
|
create_table "user_roles", :force => true do |t|
|
||||||
t.integer "role_id"
|
t.string "role"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.datetime "ends"
|
t.datetime "ends"
|
||||||
@@ -179,6 +167,7 @@ ActiveRecord::Schema.define(:version => 20130629152047) do
|
|||||||
t.datetime "last_sign_in_at"
|
t.datetime "last_sign_in_at"
|
||||||
t.string "current_sign_in_ip"
|
t.string "current_sign_in_ip"
|
||||||
t.string "last_sign_in_ip"
|
t.string "last_sign_in_ip"
|
||||||
|
t.integer "user_role_id", :default => 1, :null => false
|
||||||
t.integer "bike_id"
|
t.integer "bike_id"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
@@ -187,12 +176,11 @@ ActiveRecord::Schema.define(:version => 20130629152047) do
|
|||||||
t.datetime "locked_at"
|
t.datetime "locked_at"
|
||||||
t.string "first_name", :default => "", :null => false
|
t.string "first_name", :default => "", :null => false
|
||||||
t.string "last_name", :default => "", :null => false
|
t.string "last_name", :default => "", :null => false
|
||||||
t.string "username"
|
t.string "nickname"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "users", ["bike_id"], :name => "index_users_on_bike_id", :unique => true
|
add_index "users", ["bike_id"], :name => "index_users_on_bike_id", :unique => true
|
||||||
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
||||||
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
||||||
add_index "users", ["username"], :name => "index_users_on_username", :unique => true
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,8 +13,3 @@ staff:
|
|||||||
action: STAFF
|
action: STAFF
|
||||||
created_at: <%= Time.now %>
|
created_at: <%= Time.now %>
|
||||||
updated_at: <%= Time.now %>
|
updated_at: <%= Time.now %>
|
||||||
checkin:
|
|
||||||
id: 4
|
|
||||||
action: CHECKIN
|
|
||||||
created_at: <%= Time.now %>
|
|
||||||
updated_at: <%= Time.now %>
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
conversion:
|
|
||||||
id: 1
|
|
||||||
conversion: 10
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
user:
|
|
||||||
id: 1
|
|
||||||
role: user
|
|
||||||
bike_admin:
|
|
||||||
id: 2
|
|
||||||
role: bike_admin
|
|
||||||
staff:
|
|
||||||
id: 3
|
|
||||||
role: staff
|
|
||||||
admin:
|
|
||||||
id: 4
|
|
||||||
role: admin
|
|
||||||
+3
-17
@@ -15,19 +15,17 @@ end
|
|||||||
#Load bike brands and models from sql
|
#Load bike brands and models from sql
|
||||||
if BikeBrand.all.empty? and BikeModel.all.empty?
|
if BikeBrand.all.empty? and BikeModel.all.empty?
|
||||||
sql_path = File.join(Rails.root, 'db', 'seed', 'sql', 'bike_brands_and_models.sql')
|
sql_path = File.join(Rails.root, 'db', 'seed', 'sql', 'bike_brands_and_models.sql')
|
||||||
db_config = Rails.application.config.database_configuration[Rails.env]
|
system "sqlite3 db/development.sqlite3 < #{sql_path}" if Rails.env.development?
|
||||||
cmd = "psql #{db_config["database"]} < #{sql_path}"
|
|
||||||
system cmd
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if Rails.env.development?
|
if Rails.env.development?
|
||||||
|
|
||||||
#create default admin user
|
#create default admin user
|
||||||
if User.all.empty?
|
if UserRole.all.empty? and User.all.empty?
|
||||||
FactoryGirl.create(:user)
|
FactoryGirl.create(:user)
|
||||||
FactoryGirl.create(:staff)
|
FactoryGirl.create(:staff)
|
||||||
FactoryGirl.create(:bike_admin)
|
|
||||||
FactoryGirl.create(:admin)
|
FactoryGirl.create(:admin)
|
||||||
|
FactoryGirl.create(:bike_admin)
|
||||||
FactoryGirl.create(:user_profile)
|
FactoryGirl.create(:user_profile)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -37,16 +35,4 @@ if Rails.env.development?
|
|||||||
FactoryGirl.create(:bike)
|
FactoryGirl.create(:bike)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif Rails.env.production?
|
|
||||||
|
|
||||||
unless User.find_by_username('admin')
|
|
||||||
#create an admin
|
|
||||||
admin = User.create!( :username => 'admin',
|
|
||||||
:first_name => 'admin',
|
|
||||||
:last_name => 'admin',
|
|
||||||
:email=>'admin@example.com',
|
|
||||||
:password=>'password')
|
|
||||||
admin.roles << Role.find_by_role('admin')
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :role do
|
factory :user_role do
|
||||||
factory :role_staff do
|
factory :role_staff do
|
||||||
role 'staff'
|
role 'staff'
|
||||||
end
|
end
|
||||||
+4
-16
@@ -1,38 +1,26 @@
|
|||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :user do
|
factory :user do
|
||||||
sequence(:username) { |n| "user_#{n}" }
|
|
||||||
sequence(:email) { |n| "user_#{n}@example.com" }
|
sequence(:email) { |n| "user_#{n}@example.com" }
|
||||||
password 'password'
|
password 'password'
|
||||||
password_confirmation { password }
|
password_confirmation { password }
|
||||||
first_name 'Michael'
|
first_name 'Michael'
|
||||||
last_name 'Scott'
|
last_name 'Scott'
|
||||||
sequence(:bike_id) { |n| n }
|
sequence(:bike_id) { |n| n }
|
||||||
after_build do |r|
|
association :user_role, factory: :role_user
|
||||||
r.roles << (Role.find_by_role("user") || FactoryGirl.create(:role_user))
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :staff do
|
factory :staff do
|
||||||
username "staff"
|
|
||||||
first_name 'Staff'
|
first_name 'Staff'
|
||||||
after_build do |r|
|
association :user_role, factory: :role_staff
|
||||||
r.roles << (Role.find_by_role("staff") || FactoryGirl.create(:role_staff))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :admin do
|
factory :admin do
|
||||||
username "admin"
|
|
||||||
first_name 'Admin'
|
first_name 'Admin'
|
||||||
after_build do |r|
|
association :user_role, factory: :role_admin
|
||||||
r.roles << (Role.find_by_role("admin") || FactoryGirl.create(:role_admin))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :bike_admin do
|
factory :bike_admin do
|
||||||
username "bike_admin"
|
|
||||||
first_name 'BikeAdmin'
|
first_name 'BikeAdmin'
|
||||||
after_build do |r|
|
association :user_role, factory: :role_bike_admin
|
||||||
r.roles << (Role.find_by_role("bike_admin") || FactoryGirl.create(:role_bike_admin))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user