smartkiosk-server 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +32 -0
- data/.rspec +1 -0
- data/Capfile +4 -0
- data/Gemfile +71 -0
- data/Gemfile.lock +439 -0
- data/Guardfile +25 -0
- data/LICENSE +287 -0
- data/README.md +13 -0
- data/Rakefile +5 -0
- data/app/acquirers/cards_mkb_acquirer.rb +87 -0
- data/app/acquirers/cash_acquirer.rb +22 -0
- data/app/admin/agents.rb +108 -0
- data/app/admin/collections.rb +62 -0
- data/app/admin/commissions.rb +87 -0
- data/app/admin/gateways.rb +183 -0
- data/app/admin/limits.rb +82 -0
- data/app/admin/payments.rb +246 -0
- data/app/admin/provider_groups.rb +60 -0
- data/app/admin/provider_profiles.rb +11 -0
- data/app/admin/provider_receipt_templates.rb +82 -0
- data/app/admin/providers.rb +201 -0
- data/app/admin/rebates.rb +83 -0
- data/app/admin/report_results.rb +66 -0
- data/app/admin/report_templates.rb +209 -0
- data/app/admin/reports.rb +158 -0
- data/app/admin/revisions.rb +120 -0
- data/app/admin/system_receipt_templates.rb +76 -0
- data/app/admin/terminal_builds.rb +39 -0
- data/app/admin/terminal_profiles.rb +123 -0
- data/app/admin/terminals.rb +388 -0
- data/app/admin/users.rb +117 -0
- data/app/admin/versions.rb +131 -0
- data/app/admin/welcome.rb +64 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.eot +0 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.svg +6386 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.ttf +0 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.woff +0 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.eot +0 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.svg +5650 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.ttf +0 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.woff +0 -0
- data/app/assets/images/chosen-sprite.png +0 -0
- data/app/assets/javascripts/active_admin/chosen.js.erb.coffee +12 -0
- data/app/assets/javascripts/active_admin/qtip.js.coffee +22 -0
- data/app/assets/javascripts/active_admin/sortable_forms.js.coffee +14 -0
- data/app/assets/javascripts/active_admin.js.coffee +9 -0
- data/app/assets/javascripts/application.js +15 -0
- data/app/assets/javascripts/report_templates.js.coffee +10 -0
- data/app/assets/javascripts/terminals.js.coffee +12 -0
- data/app/assets/stylesheets/active_admin/PIE.css.scss +18 -0
- data/app/assets/stylesheets/active_admin/filter_numeric_range.css.scss +14 -0
- data/app/assets/stylesheets/active_admin/selectable_check_boxes.css.scss +12 -0
- data/app/assets/stylesheets/active_admin/sortable_forms.css.scss +11 -0
- data/app/assets/stylesheets/active_admin.css.scss +705 -0
- data/app/assets/stylesheets/fonts.css.scss +14 -0
- data/app/assets/stylesheets/provider_groups.css.scss +12 -0
- data/app/assets/stylesheets/provider_receipt_templates.css.scss +12 -0
- data/app/assets/stylesheets/terminals.css.scss +9 -0
- data/app/controllers/application_controller.rb +12 -0
- data/app/controllers/collections_controller.rb +10 -0
- data/app/controllers/payments_controller.rb +73 -0
- data/app/controllers/system_receipt_templates_controller.rb +10 -0
- data/app/controllers/terminal_builds_controller.rb +5 -0
- data/app/controllers/terminal_orders_controller.rb +25 -0
- data/app/controllers/terminal_pings_controller.rb +45 -0
- data/app/controllers/welcome_controller.rb +5 -0
- data/app/helpers/active_admin/report_templates_helper.rb +56 -0
- data/app/helpers/active_admin/views_helper.rb +20 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/ability.rb +30 -0
- data/app/models/agent.rb +24 -0
- data/app/models/collection.rb +65 -0
- data/app/models/commission.rb +77 -0
- data/app/models/commission_section.rb +75 -0
- data/app/models/gateway.rb +99 -0
- data/app/models/gateway_attachment.rb +9 -0
- data/app/models/gateway_setting.rb +7 -0
- data/app/models/gateway_switch.rb +7 -0
- data/app/models/limit.rb +77 -0
- data/app/models/limit_section.rb +58 -0
- data/app/models/payment.rb +322 -0
- data/app/models/provider.rb +59 -0
- data/app/models/provider_field.rb +7 -0
- data/app/models/provider_gateway.rb +47 -0
- data/app/models/provider_group.rb +45 -0
- data/app/models/provider_profile.rb +9 -0
- data/app/models/provider_rebate.rb +69 -0
- data/app/models/provider_receipt_template.rb +85 -0
- data/app/models/rebate.rb +84 -0
- data/app/models/report.rb +71 -0
- data/app/models/report_result.rb +11 -0
- data/app/models/report_template.rb +56 -0
- data/app/models/revision.rb +104 -0
- data/app/models/role.rb +48 -0
- data/app/models/system_receipt_template.rb +13 -0
- data/app/models/terminal.rb +126 -0
- data/app/models/terminal_build.rb +62 -0
- data/app/models/terminal_order.rb +42 -0
- data/app/models/terminal_ping.rb +120 -0
- data/app/models/terminal_profile.rb +51 -0
- data/app/models/terminal_profile_promotion.rb +18 -0
- data/app/models/terminal_profile_provider.rb +11 -0
- data/app/models/terminal_profile_provider_group.rb +19 -0
- data/app/models/user.rb +38 -0
- data/app/models/user_role.rb +45 -0
- data/app/reports/agents_report.rb +81 -0
- data/app/reports/collections_report.rb +151 -0
- data/app/reports/payments_report.rb +189 -0
- data/app/reports/terminals_report.rb +123 -0
- data/app/uploaders/file_uploader.rb +53 -0
- data/app/uploaders/icon_uploader.rb +15 -0
- data/app/uploaders/zip_uploader.rb +53 -0
- data/app/views/admin/gateways/providers.html.arb +10 -0
- data/app/views/admin/revisions/payments.html.arb +28 -0
- data/app/views/admin/terminal_profiles/_tree.html.haml +35 -0
- data/app/views/admin/terminal_profiles/sort.html.haml +21 -0
- data/app/views/admin/terminals/pings.html.arb +55 -0
- data/app/views/admin/terminals/upgrade_build.html.arb +30 -0
- data/app/views/layouts/application.html.erb +1 -0
- data/app/views/welcome/index.html.erb +25 -0
- data/app/workers/pay_worker.rb +11 -0
- data/app/workers/report_worker.rb +7 -0
- data/app/workers/revise_worker.rb +7 -0
- data/config/acquiring.yml +13 -0
- data/config/application.rb +75 -0
- data/config/boot.rb +6 -0
- data/config/database.yml +17 -0
- data/config/deploy/roundlake-passenger.rb +3 -0
- data/config/deploy/roundlake-trinidad.rb +3 -0
- data/config/deploy.rb +37 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +39 -0
- data/config/environments/production.rb +67 -0
- data/config/environments/test.rb +37 -0
- data/config/initializers/active_admin.rb +31 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/devise.rb +232 -0
- data/config/initializers/inflections.rb +15 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/money.rb +6 -0
- data/config/initializers/redis.rb +4 -0
- data/config/initializers/secret_token.rb +7 -0
- data/config/initializers/session_store.rb +8 -0
- data/config/initializers/setup_rack.rb +1 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/active_admin.ru.yml +71 -0
- data/config/locales/activerecord.ru.yml +645 -0
- data/config/locales/devise.ru.yml +57 -0
- data/config/locales/ru.yml +33 -0
- data/config/locales/smartkiosk.gateways.ru.yml +241 -0
- data/config/locales/smartkiosk.hardware.ru.yml +38 -0
- data/config/locales/smartkiosk.reports.ru.yml +56 -0
- data/config/locales/smartkiosk.ru.yml +163 -0
- data/config/nginx.conf +9 -0
- data/config/redis.yml +9 -0
- data/config/routes.rb +48 -0
- data/config/schedule.rb +13 -0
- data/config/sidekiq.yml +5 -0
- data/config/trinidad.yml +6 -0
- data/config.ru +4 -0
- data/db/migrate/20120825083035_create_terminals.rb +47 -0
- data/db/migrate/20120825083305_create_payments.rb +51 -0
- data/db/migrate/20120827062618_devise_create_users.rb +50 -0
- data/db/migrate/20120827132621_create_admin_notes.rb +17 -0
- data/db/migrate/20120827132622_move_admin_notes_to_comments.rb +25 -0
- data/db/migrate/20120903193346_create_providers.rb +24 -0
- data/db/migrate/20120922075345_create_collections.rb +26 -0
- data/db/migrate/20120922080440_create_agents.rb +29 -0
- data/db/migrate/20120922081104_create_commissions.rb +10 -0
- data/db/migrate/20120927035841_create_gateways.rb +13 -0
- data/db/migrate/20120927040626_create_provider_gateways.rb +13 -0
- data/db/migrate/20120927091849_create_limits.rb +10 -0
- data/db/migrate/20120927164647_create_roles.rb +14 -0
- data/db/migrate/20121003131522_create_report_templates.rb +18 -0
- data/db/migrate/20121007135652_create_reports.rb +13 -0
- data/db/migrate/20121008073905_create_report_results.rb +10 -0
- data/db/migrate/20121017114538_create_gateway_settings.rb +12 -0
- data/db/migrate/20121017114556_create_gateway_attachments.rb +10 -0
- data/db/migrate/20121019132606_create_revisions.rb +19 -0
- data/db/migrate/20121023073501_create_gateway_switches.rb +10 -0
- data/db/migrate/20121112142743_create_terminal_orders.rb +13 -0
- data/db/migrate/20121118191553_create_versions.rb +19 -0
- data/db/migrate/20121125093414_create_system_receipt_templates.rb +9 -0
- data/db/migrate/20121127192257_create_terminal_builds.rb +10 -0
- data/db/migrate/20121212053441_create_rebates.rb +15 -0
- data/db/migrate/20121216143855_create_provider_receipt_templates.rb +9 -0
- data/db/migrate/20130101091100_create_terminal_profiles.rb +13 -0
- data/db/migrate/20130101091734_create_provider_rebates.rb +21 -0
- data/db/migrate/20130102164447_create_limit_sections.rb +14 -0
- data/db/migrate/20130102164503_create_commission_sections.rb +17 -0
- data/db/migrate/20130102171743_create_provider_profiles.rb +10 -0
- data/db/migrate/20130103152507_create_provider_fields.rb +17 -0
- data/db/migrate/20130103154526_create_provider_groups.rb +10 -0
- data/db/migrate/20130104063628_create_terminal_profile_providers.rb +11 -0
- data/db/migrate/20130104090957_create_terminal_profile_provider_groups.rb +11 -0
- data/db/migrate/20130108091644_create_terminal_profile_promotions.rb +10 -0
- data/db/schema.rb +489 -0
- data/db/seeds/receipt_templates/payment.txt +19 -0
- data/db/seeds/receipt_templates/system/balance.txt +13 -0
- data/db/seeds/receipt_templates/system/collection.txt +17 -0
- data/db/seeds/receipt_templates/system/touchtest.txt +15 -0
- data/db/seeds.rb +18 -0
- data/doc/README_FOR_APP +2 -0
- data/init.rb +1 -0
- data/lib/active_admin/cancan_integration.rb +81 -0
- data/lib/active_admin/form_builder_fix.rb +76 -0
- data/lib/active_admin/inputs/filter_date_range_input_fix.rb +24 -0
- data/lib/active_admin/inputs/filter_multiple_select_input.rb +18 -0
- data/lib/active_admin/inputs/filter_numeric_range_input.rb +31 -0
- data/lib/active_admin/resource_controller_fix.rb +23 -0
- data/lib/active_admin/views/pages/base_fix.rb +13 -0
- data/lib/assets/.gitkeep +0 -0
- data/lib/blueprints.rb +79 -0
- data/lib/date_expander.rb +38 -0
- data/lib/dav4rack/build_resource.rb +59 -0
- data/lib/formtastic/inputs/selectable_check_boxes.rb +39 -0
- data/lib/paper_trail/version_fix.rb +3 -0
- data/lib/report_builder.rb +88 -0
- data/lib/seeder.rb +103 -0
- data/lib/smartkiosk/server/version.rb +5 -0
- data/lib/smartkiosk/server.rb +35 -0
- data/lib/string_file.rb +12 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/db.rake +27 -0
- data/lib/tasks/dump.rake +53 -0
- data/lib/tasks/matrioshka.rake +16 -0
- data/log/.gitkeep +0 -0
- data/log/gateways/.gitkeep +0 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +25 -0
- data/public/robots.txt +5 -0
- data/script/rails +6 -0
- data/smartkiosk-server.gemspec +23 -0
- data/spec/controllers/collections_controller_spec.rb +32 -0
- data/spec/controllers/payments_controller_spec.rb +123 -0
- data/spec/controllers/system_receipt_templates_controller_spec.rb +5 -0
- data/spec/controllers/terminal_builds_controller_spec.rb +5 -0
- data/spec/controllers/terminal_orders_controller_spec.rb +32 -0
- data/spec/controllers/terminal_pings_controller_spec.rb +31 -0
- data/spec/spec_helper.rb +66 -0
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/javascripts/chosen.jquery.js +1026 -0
- data/vendor/assets/javascripts/datepicker-ru.jquery.js +21 -0
- data/vendor/assets/javascripts/nestedSortable.jquery.js +429 -0
- data/vendor/assets/javascripts/qtip.jquery.js +3403 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/chosen.jquery.css +397 -0
- data/vendor/assets/stylesheets/modules/PIE.htc +96 -0
- data/vendor/assets/stylesheets/qtip.jquery.css.scss +604 -0
- data/vendor/plugins/.gitkeep +0 -0
- metadata +333 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module ViewHelpers
|
3
|
+
# lib/active_admin/view_helpers/auto_link_helper.rb
|
4
|
+
|
5
|
+
def auto_link(resource, link_content = nil)
|
6
|
+
content = link_content || display_name(resource)
|
7
|
+
if can?(:read, resource) && registration = active_admin_resource_for(resource.class)
|
8
|
+
begin
|
9
|
+
content = link_to(content, send(registration.route_instance_path, resource))
|
10
|
+
rescue
|
11
|
+
end
|
12
|
+
end
|
13
|
+
content
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Views
|
18
|
+
class IndexAsTable
|
19
|
+
class IndexTableFor
|
20
|
+
# lib/active_admin/views/index_as_table.rb
|
21
|
+
|
22
|
+
def default_actions(options = {})
|
23
|
+
options = {
|
24
|
+
:name => ""
|
25
|
+
}.merge(options)
|
26
|
+
column options[:name] do |resource|
|
27
|
+
links = ''.html_safe
|
28
|
+
if controller.action_methods.include?('show') && can?(:read, resource)
|
29
|
+
links += link_to I18n.t('active_admin.view'), resource_path(resource), :class => "member_link view_link"
|
30
|
+
end
|
31
|
+
if controller.action_methods.include?('edit') && can?(:update, resource)
|
32
|
+
links += link_to I18n.t('active_admin.edit'), edit_resource_path(resource), :class => "member_link edit_link"
|
33
|
+
end
|
34
|
+
if controller.action_methods.include?('destroy') && can?(:destroy, resource)
|
35
|
+
links += link_to I18n.t('active_admin.delete'), resource_path(resource), :method => :delete, :data => {:confirm => I18n.t('active_admin.delete_confirmation')}, :class => "member_link delete_link"
|
36
|
+
end
|
37
|
+
links += yield(resource) if block_given?
|
38
|
+
links
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Resource
|
46
|
+
# lib/active_admin/resource/menu.rb
|
47
|
+
|
48
|
+
# The :if block is evaluated by TabbedNavigation#display_item?
|
49
|
+
def default_menu_options
|
50
|
+
klass = resource_class # avoid variable capture
|
51
|
+
super.merge(:if => proc{ can? :read, klass })
|
52
|
+
end
|
53
|
+
|
54
|
+
# lib/active_admin/resource/action_items.rb
|
55
|
+
|
56
|
+
def add_default_action_items
|
57
|
+
# New Link on all actions except :new and :show
|
58
|
+
add_action_item(:except => [:new, :show], :if => proc{ can? :create, active_admin_config.resource_class }) do
|
59
|
+
if controller.action_methods.include?('new')
|
60
|
+
link_to(I18n.t('active_admin.new_model', :model => active_admin_config.resource_label), new_resource_path)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Edit link on show
|
65
|
+
add_action_item(:only => :show, :if => proc{ can? :update, resource }) do
|
66
|
+
if controller.action_methods.include?('edit')
|
67
|
+
link_to(I18n.t('active_admin.edit_model', :model => active_admin_config.resource_label), edit_resource_path(resource))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Destroy link on show
|
72
|
+
add_action_item(:only => :show, :if => proc{ can? :destroy, resource }) do
|
73
|
+
if controller.action_methods.include?("destroy")
|
74
|
+
link_to(I18n.t('active_admin.delete_model', :model => active_admin_config.resource_label),
|
75
|
+
resource_path(resource),
|
76
|
+
:method => :delete, :data => {:confirm => I18n.t('active_admin.delete_confirmation')})
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
ActiveAdmin::FormBuilder.class_eval do
|
2
|
+
# TODO: Upgrade AA and remove
|
3
|
+
def semantic_errors(*args)
|
4
|
+
content = with_new_form_buffer { super }
|
5
|
+
form_buffers.last << content.html_safe unless content.nil?
|
6
|
+
end
|
7
|
+
|
8
|
+
# TODO: Support consistency
|
9
|
+
def has_many(association, options = {}, &block)
|
10
|
+
options = { :for => association }.merge(options)
|
11
|
+
options[:class] ||= ""
|
12
|
+
options[:class] << "inputs has_many_fields"
|
13
|
+
|
14
|
+
# Add Delete Links
|
15
|
+
form_block = proc do |has_many_form|
|
16
|
+
# @see https://github.com/justinfrench/formtastic/blob/2.2.1/lib/formtastic/helpers/inputs_helper.rb#L373
|
17
|
+
contents = if block.arity == 1 # for backwards compatibility with REE & Ruby 1.8.x
|
18
|
+
block.call(has_many_form)
|
19
|
+
else
|
20
|
+
index = parent_child_index(options[:parent]) if options[:parent]
|
21
|
+
block.call(has_many_form, index)
|
22
|
+
end
|
23
|
+
|
24
|
+
if has_many_form.object.new_record?
|
25
|
+
contents += template.content_tag(:li) do
|
26
|
+
template.link_to I18n.t('active_admin.has_many_delete'), "#", :onclick => "$(this).closest('.has_many_fields').remove(); return false;", :class => "button"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
contents
|
31
|
+
end
|
32
|
+
|
33
|
+
content = with_new_form_buffer do
|
34
|
+
attributes = { :class => "has_many #{association}" }
|
35
|
+
unless options[:sortable].blank?
|
36
|
+
attributes[:class] << " sortable"
|
37
|
+
attributes['data-sortable'] = options[:sortable]
|
38
|
+
end
|
39
|
+
|
40
|
+
template.content_tag :div, attributes do
|
41
|
+
form_buffers.last << template.content_tag(:h3, object.class.reflect_on_association(association).klass.model_name.human(:count => 1.1))
|
42
|
+
inputs options, &form_block
|
43
|
+
|
44
|
+
js = js_for_has_many(association, form_block, template)
|
45
|
+
form_buffers.last << js.html_safe
|
46
|
+
end
|
47
|
+
end
|
48
|
+
form_buffers.last << content.html_safe
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# TODO: Remove as https://github.com/gregbell/active_admin/issues/1832 is closed
|
54
|
+
def js_for_has_many(association, form_block, template)
|
55
|
+
association_reflection = object.class.reflect_on_association(association)
|
56
|
+
association_human_name = association_reflection.klass.model_name
|
57
|
+
placeholder = "NEW_#{association_human_name.upcase.split(' ').join('_')}_RECORD"
|
58
|
+
|
59
|
+
js = with_new_form_buffer do
|
60
|
+
inputs_for_nested_attributes :for => [association, association_reflection.klass.new],
|
61
|
+
:class => "inputs has_many_fields",
|
62
|
+
:for_options => { :child_index => placeholder },
|
63
|
+
&form_block
|
64
|
+
end
|
65
|
+
|
66
|
+
js = template.escape_javascript(js)
|
67
|
+
|
68
|
+
text = I18n.t 'active_admin.has_many_new', :model => association_human_name.human
|
69
|
+
onclick = "$(this).siblings('li.input').append('#{js}'.replace(/#{placeholder}/g, new Date().getTime())); return false;"
|
70
|
+
|
71
|
+
template.link_to text, "#",
|
72
|
+
:onclick => onclick,
|
73
|
+
:class => "button"
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Inputs
|
3
|
+
class FilterDateRangeInput
|
4
|
+
|
5
|
+
def to_html
|
6
|
+
input_wrapping do
|
7
|
+
[ label_html,
|
8
|
+
builder.text_field(gt_input_name, input_html_options(gt_input_name, 'datepickergte')),
|
9
|
+
template.content_tag(:span, "-", :class => "seperator"),
|
10
|
+
builder.text_field(lt_input_name, input_html_options(lt_input_name, 'datepickerlte')),
|
11
|
+
].join("\n").html_safe
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def input_html_options(input_name = gt_input_name, extra_class = '')
|
16
|
+
current_value = @object.send(input_name)
|
17
|
+
{ :size => 12,
|
18
|
+
:class => "datepicker #{extra_class}",
|
19
|
+
:max => 10,
|
20
|
+
:value => current_value.respond_to?(:strftime) ? current_value.strftime("%Y-%m-%d") : "" }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Inputs
|
3
|
+
class FilterMultipleSelectInput < Formtastic::Inputs::SelectInput
|
4
|
+
include FilterBase
|
5
|
+
|
6
|
+
def input_name
|
7
|
+
"#{super}_in"
|
8
|
+
end
|
9
|
+
|
10
|
+
def extra_input_html_options
|
11
|
+
{
|
12
|
+
:multiple => 'multiple',
|
13
|
+
:'data-placeholder' => I18n.t('active_admin.filters.multiple_select.placeholder')
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Inputs
|
3
|
+
class FilterNumericRangeInput < ::Formtastic::Inputs::StringInput
|
4
|
+
include FilterBase
|
5
|
+
|
6
|
+
def to_html
|
7
|
+
input_wrapping do
|
8
|
+
[ label_html,
|
9
|
+
builder.text_field(gt_input_name, input_html_options(gt_input_name)),
|
10
|
+
template.content_tag(:span, "-".html_safe, :class => "seperator"),
|
11
|
+
builder.text_field(lt_input_name, input_html_options(lt_input_name)),
|
12
|
+
].join("\n").html_safe
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def gt_input_name
|
17
|
+
"#{method}_gte"
|
18
|
+
end
|
19
|
+
alias :input_name :gt_input_name
|
20
|
+
|
21
|
+
def lt_input_name
|
22
|
+
"#{method}_lte"
|
23
|
+
end
|
24
|
+
|
25
|
+
def input_html_options(input_name = gt_input_name)
|
26
|
+
current_value = @object.send(input_name)
|
27
|
+
{ :size => 10, :id => "#{input_name}_numeric" , :value => current_value}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
class ResourceController < BaseController
|
3
|
+
before_filter :fix_datetime_filter_inclusion, :only => :index
|
4
|
+
|
5
|
+
def clean_search_params(search_params)
|
6
|
+
super.delete_if do |key, value|
|
7
|
+
value == [""]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def fix_datetime_filter_inclusion
|
14
|
+
resource_class.columns.each do |c|
|
15
|
+
next unless c.type == :datetime
|
16
|
+
|
17
|
+
if !params["q"].blank? && !params["q"]["#{c.name}_lte"].blank?
|
18
|
+
params["q"]["#{c.name}_lte"] += " 23:59:59.999999"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class ActiveAdmin::Views::Pages::Base < Arbre::HTML::Document
|
2
|
+
|
3
|
+
private
|
4
|
+
|
5
|
+
# Renders the content for the footer
|
6
|
+
def build_footer
|
7
|
+
div :id => "footer" do
|
8
|
+
revision = Smartkiosk::Server.revision.blank? ? '' : "(#{Smartkiosk::Server.revision})"
|
9
|
+
para "Smartkiosk #{Smartkiosk::Server::VERSION} #{revision} © 2012 — #{Date.today.year}".html_safe
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/lib/assets/.gitkeep
ADDED
File without changes
|
data/lib/blueprints.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'machinist/active_record'
|
2
|
+
|
3
|
+
require 'provider_field'
|
4
|
+
|
5
|
+
User.blueprint do
|
6
|
+
full_name { Faker::Name.name }
|
7
|
+
end
|
8
|
+
|
9
|
+
Agent.blueprint do
|
10
|
+
title { Faker::Name.name }
|
11
|
+
end
|
12
|
+
|
13
|
+
ProviderProfile.blueprint do
|
14
|
+
title { Faker::HipsterIpsum.words(2).join(' ') }
|
15
|
+
end
|
16
|
+
|
17
|
+
TerminalProfile.blueprint do
|
18
|
+
title { Faker::HipsterIpsum.words(2).join(' ') }
|
19
|
+
support_phone { Faker::PhoneNumber.short_phone_number }
|
20
|
+
end
|
21
|
+
|
22
|
+
ProviderGroup.blueprint do
|
23
|
+
title { Faker::HipsterIpsum.words(2).join(' ') }
|
24
|
+
end
|
25
|
+
|
26
|
+
Terminal.blueprint do
|
27
|
+
terminal_profile { TerminalProfile.first || TerminalProfile.make! }
|
28
|
+
agent { Agent.first }
|
29
|
+
address { Faker::Address.street_address }
|
30
|
+
keyword { "TEST-" + (Terminal.count + 1).to_s }
|
31
|
+
condition { ['ok', 'warning', 'error'].sample }
|
32
|
+
state { ['active', 'disabled', 'upgrading', 'rebooting'].sample }
|
33
|
+
notified_at { DateTime.now }
|
34
|
+
collected_at { DateTime.now }
|
35
|
+
printer_error { [nil, 1, 2000].sample }
|
36
|
+
cash_acceptor_error { [nil, 1, 2000].sample }
|
37
|
+
modem_error { [nil, 1, 2000].sample }
|
38
|
+
issues_started_at { [nil, nil, DateTime.now].sample }
|
39
|
+
has_adv_monitor { [true, false].sample }
|
40
|
+
end
|
41
|
+
|
42
|
+
Payment.blueprint do
|
43
|
+
payment_type { [0,1,2].sample }
|
44
|
+
session_id { Random.new.rand(1...1000000) }
|
45
|
+
terminal { Terminal.all.sample }
|
46
|
+
gateway { Gateway.first }
|
47
|
+
provider { Provider.all.sample }
|
48
|
+
paid_amount { Random.new.rand(100..10000).round(2) }
|
49
|
+
enrolled_amount { Random.new.rand(100..10000).round(2) }
|
50
|
+
commission_amount { Random.new.rand(1..1000).round(2) }
|
51
|
+
rebate_amount { Random.new.rand(1..1000).round(2) }
|
52
|
+
paid_at { DateTime.now }
|
53
|
+
state { ['error', 'queue', 'manual', 'paid', 'checked'].sample }
|
54
|
+
end
|
55
|
+
|
56
|
+
TerminalPing.blueprint do
|
57
|
+
state { 'active' }
|
58
|
+
ip { '127.0.0.1' }
|
59
|
+
version { '0.0.1' }
|
60
|
+
banknotes { {'50' => 5, '1000' => 3} }
|
61
|
+
cash_acceptor { {'error' => nil, 'version' => '1.0'} }
|
62
|
+
printer { {'error' => nil, 'version' => '1.0'} }
|
63
|
+
modem { {'error' => nil, 'version' => '1.0', 'signal_level' => 4, 'balance' => 44.5} }
|
64
|
+
queues { {'payments' => 4, 'orders' => 0} }
|
65
|
+
end
|
66
|
+
|
67
|
+
Provider.blueprint do
|
68
|
+
title { Faker::HipsterIpsum.words(2).join(' ') }
|
69
|
+
provider_profile { ProviderProfile.first || ProviderProfile.make! }
|
70
|
+
provider_group { ProviderGroup.first || ProviderGroup.make! }
|
71
|
+
end
|
72
|
+
|
73
|
+
ProviderField.blueprint do
|
74
|
+
keyword { Faker::Lorem.word }
|
75
|
+
title { Faker::HipsterIpsum.word }
|
76
|
+
kind { ['phone', 'string', 'date', 'select'].sample }
|
77
|
+
values { Faker::HipsterIpsum.words(3).join(',') }
|
78
|
+
mask { ['1-x-2', '1-1', nil].sample }
|
79
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module DateExpander extend ActiveSupport::Concern
|
2
|
+
included do
|
3
|
+
cattr_accessor :date_expander_field
|
4
|
+
expand_date_from :created_at
|
5
|
+
|
6
|
+
before_create do
|
7
|
+
x = self.class.date_expander_field
|
8
|
+
x = self.send(x)
|
9
|
+
|
10
|
+
if self.class.date_expander_field == :created_at && x.blank?
|
11
|
+
x = DateTime.now
|
12
|
+
end
|
13
|
+
|
14
|
+
unless x.blank?
|
15
|
+
self.hour = x.change(:min => 0)
|
16
|
+
self.day = x.change(:hour => 0).to_date
|
17
|
+
self.month = x.change(:day => 1, :hour => 0).to_date
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
before_update do
|
22
|
+
x = self.class.date_expander_field
|
23
|
+
x = self.send(x)
|
24
|
+
|
25
|
+
unless x.blank?
|
26
|
+
self.hour = x.change(:min => 0)
|
27
|
+
self.day = x.change(:hour => 0).to_date
|
28
|
+
self.month = x.change(:day => 1, :hour => 0).to_date
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
module ClassMethods
|
34
|
+
def expand_date_from(field)
|
35
|
+
self.date_expander_field = field
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'dav4rack/file_resource'
|
2
|
+
|
3
|
+
module DAV4Rack
|
4
|
+
|
5
|
+
class BuildResource < FileResource
|
6
|
+
|
7
|
+
# TODO: This is a workaround of Rack bug
|
8
|
+
# Fix is in master which is incompatible with current Rails (facepalm)
|
9
|
+
# https://github.com/rack/rack/commit/7c36a88f73339bebe8b91b27e47ac958a7965f4f
|
10
|
+
#
|
11
|
+
# The whole method should be removed as soon as new Rack is released
|
12
|
+
def get(request, response)
|
13
|
+
return super unless stat.directory?
|
14
|
+
|
15
|
+
response.body = ""
|
16
|
+
|
17
|
+
rack_directory = Rack::Directory.new(root).call(request.env)[2]
|
18
|
+
|
19
|
+
rack_directory.files.map do |x|
|
20
|
+
x[0].gsub! /^#{Regexp.escape('%2Fbuilds')}/, '/builds'
|
21
|
+
x
|
22
|
+
end
|
23
|
+
|
24
|
+
rack_directory.each do |line|
|
25
|
+
response.body << line
|
26
|
+
end
|
27
|
+
response['Content-Length'] = response.body.bytesize.to_s
|
28
|
+
OK
|
29
|
+
end
|
30
|
+
|
31
|
+
def put(*args)
|
32
|
+
raise HTTPStatus::Forbidden
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete(*args)
|
36
|
+
raise HTTPStatus::Forbidden
|
37
|
+
end
|
38
|
+
|
39
|
+
def copy(*args)
|
40
|
+
raise HTTPStatus::Forbidden
|
41
|
+
end
|
42
|
+
|
43
|
+
def move(*args)
|
44
|
+
raise HTTPStatus::Forbidden
|
45
|
+
end
|
46
|
+
|
47
|
+
def make_collection
|
48
|
+
raise HTTPStatus::Forbidden
|
49
|
+
end
|
50
|
+
|
51
|
+
protected
|
52
|
+
|
53
|
+
def prop_hash
|
54
|
+
{}
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Formtastic
|
2
|
+
module Inputs
|
3
|
+
class SelectableCheckBoxesInput < CheckBoxesInput
|
4
|
+
def to_html
|
5
|
+
input_wrapping do
|
6
|
+
choices_wrapping do
|
7
|
+
legend_html <<
|
8
|
+
hidden_field_for_all <<
|
9
|
+
choices_group_wrapping do
|
10
|
+
select_all_html +
|
11
|
+
collection.map { |choice|
|
12
|
+
choice_wrapping(choice_wrapping_html_options(choice)) do
|
13
|
+
choice_html(choice)
|
14
|
+
end
|
15
|
+
}.join("\n").html_safe
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def select_all_html
|
22
|
+
choice_wrapping({}) do
|
23
|
+
check_box = template.check_box_tag(nil, nil, false,
|
24
|
+
:onclick => <<-JS
|
25
|
+
selector = $(this);
|
26
|
+
condition = selector.is(':checked');
|
27
|
+
|
28
|
+
selector.closest('.choices-group').find('[type=checkbox]').attr('checked', condition);
|
29
|
+
JS
|
30
|
+
)
|
31
|
+
|
32
|
+
template.content_tag(:label,
|
33
|
+
check_box << I18n.t('select_all')
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module ReportBuilder
|
2
|
+
def self.constantize(keyword)
|
3
|
+
"#{keyword.camelize}Report".constantize rescue false
|
4
|
+
end
|
5
|
+
|
6
|
+
class Base
|
7
|
+
attr_accessor :report
|
8
|
+
attr_accessor :template
|
9
|
+
|
10
|
+
def self.requires_dates!
|
11
|
+
@requires_dates = true
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.requires_dates?
|
15
|
+
!!@requires_dates
|
16
|
+
end
|
17
|
+
|
18
|
+
def requires_dates?
|
19
|
+
self.class.requires_dates?
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(report=nil)
|
23
|
+
unless report.blank?
|
24
|
+
self.report = report
|
25
|
+
self.template = report.report_template
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def keyword
|
30
|
+
self.class.name.underscore.gsub('_report', '')
|
31
|
+
end
|
32
|
+
|
33
|
+
def arelize(field)
|
34
|
+
field = field.split('.')
|
35
|
+
table = tables[field.first]
|
36
|
+
|
37
|
+
raise "Table `#{field.first}' not found for `#{template.kind}' report kind" if table.blank?
|
38
|
+
|
39
|
+
table[field.last.to_sym]
|
40
|
+
end
|
41
|
+
|
42
|
+
def query
|
43
|
+
query = context(report.start, report.finish)
|
44
|
+
|
45
|
+
aggregate = {
|
46
|
+
'postgresql' => 'MIN'
|
47
|
+
}[ActiveRecord::Base.configurations[Rails.env]['adapter']]
|
48
|
+
|
49
|
+
fields = template.fields.select{|x| !x.blank?}.each do |field|
|
50
|
+
projection = arelize(field)
|
51
|
+
|
52
|
+
if !aggregate.blank? && !template.groupping.blank?
|
53
|
+
projection = Arel::Nodes::NamedFunction.new(
|
54
|
+
aggregate, [ projection ]
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
projection = projection.as("\"#{field}\"")
|
59
|
+
query = query.project(projection)
|
60
|
+
end
|
61
|
+
|
62
|
+
order = arelize(template.sorting) unless template.sorting.blank?
|
63
|
+
order = order.desc if !order.blank? && template.sort_desc
|
64
|
+
query = query.group(arelize template.groupping) unless template.groupping.blank?
|
65
|
+
query = query.order(order) unless order.blank?
|
66
|
+
|
67
|
+
unless template.conditions.blank?
|
68
|
+
template.conditions.each do |column, value|
|
69
|
+
next if value.blank?
|
70
|
+
|
71
|
+
if value.is_a?(Array)
|
72
|
+
query = query.where(arelize(column).in(value))
|
73
|
+
else
|
74
|
+
query = query.where(arelize(column).eq(value))
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
unless template.calculations.blank?
|
80
|
+
template.calculations.select{|x| !x.blank?}.each do |calculation|
|
81
|
+
query = calculations[calculation].call(query, template)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
query.to_sql
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/seeder.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'blueprints'
|
4
|
+
|
5
|
+
require 'role'
|
6
|
+
require 'provider_gateway'
|
7
|
+
require 'terminal_profile_promotion'
|
8
|
+
|
9
|
+
class Seeder
|
10
|
+
seeds_root = File.expand_path "../../db/seeds/", __FILE__
|
11
|
+
|
12
|
+
cattr_accessor :engines
|
13
|
+
cattr_accessor :system_receipt_templates_path, :providers_receipt_template_path
|
14
|
+
attr_accessor :user, :agent, :terminals, :dummy
|
15
|
+
|
16
|
+
@@engines = []
|
17
|
+
@@system_receipt_templates_path = "#{seeds_root}/receipt_templates/system/*.txt"
|
18
|
+
@@providers_receipt_template_path = "#{seeds_root}/receipt_templates/payment.txt"
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
seed_roles
|
22
|
+
|
23
|
+
@user = User.make! :root => true, :email => 'admin@example.com', :password => 'password'
|
24
|
+
@agent = Agent.make!
|
25
|
+
@terminals = []
|
26
|
+
end
|
27
|
+
|
28
|
+
def truncate_database
|
29
|
+
DatabaseCleaner.strategy = :truncation
|
30
|
+
DatabaseCleaner.clean
|
31
|
+
end
|
32
|
+
|
33
|
+
def seed_engines
|
34
|
+
self.class.engines.each do |e|
|
35
|
+
e.const_get('Engine').load_seed
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def seed_roles
|
40
|
+
Role.entries.each do |x|
|
41
|
+
Role.create! :keyword => x
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def seed_gateways
|
46
|
+
@dummy = Gateway.create! :title => 'Заглушка', :keyword => 'dummy', :payzilla => 'dummy'
|
47
|
+
end
|
48
|
+
|
49
|
+
def seed_terminal(keyword)
|
50
|
+
Terminal.make!(:keyword => keyword, :agent => @agent).ping! TerminalPing.make
|
51
|
+
end
|
52
|
+
|
53
|
+
def seed_test_terminals
|
54
|
+
100.times do |i|
|
55
|
+
@terminals << Terminal.make!(:agent => @agent)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def seed_terminal_profiles
|
60
|
+
TerminalProfile.make!
|
61
|
+
end
|
62
|
+
|
63
|
+
def seed_test_providers
|
64
|
+
Provider.make! :keyword => 'first'
|
65
|
+
Provider.make! :keyword => 'second'
|
66
|
+
Provider.make! :keyword => 'third'
|
67
|
+
Provider.make! :keyword => 'fourth'
|
68
|
+
|
69
|
+
Provider.all.each do |p|
|
70
|
+
ProviderGateway.create! :provider => p, :gateway => @dummy, :priority => 1
|
71
|
+
|
72
|
+
([1,5].sample).times do
|
73
|
+
ProviderField.make! :provider => p
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def seed_test_terminal_profile_promotions
|
79
|
+
profile = TerminalProfile.first
|
80
|
+
|
81
|
+
Provider.all.each_with_index do |p, i|
|
82
|
+
TerminalProfilePromotion.create! :terminal_profile => profile, :provider => p
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def seed_test_payments
|
87
|
+
100.times do |i|
|
88
|
+
Payment.make! :agent => @agent, :terminal => @terminals.sample, :provider_gateway => @dummy.provider_gateways.sample, :gateway_error => [nil, -1].sample
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def seed_receipt_templates
|
93
|
+
Dir[self.class.system_receipt_templates_path].each do |rt|
|
94
|
+
SystemReceiptTemplate.create! :keyword => File.basename(rt).gsub('.txt', ''), :template => File.read(rt)
|
95
|
+
end
|
96
|
+
|
97
|
+
ProviderReceiptTemplate.create!(
|
98
|
+
:system => true,
|
99
|
+
:template => File.read(providers_receipt_template_path)
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|