Merge branch 'master' of bitbucket.org:code2lab/nemo_encoder
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -16,6 +16,8 @@
|
|||||||
/tmp/*
|
/tmp/*
|
||||||
!/log/.keep
|
!/log/.keep
|
||||||
!/tmp/.keep
|
!/tmp/.keep
|
||||||
|
/ssh
|
||||||
|
|
||||||
# Ignore Byebug command history file.
|
# Ignore Byebug command history file.
|
||||||
.byebug_history
|
.byebug_history
|
||||||
|
config/database.yml\nconfig/secrets.yml
|
||||||
|
|||||||
47
Capfile
Normal file
47
Capfile
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# Load DSL and set up stages
|
||||||
|
require "capistrano/setup"
|
||||||
|
|
||||||
|
# Include default deployment tasks
|
||||||
|
require "capistrano/deploy"
|
||||||
|
|
||||||
|
# Load the SCM plugin appropriate to your project:
|
||||||
|
#
|
||||||
|
# require "capistrano/scm/hg"
|
||||||
|
# install_plugin Capistrano::SCM::Hg
|
||||||
|
# or
|
||||||
|
# require "capistrano/scm/svn"
|
||||||
|
# install_plugin Capistrano::SCM::Svn
|
||||||
|
# or
|
||||||
|
require "capistrano/scm/git"
|
||||||
|
install_plugin Capistrano::SCM::Git
|
||||||
|
|
||||||
|
# Include tasks from other gems included in your Gemfile
|
||||||
|
#
|
||||||
|
# For documentation on these, see for example:
|
||||||
|
#
|
||||||
|
# https://github.com/capistrano/rvm
|
||||||
|
# https://github.com/capistrano/rbenv
|
||||||
|
# https://github.com/capistrano/chruby
|
||||||
|
# https://github.com/capistrano/bundler
|
||||||
|
# https://github.com/capistrano/rails
|
||||||
|
# https://github.com/capistrano/passenger
|
||||||
|
#
|
||||||
|
# require "capistrano/rvm"
|
||||||
|
# require "capistrano/rbenv"
|
||||||
|
# require "capistrano/chruby"
|
||||||
|
# require "capistrano/bundler"
|
||||||
|
# require "capistrano/rails/assets"
|
||||||
|
# require "capistrano/rails/migrations"
|
||||||
|
# require "capistrano/passenger"
|
||||||
|
|
||||||
|
require 'capistrano/rails'
|
||||||
|
#require 'capistrano/passenger'
|
||||||
|
|
||||||
|
require 'capistrano/rbenv'
|
||||||
|
set :rbenv_type, :user
|
||||||
|
set :rbenv_ruby, '2.3.3'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
|
||||||
|
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
|
||||||
19
Gemfile
19
Gemfile
@@ -1,6 +1,7 @@
|
|||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||||
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
|
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
|
||||||
# Use sqlite3 as the database for Active Record
|
# Use sqlite3 as the database for Active Record
|
||||||
@@ -15,11 +16,13 @@ gem 'uglifier', '>= 1.3.0'
|
|||||||
gem 'coffee-rails', '~> 4.2'
|
gem 'coffee-rails', '~> 4.2'
|
||||||
# See https://github.com/rails/execjs#readme for more supported runtimes
|
# See https://github.com/rails/execjs#readme for more supported runtimes
|
||||||
# gem 'therubyracer', platforms: :ruby
|
# gem 'therubyracer', platforms: :ruby
|
||||||
|
gem 'unicorn'
|
||||||
|
gem 'execjs'
|
||||||
|
gem 'rack', '~> 2.0.1'
|
||||||
|
gem 'therubyracer'
|
||||||
platform :ruby do
|
platform :ruby do
|
||||||
gem 'pg'
|
gem 'pg'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Use jquery as the JavaScript library
|
# Use jquery as the JavaScript library
|
||||||
gem 'jquery-rails'
|
gem 'jquery-rails'
|
||||||
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
|
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
|
||||||
@@ -37,14 +40,20 @@ gem 'jbuilder', '~> 2.5'
|
|||||||
gem 'devise'
|
gem 'devise'
|
||||||
gem 'devise_uid'
|
gem 'devise_uid'
|
||||||
gem 'bcrypt', '~> 3.1.7'
|
gem 'bcrypt', '~> 3.1.7'
|
||||||
gem 'simple_form'
|
gem 'simple_form'
|
||||||
gem 'kaminari'
|
gem 'kaminari'
|
||||||
gem 'to_csv-rails'
|
gem 'to_csv-rails'
|
||||||
gem 'bootstrap-multiselect-rails'
|
# gem 'bootstrap-multiselect-rails'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||||
gem 'byebug', platform: :mri
|
gem 'byebug', platform: :mri
|
||||||
|
gem 'capistrano'
|
||||||
|
gem 'capistrano-bundler'
|
||||||
|
gem 'capistrano-rails'
|
||||||
|
gem 'capistrano-rbenv'
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
@@ -58,3 +67,5 @@ end
|
|||||||
|
|
||||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
65
Gemfile.lock
65
Gemfile.lock
@@ -38,12 +38,28 @@ GEM
|
|||||||
i18n (~> 0.7)
|
i18n (~> 0.7)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
|
airbrussh (1.1.2)
|
||||||
|
sshkit (>= 1.6.1, != 1.7.0)
|
||||||
arel (7.1.4)
|
arel (7.1.4)
|
||||||
bcrypt (3.1.11)
|
bcrypt (3.1.11)
|
||||||
bootstrap-multiselect-rails (0.9.9)
|
|
||||||
rails (>= 4.0.0)
|
|
||||||
builder (3.2.3)
|
builder (3.2.3)
|
||||||
byebug (9.0.6)
|
byebug (9.0.6)
|
||||||
|
capistrano (3.7.2)
|
||||||
|
airbrussh (>= 1.0.0)
|
||||||
|
capistrano-harrow
|
||||||
|
i18n
|
||||||
|
rake (>= 10.0.0)
|
||||||
|
sshkit (>= 1.9.0)
|
||||||
|
capistrano-bundler (1.2.0)
|
||||||
|
capistrano (~> 3.1)
|
||||||
|
sshkit (~> 1.2)
|
||||||
|
capistrano-harrow (0.5.3)
|
||||||
|
capistrano-rails (1.2.2)
|
||||||
|
capistrano (~> 3.1)
|
||||||
|
capistrano-bundler (~> 1.1)
|
||||||
|
capistrano-rbenv (2.1.0)
|
||||||
|
capistrano (~> 3.1)
|
||||||
|
sshkit (~> 1.3)
|
||||||
coffee-rails (4.2.1)
|
coffee-rails (4.2.1)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
railties (>= 4.0.0, < 5.2.x)
|
railties (>= 4.0.0, < 5.2.x)
|
||||||
@@ -67,8 +83,8 @@ GEM
|
|||||||
ffi (1.9.17)
|
ffi (1.9.17)
|
||||||
globalid (0.3.7)
|
globalid (0.3.7)
|
||||||
activesupport (>= 4.1.0)
|
activesupport (>= 4.1.0)
|
||||||
i18n (0.7.0)
|
i18n (0.8.1)
|
||||||
jbuilder (2.6.1)
|
jbuilder (2.6.2)
|
||||||
activesupport (>= 3.0.0, < 5.1)
|
activesupport (>= 3.0.0, < 5.1)
|
||||||
multi_json (~> 1.2)
|
multi_json (~> 1.2)
|
||||||
jquery-rails (4.2.2)
|
jquery-rails (4.2.2)
|
||||||
@@ -87,6 +103,8 @@ GEM
|
|||||||
activerecord
|
activerecord
|
||||||
kaminari-core (= 1.0.1)
|
kaminari-core (= 1.0.1)
|
||||||
kaminari-core (1.0.1)
|
kaminari-core (1.0.1)
|
||||||
|
kgio (2.11.0)
|
||||||
|
libv8 (3.16.14.17)
|
||||||
listen (3.0.8)
|
listen (3.0.8)
|
||||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||||
rb-inotify (~> 0.9, >= 0.9.7)
|
rb-inotify (~> 0.9, >= 0.9.7)
|
||||||
@@ -101,12 +119,15 @@ GEM
|
|||||||
mini_portile2 (2.1.0)
|
mini_portile2 (2.1.0)
|
||||||
minitest (5.10.1)
|
minitest (5.10.1)
|
||||||
multi_json (1.12.1)
|
multi_json (1.12.1)
|
||||||
|
net-scp (1.2.1)
|
||||||
|
net-ssh (>= 2.6.5)
|
||||||
|
net-ssh (4.1.0)
|
||||||
nio4r (1.2.1)
|
nio4r (1.2.1)
|
||||||
nokogiri (1.7.0.1)
|
nokogiri (1.7.0.1)
|
||||||
mini_portile2 (~> 2.1.0)
|
mini_portile2 (~> 2.1.0)
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
pg (0.19.0)
|
pg (0.19.0)
|
||||||
puma (3.6.2)
|
puma (3.7.1)
|
||||||
rack (2.0.1)
|
rack (2.0.1)
|
||||||
rack-test (0.6.3)
|
rack-test (0.6.3)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
@@ -133,10 +154,12 @@ GEM
|
|||||||
method_source
|
method_source
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.18.1, < 2.0)
|
thor (>= 0.18.1, < 2.0)
|
||||||
|
raindrops (0.17.0)
|
||||||
rake (12.0.0)
|
rake (12.0.0)
|
||||||
rb-fsevent (0.9.8)
|
rb-fsevent (0.9.8)
|
||||||
rb-inotify (0.9.7)
|
rb-inotify (0.9.8)
|
||||||
ffi (>= 0.5.0)
|
ffi (>= 0.5.0)
|
||||||
|
ref (2.0.0)
|
||||||
responders (2.3.0)
|
responders (2.3.0)
|
||||||
railties (>= 4.2.0, < 5.1)
|
railties (>= 4.2.0, < 5.1)
|
||||||
sass (3.4.23)
|
sass (3.4.23)
|
||||||
@@ -149,7 +172,7 @@ GEM
|
|||||||
simple_form (3.4.0)
|
simple_form (3.4.0)
|
||||||
actionpack (> 4, < 5.1)
|
actionpack (> 4, < 5.1)
|
||||||
activemodel (> 4, < 5.1)
|
activemodel (> 4, < 5.1)
|
||||||
spring (2.0.0)
|
spring (2.0.1)
|
||||||
activesupport (>= 4.2)
|
activesupport (>= 4.2)
|
||||||
spring-watcher-listen (2.0.1)
|
spring-watcher-listen (2.0.1)
|
||||||
listen (>= 2.7, < 4.0)
|
listen (>= 2.7, < 4.0)
|
||||||
@@ -161,9 +184,15 @@ GEM
|
|||||||
actionpack (>= 4.0)
|
actionpack (>= 4.0)
|
||||||
activesupport (>= 4.0)
|
activesupport (>= 4.0)
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
|
sshkit (1.12.0)
|
||||||
|
net-scp (>= 1.1.2)
|
||||||
|
net-ssh (>= 2.8.0)
|
||||||
|
therubyracer (0.12.3)
|
||||||
|
libv8 (~> 3.16.14.15)
|
||||||
|
ref
|
||||||
thor (0.19.4)
|
thor (0.19.4)
|
||||||
thread_safe (0.3.5)
|
thread_safe (0.3.6)
|
||||||
tilt (2.0.5)
|
tilt (2.0.6)
|
||||||
to_csv-rails (0.1.5)
|
to_csv-rails (0.1.5)
|
||||||
turbolinks (5.0.1)
|
turbolinks (5.0.1)
|
||||||
turbolinks-source (~> 5)
|
turbolinks-source (~> 5)
|
||||||
@@ -172,14 +201,17 @@ GEM
|
|||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
uglifier (3.0.4)
|
uglifier (3.0.4)
|
||||||
execjs (>= 0.3.0, < 3)
|
execjs (>= 0.3.0, < 3)
|
||||||
warden (1.2.6)
|
unicorn (5.2.0)
|
||||||
|
kgio (~> 2.6)
|
||||||
|
raindrops (~> 0.7)
|
||||||
|
warden (1.2.7)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
web-console (3.4.0)
|
web-console (3.4.0)
|
||||||
actionview (>= 5.0)
|
actionview (>= 5.0)
|
||||||
activemodel (>= 5.0)
|
activemodel (>= 5.0)
|
||||||
debug_inspector
|
debug_inspector
|
||||||
railties (>= 5.0)
|
railties (>= 5.0)
|
||||||
websocket-driver (0.6.4)
|
websocket-driver (0.6.5)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.2)
|
websocket-extensions (0.1.2)
|
||||||
|
|
||||||
@@ -188,27 +220,34 @@ PLATFORMS
|
|||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
bcrypt (~> 3.1.7)
|
bcrypt (~> 3.1.7)
|
||||||
bootstrap-multiselect-rails
|
|
||||||
byebug
|
byebug
|
||||||
|
capistrano
|
||||||
|
capistrano-bundler
|
||||||
|
capistrano-rails
|
||||||
|
capistrano-rbenv
|
||||||
coffee-rails (~> 4.2)
|
coffee-rails (~> 4.2)
|
||||||
devise
|
devise
|
||||||
devise_uid
|
devise_uid
|
||||||
|
execjs
|
||||||
jbuilder (~> 2.5)
|
jbuilder (~> 2.5)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
kaminari
|
kaminari
|
||||||
listen (~> 3.0.5)
|
listen (~> 3.0.5)
|
||||||
pg
|
pg
|
||||||
puma (~> 3.0)
|
puma (~> 3.0)
|
||||||
|
rack (~> 2.0.1)
|
||||||
rails (~> 5.0.0, >= 5.0.0.1)
|
rails (~> 5.0.0, >= 5.0.0.1)
|
||||||
sass-rails (~> 5.0)
|
sass-rails (~> 5.0)
|
||||||
simple_form
|
simple_form
|
||||||
spring
|
spring
|
||||||
spring-watcher-listen (~> 2.0.0)
|
spring-watcher-listen (~> 2.0.0)
|
||||||
|
therubyracer
|
||||||
to_csv-rails
|
to_csv-rails
|
||||||
turbolinks (~> 5)
|
turbolinks (~> 5)
|
||||||
tzinfo-data
|
tzinfo-data
|
||||||
uglifier (>= 1.3.0)
|
uglifier (>= 1.3.0)
|
||||||
|
unicorn
|
||||||
web-console
|
web-console
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.13.7
|
1.14.3
|
||||||
|
|||||||
BIN
app/assets/.DS_Store
vendored
BIN
app/assets/.DS_Store
vendored
Binary file not shown.
@@ -13,6 +13,5 @@
|
|||||||
//= require jquery
|
//= require jquery
|
||||||
//= require jquery_ujs
|
//= require jquery_ujs
|
||||||
//= require turbolinks
|
//= require turbolinks
|
||||||
//= require bootstrap.v4a2.min
|
//= require bootstrap.v4a2.min
|
||||||
//= require bootstrap-multiselect
|
|
||||||
//= require_tree .
|
//= require_tree .
|
||||||
|
|||||||
1716
app/assets/javascripts/multiselect.js
Normal file
1716
app/assets/javascripts/multiselect.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -13,5 +13,4 @@
|
|||||||
*= require_tree .
|
*= require_tree .
|
||||||
*= require_self
|
*= require_self
|
||||||
*/
|
*/
|
||||||
@import "bootstrap.v4a2.min";
|
@import "bootstrap.v4a2.min";
|
||||||
@import "bootstrap-multiselect";
|
|
||||||
1
app/assets/stylesheets/multiselect.css
Normal file
1
app/assets/stylesheets/multiselect.css
Normal file
@@ -0,0 +1 @@
|
|||||||
|
span.multiselect-native-select{position:relative}span.multiselect-native-select select{border:0!important;clip:rect(0 0 0 0)!important;height:1px!important;margin:-1px -1px -1px -3px!important;overflow:hidden!important;padding:0!important;position:absolute!important;width:1px!important;left:50%;top:30px}.multiselect-container{position:absolute;list-style-type:none;margin:0;padding:0}.multiselect-container .input-group{margin:5px}.multiselect-container>li{padding:0}.multiselect-container>li>a.multiselect-all label{font-weight:700}.multiselect-container>li.multiselect-group label{margin:0;padding:3px 20px 3px 20px;height:100%;font-weight:700}.multiselect-container>li.multiselect-group-clickable label{cursor:pointer}.multiselect-container>li>a{padding:0}.multiselect-container>li>a>label{margin:0;height:100%;cursor:pointer;font-weight:400;padding:3px 20px 3px 40px}.multiselect-container>li>a>label.radio,.multiselect-container>li>a>label.checkbox{margin:0}.multiselect-container>li>a>label>input[type=checkbox]{margin-bottom:5px}.btn-group>.btn-group:nth-child(2)>.multiselect.btn{border-top-left-radius:4px;border-bottom-left-radius:4px}.form-inline .multiselect-container label.checkbox,.form-inline .multiselect-container label.radio{padding:3px 20px 3px 40px}.form-inline .multiselect-container li a label.checkbox input[type=checkbox],.form-inline .multiselect-container li a label.radio input[type=radio]{margin-left:-20px;margin-right:0}
|
||||||
@@ -3,8 +3,8 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
def register
|
def register
|
||||||
batch_id=params[:batch_id]
|
batch_id=params[:batch_id]
|
||||||
session_token=params[:session_token]
|
session_token=params[:session_token]
|
||||||
manufacture_uid = params[:card_manufacture]
|
manufacture_uid = params[:card_manufacture]
|
||||||
|
card_account_no=params[:card_account_no]
|
||||||
client_id=""
|
client_id=""
|
||||||
|
|
||||||
check_member= Member.authenticate_session_token(session_token)
|
check_member= Member.authenticate_session_token(session_token)
|
||||||
@@ -13,12 +13,12 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
asset_identity=""
|
asset_identity=""
|
||||||
|
|
||||||
find_batch = Batch.find_by_id(batch_id)
|
find_batch = Batch.find_by_id(batch_id)
|
||||||
if !find_batch.nil?
|
if !find_batch.nil?
|
||||||
card_type=find_batch.adult_or_child.upcase
|
card_type=find_batch.adult_or_child.upcase
|
||||||
product_category_id=find_batch.product_category_id
|
product_category_id=find_batch.product_category_id
|
||||||
find_product_category=ProductCategory.find_by_id(product_category_id)
|
find_product_category=ProductCategory.find_by_id(product_category_id)
|
||||||
|
|
||||||
if !find_product_category.nil?
|
if !find_product_category.nil?
|
||||||
product_type=find_product_category.product_type_id
|
product_type=find_product_category.product_type_id
|
||||||
|
|
||||||
find_user=Client.find_by_id(find_batch.client_id)
|
find_user=Client.find_by_id(find_batch.client_id)
|
||||||
@@ -27,10 +27,9 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
location_code=find_user.location_code
|
location_code=find_user.location_code
|
||||||
|
|
||||||
client_id=find_user.id
|
client_id=find_user.id
|
||||||
|
if !encrypt_key.nil?
|
||||||
if !encrypt_key.nil?
|
check_manufacture = BatchLineItem.find_by_manufacture_uid(manufacture_uid)
|
||||||
check_manufacture = BatchLineItem.find_by_manufacture_uid(manufacture_uid)
|
if check_manufacture.nil?
|
||||||
if check_manufacture.nil?
|
|
||||||
serial_no=BatchLineItem.generate_serial_no(client_id.to_s)
|
serial_no=BatchLineItem.generate_serial_no(client_id.to_s)
|
||||||
|
|
||||||
if product_type ==1 #CARD
|
if product_type ==1 #CARD
|
||||||
@@ -49,17 +48,21 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
if check_asset.nil?
|
if check_asset.nil?
|
||||||
@out=BatchLineItem.create_product(asset_identity,serial_no,batch_id,manufacture_uid,card_type)
|
@out=BatchLineItem.create_product(asset_identity,serial_no,batch_id,manufacture_uid,card_type)
|
||||||
else
|
else
|
||||||
@out=false,'Asset Identity is already registered!'
|
@out=false,'Asset Identity is already registered!'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,'Manufacture UID is already registered!'
|
if check_manufacture.asset_identity !=card_account_no
|
||||||
|
@out=true,check_manufacture.serial_no,check_manufacture.asset_identity
|
||||||
|
else
|
||||||
|
@out=false,'Manufacture UID is already registered!'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,'Invalid User!'
|
@out=false,'Invalid User!'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,"Client doesn't exist!"
|
@out=false,"Client doesn't exist!"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,"Product Category doesn't exist!"
|
@out=false,"Product Category doesn't exist!"
|
||||||
@@ -70,5 +73,5 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
else
|
else
|
||||||
@out=false,'Sorry!Unauthorized user!'
|
@out=false,'Sorry!Unauthorized user!'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -5,28 +5,34 @@ class Api::BatchesController < ApplicationController
|
|||||||
check_member= Member.authenticate_session_token(session_token)
|
check_member= Member.authenticate_session_token(session_token)
|
||||||
if !check_member.nil?
|
if !check_member.nil?
|
||||||
date = DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d")
|
date = DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d")
|
||||||
order_ref = params[:order_ref]
|
order_ref = params[:order_ref]
|
||||||
|
order_ref=order_ref.delete(' ')
|
||||||
adult_or_child=params[:adult_or_child]
|
adult_or_child=params[:adult_or_child]
|
||||||
client_id=params[:client_id]
|
client_id=params[:client_id]
|
||||||
product_category_id=params[:product_category_id]
|
product_category_id=params[:product_category_id]
|
||||||
|
|
||||||
find_client=Client.find_by_id(client_id)
|
find_batch=Batch.find_by_order_ref(order_ref)
|
||||||
if !find_client.nil?
|
if find_batch.nil?
|
||||||
find_product_category=ProductCategory.find_by_id(product_category_id)
|
find_client=Client.find_by_id(client_id)
|
||||||
if !find_product_category.nil?
|
if !find_client.nil?
|
||||||
user_id=check_member.user_id
|
find_product_category=ProductCategory.find_by_id(product_category_id)
|
||||||
|
if !find_product_category.nil?
|
||||||
|
user_id=check_member.user_id
|
||||||
|
|
||||||
batch = Batch.create_batch(date,order_ref,user_id,adult_or_child,client_id,product_category_id)
|
batch = Batch.create_batch(date,order_ref,user_id,adult_or_child,client_id,product_category_id)
|
||||||
if !batch.nil?
|
if !batch.nil?
|
||||||
@out=true,batch.id
|
@out=true,batch.id
|
||||||
else
|
else
|
||||||
@out=false,'Error occurs in creating batch!'
|
@out=false,'Error occurs in creating batch!'
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
@out=false,'Product Category does not exists!'
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@out=false,'Product Category does not exists!'
|
@out = false, "Client does not exist!"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out = false, "Client does not exist!"
|
@out=false,order_ref.to_s+ " is already taken!"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out = false, "Sorry!Unauthorized user!"
|
@out = false, "Sorry!Unauthorized user!"
|
||||||
|
|||||||
@@ -5,4 +5,5 @@
|
|||||||
else
|
else
|
||||||
json.set! :status, @out[0]
|
json.set! :status, @out[0]
|
||||||
json.set! :message,@out[1]
|
json.set! :message,@out[1]
|
||||||
|
json.set! :data,@out[2]
|
||||||
end
|
end
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('#loading').hide();
|
$('#loading').hide();
|
||||||
client_id=$("#client").val();
|
client_id=$("#client").val();
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
<%= stylesheet_link_tag 'application', media: 'all' %>
|
<%= stylesheet_link_tag 'application', media: 'all' %>
|
||||||
<%= javascript_include_tag 'application', 'data-turbolinks-eval' => true %>
|
<%= javascript_include_tag 'application', 'data-turbolinks-eval' => true %>
|
||||||
|
<script src="/assets/multiselect.js" type="text/javascript"></script>
|
||||||
|
<link href="/assets/multiselect.css" rel="stylesheet" type="text/css" />
|
||||||
<link href="/assets/style.css" rel="stylesheet" type="text/css" />
|
<link href="/assets/style.css" rel="stylesheet" type="text/css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -23,4 +23,6 @@ test:
|
|||||||
|
|
||||||
production:
|
production:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: db/production.sqlite3
|
database: nemo
|
||||||
|
username: deploy
|
||||||
|
password: OU771o3ja3Hn4$r
|
||||||
|
|||||||
61
config/deploy.rb
Normal file
61
config/deploy.rb
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# config valid only for current version of Capistrano
|
||||||
|
lock "3.7.2"
|
||||||
|
|
||||||
|
set :application, "nemo_encoder"
|
||||||
|
set :repo_url, "git@bitbucket.org:code2lab/nemo_encoder.git"
|
||||||
|
|
||||||
|
|
||||||
|
#set :branch, 'master'
|
||||||
|
# Default deploy_to directory is /var/www/my_app_name
|
||||||
|
set :deploy_user, 'ubuntu'
|
||||||
|
|
||||||
|
# setup rbenv.
|
||||||
|
set :rbenv_type, :global
|
||||||
|
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
|
||||||
|
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
|
||||||
|
|
||||||
|
# how many old releases do we want to keep, not much
|
||||||
|
set :keep_releases, 5
|
||||||
|
|
||||||
|
# files we want symlinking to specific entries in shared
|
||||||
|
set :linked_files, %w{config/database.yml config/secrets.yml}
|
||||||
|
|
||||||
|
# dirs we want symlinking to shared
|
||||||
|
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system pids sockets}
|
||||||
|
|
||||||
|
# what specs should be run before deployment is allowed to
|
||||||
|
# continue, see lib/capistrano/tasks/run_tests.cap
|
||||||
|
set :tests, []
|
||||||
|
#set :pty, true
|
||||||
|
set :pty, true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Default branch is :master
|
||||||
|
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
|
||||||
|
|
||||||
|
# Default deploy_to directory is /var/www/my_app_name
|
||||||
|
# set :deploy_to, "/var/www/my_app_name"
|
||||||
|
|
||||||
|
# Default value for :format is :airbrussh.
|
||||||
|
# set :format, :airbrussh
|
||||||
|
|
||||||
|
# You can configure the Airbrussh format using :format_options.
|
||||||
|
# These are the defaults.
|
||||||
|
# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto
|
||||||
|
|
||||||
|
# Default value for :pty is false
|
||||||
|
# set :pty, true
|
||||||
|
|
||||||
|
# Default value for :linked_files is []
|
||||||
|
# append :linked_files, "config/database.yml", "config/secrets.yml"
|
||||||
|
|
||||||
|
# Default value for linked_dirs is []
|
||||||
|
# append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system"
|
||||||
|
|
||||||
|
# Default value for default_env is {}
|
||||||
|
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
||||||
|
|
||||||
|
# Default value for keep_releases is 5
|
||||||
|
# set :keep_releases, 5
|
||||||
81
config/deploy/production.rb
Normal file
81
config/deploy/production.rb
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
# server-based syntax
|
||||||
|
# ======================
|
||||||
|
# Defines a single server with a list of roles and multiple properties.
|
||||||
|
# You can define all roles on a single server, or split them:
|
||||||
|
|
||||||
|
# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
|
||||||
|
# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
|
||||||
|
# server "db.example.com", user: "deploy", roles: %w{db}
|
||||||
|
|
||||||
|
set :stage, :production
|
||||||
|
set :server_name, "svr.nemo.host"
|
||||||
|
# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
|
||||||
|
# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
|
||||||
|
# server "db.example.com", user: "deploy", roles: %w{db}
|
||||||
|
set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"
|
||||||
|
|
||||||
|
|
||||||
|
server 'ec2-54-169-212-254.ap-southeast-1.compute.amazonaws.com', user: 'ubuntu', roles: %w{web app db}, primary: true
|
||||||
|
set :ssh_options, {
|
||||||
|
keys: %w(/home/deploy/nemo_encoder/ssh/nemo.pem),
|
||||||
|
forward_agent: false,
|
||||||
|
user: 'ubuntu'
|
||||||
|
}
|
||||||
|
|
||||||
|
set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}"
|
||||||
|
set :rbenv_ruby, '2.3.1'
|
||||||
|
set :rails_env, :production
|
||||||
|
|
||||||
|
set :unicorn_worker_count, 5
|
||||||
|
|
||||||
|
|
||||||
|
# role-based syntax
|
||||||
|
# ==================
|
||||||
|
|
||||||
|
# Defines a role with one or multiple servers. The primary server in each
|
||||||
|
# group is considered to be the first unless any hosts have the primary
|
||||||
|
# property set. Specify the username and a domain or IP for the server.
|
||||||
|
# Don't use `:all`, it's a meta role.
|
||||||
|
|
||||||
|
# role :app, %w{deploy@example.com}, my_property: :my_value
|
||||||
|
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
|
||||||
|
# role :db, %w{deploy@example.com}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
# =============
|
||||||
|
# You can set any configuration variable like in config/deploy.rb
|
||||||
|
# These variables are then only loaded and set in this stage.
|
||||||
|
# For available Capistrano configuration variables see the documentation page.
|
||||||
|
# http://capistranorb.com/documentation/getting-started/configuration/
|
||||||
|
# Feel free to add new variables to customise your setup.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Custom SSH Options
|
||||||
|
# ==================
|
||||||
|
# You may pass any option but keep in mind that net/ssh understands a
|
||||||
|
# limited set of options, consult the Net::SSH documentation.
|
||||||
|
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
|
||||||
|
#
|
||||||
|
# Global options
|
||||||
|
# --------------
|
||||||
|
# set :ssh_options, {
|
||||||
|
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
||||||
|
# forward_agent: false,
|
||||||
|
# auth_methods: %w(password)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# The server-based syntax can be used to override options:
|
||||||
|
# ------------------------------------
|
||||||
|
# server "example.com",
|
||||||
|
# user: "user_name",
|
||||||
|
# roles: %w{web app},
|
||||||
|
# ssh_options: {
|
||||||
|
# user: "user_name", # overrides user setting above
|
||||||
|
# keys: %w(/home/user_name/.ssh/id_rsa),
|
||||||
|
# forward_agent: false,
|
||||||
|
# auth_methods: %w(publickey password)
|
||||||
|
# # password: "please use keys"
|
||||||
|
# }
|
||||||
61
config/deploy/production.rb.save
Normal file
61
config/deploy/production.rb.save
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# server-based syntax
|
||||||
|
# ======================
|
||||||
|
# Defines a single server with a list of roles and multiple properties.
|
||||||
|
# You can define all roles on a single server, or split them:
|
||||||
|
|
||||||
|
# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value
|
||||||
|
# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
|
||||||
|
# server "db.example.com", user: "deploy", roles: %w{db}
|
||||||
|
/deploy/production.rb:
|
||||||
|
|
||||||
|
|
||||||
|
# role-based syntax
|
||||||
|
# ==================
|
||||||
|
|
||||||
|
# Defines a role with one or multiple servers. The primary server in each
|
||||||
|
# group is considered to be the first unless any hosts have the primary
|
||||||
|
# property set. Specify the username and a domain or IP for the server.
|
||||||
|
# Don't use `:all`, it's a meta role.
|
||||||
|
|
||||||
|
# role :app, %w{deploy@example.com}, my_property: :my_value
|
||||||
|
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
|
||||||
|
# role :db, %w{deploy@example.com}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
# =============
|
||||||
|
# You can set any configuration variable like in config/deploy.rb
|
||||||
|
# These variables are then only loaded and set in this stage.
|
||||||
|
# For available Capistrano configuration variables see the documentation page.
|
||||||
|
# http://capistranorb.com/documentation/getting-started/configuration/
|
||||||
|
# Feel free to add new variables to customise your setup.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Custom SSH Options
|
||||||
|
# ==================
|
||||||
|
# You may pass any option but keep in mind that net/ssh understands a
|
||||||
|
# limited set of options, consult the Net::SSH documentation.
|
||||||
|
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
|
||||||
|
#
|
||||||
|
# Global options
|
||||||
|
# --------------
|
||||||
|
# set :ssh_options, {
|
||||||
|
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
||||||
|
# forward_agent: false,
|
||||||
|
# auth_methods: %w(password)
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# The server-based syntax can be used to override options:
|
||||||
|
# ------------------------------------
|
||||||
|
# server "example.com",
|
||||||
|
# user: "user_name",
|
||||||
|
# roles: %w{web app},
|
||||||
|
# ssh_options: {
|
||||||
|
# user: "user_name", # overrides user setting above
|
||||||
|
# keys: %w(/home/user_name/.ssh/id_rsa),
|
||||||
|
# forward_agent: false,
|
||||||
|
# auth_methods: %w(publickey password)
|
||||||
|
# # password: "please use keys"
|
||||||
|
# }
|
||||||
@@ -16,14 +16,14 @@ Rails.application.configure do
|
|||||||
|
|
||||||
# Disable serving static files from the `/public` folder by default since
|
# Disable serving static files from the `/public` folder by default since
|
||||||
# Apache or NGINX already handles this.
|
# Apache or NGINX already handles this.
|
||||||
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
#config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
||||||
|
config.public_file_server.enabled = true
|
||||||
# Compress JavaScripts and CSS.
|
# Compress JavaScripts and CSS.
|
||||||
config.assets.js_compressor = :uglifier
|
config.assets.js_compressor = :uglifier
|
||||||
# config.assets.css_compressor = :sass
|
# config.assets.css_compressor = :sass
|
||||||
|
|
||||||
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
||||||
config.assets.compile = false
|
config.assets.compile = true
|
||||||
|
|
||||||
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ Rails.application.configure do
|
|||||||
# Use a real queuing backend for Active Job (and separate queues per environment)
|
# Use a real queuing backend for Active Job (and separate queues per environment)
|
||||||
# config.active_job.queue_adapter = :resque
|
# config.active_job.queue_adapter = :resque
|
||||||
# config.active_job.queue_name_prefix = "nemo_encoder_#{Rails.env}"
|
# config.active_job.queue_name_prefix = "nemo_encoder_#{Rails.env}"
|
||||||
config.action_mailer.perform_caching = false
|
config.action_mailer.perform_caching = true
|
||||||
|
|
||||||
# Ignore bad email addresses and do not raise email delivery errors.
|
# Ignore bad email addresses and do not raise email delivery errors.
|
||||||
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
||||||
|
|||||||
69
config/nemo.sh
Normal file
69
config/nemo.sh
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: unicorn
|
||||||
|
# Required-Start: $all
|
||||||
|
# Required-Stop: $all
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
# Short-Description: starts the unicorn app server
|
||||||
|
# Description: starts unicorn using start-stop-daemon
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
set -e
|
||||||
|
USAGE="Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"
|
||||||
|
|
||||||
|
# app settings
|
||||||
|
USER="ubuntu"
|
||||||
|
APP_NAME="nemo_encoder_production"
|
||||||
|
APP_ROOT="/home/$USER/apps/$APP_NAME/current"
|
||||||
|
ENV="production"
|
||||||
|
|
||||||
|
# environment settings
|
||||||
|
PATH="/home/$USER/.rbenv/shims:/home/$USER/.rbenv/bin:$PATH"
|
||||||
|
CMD="/home/$USER/.rbenv/shims/unicorn_rails -c $APP_ROOT/config/unicorn.rb -E $ENV -D"
|
||||||
|
PID="$APP_ROOT/pids/unicorn.nemo.pid"
|
||||||
|
OLD_PID="$PID.oldbin"
|
||||||
|
|
||||||
|
|
||||||
|
cd $APP_ROOT || exit 1
|
||||||
|
|
||||||
|
sig () {
|
||||||
|
test -s "$PID" && kill -$1 `cat $PID`
|
||||||
|
}
|
||||||
|
|
||||||
|
oldsig () {
|
||||||
|
test -s $OLD_PID && kill -$1 `cat $OLD_PID`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
start)
|
||||||
|
sig 0 && echo >&2 "Already running" && exit 0
|
||||||
|
echo "Starting $APP_NAME"
|
||||||
|
su - $USER -c "$CMD"
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
echo "Stopping $APP_NAME"
|
||||||
|
sig QUIT && exit 0
|
||||||
|
echo >&2 "Not running"
|
||||||
|
;;
|
||||||
|
force-stop)
|
||||||
|
echo "Force stopping $APP_NAME"
|
||||||
|
sig TERM && exit 0
|
||||||
|
echo >&2 "Not running"
|
||||||
|
;;
|
||||||
|
restart|reload|upgrade)
|
||||||
|
sig USR2 && echo "reloaded $APP_NAME" && exit 0
|
||||||
|
echo >&2 "Couldn't reload, starting '$CMD' instead"
|
||||||
|
$CMD
|
||||||
|
;;
|
||||||
|
rotate)
|
||||||
|
sig USR1 && echo rotated logs OK && exit 0
|
||||||
|
echo >&2 "Couldn't rotate logs" && exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo >&2 $USAGE
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
39
config/unicorn.rb
Normal file
39
config/unicorn.rb
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
root=File.expand_path(File.dirname(__FILE__) + '/..')
|
||||||
|
#shared_dir="#{root}/shared"
|
||||||
|
working_directory root
|
||||||
|
pid "#{root}/pids/unicorn.nemo.pid"
|
||||||
|
stderr_path "#{root}/log/unicorn.stderr.log"
|
||||||
|
stdout_path "#{root}/log/unicorn.stdout.log"
|
||||||
|
listen "#{root}/sockets/unicorn.nemo.sock", :backlog => 64
|
||||||
|
listen(8081, backlog: 64) if ENV['RAILS_ENV'] == 'production'
|
||||||
|
worker_processes 2
|
||||||
|
preload_app true
|
||||||
|
timeout 30
|
||||||
|
|
||||||
|
|
||||||
|
before_fork do |server, worker|
|
||||||
|
# the following is highly recomended for Rails + "preload_app true"
|
||||||
|
# as there's no need for the master process to hold a connection
|
||||||
|
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
|
||||||
|
|
||||||
|
##
|
||||||
|
# When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
|
||||||
|
# immediately start loading up a new version of itself (loaded with a new
|
||||||
|
# version of our app). When this new Unicorn is completely loaded
|
||||||
|
# it will begin spawning workers. The first worker spawned will check to
|
||||||
|
# see if an .oldbin pidfile exists. If so, this means we've just booted up
|
||||||
|
# a new Unicorn and need to tell the old one that it can now die. To do so
|
||||||
|
# we send it a QUIT.
|
||||||
|
#
|
||||||
|
# Using this method we get 0 downtime deploys.
|
||||||
|
|
||||||
|
old_pid = "#{root}/pids/unicorn.nemo.pid.oldbin"
|
||||||
|
if File.exists?(old_pid) && server.pid != old_pid
|
||||||
|
begin
|
||||||
|
Process.kill("QUIT", File.read(old_pid).to_i)
|
||||||
|
rescue Errno::ENOENT, Errno::ESRCH
|
||||||
|
# someone else did our job for us
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@@ -26,9 +26,11 @@ namespace :setup do
|
|||||||
task :set_product_category, [:name,:product_type] => :environment do |t, args|
|
task :set_product_category, [:name,:product_type] => :environment do |t, args|
|
||||||
find_product_type=ProductType.find_by_id(args.product_type)
|
find_product_type=ProductType.find_by_id(args.product_type)
|
||||||
if !find_product_type.nil?
|
if !find_product_type.nil?
|
||||||
|
|
||||||
find_product_category=ProductCategory.find_by_name(args.name)
|
find_product_category=ProductCategory.find_by_name(args.name)
|
||||||
|
|
||||||
if find_product_category.nil?
|
if find_product_category.nil?
|
||||||
|
|
||||||
product_category=ProductCategory.new
|
product_category=ProductCategory.new
|
||||||
product_category.name=args.name
|
product_category.name=args.name
|
||||||
product_category.product_type_id=args.product_type
|
product_category.product_type_id=args.product_type
|
||||||
|
|||||||
Reference in New Issue
Block a user