brisk-bills 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/COPYING +674 -0
- data/COPYING.LESSER +165 -0
- data/INSTALL +5 -0
- data/README +22 -0
- data/Rakefile +11 -0
- data/TODO.txt +112 -0
- data/app/controllers/admin/activities_controller.rb +151 -0
- data/app/controllers/admin/activities_controller/adjustment.rb +16 -0
- data/app/controllers/admin/activities_controller/labor.rb +119 -0
- data/app/controllers/admin/activities_controller/labor/slimtimer.rb +28 -0
- data/app/controllers/admin/activities_controller/material.rb +20 -0
- data/app/controllers/admin/activities_controller/proposal.rb +15 -0
- data/app/controllers/admin/activities_with_prices_controller.rb +68 -0
- data/app/controllers/admin/adjustments_controller.rb +22 -0
- data/app/controllers/admin/client_accounting_controller.rb +49 -0
- data/app/controllers/admin/client_financial_transactions_controller.rb +24 -0
- data/app/controllers/admin/client_representatives_controller.rb +31 -0
- data/app/controllers/admin/clients_controller.rb +31 -0
- data/app/controllers/admin/employee_client_labor_rate_controller.rb +30 -0
- data/app/controllers/admin/employees_controller.rb +32 -0
- data/app/controllers/admin/employees_controller/slimtimer.rb +29 -0
- data/app/controllers/admin/invoices_controller.rb +165 -0
- data/app/controllers/admin/labors_controller.rb +103 -0
- data/app/controllers/admin/labors_controller/slimtimer.rb +31 -0
- data/app/controllers/admin/materials_controller.rb +24 -0
- data/app/controllers/admin/payments_controller.rb +75 -0
- data/app/controllers/admin/proposals_controller.rb +22 -0
- data/app/controllers/admin/settings_controller.rb +23 -0
- data/app/controllers/application_controller.rb +22 -0
- data/app/controllers/authentication_controller.rb +131 -0
- data/app/helpers/activity_type_model_helper.rb +194 -0
- data/app/helpers/admin/activities_helper.rb +110 -0
- data/app/helpers/admin/activities_helper/labor_helper.rb +28 -0
- data/app/helpers/admin/activities_helper/proposal_helper.rb +11 -0
- data/app/helpers/admin/activities_helper/slimtimer_helper.rb +13 -0
- data/app/helpers/admin/activities_with_prices_helper.rb +17 -0
- data/app/helpers/admin/activity_tax_controller_helper.rb +48 -0
- data/app/helpers/admin/activity_tax_field_helper.rb +33 -0
- data/app/helpers/admin/activity_type_controller_helper.rb +83 -0
- data/app/helpers/admin/activity_type_field_helper.rb +45 -0
- data/app/helpers/admin/adjustments_helper.rb +5 -0
- data/app/helpers/admin/client_accounting_helper.rb +13 -0
- data/app/helpers/admin/client_financial_transactions_helper.rb +9 -0
- data/app/helpers/admin/client_representatives_helper.rb +26 -0
- data/app/helpers/admin/clients_helper.rb +6 -0
- data/app/helpers/admin/employee_client_labor_rate_helper.rb +77 -0
- data/app/helpers/admin/employees_helper.rb +9 -0
- data/app/helpers/admin/employees_helper/slimtimer_helper.rb +2 -0
- data/app/helpers/admin/has_credential_column_helper.rb +60 -0
- data/app/helpers/admin/invoices_helper.rb +59 -0
- data/app/helpers/admin/is_active_column_helper.rb +46 -0
- data/app/helpers/admin/labors_helper.rb +20 -0
- data/app/helpers/admin/labors_helper/slimtimer_helper.rb +13 -0
- data/app/helpers/admin/materials_helper.rb +5 -0
- data/app/helpers/admin/payments_helper.rb +41 -0
- data/app/helpers/admin/proposals_helper.rb +3 -0
- data/app/helpers/admin/settings_helper.rb +8 -0
- data/app/helpers/admin_layout_helper.rb +91 -0
- data/app/helpers/application_helper.rb +27 -0
- data/app/helpers/authentication_helper.rb +61 -0
- data/app/helpers/extensible_object_helper.rb +28 -0
- data/app/helpers/has_credential_model_helper.rb +39 -0
- data/app/helpers/invoice_pdf_helper.rb +71 -0
- data/app/helpers/is_active_model_helper.rb +40 -0
- data/app/helpers/money_model_helper.rb +21 -0
- data/app/model_views/client_accounting.rb +5 -0
- data/app/model_views/client_financial_transaction.rb +15 -0
- data/app/model_views/invoices_with_total.rb +36 -0
- data/app/models/activity.rb +104 -0
- data/app/models/activity/adjustment.rb +34 -0
- data/app/models/activity/labor.rb +91 -0
- data/app/models/activity/labor/slimtimer.rb +28 -0
- data/app/models/activity/material.rb +16 -0
- data/app/models/activity/proposal.rb +17 -0
- data/app/models/activity_type.rb +2 -0
- data/app/models/client.rb +93 -0
- data/app/models/client_eventlog.rb +5 -0
- data/app/models/client_representative.rb +22 -0
- data/app/models/credential.rb +195 -0
- data/app/models/employee.rb +49 -0
- data/app/models/employee/labor.rb +13 -0
- data/app/models/employee/slimtimer.rb +43 -0
- data/app/models/employee_client_labor_rate.rb +20 -0
- data/app/models/invoice.rb +280 -0
- data/app/models/invoice_payment.rb +8 -0
- data/app/models/notifier.rb +85 -0
- data/app/models/payment.rb +108 -0
- data/app/models/payment_method.rb +7 -0
- data/app/models/setting.rb +39 -0
- data/app/models/slimtimer_task.rb +6 -0
- data/app/models/slimtimer_time_entry.rb +69 -0
- data/app/views/admin/activities/_adjustment_column.rhtml +23 -0
- data/app/views/admin/activities/_form.rhtml +20 -0
- data/app/views/admin/activities/_form_attribute.rhtml +12 -0
- data/app/views/admin/activities/_labor_column.rhtml +17 -0
- data/app/views/admin/activities/_material_column.rhtml +10 -0
- data/app/views/admin/activities/_proposal_column.rhtml +11 -0
- data/app/views/admin/activities_with_prices/move_to_invoice.rhtml +44 -0
- data/app/views/admin/activities_with_prices/move_to_invoice.rjs +9 -0
- data/app/views/admin/invoices/download.rpdf +224 -0
- data/app/views/authentication/email.rjs +9 -0
- data/app/views/authentication/login.rhtml +75 -0
- data/app/views/authentication/login.rjs +14 -0
- data/app/views/authentication/reset_password_via_token.rhtml +16 -0
- data/app/views/authentication/reset_password_via_token.rjs +6 -0
- data/app/views/authentication/sign_in_error.rjs +2 -0
- data/app/views/layouts/_navigation_tree.rhtml +15 -0
- data/app/views/layouts/admin.rhtml +26 -0
- data/app/views/layouts/public.rhtml +18 -0
- data/app/views/notifier/_email_footer.html.rhtml +12 -0
- data/app/views/notifier/_email_footer.plain.rhtml +3 -0
- data/app/views/notifier/_email_header.html.rhtml +53 -0
- data/app/views/notifier/invoice_available.html.rhtml +5 -0
- data/app/views/notifier/invoice_available.plain.rhtml +4 -0
- data/app/views/notifier/reset_password_requested.html.rhtml +15 -0
- data/app/views/notifier/reset_password_requested.plain.rhtml +9 -0
- data/bin/brisk-bills +51 -0
- data/config/boot.rb +164 -0
- data/config/environment.rb +39 -0
- data/config/environments/development.rb +17 -0
- data/config/environments/production.rb +18 -0
- data/config/environments/test.rb +19 -0
- data/config/locale/en.rb +26 -0
- data/config/routes.rb +20 -0
- data/config/secrets.yml +2 -0
- data/db/migrate/001_create_employees.rb +14 -0
- data/db/migrate/002_create_employee_slimtimers.rb +14 -0
- data/db/migrate/003_create_slimtimer_tasks.rb +21 -0
- data/db/migrate/004_create_slimtimer_time_entries.rb +25 -0
- data/db/migrate/005_create_clients.rb +12 -0
- data/db/migrate/006_create_client_representatives.rb +16 -0
- data/db/migrate/007_create_client_eventlogs.rb +13 -0
- data/db/migrate/008_create_activities.rb +17 -0
- data/db/migrate/009_create_activity_labors.rb +16 -0
- data/db/migrate/010_create_employee_client_labor_rates.rb +19 -0
- data/db/migrate/011_create_activity_adjustments.rb +16 -0
- data/db/migrate/012_create_activity_materials.rb +16 -0
- data/db/migrate/013_create_activity_proposals.rb +18 -0
- data/db/migrate/014_create_invoices.rb +16 -0
- data/db/migrate/015_create_payments.rb +18 -0
- data/db/migrate/016_create_payment_methods.rb +18 -0
- data/db/migrate/017_create_invoice_payments.rb +14 -0
- data/db/migrate/018_create_activity_types.rb +37 -0
- data/db/migrate/019_create_settings.rb +45 -0
- data/db/migrate/020_is_active_employees_clients.rb +11 -0
- data/db/migrate/021_create_views_and_indexes.rb +78 -0
- data/db/migrate/022_create_client_financial_transactions.rb +32 -0
- data/db/migrate/023_create_credentials_migrate_representatives.rb +133 -0
- data/db/migrate/024_updates_for_sales_tax.rb +91 -0
- data/db/migrate/025_alter_credentials_for_reset.rb +11 -0
- data/db/migrate/026_create_st_settings.rb +17 -0
- data/db/migrate/027_create_sessions.rb +16 -0
- data/db/migrate/028_money_to_cents.rb +136 -0
- data/db/schema.rb +301 -0
- data/lib/brisk-bills.rb +17 -0
- data/lib/brisk-bills/initializer.rb +100 -0
- data/lib/dti-navigation-menu/lib/dti-navigation-menu.rb +27 -0
- data/lib/generators/generator_base_extension.rb +16 -0
- data/lib/generators/instance/instance_generator.rb +117 -0
- data/lib/generators/instance/templates/databases/mysql.yml +47 -0
- data/lib/generators/instance/templates/instance_boot.rb +166 -0
- data/lib/generators/instance/templates/instance_environment.rb +65 -0
- data/lib/generators/instance/templates/instance_generate +18 -0
- data/lib/generators/instance/templates/instance_rakefile +3 -0
- data/lib/generators/instance/templates/instance_routes.rb +1 -0
- data/lib/tasks/create_last_months_invoices.rake +37 -0
- data/lib/tasks/credential_tasks.rake +47 -0
- data/lib/tasks/first_time_setup.rake +96 -0
- data/lib/tasks/instance.rake +27 -0
- data/lib/tasks/invoice_as_csv.rake +32 -0
- data/lib/tasks/package.rake +120 -0
- data/lib/tasks/slimtimer_import.rake +198 -0
- data/lib/utilities.rb +18 -0
- data/log/.keep +0 -0
- data/public/.htaccess +40 -0
- data/public/404.html +30 -0
- data/public/500.html +30 -0
- data/public/blank.html +33 -0
- data/public/blank_iframe.html +2 -0
- data/public/dispatch.cgi +10 -0
- data/public/dispatch.fcgi +24 -0
- data/public/dispatch.rb +10 -0
- data/public/favicon.ico +0 -0
- data/public/images/active_scaffold/DO_NOT_EDIT +2 -0
- data/public/images/active_scaffold/default/add.gif +0 -0
- data/public/images/active_scaffold/default/arrow_down.gif +0 -0
- data/public/images/active_scaffold/default/arrow_up.gif +0 -0
- data/public/images/active_scaffold/default/close.gif +0 -0
- data/public/images/active_scaffold/default/cross.png +0 -0
- data/public/images/active_scaffold/default/indicator-small.gif +0 -0
- data/public/images/active_scaffold/default/indicator.gif +0 -0
- data/public/images/active_scaffold/default/magnifier.png +0 -0
- data/public/images/background.gif +0 -0
- data/public/images/brisk-bills-logo.gif +0 -0
- data/public/images/calendar_date_select/calendar.gif +0 -0
- data/public/images/dti-logo.gif +0 -0
- data/public/images/dti-logo.jpg +0 -0
- data/public/images/favicon.ico +0 -0
- data/public/images/invoice-background.jpg +0 -0
- data/public/images/login-form-spinner.gif +0 -0
- data/public/images/nav-arrow.gif +0 -0
- data/public/images/notice-error.gif +0 -0
- data/public/images/notice-info.gif +0 -0
- data/public/images/rails.png +0 -0
- data/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
- data/public/javascripts/active_scaffold/default/active_scaffold.js +430 -0
- data/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
- data/public/javascripts/active_scaffold/default/form_enhancements.js +114 -0
- data/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
- data/public/javascripts/application.js +2 -0
- data/public/javascripts/briskbills-quick-helpers.js +9 -0
- data/public/javascripts/builder.js +136 -0
- data/public/javascripts/controls.js +963 -0
- data/public/javascripts/dragdrop.js +973 -0
- data/public/javascripts/effects.js +1128 -0
- data/public/javascripts/modalbox.js +573 -0
- data/public/javascripts/prototype.js +4320 -0
- data/public/javascripts/scriptaculous.js +58 -0
- data/public/javascripts/shadedborder.js +249 -0
- data/public/javascripts/slider.js +275 -0
- data/public/javascripts/sound.js +55 -0
- data/public/javascripts/unittest.js +568 -0
- data/public/robots.txt +1 -0
- data/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
- data/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
- data/public/stylesheets/active_scaffold/default/stylesheet.css +809 -0
- data/public/stylesheets/admin/global.css +152 -0
- data/public/stylesheets/admin/pages.css +137 -0
- data/public/stylesheets/admin/screen.css +3 -0
- data/public/stylesheets/admin/structure.css +88 -0
- data/public/stylesheets/modalbox.css +95 -0
- data/public/stylesheets/public/global.css +36 -0
- data/public/stylesheets/public/pages.css +105 -0
- data/public/stylesheets/public/screen.css +3 -0
- data/public/stylesheets/public/structure.css +0 -0
- data/public/stylesheets/spinner.gif +0 -0
- data/script/about +3 -0
- data/script/breakpointer +3 -0
- data/script/console +3 -0
- data/script/dbconsole +3 -0
- data/script/destroy +3 -0
- data/script/generate +3 -0
- data/script/performance/benchmarker +3 -0
- data/script/performance/profiler +3 -0
- data/script/performance/request +3 -0
- data/script/plugin +3 -0
- data/script/process/inspector +3 -0
- data/script/process/reaper +3 -0
- data/script/process/spawner +3 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/test/fixtures/activities.yml +28 -0
- data/test/fixtures/activity_adjustments.yml +7 -0
- data/test/fixtures/activity_labors.yml +25 -0
- data/test/fixtures/activity_materials.yml +7 -0
- data/test/fixtures/activity_proposals.yml +7 -0
- data/test/fixtures/activity_types.yml +23 -0
- data/test/fixtures/client_eventlogs.yml +5 -0
- data/test/fixtures/client_financial_transactions.yml +7 -0
- data/test/fixtures/client_representatives.yml +56 -0
- data/test/fixtures/clients.yml +172 -0
- data/test/fixtures/credentials.yml +34 -0
- data/test/fixtures/employee_client_labor_rates.yml +365 -0
- data/test/fixtures/employee_slimtimers.yml +19 -0
- data/test/fixtures/employees.yml +22 -0
- data/test/fixtures/invoice_payments.yml +7 -0
- data/test/fixtures/invoices.yml +7 -0
- data/test/fixtures/payment_methods.yml +7 -0
- data/test/fixtures/payments.yml +7 -0
- data/test/fixtures/settings.yml +7 -0
- data/test/fixtures/slimtimer_tasks.yml +5 -0
- data/test/fixtures/slimtimer_time_entries.yml +5 -0
- data/test/functional/admin/activities_controller_test.rb +8 -0
- data/test/functional/admin/adjustments_controller_test.rb +8 -0
- data/test/functional/admin/client_accounting_controller_test.rb +8 -0
- data/test/functional/admin/client_financial_transactions_controller_test.rb +8 -0
- data/test/functional/admin/client_representatives_controller_test.rb +8 -0
- data/test/functional/admin/clients_controller_test.rb +8 -0
- data/test/functional/admin/employee_client_labor_rate_controller_test.rb +8 -0
- data/test/functional/admin/employees/slimtimer_controller_test.rb +8 -0
- data/test/functional/admin/employees_controller_test.rb +8 -0
- data/test/functional/admin/invoices_controller_test.rb +8 -0
- data/test/functional/admin/labors_controller_test.rb +8 -0
- data/test/functional/admin/materials_controller_test.rb +8 -0
- data/test/functional/admin/payments_controller_test.rb +8 -0
- data/test/functional/admin/proposals_controller_test.rb +8 -0
- data/test/functional/admin/settings_controller_test.rb +8 -0
- data/test/functional/authentication_controller_test.rb +8 -0
- data/test/test_helper.rb +30 -0
- data/test/test_unit_factory_helper.rb +154 -0
- data/test/unit/activity/adjustment_test.rb +8 -0
- data/test/unit/activity/labor_test.rb +279 -0
- data/test/unit/activity/material_test.rb +8 -0
- data/test/unit/activity/proposal_test.rb +8 -0
- data/test/unit/activity_test.rb +83 -0
- data/test/unit/activity_type_test.rb +8 -0
- data/test/unit/client_eventlog_test.rb +10 -0
- data/test/unit/client_financial_transaction_test.rb +8 -0
- data/test/unit/client_representative_test.rb +10 -0
- data/test/unit/client_test.rb +24 -0
- data/test/unit/credential_test.rb +217 -0
- data/test/unit/employee/slimtimer_test.rb +10 -0
- data/test/unit/employee_client_labor_rate_test.rb +8 -0
- data/test/unit/employee_test.rb +25 -0
- data/test/unit/invoice_payment_test.rb +8 -0
- data/test/unit/invoice_test.rb +459 -0
- data/test/unit/notifier_test.rb +9 -0
- data/test/unit/payment_method_test.rb +8 -0
- data/test/unit/payment_test.rb +155 -0
- data/test/unit/setting_test.rb +8 -0
- data/test/unit/slimtimer_task_test.rb +10 -0
- data/test/unit/slimtimer_time_entry_test.rb +132 -0
- data/vendor/plugins/InlineAttachment-0.3.0-modified/README +79 -0
- data/vendor/plugins/InlineAttachment-0.3.0-modified/init.rb +2 -0
- data/vendor/plugins/InlineAttachment-0.3.0-modified/lib/inline_attachment.rb +136 -0
- data/vendor/plugins/InlineAttachment-0.3.0-modified/lib/tmail_content_id.rb +40 -0
- data/vendor/plugins/active_scaffold/CHANGELOG +152 -0
- data/vendor/plugins/active_scaffold/MIT-LICENSE +20 -0
- data/vendor/plugins/active_scaffold/README +28 -0
- data/vendor/plugins/active_scaffold/Rakefile +24 -0
- data/vendor/plugins/active_scaffold/environment.rb +17 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/add.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/arrow_down.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/arrow_up.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/close.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/cross.png +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/indicator-small.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/indicator.gif +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/images/magnifier.png +0 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/active_scaffold.js +430 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/dhtml_history.js +867 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/form_enhancements.js +114 -0
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/rico_corner.js +370 -0
- data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet-ie.css +35 -0
- data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet.css +809 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_add_existing_form.html.erb +40 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_create_form.html.erb +49 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_create_form_on_list.html.erb +38 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_field_search.html.erb +45 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form.html.erb +18 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association.html.erb +20 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_footer.html.erb +42 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_header.html.erb +10 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_record.html.erb +27 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_attribute.html.erb +12 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_hidden_attribute.html.erb +1 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_messages.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform.html.erb +21 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list.html.erb +37 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_actions.html.erb +13 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_calculations.html.erb +22 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_column_headings.html.erb +32 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_header.html.erb +14 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_inline_adapter.html.erb +9 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_pagination_links.html.erb +30 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_record.html.erb +35 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_live_search.html.erb +25 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_messages.html.erb +10 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_nested.html.erb +44 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_search.html.erb +21 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_show.html.erb +8 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_show_columns.html.erb +11 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_update_actions.html.erb +9 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_update_form.html.erb +53 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/add_existing.js.rjs +16 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/add_existing_form.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/create.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/delete.html.erb +13 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/destroy.js.rjs +10 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/edit_associated.js.rjs +15 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/field_search.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages.js.rjs +1 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_create.js.rjs +2 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_update.js.rjs +2 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/list.html.erb +44 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/on_create.js.rjs +25 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/on_update.js.rjs +11 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/search.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/show.html.erb +5 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/update.html.erb +8 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/update_column.js.rjs +12 -0
- data/vendor/plugins/active_scaffold/init.rb +18 -0
- data/vendor/plugins/active_scaffold/install.rb +40 -0
- data/vendor/plugins/active_scaffold/install_assets.rb +36 -0
- data/vendor/plugins/active_scaffold/lib/active_record_permissions.rb +123 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold.rb +144 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/core.rb +102 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/create.rb +120 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/delete.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/field_search.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb +77 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/live_search.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/nested.rb +215 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/search.rb +40 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/show.rb +34 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/subform.rb +17 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/update.rb +114 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/attribute_params.rb +185 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/base.rb +37 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/core.rb +189 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/create.rb +43 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/delete.rb +25 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/field_search.rb +53 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/form.rb +49 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/list.rb +134 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/live_search.rb +52 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/nested.rb +31 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/search.rb +52 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/show.rb +39 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/subform.rb +33 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/update.rb +32 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/configurable.rb +29 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/constraints.rb +178 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_columns.rb +97 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb +136 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_links.rb +47 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/actions.rb +45 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb +297 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb +75 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/error_message.rb +24 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/set.rb +62 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/sorting.rb +89 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/finder.rb +234 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb +40 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/controller_helpers.rb +25 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/country_helpers.rb +348 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb +267 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/id_helpers.rb +125 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb +178 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb +37 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/search_column_helpers.rb +172 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb +196 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/en.rb +66 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/es.yml +64 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/hu.yml +62 -0
- data/vendor/plugins/active_scaffold/lib/bridges/bridge.rb +52 -0
- data/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/bridge.rb +11 -0
- data/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/lib/as_cds_bridge.rb +53 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/bridge.rb +12 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/as_file_column_bridge.rb +49 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb +51 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/form_ui.rb +32 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/list_ui.rb +26 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/functional/file_column_keep_test.rb +43 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/mock_model.rb +9 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/test_helper.rb +15 -0
- data/vendor/plugins/active_scaffold/lib/dhtml_confirm.rb +54 -0
- data/vendor/plugins/active_scaffold/lib/extensions/action_controller_rendering.rb +20 -0
- data/vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb +87 -0
- data/vendor/plugins/active_scaffold/lib/extensions/array.rb +7 -0
- data/vendor/plugins/active_scaffold/lib/extensions/component_response_with_namespacing.rb +17 -0
- data/vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb +33 -0
- data/vendor/plugins/active_scaffold/lib/extensions/localize.rb +10 -0
- data/vendor/plugins/active_scaffold/lib/extensions/name_option_for_datetime.rb +12 -0
- data/vendor/plugins/active_scaffold/lib/extensions/nil_id_in_url_params.rb +7 -0
- data/vendor/plugins/active_scaffold/lib/extensions/resources.rb +26 -0
- data/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb +56 -0
- data/vendor/plugins/active_scaffold/lib/extensions/to_label.rb +8 -0
- data/vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb +61 -0
- data/vendor/plugins/active_scaffold/lib/extensions/unsaved_record.rb +20 -0
- data/vendor/plugins/active_scaffold/lib/extensions/usa_state.rb +46 -0
- data/vendor/plugins/active_scaffold/lib/paginator.rb +136 -0
- data/vendor/plugins/active_scaffold/lib/responds_to_parent.rb +68 -0
- data/vendor/plugins/active_scaffold/public/blank.html +33 -0
- data/vendor/plugins/active_scaffold/test/bridges/bridge_test.rb +47 -0
- data/vendor/plugins/active_scaffold/test/config/create_test.rb +55 -0
- data/vendor/plugins/active_scaffold/test/config/list_test.rb +74 -0
- data/vendor/plugins/active_scaffold/test/config/update_test.rb +17 -0
- data/vendor/plugins/active_scaffold/test/const_mocker.rb +36 -0
- data/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb +119 -0
- data/vendor/plugins/active_scaffold/test/data_structures/action_link_test.rb +78 -0
- data/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb +78 -0
- data/vendor/plugins/active_scaffold/test/data_structures/actions_test.rb +25 -0
- data/vendor/plugins/active_scaffold/test/data_structures/association_column_test.rb +41 -0
- data/vendor/plugins/active_scaffold/test/data_structures/column_test.rb +161 -0
- data/vendor/plugins/active_scaffold/test/data_structures/columns_test.rb +69 -0
- data/vendor/plugins/active_scaffold/test/data_structures/error_message_test.rb +28 -0
- data/vendor/plugins/active_scaffold/test/data_structures/set_test.rb +86 -0
- data/vendor/plugins/active_scaffold/test/data_structures/sorting_test.rb +96 -0
- data/vendor/plugins/active_scaffold/test/data_structures/standard_column_test.rb +34 -0
- data/vendor/plugins/active_scaffold/test/data_structures/virtual_column_test.rb +34 -0
- data/vendor/plugins/active_scaffold/test/extensions/active_record_test.rb +45 -0
- data/vendor/plugins/active_scaffold/test/extensions/array.rb +12 -0
- data/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb +154 -0
- data/vendor/plugins/active_scaffold/test/misc/configurable_test.rb +96 -0
- data/vendor/plugins/active_scaffold/test/misc/constraints_test.rb +175 -0
- data/vendor/plugins/active_scaffold/test/misc/finder_test.rb +70 -0
- data/vendor/plugins/active_scaffold/test/misc/lang_test.rb +12 -0
- data/vendor/plugins/active_scaffold/test/model_stub.rb +39 -0
- data/vendor/plugins/active_scaffold/test/run_all.rb +8 -0
- data/vendor/plugins/active_scaffold/test/test_helper.rb +13 -0
- data/vendor/plugins/active_scaffold/uninstall.rb +12 -0
- data/vendor/plugins/active_scaffold_as_gem/init.rb +21 -0
- data/vendor/plugins/active_scaffold_form_observation/init.rb +4 -0
- data/vendor/plugins/active_scaffold_form_observation/lib/active_scaffold_form_observation.rb +99 -0
- data/vendor/plugins/active_scaffold_full_refresh/init.rb +7 -0
- data/vendor/plugins/active_scaffold_full_refresh/lib/active_scaffold_full_refresh.rb +46 -0
- data/vendor/plugins/active_scaffold_move_column_under/init.rb +17 -0
- data/vendor/plugins/acts_as_money/README +24 -0
- data/vendor/plugins/acts_as_money/Rakefile +22 -0
- data/vendor/plugins/acts_as_money/init.rb +3 -0
- data/vendor/plugins/acts_as_money/install.rb +1 -0
- data/vendor/plugins/acts_as_money/lib/acts_as_money.rb +27 -0
- data/vendor/plugins/acts_as_money/tasks/money_tasks.rake +4 -0
- data/vendor/plugins/acts_as_money/test/money_test.rb +8 -0
- data/vendor/plugins/association_hacks/init.rb +1 -0
- data/vendor/plugins/association_hacks/lib/association_hacks.rb +27 -0
- data/vendor/plugins/railspdf/CHANGELOG +5 -0
- data/vendor/plugins/railspdf/README +88 -0
- data/vendor/plugins/railspdf/Rakefile +22 -0
- data/vendor/plugins/railspdf/TODO +1 -0
- data/vendor/plugins/railspdf/init.rb +3 -0
- data/vendor/plugins/railspdf/lib/railspdf.rb +65 -0
- data/vendor/plugins/railspdf/test/railspdf_test.rb +14 -0
- data/vendor/plugins/railspdf/test/test_helper.rb +9 -0
- data/vendor/plugins/render_component/README +37 -0
- data/vendor/plugins/render_component/Rakefile +22 -0
- data/vendor/plugins/render_component/init.rb +2 -0
- data/vendor/plugins/render_component/lib/components.rb +142 -0
- data/vendor/plugins/render_component/test/abstract_unit.rb +8 -0
- data/vendor/plugins/render_component/test/components_test.rb +140 -0
- metadata +657 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
cancel_selector = "##{element_form_id(:action => :update)} a.cancel".to_json
|
2
|
+
|
3
|
+
if controller.send :successful?
|
4
|
+
page << "$$(#{cancel_selector}).first().link.close_with_refresh();"
|
5
|
+
page.replace active_scaffold_calculations_id, :partial => 'list_calculations' if active_scaffold_config.list.columns.any? {|c| c.calculation?}
|
6
|
+
else
|
7
|
+
page << "l = $$(#{cancel_selector}).first().link;"
|
8
|
+
page.replace element_form_id(:action => :update), :partial => 'update_form'
|
9
|
+
page << "l.register_cancel_hooks();"
|
10
|
+
end
|
11
|
+
page.replace_html active_scaffold_messages_id, :partial => 'messages'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<div class="active-scaffold">
|
2
|
+
<div class="update-view <%= "#{params[:controller]}-view" %> view">
|
3
|
+
<% if active_scaffold_config.update.nested_links and active_scaffold_config.action_links.any? {|link| link.type == :record } -%>
|
4
|
+
<%= render :partial => 'update_actions', :locals => {:record => @record, :url_options => params_for(:action => :list, :id => @record.id)} %>
|
5
|
+
<% end -%>
|
6
|
+
<%= render :partial => 'update_form' -%>
|
7
|
+
</div>
|
8
|
+
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
column_span_id = element_cell_id(:id => @record.id.to_s, :action => 'update_column', :name => params[:column])
|
2
|
+
unless controller.send :successful?
|
3
|
+
page.alert(@record.errors.full_messages(active_scaffold_config).join("\n"))
|
4
|
+
@record.reload
|
5
|
+
end
|
6
|
+
column = active_scaffold_config.columns[params[:column]]
|
7
|
+
if column.inplace_edit
|
8
|
+
page.replace_html(column_span_id,format_inplace_edit_column(@record, column))
|
9
|
+
else
|
10
|
+
formatted_value = get_column_value(@record, column)
|
11
|
+
page.replace_html(column_span_id, formatted_value)
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
##
|
2
|
+
## Initialize the environment
|
3
|
+
##
|
4
|
+
unless Rails::VERSION::MAJOR == 2 && Rails::VERSION::MINOR >= 3
|
5
|
+
raise "This version of ActiveScaffold requires Rails 2.3 or higher. Please use an earlier version."
|
6
|
+
end
|
7
|
+
|
8
|
+
require File.dirname(__FILE__) + '/environment'
|
9
|
+
|
10
|
+
##
|
11
|
+
## Run the install assets script, too, just to make sure
|
12
|
+
## But at least rescue the action in production
|
13
|
+
##
|
14
|
+
begin
|
15
|
+
require File.dirname(__FILE__) + '/install_assets'
|
16
|
+
rescue
|
17
|
+
raise $! unless Rails.env == 'production'
|
18
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
##
|
2
|
+
## Install ActiveScaffold assets into /public
|
3
|
+
##
|
4
|
+
|
5
|
+
require File.dirname(__FILE__) + '/install_assets'
|
6
|
+
|
7
|
+
##
|
8
|
+
## Install Counter
|
9
|
+
##
|
10
|
+
#
|
11
|
+
# What's going on here?
|
12
|
+
# We're incrementing a web counter so we can track SVN installs of ActiveScaffold
|
13
|
+
#
|
14
|
+
# How?
|
15
|
+
# We're making a GET request to errcount.com to update a simple counter. No data is transmitted.
|
16
|
+
#
|
17
|
+
# Why?
|
18
|
+
# So we can know how many people are using ActiveScaffold and modulate our level of effort accordingly.
|
19
|
+
# Despite numerous pleas our Googly overlords still only provide us with download stats for the zip distro.
|
20
|
+
#
|
21
|
+
# *Thanks for your understanding*
|
22
|
+
#
|
23
|
+
|
24
|
+
class ErrCounter # using errcount.com
|
25
|
+
require "net/http"
|
26
|
+
|
27
|
+
@@ACCOUNT_ID = 341
|
28
|
+
@@SITE_DOMAIN = 'installs.activescaffold.com'
|
29
|
+
|
30
|
+
def self.increment
|
31
|
+
@http = Net::HTTP.new("errcount.com")
|
32
|
+
resp, data = @http.get2("/ctr/#{@@ACCOUNT_ID}.js", {'Referer' => @@SITE_DOMAIN})
|
33
|
+
puts resp.body
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
begin
|
38
|
+
ErrCounter.increment
|
39
|
+
rescue
|
40
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Workaround a problem with script/plugin and http-based repos.
|
2
|
+
# See http://dev.rubyonrails.org/ticket/8189
|
3
|
+
Dir.chdir(Dir.getwd.sub(/vendor.*/, '')) do
|
4
|
+
|
5
|
+
##
|
6
|
+
## Copy over asset files (javascript/css/images) from the plugin directory to public/
|
7
|
+
##
|
8
|
+
|
9
|
+
def copy_files(source_path, destination_path, directory)
|
10
|
+
source, destination = File.join(directory, source_path), File.join(Rails.root, destination_path)
|
11
|
+
FileUtils.mkdir(destination) unless File.exist?(destination)
|
12
|
+
FileUtils.cp_r(Dir.glob(source+'/*.*'), destination)
|
13
|
+
end
|
14
|
+
|
15
|
+
directory = File.dirname(__FILE__)
|
16
|
+
|
17
|
+
copy_files("/public", "/public", directory)
|
18
|
+
|
19
|
+
available_frontends = Dir[File.join(directory, 'frontends', '*')].collect { |d| File.basename d }
|
20
|
+
[ :stylesheets, :javascripts, :images].each do |asset_type|
|
21
|
+
path = "/public/#{asset_type}/active_scaffold"
|
22
|
+
copy_files(path, path, directory)
|
23
|
+
|
24
|
+
File.open(File.join(Rails.root, path, 'DO_NOT_EDIT'), 'w') do |f|
|
25
|
+
f.puts "Any changes made to files in sub-folders will be lost."
|
26
|
+
f.puts "See http://activescaffold.com/tutorials/faq#custom-css."
|
27
|
+
end
|
28
|
+
|
29
|
+
available_frontends.each do |frontend|
|
30
|
+
source = "/frontends/#{frontend}/#{asset_type}/"
|
31
|
+
destination = "/public/#{asset_type}/active_scaffold/#{frontend}"
|
32
|
+
copy_files(source, destination, directory)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# This module attempts to create permissions conventions for your ActiveRecord models. It supports english-based
|
2
|
+
# methods that let you restrict access per-model, per-record, per-column, per-action, and per-user. All at once.
|
3
|
+
#
|
4
|
+
# You may define instance methods in the following formats:
|
5
|
+
# def #{column}_authorized_for_#{action}?
|
6
|
+
# def #{column}_authorized?
|
7
|
+
# def authorized_for_#{action}?
|
8
|
+
#
|
9
|
+
# Your methods should allow for the following special cases:
|
10
|
+
# * cron scripts
|
11
|
+
# * guest users (or nil current_user objects)
|
12
|
+
module ActiveRecordPermissions
|
13
|
+
# ActiveRecordPermissions needs to know what method on your ApplicationController will return the current user,
|
14
|
+
# if available. This defaults to the :current_user method. You may configure this in your environment.rb if you
|
15
|
+
# have a different setup.
|
16
|
+
def self.current_user_method=(v); @@current_user_method = v; end
|
17
|
+
def self.current_user_method; @@current_user_method; end
|
18
|
+
@@current_user_method = :current_user
|
19
|
+
|
20
|
+
# Whether the default permission is permissive or not
|
21
|
+
# If set to true, then everything's allowed until configured otherwise
|
22
|
+
def self.default_permission=(v); @@default_permission = v; end
|
23
|
+
def self.default_permission; @@default_permission; end
|
24
|
+
@@default_permission = true
|
25
|
+
|
26
|
+
# This is a module aimed at making the current_user available to ActiveRecord models for permissions.
|
27
|
+
module ModelUserAccess
|
28
|
+
module Controller
|
29
|
+
def self.included(base)
|
30
|
+
base.prepend_before_filter :assign_current_user_to_models
|
31
|
+
end
|
32
|
+
|
33
|
+
# We need to give the ActiveRecord classes a handle to the current user. We don't want to just pass the object,
|
34
|
+
# because the object may change (someone may log in or out). So we give ActiveRecord a proc that ties to the
|
35
|
+
# current_user_method on this ApplicationController.
|
36
|
+
def assign_current_user_to_models
|
37
|
+
ActiveRecord::Base.current_user_proc = proc {send(ActiveRecordPermissions.current_user_method)}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
module Model
|
42
|
+
def self.included(base)
|
43
|
+
base.extend ClassMethods
|
44
|
+
end
|
45
|
+
|
46
|
+
module ClassMethods
|
47
|
+
# The proc to call that retrieves the current_user from the ApplicationController.
|
48
|
+
attr_accessor :current_user_proc
|
49
|
+
|
50
|
+
# Class-level access to the current user
|
51
|
+
def current_user
|
52
|
+
ActiveRecord::Base.current_user_proc.call if ActiveRecord::Base.current_user_proc
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Instance-level access to the current user
|
57
|
+
def current_user
|
58
|
+
self.class.current_user
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
module Permissions
|
64
|
+
def self.included(base)
|
65
|
+
base.extend ClassMethods
|
66
|
+
end
|
67
|
+
|
68
|
+
# A generic authorization query. This is what will be called programatically, since
|
69
|
+
# the actual permission methods can't be guaranteed to exist. And because we want to
|
70
|
+
# intelligently combine multiple applicable methods.
|
71
|
+
#
|
72
|
+
# options[:action] should be a CRUD verb (:create, :read, :update, :destroy)
|
73
|
+
# options[:column] should be the name of a model attribute
|
74
|
+
def authorized_for?(options = {})
|
75
|
+
raise ArgumentError, "unknown action #{options[:action]}" if options[:action] and ![:create, :read, :update, :destroy].include?(options[:action])
|
76
|
+
|
77
|
+
# collect the possibly-related methods that actually exist
|
78
|
+
methods = [
|
79
|
+
column_security_method(options[:column]),
|
80
|
+
action_security_method(options[:action]),
|
81
|
+
column_and_action_security_method(options[:column], options[:action])
|
82
|
+
].compact.select {|m| respond_to?(m)}
|
83
|
+
|
84
|
+
# if any method returns false, then return false
|
85
|
+
return false if methods.any? {|m| !send(m)}
|
86
|
+
|
87
|
+
# if any method actually exists then it must've returned true, so return true
|
88
|
+
return true unless methods.empty?
|
89
|
+
|
90
|
+
# if no method exists, return the default permission
|
91
|
+
return ActiveRecordPermissions.default_permission
|
92
|
+
end
|
93
|
+
|
94
|
+
# Because any class-level queries get delegated to the instance level via a new record,
|
95
|
+
# it's useful to know when the authorization query is meant for a specific record or not.
|
96
|
+
# But using new_record? is confusing, even though accurate. So this is basically just a wrapper.
|
97
|
+
def existing_record_check?
|
98
|
+
!new_record?
|
99
|
+
end
|
100
|
+
|
101
|
+
module ClassMethods
|
102
|
+
# Class level just delegates to instance level
|
103
|
+
def authorized_for?(*args)
|
104
|
+
@authorized_for_delegatee ||= self.new
|
105
|
+
@authorized_for_delegatee.authorized_for?(*args)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def column_security_method(column)
|
112
|
+
"#{column}_authorized?" if column
|
113
|
+
end
|
114
|
+
|
115
|
+
def action_security_method(action)
|
116
|
+
"authorized_for_#{action}?" if action
|
117
|
+
end
|
118
|
+
|
119
|
+
def column_and_action_security_method(column, action)
|
120
|
+
"#{column}_authorized_for_#{action}?" if column and action
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
class ControllerNotFound < RuntimeError; end
|
3
|
+
class DependencyFailure < RuntimeError; end
|
4
|
+
class MalformedConstraint < RuntimeError; end
|
5
|
+
class RecordNotAllowed < SecurityError; end
|
6
|
+
class ReverseAssociationRequired < RuntimeError; end
|
7
|
+
|
8
|
+
def self.included(base)
|
9
|
+
base.extend(ClassMethods)
|
10
|
+
base.module_eval do
|
11
|
+
# TODO: these should be in actions/core
|
12
|
+
before_filter :handle_user_settings
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.set_defaults(&block)
|
17
|
+
ActiveScaffold::Config::Core.configure &block
|
18
|
+
end
|
19
|
+
|
20
|
+
def active_scaffold_config
|
21
|
+
self.class.active_scaffold_config
|
22
|
+
end
|
23
|
+
|
24
|
+
def active_scaffold_config_for(klass)
|
25
|
+
self.class.active_scaffold_config_for(klass)
|
26
|
+
end
|
27
|
+
|
28
|
+
def active_scaffold_session_storage
|
29
|
+
id = params[:eid] || params[:controller]
|
30
|
+
session_index = "as:#{id}"
|
31
|
+
session[session_index] ||= {}
|
32
|
+
session[session_index]
|
33
|
+
end
|
34
|
+
|
35
|
+
# at some point we need to pass the session and params into config. we'll just take care of that before any particular action occurs by passing those hashes off to the UserSettings class of each action.
|
36
|
+
def handle_user_settings
|
37
|
+
if self.class.uses_active_scaffold?
|
38
|
+
active_scaffold_config.actions.each do |action_name|
|
39
|
+
conf_instance = active_scaffold_config.send(action_name) rescue next
|
40
|
+
next if conf_instance.class::UserSettings == ActiveScaffold::Config::Base::UserSettings # if it hasn't been extended, skip it
|
41
|
+
active_scaffold_session_storage[action_name] ||= {}
|
42
|
+
conf_instance.user = conf_instance.class::UserSettings.new(conf_instance, active_scaffold_session_storage[action_name], params)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module ClassMethods
|
48
|
+
def active_scaffold(model_id = nil, &block)
|
49
|
+
# initialize bridges here
|
50
|
+
ActiveScaffold::Bridge.run_all
|
51
|
+
|
52
|
+
# converts Foo::BarController to 'bar' and FooBarsController to 'foo_bar' and AddressController to 'address'
|
53
|
+
model_id = self.to_s.split('::').last.sub(/Controller$/, '').pluralize.singularize.underscore unless model_id
|
54
|
+
|
55
|
+
# run the configuration
|
56
|
+
@active_scaffold_config = ActiveScaffold::Config::Core.new(model_id)
|
57
|
+
self.active_scaffold_config.configure &block if block_given?
|
58
|
+
self.active_scaffold_config._load_action_columns
|
59
|
+
|
60
|
+
# defines the attribute read methods on the model, so record.send() doesn't find protected/private methods instead
|
61
|
+
klass = self.active_scaffold_config.model
|
62
|
+
klass.define_attribute_methods unless klass.generated_methods?
|
63
|
+
|
64
|
+
@active_scaffold_overrides = []
|
65
|
+
ActionController::Base.view_paths.each do |dir|
|
66
|
+
active_scaffold_overrides_dir = File.join(dir,"active_scaffold_overrides")
|
67
|
+
@active_scaffold_overrides << active_scaffold_overrides_dir if File.exists?(active_scaffold_overrides_dir)
|
68
|
+
end
|
69
|
+
@active_scaffold_frontends = []
|
70
|
+
if active_scaffold_config.frontend.to_sym != :default
|
71
|
+
active_scaffold_custom_frontend_path = File.join(Rails.root, 'vendor', 'plugins', ActiveScaffold::Config::Core.plugin_directory, 'frontends', active_scaffold_config.frontend.to_s , 'views')
|
72
|
+
@active_scaffold_frontends << active_scaffold_custom_frontend_path
|
73
|
+
end
|
74
|
+
active_scaffold_default_frontend_path = File.join(Rails.root, 'vendor', 'plugins', ActiveScaffold::Config::Core.plugin_directory, 'frontends', 'default' , 'views')
|
75
|
+
@active_scaffold_frontends << active_scaffold_default_frontend_path
|
76
|
+
|
77
|
+
# include the rest of the code into the controller: the action core and the included actions
|
78
|
+
module_eval do
|
79
|
+
include ActiveScaffold::Finder
|
80
|
+
include ActiveScaffold::Constraints
|
81
|
+
include ActiveScaffold::AttributeParams
|
82
|
+
include ActiveScaffold::Actions::Core
|
83
|
+
active_scaffold_config.actions.each do |mod|
|
84
|
+
name = mod.to_s.camelize
|
85
|
+
include "ActiveScaffold::Actions::#{name}".constantize rescue nil
|
86
|
+
|
87
|
+
# sneak the action links from the actions into the main set
|
88
|
+
if link = active_scaffold_config.send(mod).link rescue nil
|
89
|
+
active_scaffold_config.action_links << link
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def active_scaffold_paths
|
96
|
+
@active_scaffold_paths ||= ActionView::PathSet.new(@active_scaffold_overrides + @active_scaffold_frontends) unless @active_scaffold_overrides.nil? || @active_scaffold_frontends.nil?
|
97
|
+
end
|
98
|
+
|
99
|
+
def active_scaffold_config
|
100
|
+
@active_scaffold_config || self.superclass.instance_variable_get('@active_scaffold_config')
|
101
|
+
end
|
102
|
+
|
103
|
+
def active_scaffold_config_for(klass)
|
104
|
+
begin
|
105
|
+
controller = active_scaffold_controller_for(klass)
|
106
|
+
rescue ActiveScaffold::ControllerNotFound
|
107
|
+
config = ActiveScaffold::Config::Core.new(klass)
|
108
|
+
config._load_action_columns
|
109
|
+
config
|
110
|
+
else
|
111
|
+
controller.active_scaffold_config
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Tries to find a controller for the given ActiveRecord model.
|
116
|
+
# Searches in the namespace of the current controller for singular and plural versions of the conventional "#{model}Controller" syntax.
|
117
|
+
# You may override this method to customize the search routine.
|
118
|
+
def active_scaffold_controller_for(klass)
|
119
|
+
namespace = self.to_s.split('::')[0...-1].join('::') + '::'
|
120
|
+
error_message = []
|
121
|
+
["#{klass.to_s.underscore.pluralize}", "#{klass.to_s.underscore.pluralize.singularize}"].each do |controller_name|
|
122
|
+
begin
|
123
|
+
controller = "#{namespace}#{controller_name.camelize}Controller".constantize
|
124
|
+
rescue NameError => error
|
125
|
+
# Only rescue NameError associated with the controller constant not existing - not other compile errors
|
126
|
+
if error.message["uninitialized constant #{controller}"]
|
127
|
+
error_message << "#{namespace}#{controller_name.camelize}Controller"
|
128
|
+
next
|
129
|
+
else
|
130
|
+
raise
|
131
|
+
end
|
132
|
+
end
|
133
|
+
raise ActiveScaffold::ControllerNotFound, "#{controller} missing ActiveScaffold", caller unless controller.uses_active_scaffold?
|
134
|
+
raise ActiveScaffold::ControllerNotFound, "ActiveScaffold on #{controller} is not for #{klass} model.", caller unless controller.active_scaffold_config.model == klass
|
135
|
+
return controller
|
136
|
+
end
|
137
|
+
raise ActiveScaffold::ControllerNotFound, "Could not find " + error_message.join(" or "), caller
|
138
|
+
end
|
139
|
+
|
140
|
+
def uses_active_scaffold?
|
141
|
+
!active_scaffold_config.nil?
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module ActiveScaffold::Actions
|
2
|
+
module Core
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
after_filter :clear_flashes
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
def authorized_for?(*args)
|
12
|
+
active_scaffold_config.model.authorized_for?(*args)
|
13
|
+
end
|
14
|
+
|
15
|
+
def clear_flashes
|
16
|
+
if request.xhr?
|
17
|
+
flash.keys.each do |flash_key|
|
18
|
+
flash[flash_key] = nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns true if the client accepts one of the MIME types passed to it
|
24
|
+
# ex: accepts? :html, :xml
|
25
|
+
def accepts?(*types)
|
26
|
+
for priority in request.accepts.compact
|
27
|
+
if priority == Mime::ALL
|
28
|
+
# Because IE always sends */* in the accepts header and we assume
|
29
|
+
# that if you really wanted XML or something else you would say so
|
30
|
+
# explicitly, we will assume */* to only ask for :html
|
31
|
+
return types.include?(:html)
|
32
|
+
elsif types.include?(priority.to_sym)
|
33
|
+
return true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
def response_status
|
40
|
+
successful? ? 200 : 500
|
41
|
+
end
|
42
|
+
|
43
|
+
# API response object that will be converted to XML/YAML/JSON using to_xxx
|
44
|
+
def response_object
|
45
|
+
@response_object = successful? ? (@record || @records) : @record.errors
|
46
|
+
end
|
47
|
+
|
48
|
+
# Success is the existence of certain variables and the absence of errors (when applicable).
|
49
|
+
# Success can also be defined.
|
50
|
+
def successful?
|
51
|
+
if @successful.nil?
|
52
|
+
@records or (@record and @record.errors.count == 0 and @record.no_errors_in_associated?)
|
53
|
+
else
|
54
|
+
@successful
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def successful=(val)
|
59
|
+
@successful = (val) ? true : false
|
60
|
+
end
|
61
|
+
|
62
|
+
# Redirect to the main page (override if the ActiveScaffold is used as a component on another controllers page) for Javascript degradation
|
63
|
+
def return_to_main
|
64
|
+
unless params[:parent_controller].nil?
|
65
|
+
params[:controller] = params[:parent_controller]
|
66
|
+
params[:eid] = nil
|
67
|
+
params[:parent_model] = nil
|
68
|
+
params[:parent_column] = nil
|
69
|
+
params[:parent_id] = nil
|
70
|
+
end
|
71
|
+
redirect_to params_for(:action => "index")
|
72
|
+
end
|
73
|
+
|
74
|
+
# Override this method on your controller to define conditions to be used when querying a recordset (e.g. for List). The return of this method should be any format compatible with the :conditions clause of ActiveRecord::Base's find.
|
75
|
+
def conditions_for_collection
|
76
|
+
end
|
77
|
+
|
78
|
+
# Override this method on your controller to define joins to be used when querying a recordset (e.g. for List). The return of this method should be any format compatible with the :joins clause of ActiveRecord::Base's find.
|
79
|
+
def joins_for_collection
|
80
|
+
end
|
81
|
+
|
82
|
+
# Override this method on your controller to provide custom finder options to the find() call. The return of this method should be a hash.
|
83
|
+
def custom_finder_options
|
84
|
+
{}
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
# Builds search conditions by search params for column names. This allows urls like "contacts/list?company_id=5".
|
89
|
+
def conditions_from_params
|
90
|
+
conditions = nil
|
91
|
+
params.reject {|key, value| [:controller, :action, :id].include?(key.to_sym)}.each do |key, value|
|
92
|
+
next unless active_scaffold_config.model.column_names.include?(key)
|
93
|
+
if value.is_a?(Array)
|
94
|
+
conditions = merge_conditions(conditions, ["#{active_scaffold_config.model.table_name}.#{key.to_s} in (?)", value])
|
95
|
+
else
|
96
|
+
conditions = merge_conditions(conditions, ["#{active_scaffold_config.model.table_name}.#{key.to_s} = ?", value])
|
97
|
+
end
|
98
|
+
end
|
99
|
+
conditions
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|