brisk-bills 0.7.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +55 -0
- data/TODO.txt +36 -67
- data/app/controllers/admin/activities_controller.rb +4 -3
- data/app/controllers/admin/activities_with_prices_controller.rb +28 -14
- data/app/controllers/admin/client_accounting_controller.rb +11 -8
- data/app/controllers/admin/client_representatives_controller.rb +34 -5
- data/app/controllers/admin/clients_controller.rb +1 -1
- data/app/controllers/admin/draft_invoices_controller.rb +92 -0
- data/app/controllers/admin/{employee_client_labor_rate_controller.rb → employee_client_labor_rates_controller.rb} +1 -1
- data/app/controllers/admin/employees_controller.rb +3 -4
- data/app/controllers/admin/invoices_controller.rb +111 -53
- data/app/controllers/admin/payments_controller.rb +168 -41
- data/app/controllers/authentication_controller.rb +3 -3
- data/app/helpers/admin/activities_helper.rb +16 -13
- data/app/helpers/admin/activities_helper/labor_helper.rb +4 -4
- data/app/helpers/admin/activities_helper/proposal_helper.rb +1 -1
- data/app/helpers/admin/activities_helper/slimtimer_helper.rb +1 -1
- data/app/helpers/admin/activities_with_prices_helper.rb +2 -2
- data/app/helpers/admin/activity_type_controller_helper.rb +6 -0
- data/app/helpers/admin/activity_type_field_helper.rb +9 -9
- data/app/helpers/admin/adjustments_helper.rb +9 -1
- data/app/helpers/admin/client_accounting_helper.rb +2 -2
- data/app/helpers/admin/client_financial_transactions_helper.rb +1 -1
- data/app/helpers/admin/client_representatives_helper.rb +16 -12
- data/app/helpers/admin/clients_helper.rb +2 -0
- data/app/helpers/admin/draft_invoices_helper.rb +24 -0
- data/app/helpers/admin/{employee_client_labor_rate_helper.rb → employee_client_labor_rates_helper.rb} +8 -8
- data/app/helpers/admin/employees_helper.rb +6 -0
- data/app/helpers/admin/has_credential_column_helper.rb +8 -8
- data/app/helpers/admin/invoices_helper.rb +71 -16
- data/app/helpers/admin/is_active_column_helper.rb +2 -2
- data/app/helpers/admin/labors_helper.rb +12 -1
- data/app/helpers/admin/labors_helper/slimtimer_helper.rb +1 -1
- data/app/helpers/admin/materials_helper.rb +11 -0
- data/app/helpers/admin/payments_helper.rb +204 -29
- data/app/helpers/admin/proposals_helper.rb +10 -0
- data/app/helpers/admin/settings_helper.rb +1 -1
- data/app/helpers/admin_layout_helper.rb +3 -6
- data/app/helpers/authentication_helper.rb +7 -10
- data/app/helpers/money_model_helper.rb +1 -2
- data/app/models/activity.rb +17 -7
- data/app/models/client.rb +35 -8
- data/app/{model_views → models}/client_financial_transaction.rb +0 -0
- data/app/models/client_representative.rb +6 -14
- data/app/models/credential.rb +1 -1
- data/app/models/employee.rb +9 -11
- data/app/models/invoice.rb +13 -9
- data/app/models/invoice_payment.rb +1 -1
- data/app/models/notifier.rb +2 -2
- data/app/models/payment.rb +51 -7
- data/app/models/setting.rb +3 -1
- data/app/views/active_scaffold_overrides/add_existing.js.rjs +25 -0
- data/app/views/admin/activities/_adjustment_column.html.erb +10 -0
- data/app/views/admin/activities/{_form.rhtml → _form.html.erb} +0 -0
- data/app/views/admin/activities/{_form_attribute.rhtml → _form_attribute.html.erb} +0 -0
- data/app/views/admin/activities/{_labor_column.rhtml → _labor_column.html.erb} +0 -0
- data/app/views/admin/activities/{_material_column.rhtml → _material_column.html.erb} +0 -0
- data/app/views/admin/activities/{_proposal_column.rhtml → _proposal_column.html.erb} +0 -0
- data/app/views/admin/activities_with_prices/{move_to_invoice.rhtml → move_to_invoice.html.erb} +2 -2
- data/app/views/admin/activities_with_prices/move_to_invoice.js.rjs +5 -0
- data/app/views/admin/draft_invoices/batch_create.html.erb +73 -0
- data/app/views/admin/draft_invoices/batch_create.js.rjs +5 -0
- data/app/views/admin/invoices/confirm_publish_modal.html.erb +48 -0
- data/app/views/admin/payments/commit_payment_warning.html.erb +8 -0
- data/app/views/admin/payments/observation_error.js.rjs +28 -0
- data/app/views/admin/payments/on_assignment_observation.js.rjs +28 -0
- data/app/views/authentication/{email.rjs → email.js.rjs} +0 -0
- data/app/views/authentication/{login.rhtml → login.html.erb} +21 -26
- data/app/views/authentication/{login.rjs → login.js.rjs} +0 -0
- data/app/views/authentication/{reset_password_via_token.rhtml → reset_password_via_token.html.erb} +0 -0
- data/app/views/authentication/{reset_password_via_token.rjs → reset_password_via_token.js.rjs} +0 -0
- data/app/views/authentication/{sign_in_error.rjs → sign_in_error.js.rjs} +0 -0
- data/app/views/layouts/{_navigation_tree.rhtml → _navigation_tree.html.erb} +0 -0
- data/app/views/layouts/{admin.rhtml → admin.html.erb} +0 -0
- data/app/views/layouts/{public.rhtml → public.html.erb} +0 -0
- data/app/views/notifier/{_email_footer.html.rhtml → _email_footer.html.erb} +0 -0
- data/app/views/notifier/{_email_footer.plain.rhtml → _email_footer.plain.erb} +0 -0
- data/app/views/notifier/{_email_header.html.rhtml → _email_header.html.erb} +0 -0
- data/app/views/notifier/invoice_available.html.erb +5 -0
- data/app/views/notifier/{invoice_available.plain.rhtml → invoice_available.plain.erb} +1 -1
- data/app/views/notifier/{reset_password_requested.html.rhtml → reset_password_requested.html.erb} +2 -2
- data/app/views/notifier/{reset_password_requested.plain.rhtml → reset_password_requested.plain.erb} +1 -1
- data/config/environment.rb +6 -5
- data/config/locale/en.rb +9 -0
- data/db/migrate/001_create_employees.rb +1 -1
- data/db/migrate/002_create_employee_slimtimers.rb +1 -1
- data/db/migrate/003_create_slimtimer_tasks.rb +1 -1
- data/db/migrate/004_create_slimtimer_time_entries.rb +1 -1
- data/db/migrate/005_create_clients.rb +1 -1
- data/db/migrate/006_create_client_representatives.rb +1 -1
- data/db/migrate/008_create_activities.rb +1 -1
- data/db/migrate/009_create_activity_labors.rb +1 -1
- data/db/migrate/010_create_employee_client_labor_rates.rb +1 -1
- data/db/migrate/011_create_activity_adjustments.rb +1 -1
- data/db/migrate/012_create_activity_materials.rb +1 -1
- data/db/migrate/013_create_activity_proposals.rb +1 -1
- data/db/migrate/014_create_invoices.rb +1 -1
- data/db/migrate/015_create_payments.rb +1 -1
- data/db/migrate/016_create_payment_methods.rb +1 -1
- data/db/migrate/017_create_invoice_payments.rb +1 -1
- data/db/migrate/018_create_activity_types.rb +2 -2
- data/db/migrate/019_create_settings.rb +1 -1
- data/db/migrate/023_create_credentials_migrate_representatives.rb +2 -2
- data/db/migrate/028_money_to_cents.rb +2 -2
- data/db/schema.rb +10 -10
- data/lib/brisk-bills.rb +2 -2
- data/lib/brisk-bills/initializer.rb +2 -2
- data/lib/generators/instance/templates/instance_environment.rb +1 -1
- data/lib/libpptable.rb +48 -0
- data/lib/tasks/create_last_months_invoices.rake +1 -14
- data/lib/tasks/first_time_setup.rake +2 -2
- data/lib/tasks/package.rake +2 -1
- data/lib/tasks/payment_assignment_consistency_check.rake +110 -0
- data/lib/utilities.rb +4 -4
- data/public/images/page-new.gif +0 -0
- data/public/javascripts/active_scaffold/default/active_scaffold.js +532 -430
- data/public/javascripts/active_scaffold/default/dhtml_history.js +1 -1
- data/public/javascripts/active_scaffold/default/form_enhancements.js +7 -4
- data/public/stylesheets/active_scaffold/default/stylesheet-ie.css +5 -5
- data/public/stylesheets/active_scaffold/default/stylesheet.css +54 -18
- data/public/stylesheets/admin/global.css +1 -1
- data/public/stylesheets/admin/pages.css +29 -0
- data/test/unit/activity/adjustment_test.rb +1 -1
- data/test/unit/activity/labor_test.rb +1 -1
- data/test/unit/activity/material_test.rb +1 -1
- data/test/unit/activity/proposal_test.rb +1 -1
- data/test/unit/activity_test.rb +1 -1
- data/test/unit/activity_type_test.rb +1 -1
- data/test/unit/client_eventlog_test.rb +1 -1
- data/test/unit/client_financial_transaction_test.rb +1 -1
- data/test/unit/client_representative_test.rb +1 -1
- data/test/unit/client_test.rb +37 -6
- data/test/unit/credential_test.rb +1 -1
- data/test/unit/employee/slimtimer_test.rb +1 -1
- data/test/unit/employee_client_labor_rate_test.rb +1 -1
- data/test/unit/employee_test.rb +1 -1
- data/test/unit/helpers/admin/draft_invoices_helper_test.rb +4 -0
- data/test/unit/invoice_payment_test.rb +90 -50
- data/test/unit/invoice_test.rb +48 -8
- data/test/unit/notifier_test.rb +1 -1
- data/test/unit/payment_method_test.rb +1 -1
- data/test/unit/payment_test.rb +7 -7
- data/test/unit/setting_test.rb +1 -1
- data/test/unit/slimtimer_task_test.rb +1 -1
- data/test/unit/slimtimer_time_entry_test.rb +1 -1
- data/vendor/plugins/active_scaffold/CHANGELOG +3 -1
- data/vendor/plugins/active_scaffold/README +18 -5
- data/vendor/plugins/active_scaffold/environment.rb +1 -1
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/active_scaffold.js +532 -430
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/dhtml_history.js +1 -1
- data/vendor/plugins/active_scaffold/frontends/default/javascripts/form_enhancements.js +7 -4
- data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet-ie.css +5 -5
- data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet.css +54 -18
- data/vendor/plugins/active_scaffold/frontends/default/views/_add_existing_form.html.erb +3 -7
- data/vendor/plugins/active_scaffold/frontends/default/views/_create_form.html.erb +10 -7
- data/vendor/plugins/active_scaffold/frontends/default/views/_field_search.html.erb +7 -12
- data/vendor/plugins/active_scaffold/frontends/default/views/_form.html.erb +3 -3
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association.html.erb +15 -20
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_footer.html.erb +8 -10
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_attribute.html.erb +5 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_hidden_attribute.html.erb +2 -1
- data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform.html.erb +19 -21
- data/vendor/plugins/active_scaffold/frontends/default/views/{_form_association_header.html.erb → _horizontal_subform_header.html.erb} +2 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform_record.html.erb +31 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list.html.erb +4 -18
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_actions.html.erb +18 -5
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_calculations.html.erb +2 -9
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_column_headings.html.erb +4 -4
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_header.html.erb +6 -6
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_inline_adapter.html.erb +2 -1
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_messages.html.erb +20 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_pagination.html.erb +11 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_pagination_links.html.erb +3 -5
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_record.html.erb +2 -26
- data/vendor/plugins/active_scaffold/frontends/default/views/_list_record_columns.html.erb +9 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_nested.html.erb +3 -12
- data/vendor/plugins/active_scaffold/frontends/default/views/_render_fields.js.rjs +11 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_search.html.erb +17 -11
- data/vendor/plugins/active_scaffold/frontends/default/views/_show.html.erb +3 -3
- data/vendor/plugins/active_scaffold/frontends/default/views/_show_columns.html.erb +8 -7
- data/vendor/plugins/active_scaffold/frontends/default/views/_update_actions.html.erb +3 -3
- data/vendor/plugins/active_scaffold/frontends/default/views/_update_form.html.erb +9 -6
- data/vendor/plugins/active_scaffold/frontends/default/views/_vertical_subform.html.erb +7 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/_vertical_subform_record.html.erb +38 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/add_existing.js.rjs +2 -1
- data/vendor/plugins/active_scaffold/frontends/default/views/delete.html.erb +1 -1
- data/vendor/plugins/active_scaffold/frontends/default/views/destroy.js.rjs +2 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/edit_associated.js.rjs +20 -15
- data/vendor/plugins/active_scaffold/frontends/default/views/list.html.erb +12 -8
- data/vendor/plugins/active_scaffold/frontends/default/views/list.js.rjs +1 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/mark.js.rjs +6 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/on_create.js.rjs +12 -8
- data/vendor/plugins/active_scaffold/frontends/default/views/on_update.js.rjs +13 -6
- data/vendor/plugins/active_scaffold/frontends/default/views/render_field.js.rjs +1 -0
- data/vendor/plugins/active_scaffold/frontends/default/views/search.html.erb +2 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/update.html.erb +2 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/update_column.js.rjs +4 -3
- data/vendor/plugins/active_scaffold/frontends/default/views/update_row.js.rjs +2 -0
- data/vendor/plugins/active_scaffold/init.rb +2 -2
- data/vendor/plugins/active_scaffold/install.rb +1 -2
- data/vendor/plugins/active_scaffold/install_assets.rb +1 -1
- data/vendor/plugins/active_scaffold/lib/active_record_permissions.rb +53 -42
- data/vendor/plugins/active_scaffold/lib/active_scaffold.rb +96 -23
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/common_search.rb +18 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/core.rb +152 -102
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/create.rb +81 -49
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/delete.rb +44 -17
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/field_search.rb +60 -46
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb +42 -37
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/mark.rb +72 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/nested.rb +94 -92
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/search.rb +54 -40
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/show.rb +30 -10
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/update.rb +62 -47
- data/vendor/plugins/active_scaffold/lib/active_scaffold/attribute_params.rb +187 -185
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/base.rb +28 -3
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/core.rb +43 -3
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/create.rb +8 -15
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/delete.rb +3 -4
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/field_search.rb +19 -17
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/form.rb +2 -9
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/list.rb +46 -9
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/nested.rb +17 -7
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/search.rb +36 -16
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/show.rb +5 -12
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/subform.rb +8 -6
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/update.rb +12 -8
- data/vendor/plugins/active_scaffold/lib/active_scaffold/configurable.rb +2 -2
- data/vendor/plugins/active_scaffold/lib/active_scaffold/constraints.rb +173 -178
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_columns.rb +101 -97
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb +29 -19
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb +74 -34
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb +74 -74
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/set.rb +57 -62
- data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/sorting.rb +73 -3
- data/vendor/plugins/active_scaffold/lib/active_scaffold/finder.rb +304 -234
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb +40 -40
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/controller_helpers.rb +39 -24
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/country_helpers.rb +32 -28
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb +157 -86
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/id_helpers.rb +7 -7
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb +278 -85
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb +38 -12
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/search_column_helpers.rb +74 -35
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb +53 -46
- data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb +51 -17
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/de.yml +69 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/en.yml +72 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/es.yml +23 -13
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/fr.yml +68 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/hu.yml +24 -14
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/ja.yml +69 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/ru.yml +72 -0
- data/vendor/plugins/active_scaffold/lib/active_scaffold/marked_model.rb +38 -0
- data/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/lib/as_cds_bridge.rb +47 -13
- data/vendor/plugins/active_scaffold/lib/bridges/dependent_protect/bridge.rb +10 -0
- data/vendor/plugins/active_scaffold/lib/bridges/dependent_protect/lib/dependent_protect_bridge.rb +11 -0
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/as_file_column_bridge.rb +3 -6
- data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/form_ui.rb +10 -2
- data/vendor/plugins/active_scaffold/lib/bridges/paperclip/bridge.rb +13 -0
- data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/form_ui.rb +20 -0
- data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/list_ui.rb +16 -0
- data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/paperclip_bridge.rb +32 -0
- data/vendor/plugins/active_scaffold/lib/bridges/paperclip/lib/paperclip_bridge_helpers.rb +18 -0
- data/vendor/plugins/active_scaffold/lib/bridges/record_select/bridge.rb +5 -0
- data/vendor/plugins/active_scaffold/lib/bridges/record_select/lib/record_select_bridge.rb +79 -0
- data/vendor/plugins/active_scaffold/lib/bridges/semantic_attributes/bridge.rb +5 -0
- data/vendor/plugins/active_scaffold/lib/bridges/semantic_attributes/lib/semantic_attributes_bridge.rb +20 -0
- data/vendor/plugins/active_scaffold/lib/bridges/tiny_mce/bridge.rb +5 -0
- data/vendor/plugins/active_scaffold/lib/bridges/tiny_mce/lib/tiny_mce_bridge.rb +57 -0
- data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/bridge.rb +9 -0
- data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/lib/form_ui.rb +14 -0
- data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/lib/unobtrusive_date_picker_bridge.rb +15 -0
- data/vendor/plugins/active_scaffold/lib/bridges/unobtrusive_date_picker/lib/view_helpers.rb +16 -0
- data/vendor/plugins/active_scaffold/lib/bridges/validation_reflection/bridge.rb +9 -0
- data/vendor/plugins/active_scaffold/lib/bridges/validation_reflection/lib/validation_reflection_bridge.rb +19 -0
- data/vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb +20 -8
- data/vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb +2 -2
- data/vendor/plugins/active_scaffold/lib/extensions/paginator_extensions.rb +26 -0
- data/vendor/plugins/active_scaffold/lib/extensions/resources.rb +6 -5
- data/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb +26 -20
- data/vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb +1 -1
- data/vendor/plugins/active_scaffold/lib/paginator.rb +1 -1
- data/vendor/plugins/active_scaffold/lib/responds_to_parent.rb +1 -1
- data/vendor/plugins/active_scaffold/shoulda_macros/macros.rb +136 -0
- data/vendor/plugins/active_scaffold/test/bridges/active_scaffold_dependent_protect_test.rb +34 -0
- data/vendor/plugins/active_scaffold/test/bridges/bridge_test.rb +43 -0
- data/vendor/plugins/active_scaffold/test/bridges/company.rb +81 -0
- data/vendor/plugins/active_scaffold/test/bridges/paperclip_test.rb +68 -0
- data/vendor/plugins/active_scaffold/test/bridges/tiny_mce_test.rb +27 -0
- data/vendor/plugins/active_scaffold/test/bridges/unobtrusive_date_picker_test.rb +49 -0
- data/vendor/plugins/active_scaffold/test/bridges/validation_reflection_test.rb +57 -0
- data/vendor/plugins/active_scaffold/test/config/base_test.rb +15 -0
- data/vendor/plugins/active_scaffold/test/config/core_test.rb +58 -0
- data/vendor/plugins/active_scaffold/test/config/create_test.rb +9 -6
- data/vendor/plugins/active_scaffold/test/config/delete_test.rb +33 -0
- data/vendor/plugins/active_scaffold/test/config/field_search_test.rb +47 -0
- data/vendor/plugins/active_scaffold/test/config/list_test.rb +66 -11
- data/vendor/plugins/active_scaffold/test/config/nested_test.rb +62 -0
- data/vendor/plugins/active_scaffold/test/config/search_test.rb +60 -0
- data/vendor/plugins/active_scaffold/test/config/show_test.rb +43 -0
- data/vendor/plugins/active_scaffold/test/config/subform_test.rb +17 -0
- data/vendor/plugins/active_scaffold/test/config/update_test.rb +27 -4
- data/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb +2 -8
- data/vendor/plugins/active_scaffold/test/data_structures/action_link_test.rb +11 -11
- data/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb +5 -5
- data/vendor/plugins/active_scaffold/test/data_structures/association_column_test.rb +4 -3
- data/vendor/plugins/active_scaffold/test/data_structures/column_test.rb +29 -5
- data/vendor/plugins/active_scaffold/test/data_structures/sorting_test.rb +31 -1
- data/vendor/plugins/active_scaffold/test/data_structures/standard_column_test.rb +3 -13
- data/vendor/plugins/active_scaffold/test/data_structures/virtual_column_test.rb +0 -11
- data/vendor/plugins/active_scaffold/test/extensions/{array.rb → array_test.rb} +0 -0
- data/vendor/plugins/active_scaffold/test/helpers/form_column_helpers_test.rb +31 -0
- data/vendor/plugins/active_scaffold/test/helpers/list_column_helpers_test.rb +42 -0
- data/vendor/plugins/active_scaffold/test/helpers/pagination_helpers_test.rb +59 -0
- data/vendor/plugins/active_scaffold/test/misc/active_record_permissions_test.rb +154 -0
- data/vendor/plugins/active_scaffold/test/misc/attribute_params_test.rb +146 -0
- data/vendor/plugins/active_scaffold/test/misc/configurable_test.rb +2 -2
- data/vendor/plugins/active_scaffold/test/misc/constraints_test.rb +26 -8
- data/vendor/plugins/active_scaffold/test/misc/finder_test.rb +41 -19
- data/vendor/plugins/active_scaffold/test/misc/lang_test.rb +5 -6
- data/vendor/plugins/active_scaffold/test/mock_app/app/controllers/application_controller.rb +10 -0
- data/vendor/plugins/active_scaffold/test/mock_app/app/helpers/application_helper.rb +3 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/boot.rb +110 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/environment.rb +43 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/environments/development.rb +17 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/environments/production.rb +28 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/environments/test.rb +28 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/backtrace_silencers.rb +7 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/inflections.rb +10 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/mime_types.rb +5 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/new_rails_defaults.rb +19 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/initializers/session_store.rb +15 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/locales/en.yml +5 -0
- data/vendor/plugins/active_scaffold/test/mock_app/config/routes.rb +43 -0
- data/vendor/plugins/active_scaffold/test/mock_app/db/test.sqlite3 +1 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/blank.html +33 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/DO_NOT_EDIT +2 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/add.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/arrow_down.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/arrow_up.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/close.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/cross.png +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/indicator-small.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/indicator.gif +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/images/active_scaffold/default/magnifier.png +0 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +532 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/form_enhancements.js +117 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
- data/vendor/plugins/active_scaffold/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +845 -0
- data/vendor/plugins/active_scaffold/test/model_stub.rb +17 -1
- data/vendor/plugins/active_scaffold/test/test_helper.rb +31 -5
- data/vendor/plugins/active_scaffold/uninstall.rb +2 -1
- data/vendor/plugins/active_scaffold_form_observation/init.rb +1 -1
- data/vendor/plugins/active_scaffold_form_observation/lib/active_scaffold_form_observation.rb +1 -2
- data/vendor/plugins/active_scaffold_full_refresh/init.rb +2 -0
- data/vendor/plugins/active_scaffold_full_refresh/lib/active_scaffold_full_refresh.rb +29 -0
- data/vendor/plugins/acts_as_money/{tasks → lib/tasks}/money_tasks.rake +0 -0
- metadata +668 -563
- data/app/model_views/client_accounting.rb +0 -5
- data/app/model_views/invoices_with_total.rb +0 -41
- data/app/views/admin/activities/_adjustment_column.rhtml +0 -23
- data/app/views/admin/activities_with_prices/move_to_invoice.rjs +0 -9
- data/app/views/notifier/invoice_available.html.rhtml +0 -5
- data/public/javascripts/prototype.js-1.6.0.3 +0 -4320
- data/test/functional/admin/activities_controller_test.rb +0 -8
- data/test/functional/admin/adjustments_controller_test.rb +0 -8
- data/test/functional/admin/client_accounting_controller_test.rb +0 -8
- data/test/functional/admin/client_financial_transactions_controller_test.rb +0 -8
- data/test/functional/admin/client_representatives_controller_test.rb +0 -8
- data/test/functional/admin/clients_controller_test.rb +0 -8
- data/test/functional/admin/employee_client_labor_rate_controller_test.rb +0 -8
- data/test/functional/admin/employees/slimtimer_controller_test.rb +0 -8
- data/test/functional/admin/employees_controller_test.rb +0 -8
- data/test/functional/admin/invoices_controller_test.rb +0 -8
- data/test/functional/admin/labors_controller_test.rb +0 -8
- data/test/functional/admin/materials_controller_test.rb +0 -8
- data/test/functional/admin/payments_controller_test.rb +0 -8
- data/test/functional/admin/proposals_controller_test.rb +0 -8
- data/test/functional/admin/settings_controller_test.rb +0 -8
- data/test/functional/authentication_controller_test.rb +0 -8
- data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_record.html.erb +0 -27
- data/vendor/plugins/active_scaffold/frontends/default/views/_live_search.html.erb +0 -25
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_create.js.rjs +0 -2
- data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_update.js.rjs +0 -2
- data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/live_search.rb +0 -46
- data/vendor/plugins/active_scaffold/lib/active_scaffold/config/live_search.rb +0 -52
- data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/en.rb +0 -66
- data/vendor/plugins/active_scaffold/lib/extensions/name_option_for_datetime.rb +0 -12
- data/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb +0 -154
@@ -3,6 +3,7 @@ module ActiveScaffold
|
|
3
3
|
class DependencyFailure < RuntimeError; end
|
4
4
|
class MalformedConstraint < RuntimeError; end
|
5
5
|
class RecordNotAllowed < SecurityError; end
|
6
|
+
class ActionNotAllowed < SecurityError; end
|
6
7
|
class ReverseAssociationRequired < RuntimeError; end
|
7
8
|
|
8
9
|
def self.included(base)
|
@@ -54,18 +55,15 @@ module ActiveScaffold
|
|
54
55
|
|
55
56
|
# run the configuration
|
56
57
|
@active_scaffold_config = ActiveScaffold::Config::Core.new(model_id)
|
57
|
-
|
58
|
-
self.
|
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?
|
58
|
+
@active_scaffold_config_block = block
|
59
|
+
self.links_for_associations
|
63
60
|
|
64
61
|
@active_scaffold_overrides = []
|
65
62
|
ActionController::Base.view_paths.each do |dir|
|
66
63
|
active_scaffold_overrides_dir = File.join(dir,"active_scaffold_overrides")
|
67
64
|
@active_scaffold_overrides << active_scaffold_overrides_dir if File.exists?(active_scaffold_overrides_dir)
|
68
65
|
end
|
66
|
+
@active_scaffold_overrides.uniq! # Fix rails duplicating some view_paths
|
69
67
|
@active_scaffold_frontends = []
|
70
68
|
if active_scaffold_config.frontend.to_sym != :default
|
71
69
|
active_scaffold_custom_frontend_path = File.join(Rails.root, 'vendor', 'plugins', ActiveScaffold::Config::Core.plugin_directory, 'frontends', active_scaffold_config.frontend.to_s , 'views')
|
@@ -73,6 +71,16 @@ module ActiveScaffold
|
|
73
71
|
end
|
74
72
|
active_scaffold_default_frontend_path = File.join(Rails.root, 'vendor', 'plugins', ActiveScaffold::Config::Core.plugin_directory, 'frontends', 'default' , 'views')
|
75
73
|
@active_scaffold_frontends << active_scaffold_default_frontend_path
|
74
|
+
@active_scaffold_custom_paths = []
|
75
|
+
|
76
|
+
self.active_scaffold_superclasses_blocks.each {|superblock| self.active_scaffold_config.configure &superblock}
|
77
|
+
self.active_scaffold_config.configure &block if block_given?
|
78
|
+
self.active_scaffold_config._configure_sti unless self.active_scaffold_config.sti_children.nil?
|
79
|
+
self.active_scaffold_config._load_action_columns
|
80
|
+
|
81
|
+
# defines the attribute read methods on the model, so record.send() doesn't find protected/private methods instead
|
82
|
+
klass = self.active_scaffold_config.model
|
83
|
+
klass.define_attribute_methods unless klass.generated_methods?
|
76
84
|
|
77
85
|
# include the rest of the code into the controller: the action core and the included actions
|
78
86
|
module_eval do
|
@@ -82,7 +90,7 @@ module ActiveScaffold
|
|
82
90
|
include ActiveScaffold::Actions::Core
|
83
91
|
active_scaffold_config.actions.each do |mod|
|
84
92
|
name = mod.to_s.camelize
|
85
|
-
include "ActiveScaffold::Actions::#{name}".constantize
|
93
|
+
include "ActiveScaffold::Actions::#{name}".constantize
|
86
94
|
|
87
95
|
# sneak the action links from the actions into the main set
|
88
96
|
if link = active_scaffold_config.send(mod).link rescue nil
|
@@ -90,14 +98,77 @@ module ActiveScaffold
|
|
90
98
|
end
|
91
99
|
end
|
92
100
|
end
|
101
|
+
self.active_scaffold_config._add_sti_create_links if self.active_scaffold_config.add_sti_create_links?
|
102
|
+
end
|
103
|
+
|
104
|
+
# Create the automatic column links. Note that this has to happen when configuration is *done*, because otherwise the Nested module could be disabled. Actually, it could still be disabled later, couldn't it?
|
105
|
+
def links_for_associations
|
106
|
+
return unless active_scaffold_config.actions.include? :list and active_scaffold_config.actions.include? :nested
|
107
|
+
active_scaffold_config.columns.each do |column|
|
108
|
+
next unless column.link.nil? and column.autolink?
|
109
|
+
if column.plural_association?
|
110
|
+
# note: we can't create nested scaffolds on :through associations because there's no reverse association.
|
111
|
+
column.set_link('nested', :parameters => {:associations => column.name.to_sym}, :html_options => {:class => column.name}) #unless column.through_association?
|
112
|
+
elsif column.polymorphic_association?
|
113
|
+
# note: we can't create inline forms on singular polymorphic associations
|
114
|
+
column.clear_link
|
115
|
+
else
|
116
|
+
model = column.association.klass
|
117
|
+
begin
|
118
|
+
controller = active_scaffold_controller_for(model)
|
119
|
+
rescue ActiveScaffold::ControllerNotFound
|
120
|
+
next
|
121
|
+
end
|
122
|
+
|
123
|
+
actions = controller.active_scaffold_config.actions
|
124
|
+
column.actions_for_association_links.delete :new unless actions.include? :create
|
125
|
+
column.actions_for_association_links.delete :edit unless actions.include? :update
|
126
|
+
column.actions_for_association_links.delete :show unless actions.include? :show
|
127
|
+
column.set_link(:none, :controller => controller.controller_path, :crud_type => nil, :label => :create_model, :html_options => {:class => column.name})
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def add_active_scaffold_path(path)
|
133
|
+
@active_scaffold_paths = nil # Force active_scaffold_paths to rebuild
|
134
|
+
@active_scaffold_custom_paths << path
|
135
|
+
end
|
136
|
+
|
137
|
+
def add_active_scaffold_override_path(path)
|
138
|
+
@active_scaffold_paths = nil # Force active_scaffold_paths to rebuild
|
139
|
+
@active_scaffold_overrides.unshift path
|
93
140
|
end
|
94
141
|
|
95
142
|
def active_scaffold_paths
|
96
|
-
@active_scaffold_paths
|
143
|
+
return @active_scaffold_paths unless @active_scaffold_paths.nil?
|
144
|
+
|
145
|
+
@active_scaffold_paths = ActionView::PathSet.new
|
146
|
+
@active_scaffold_paths.concat @active_scaffold_overrides unless @active_scaffold_overrides.nil?
|
147
|
+
@active_scaffold_paths.concat @active_scaffold_custom_paths unless @active_scaffold_custom_paths.nil?
|
148
|
+
@active_scaffold_paths.concat @active_scaffold_frontends unless @active_scaffold_frontends.nil?
|
149
|
+
@active_scaffold_paths
|
97
150
|
end
|
98
151
|
|
99
152
|
def active_scaffold_config
|
100
|
-
|
153
|
+
if @active_scaffold_config.nil?
|
154
|
+
self.superclass.active_scaffold_config if self.superclass.respond_to? :active_scaffold_config
|
155
|
+
else
|
156
|
+
@active_scaffold_config
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def active_scaffold_config_block
|
161
|
+
@active_scaffold_config_block
|
162
|
+
end
|
163
|
+
|
164
|
+
def active_scaffold_superclasses_blocks
|
165
|
+
blocks = []
|
166
|
+
klass = self.superclass
|
167
|
+
while klass.respond_to? :active_scaffold_superclasses_blocks
|
168
|
+
blocks << klass.active_scaffold_config_block
|
169
|
+
klass = klass.superclass
|
170
|
+
end
|
171
|
+
blocks.compact.reverse
|
101
172
|
end
|
102
173
|
|
103
174
|
def active_scaffold_config_for(klass)
|
@@ -116,23 +187,25 @@ module ActiveScaffold
|
|
116
187
|
# Searches in the namespace of the current controller for singular and plural versions of the conventional "#{model}Controller" syntax.
|
117
188
|
# You may override this method to customize the search routine.
|
118
189
|
def active_scaffold_controller_for(klass)
|
119
|
-
|
190
|
+
controller_namespace = self.to_s.split('::')[0...-1].join('::') + '::'
|
120
191
|
error_message = []
|
121
|
-
[
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
192
|
+
[controller_namespace, ''].each do |namespace|
|
193
|
+
["#{klass.to_s.underscore.pluralize}", "#{klass.to_s.underscore.pluralize.singularize}"].each do |controller_name|
|
194
|
+
begin
|
195
|
+
controller = "#{namespace}#{controller_name.camelize}Controller".constantize
|
196
|
+
rescue NameError => error
|
197
|
+
# Only rescue NameError associated with the controller constant not existing - not other compile errors
|
198
|
+
if error.message["uninitialized constant #{controller}"]
|
199
|
+
error_message << "#{namespace}#{controller_name.camelize}Controller"
|
200
|
+
next
|
201
|
+
else
|
202
|
+
raise
|
203
|
+
end
|
131
204
|
end
|
205
|
+
raise ActiveScaffold::ControllerNotFound, "#{controller} missing ActiveScaffold", caller unless controller.uses_active_scaffold?
|
206
|
+
raise ActiveScaffold::ControllerNotFound, "ActiveScaffold on #{controller} is not for #{klass} model.", caller unless controller.active_scaffold_config.model.to_s == klass.to_s
|
207
|
+
return controller
|
132
208
|
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
209
|
end
|
137
210
|
raise ActiveScaffold::ControllerNotFound, "Could not find " + error_message.join(" or "), caller
|
138
211
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ActiveScaffold::Actions
|
2
|
+
module CommonSearch
|
3
|
+
protected
|
4
|
+
def store_search_params_into_session
|
5
|
+
active_scaffold_session_storage[:search] = params.delete :search if params[:search]
|
6
|
+
end
|
7
|
+
|
8
|
+
def search_params
|
9
|
+
active_scaffold_session_storage[:search]
|
10
|
+
end
|
11
|
+
|
12
|
+
# The default security delegates to ActiveRecordPermissions.
|
13
|
+
# You may override the method to customize.
|
14
|
+
def search_authorized?
|
15
|
+
authorized_for?(:crud_type => :read)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,102 +1,152 @@
|
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
|
+
def render_field
|
9
|
+
@record = if params[:in_place_editing]
|
10
|
+
active_scaffold_config.model.find params[:id]
|
11
|
+
else
|
12
|
+
active_scaffold_config.model.new
|
13
|
+
end
|
14
|
+
column = active_scaffold_config.columns[params[:column]]
|
15
|
+
if params[:in_place_editing]
|
16
|
+
render :inline => "<%= active_scaffold_input_for(active_scaffold_config.columns[params[:update_column].to_sym]) %>"
|
17
|
+
elsif !column.nil?
|
18
|
+
if column.send_form_on_update_column
|
19
|
+
@record = update_record_from_params(@record, active_scaffold_config.update.columns, params[:record])
|
20
|
+
else
|
21
|
+
value = column_value_from_param_value(@record, column, params[:value])
|
22
|
+
@record.send "#{column.name}=", value
|
23
|
+
end
|
24
|
+
@update_columns = Array(params[:update_column])
|
25
|
+
after_render_field(@record, column)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
# override this method if you want to do something after render_field
|
32
|
+
def after_render_field(record, column); end
|
33
|
+
|
34
|
+
def authorized_for?(options = {})
|
35
|
+
active_scaffold_config.model.authorized_for?(options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def clear_flashes
|
39
|
+
if request.xhr?
|
40
|
+
flash.keys.each do |flash_key|
|
41
|
+
flash[flash_key] = nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def marked_records
|
47
|
+
active_scaffold_session_storage[:marked_records] ||= Set.new
|
48
|
+
end
|
49
|
+
|
50
|
+
def default_formats
|
51
|
+
[:html, :js, :json, :xml, :yaml]
|
52
|
+
end
|
53
|
+
# Returns true if the client accepts one of the MIME types passed to it
|
54
|
+
# ex: accepts? :html, :xml
|
55
|
+
def accepts?(*types)
|
56
|
+
for priority in request.accepts.compact
|
57
|
+
if priority == Mime::ALL
|
58
|
+
# Because IE always sends */* in the accepts header and we assume
|
59
|
+
# that if you really wanted XML or something else you would say so
|
60
|
+
# explicitly, we will assume */* to only ask for :html
|
61
|
+
return types.include?(:html)
|
62
|
+
elsif types.include?(priority.to_sym)
|
63
|
+
return true
|
64
|
+
end
|
65
|
+
end
|
66
|
+
false
|
67
|
+
end
|
68
|
+
|
69
|
+
def response_status
|
70
|
+
if successful?
|
71
|
+
action_name == 'create' ? 201 : 200
|
72
|
+
else
|
73
|
+
422
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# API response object that will be converted to XML/YAML/JSON using to_xxx
|
78
|
+
def response_object
|
79
|
+
@response_object = successful? ? (@record || @records) : @record.errors
|
80
|
+
end
|
81
|
+
|
82
|
+
# Success is the existence of certain variables and the absence of errors (when applicable).
|
83
|
+
# Success can also be defined.
|
84
|
+
def successful?
|
85
|
+
if @successful.nil?
|
86
|
+
@records or (@record and @record.errors.count == 0 and @record.no_errors_in_associated?)
|
87
|
+
else
|
88
|
+
@successful
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def successful=(val)
|
93
|
+
@successful = (val) ? true : false
|
94
|
+
end
|
95
|
+
|
96
|
+
# Redirect to the main page (override if the ActiveScaffold is used as a component on another controllers page) for Javascript degradation
|
97
|
+
def return_to_main
|
98
|
+
redirect_to main_path_to_return
|
99
|
+
end
|
100
|
+
|
101
|
+
# 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.
|
102
|
+
def conditions_for_collection
|
103
|
+
end
|
104
|
+
|
105
|
+
# 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.
|
106
|
+
def joins_for_collection
|
107
|
+
end
|
108
|
+
|
109
|
+
# Override this method on your controller to provide custom finder options to the find() call. The return of this method should be a hash.
|
110
|
+
def custom_finder_options
|
111
|
+
{}
|
112
|
+
end
|
113
|
+
|
114
|
+
#Overide this method on your controller to provide model with named scopes
|
115
|
+
def beginning_of_chain
|
116
|
+
active_scaffold_config.model
|
117
|
+
end
|
118
|
+
|
119
|
+
# Builds search conditions by search params for column names. This allows urls like "contacts/list?company_id=5".
|
120
|
+
def conditions_from_params
|
121
|
+
conditions = nil
|
122
|
+
params.reject {|key, value| [:controller, :action, :id, :page, :sort, :sort_direction].include?(key.to_sym)}.each do |key, value|
|
123
|
+
next unless active_scaffold_config.model.column_names.include?(key)
|
124
|
+
if value.is_a?(Array)
|
125
|
+
conditions = merge_conditions(conditions, ["#{active_scaffold_config.model.table_name}.#{key.to_s} in (?)", value])
|
126
|
+
else
|
127
|
+
conditions = merge_conditions(conditions, ["#{active_scaffold_config.model.table_name}.#{key.to_s} = ?", value])
|
128
|
+
end
|
129
|
+
end
|
130
|
+
conditions
|
131
|
+
end
|
132
|
+
private
|
133
|
+
def respond_to_action(action)
|
134
|
+
respond_to do |type|
|
135
|
+
send("#{action}_formats").each do |format|
|
136
|
+
type.send(format){ send("#{action}_respond_to_#{format}") }
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def response_code_for_rescue(exception)
|
142
|
+
case exception
|
143
|
+
when ActiveScaffold::RecordNotAllowed
|
144
|
+
"403 Record Not Allowed"
|
145
|
+
when ActiveScaffold::ActionNotAllowed
|
146
|
+
"403 Action Not Allowed"
|
147
|
+
else
|
148
|
+
super
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ActiveScaffold::Actions
|
2
2
|
module Create
|
3
3
|
def self.included(base)
|
4
|
-
base.before_filter :
|
4
|
+
base.before_filter :create_authorized_filter, :only => [:new, :create]
|
5
5
|
base.prepend_before_filter :constraints_for_nested_create, :only => [:new, :create]
|
6
6
|
base.verify :method => :post,
|
7
7
|
:only => :create,
|
@@ -10,63 +10,74 @@ module ActiveScaffold::Actions
|
|
10
10
|
|
11
11
|
def new
|
12
12
|
do_new
|
13
|
-
|
14
|
-
respond_to do |type|
|
15
|
-
type.html do
|
16
|
-
if successful?
|
17
|
-
render(:action => 'create')
|
18
|
-
else
|
19
|
-
return_to_main
|
20
|
-
end
|
21
|
-
end
|
22
|
-
type.js do
|
23
|
-
render(:partial => 'create_form')
|
24
|
-
end
|
25
|
-
end
|
13
|
+
respond_to_action(:new)
|
26
14
|
end
|
27
15
|
|
28
16
|
def create
|
29
17
|
do_create
|
30
18
|
@insert_row = params[:parent_controller].nil?
|
19
|
+
respond_to_action(:create)
|
20
|
+
end
|
31
21
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
22
|
+
protected
|
23
|
+
def response_location
|
24
|
+
url_for(params_for(:action => "show", :id => @record.id)) if successful?
|
25
|
+
end
|
26
|
+
|
27
|
+
def new_respond_to_html
|
28
|
+
if successful?
|
29
|
+
render(:action => 'create')
|
30
|
+
else
|
31
|
+
return_to_main
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def new_respond_to_js
|
36
|
+
render(:partial => 'create_form')
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_respond_to_html
|
40
|
+
if params[:iframe]=='true' # was this an iframe post ?
|
41
|
+
responds_to_parent do
|
42
|
+
render :action => 'on_create.js'
|
43
|
+
end
|
44
|
+
else
|
45
|
+
if successful?
|
46
|
+
flash[:info] = as_(:created_model, :model => @record.to_label)
|
47
|
+
if action = active_scaffold_config.create.action_after_create
|
48
|
+
redirect_to params_for(:action => action, :id => @record.id)
|
49
|
+
elsif active_scaffold_config.create.persistent
|
50
|
+
redirect_to params_for(:action => "new")
|
51
|
+
else
|
52
|
+
return_to_main
|
53
|
+
end
|
54
|
+
else
|
55
|
+
if params[:nested].nil? && active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.always_show_create
|
56
|
+
do_list
|
57
|
+
render(:action => 'list')
|
42
58
|
else
|
43
|
-
|
44
|
-
flash[:info] = as_(:created_model, :model => @record.to_label)
|
45
|
-
if active_scaffold_config.create.edit_after_create
|
46
|
-
redirect_to params.merge(:action => "edit", :id => @record.id)
|
47
|
-
else
|
48
|
-
return_to_main
|
49
|
-
end
|
50
|
-
else
|
51
|
-
if params[:nested].nil? && active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.always_show_create
|
52
|
-
do_list
|
53
|
-
render(:action => 'list')
|
54
|
-
else
|
55
|
-
render(:action => 'create')
|
56
|
-
end
|
57
|
-
end
|
59
|
+
render(:action => 'create')
|
58
60
|
end
|
59
61
|
end
|
60
|
-
type.js do
|
61
|
-
render :action => 'on_create'
|
62
|
-
end
|
63
|
-
type.xml { render :xml => response_object.to_xml, :content_type => Mime::XML, :status => response_status }
|
64
|
-
type.json { render :text => response_object.to_json, :content_type => Mime::JSON, :status => response_status }
|
65
|
-
type.yaml { render :text => response_object.to_yaml, :content_type => Mime::YAML, :status => response_status }
|
66
62
|
end
|
67
63
|
end
|
68
64
|
|
69
|
-
|
65
|
+
def create_respond_to_js
|
66
|
+
render :action => 'on_create'
|
67
|
+
end
|
68
|
+
|
69
|
+
def create_respond_to_xml
|
70
|
+
render :xml => response_object.to_xml(:only => active_scaffold_config.create.columns.names), :content_type => Mime::XML, :status => response_status, :location => response_location
|
71
|
+
end
|
72
|
+
|
73
|
+
def create_respond_to_json
|
74
|
+
render :text => response_object.to_json(:only => active_scaffold_config.create.columns.names), :content_type => Mime::JSON, :status => response_status, :location => response_location
|
75
|
+
end
|
76
|
+
|
77
|
+
def create_respond_to_yaml
|
78
|
+
render :text => Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.create.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status, :location => response_location
|
79
|
+
end
|
80
|
+
|
70
81
|
def constraints_for_nested_create
|
71
82
|
if params[:parent_column] && params[:parent_id]
|
72
83
|
@old_eid = params[:eid]
|
@@ -80,7 +91,7 @@ module ActiveScaffold::Actions
|
|
80
91
|
# A simple method to find and prepare an example new record for the form
|
81
92
|
# May be overridden to customize the behavior (add default values, for instance)
|
82
93
|
def do_new
|
83
|
-
@record =
|
94
|
+
@record = new_model
|
84
95
|
apply_constraints_to_record(@record)
|
85
96
|
params[:eid] = @old_eid if @remove_eid
|
86
97
|
@record
|
@@ -91,7 +102,7 @@ module ActiveScaffold::Actions
|
|
91
102
|
def do_create
|
92
103
|
begin
|
93
104
|
active_scaffold_config.model.transaction do
|
94
|
-
@record = update_record_from_params(
|
105
|
+
@record = update_record_from_params(new_model, active_scaffold_config.create.columns, params[:record])
|
95
106
|
apply_constraints_to_record(@record, :allow_autosave => true)
|
96
107
|
params[:eid] = @old_eid if @remove_eid
|
97
108
|
before_create_save(@record)
|
@@ -105,6 +116,16 @@ module ActiveScaffold::Actions
|
|
105
116
|
end
|
106
117
|
end
|
107
118
|
|
119
|
+
def new_model
|
120
|
+
model = active_scaffold_config.model
|
121
|
+
if model.columns_hash[model.inheritance_column]
|
122
|
+
params = self.params # in new action inheritance_column must be in params
|
123
|
+
params = params[:record] || {} unless params[model.inheritance_column] # in create action must be inside record key
|
124
|
+
model = params.delete(model.inheritance_column).camelize.constantize if params[model.inheritance_column]
|
125
|
+
end
|
126
|
+
model.new
|
127
|
+
end
|
128
|
+
|
108
129
|
# override this method if you want to inject data in the record (or its associated objects) before the save
|
109
130
|
def before_create_save(record); end
|
110
131
|
|
@@ -114,7 +135,18 @@ module ActiveScaffold::Actions
|
|
114
135
|
# The default security delegates to ActiveRecordPermissions.
|
115
136
|
# You may override the method to customize.
|
116
137
|
def create_authorized?
|
117
|
-
authorized_for?(:
|
138
|
+
authorized_for?(:crud_type => :create)
|
139
|
+
end
|
140
|
+
private
|
141
|
+
def create_authorized_filter
|
142
|
+
link = active_scaffold_config.create.link || active_scaffold_config.create.class.link
|
143
|
+
raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
|
144
|
+
end
|
145
|
+
def new_formats
|
146
|
+
(default_formats + active_scaffold_config.formats).uniq
|
147
|
+
end
|
148
|
+
def create_formats
|
149
|
+
(default_formats + active_scaffold_config.formats + active_scaffold_config.create.formats).uniq
|
118
150
|
end
|
119
151
|
end
|
120
152
|
end
|