workarea-core 3.4.45 → 3.5.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +52 -0
- data/app/assets/javascripts/workarea/core/modules/duplicate_id.js +1 -5
- data/app/assets/javascripts/workarea/core/modules/style_guide_autocomplete_fields.js +9 -42
- data/app/assets/javascripts/workarea/core/modules/url.js +14 -0
- data/app/controllers/workarea/application_controller.rb +5 -1
- data/app/controllers/workarea/authentication.rb +15 -26
- data/app/controllers/workarea/authorization.rb +3 -3
- data/app/controllers/workarea/current_referrer.rb +1 -2
- data/app/controllers/workarea/current_release.rb +1 -1
- data/app/controllers/workarea/current_segments.rb +52 -0
- data/app/controllers/workarea/current_tracking.rb +45 -0
- data/app/controllers/workarea/http_caching.rb +30 -0
- data/app/controllers/workarea/impersonation.rb +18 -44
- data/app/helpers/workarea/schema_org_helper.rb +21 -0
- data/app/mailers/workarea/application_mailer.rb +2 -4
- data/app/middleware/workarea/application_middleware.rb +44 -0
- data/app/middleware/workarea/query_cache_middleware.rb +55 -0
- data/app/middleware/workarea/release_server_middleware.rb +1 -1
- data/app/models/workarea/application_document.rb +1 -1
- data/app/models/workarea/bulk_action/product_edit.rb +6 -6
- data/app/models/workarea/calculate_percent_change.rb +1 -1
- data/app/models/workarea/catalog/category.rb +0 -2
- data/app/models/workarea/catalog/product.rb +19 -2
- data/app/models/workarea/checkout/collect_payment.rb +10 -1
- data/app/models/workarea/checkout/fraud/analyzer.rb +44 -0
- data/app/models/workarea/checkout/fraud/no_decision_analyzer.rb +14 -0
- data/app/models/workarea/checkout/fraud/test_analyzer.rb +26 -0
- data/app/models/workarea/checkout.rb +18 -6
- data/app/models/workarea/configuration/admin.rb +25 -0
- data/app/models/workarea/configuration/params.rb +45 -0
- data/app/models/workarea/content/asset.rb +5 -18
- data/app/models/workarea/content/block.rb +8 -2
- data/app/models/workarea/content/block_draft.rb +7 -2
- data/app/models/workarea/content/block_type.rb +2 -2
- data/app/models/workarea/content/block_type_definition.rb +4 -0
- data/app/models/workarea/content/preset.rb +1 -1
- data/app/models/workarea/content.rb +12 -82
- data/app/models/workarea/data_file/csv.rb +6 -8
- data/app/models/workarea/data_file/import.rb +9 -1
- data/app/models/workarea/data_file/json.rb +1 -20
- data/app/models/workarea/data_file/operation.rb +0 -4
- data/app/models/workarea/data_file/tax_rates.rb +3 -0
- data/app/models/workarea/featured_products.rb +8 -0
- data/app/models/workarea/fulfillment/policies/base.rb +21 -0
- data/app/models/workarea/fulfillment/policies/download.rb +21 -0
- data/app/models/workarea/fulfillment/policies/ignore.rb +11 -0
- data/app/models/workarea/fulfillment/policies/ship.rb +15 -0
- data/app/models/workarea/fulfillment/sku.rb +72 -0
- data/app/models/workarea/fulfillment/token.rb +36 -0
- data/app/models/workarea/inquiry.rb +1 -2
- data/app/models/workarea/insights/customer_acquisition.rb +5 -9
- data/app/models/workarea/insights/trending_products.rb +2 -2
- data/app/models/workarea/insights/trending_searches.rb +2 -2
- data/app/models/workarea/inventory/collection.rb +30 -0
- data/app/models/workarea/inventory/collection_status.rb +40 -0
- data/app/models/workarea/metrics/affinity.rb +33 -0
- data/app/models/workarea/metrics/country_by_day.rb +4 -0
- data/app/models/workarea/metrics/product_by_day.rb +3 -0
- data/app/models/workarea/metrics/product_by_week.rb +2 -0
- data/app/models/workarea/metrics/product_for_last_week.rb +8 -12
- data/app/models/workarea/metrics/sales_by_day.rb +5 -0
- data/app/models/workarea/metrics/search_by_day.rb +1 -3
- data/app/models/workarea/metrics/search_for_last_week.rb +5 -11
- data/app/models/workarea/metrics/segment_by_day.rb +31 -0
- data/app/models/workarea/metrics/sku_by_day.rb +3 -0
- data/app/models/workarea/metrics/tender_by_day.rb +11 -0
- data/app/models/workarea/metrics/update_user_aggregations.rb +77 -0
- data/app/models/workarea/metrics/user.rb +73 -87
- data/app/models/workarea/navigation/breadcrumbs.rb +10 -1
- data/app/models/workarea/order/fraud_decision.rb +18 -0
- data/app/models/workarea/order/item.rb +5 -0
- data/app/models/workarea/order/queries.rb +1 -0
- data/app/models/workarea/order/status.rb +10 -1
- data/app/models/workarea/order.rb +47 -4
- data/app/models/workarea/payment/credit_card.rb +12 -0
- data/app/models/workarea/payment.rb +7 -2
- data/app/models/workarea/pricing/cache_key.rb +9 -3
- data/app/models/workarea/pricing/calculator.rb +5 -1
- data/app/models/workarea/pricing/calculators/tax_calculator.rb +32 -5
- data/app/models/workarea/pricing/discount/application_group.rb +8 -3
- data/app/models/workarea/pricing/discount/free_gift.rb +2 -1
- data/app/models/workarea/pricing/discount/redemption.rb +1 -1
- data/app/models/workarea/pricing/discount.rb +2 -3
- data/app/models/workarea/pricing/item_tax_applier.rb +41 -0
- data/app/models/workarea/pricing/price.rb +1 -0
- data/app/models/workarea/pricing/request.rb +11 -0
- data/app/models/workarea/pricing/sku.rb +1 -0
- data/app/models/workarea/pricing/tax_application.rb +21 -0
- data/app/models/workarea/pricing/tax_applier.rb +12 -15
- data/app/models/workarea/pricing/unsupported_segmentation.rb +22 -0
- data/app/models/workarea/product_rule.rb +5 -0
- data/app/models/workarea/releasable.rb +83 -89
- data/app/models/workarea/release/activation.rb +45 -0
- data/app/models/workarea/release/changes.rb +45 -0
- data/app/models/workarea/release/changeset.rb +42 -52
- data/app/models/workarea/release/preview.rb +28 -0
- data/app/models/workarea/release/status.rb +2 -24
- data/app/models/workarea/release.rb +72 -99
- data/app/models/workarea/release_session.rb +11 -11
- data/app/models/workarea/search/admin/catalog_product.rb +1 -2
- data/app/models/workarea/search/admin/fulfillment_sku.rb +27 -0
- data/app/models/workarea/search/admin/order.rb +1 -1
- data/app/models/workarea/search/admin/pricing_discount.rb +1 -1
- data/app/models/workarea/search/admin/release.rb +1 -4
- data/app/models/workarea/search/admin/segment.rb +19 -0
- data/app/models/workarea/search/admin.rb +17 -39
- data/app/models/workarea/search/order_text.rb +23 -6
- data/app/models/workarea/search/storefront/category_query.rb +152 -0
- data/app/models/workarea/search/storefront/product/categories.rb +11 -45
- data/app/models/workarea/search/storefront.rb +33 -29
- data/app/models/workarea/segment/first_time_customer.rb +8 -0
- data/app/models/workarea/segment/first_time_visitor.rb +12 -0
- data/app/models/workarea/segment/life_cycle.rb +44 -0
- data/app/models/workarea/segment/loyal_customer.rb +12 -0
- data/app/models/workarea/segment/returning_customer.rb +14 -0
- data/app/models/workarea/segment/returning_visitor.rb +12 -0
- data/app/models/workarea/segment/rules/base.rb +16 -0
- data/app/models/workarea/segment/rules/browser_info.rb +29 -0
- data/app/models/workarea/segment/rules/geolocation.rb +29 -0
- data/app/models/workarea/segment/rules/geolocation_option.rb +53 -0
- data/app/models/workarea/segment/rules/last_order.rb +14 -0
- data/app/models/workarea/segment/rules/logged_in.rb +13 -0
- data/app/models/workarea/segment/rules/orders.rb +17 -0
- data/app/models/workarea/segment/rules/revenue.rb +17 -0
- data/app/models/workarea/segment/rules/sessions.rb +17 -0
- data/app/models/workarea/segment/rules/tags.rb +14 -0
- data/app/models/workarea/segment/rules/traffic_referrer.rb +18 -0
- data/app/models/workarea/segment.rb +54 -0
- data/app/models/workarea/segmentable.rb +66 -0
- data/app/models/workarea/sort.rb +14 -2
- data/app/models/workarea/tax/rate.rb +35 -1
- data/app/models/workarea/user/authorization.rb +19 -13
- data/app/models/workarea/user/login.rb +4 -0
- data/app/models/workarea/user/password_reset.rb +1 -3
- data/app/queries/workarea/categorization.rb +3 -3
- data/app/queries/workarea/featured_categorization.rb +53 -0
- data/app/queries/workarea/order_cancellation_metrics.rb +155 -0
- data/app/queries/workarea/order_item_details.rb +16 -3
- data/app/queries/workarea/order_metrics.rb +32 -3
- data/app/queries/workarea/product_primary_navigation.rb +13 -2
- data/app/queries/workarea/product_releases.rb +38 -0
- data/app/queries/workarea/recommendation/user_activity_based.rb +14 -6
- data/app/queries/workarea/reports/average_order_value.rb +1 -1
- data/app/queries/workarea/reports/customers.rb +14 -11
- data/app/queries/workarea/reports/first_time_vs_returning_sales.rb +1 -1
- data/app/queries/workarea/reports/group_by_time.rb +13 -17
- data/app/queries/workarea/reports/sales_by_category.rb +1 -1
- data/app/queries/workarea/reports/sales_by_country.rb +10 -3
- data/app/queries/workarea/reports/sales_by_discount.rb +1 -1
- data/app/queries/workarea/reports/sales_by_menu.rb +1 -1
- data/app/queries/workarea/reports/sales_by_product.rb +39 -4
- data/app/queries/workarea/reports/sales_by_sku.rb +39 -4
- data/app/queries/workarea/reports/sales_by_tender.rb +42 -0
- data/app/queries/workarea/reports/sales_by_traffic_referrer.rb +1 -1
- data/app/queries/workarea/reports/sales_over_time.rb +10 -3
- data/app/queries/workarea/reports/searches.rb +1 -1
- data/app/queries/workarea/reports/searches_over_time.rb +1 -1
- data/app/queries/workarea/reports/searches_without_results_over_time.rb +1 -1
- data/app/queries/workarea/search/admin_fulfillment_skus.rb +20 -0
- data/app/queries/workarea/search/admin_releases.rb +1 -4
- data/app/queries/workarea/search/admin_search.rb +0 -4
- data/app/queries/workarea/search/admin_segments.rb +16 -0
- data/app/queries/workarea/search/admin_sorting.rb +1 -1
- data/app/queries/workarea/search/pagination.rb +1 -4
- data/app/queries/workarea/search/product_display_rules.rb +40 -8
- data/app/queries/workarea/search/product_entries.rb +15 -1
- data/app/queries/workarea/search/product_search.rb +4 -1
- data/app/queries/workarea/search/storefront_search/exact_matches.rb +1 -1
- data/app/queries/workarea/search/storefront_search/response.rb +6 -4
- data/app/queries/workarea/search/storefront_search.rb +5 -4
- data/app/seeds/workarea/assets_seeds.rb +2 -1
- data/app/seeds/workarea/insights_seeds.rb +0 -23
- data/app/seeds/workarea/orders_seeds.rb +7 -6
- data/app/seeds/workarea/products_seeds.rb +2 -0
- data/app/seeds/workarea/segments_seeds.rb +8 -0
- data/app/seeds/workarea/tax_seeds.rb +3 -3
- data/app/services/workarea/cancel_order.rb +8 -3
- data/app/services/workarea/copy_order.rb +6 -0
- data/app/services/workarea/create_fulfillment.rb +5 -3
- data/app/services/workarea/direct_upload.rb +11 -19
- data/app/services/workarea/hash_update.rb +1 -18
- data/app/services/workarea/packaging.rb +1 -1
- data/app/services/workarea/save_publishing.rb +5 -1
- data/app/workers/sidekiq/callbacks.rb +4 -52
- data/app/workers/sidekiq/callbacks_worker.rb +4 -6
- data/app/workers/workarea/bulk_index_admin.rb +2 -2
- data/app/workers/workarea/bulk_index_products.rb +6 -5
- data/app/workers/workarea/bulk_index_searches.rb +5 -5
- data/app/workers/workarea/deactivate_stale_discounts.rb +3 -3
- data/app/workers/workarea/generate_insights.rb +1 -1
- data/app/workers/workarea/index_admin_search.rb +1 -0
- data/app/workers/workarea/index_categorization.rb +4 -7
- data/app/workers/workarea/index_category.rb +2 -1
- data/app/workers/workarea/index_category_changes.rb +11 -6
- data/app/workers/workarea/index_fulfillment_changes.rb +2 -1
- data/app/workers/workarea/index_help.rb +2 -1
- data/app/workers/workarea/index_page.rb +2 -1
- data/app/workers/workarea/index_payment_transactions.rb +2 -1
- data/app/workers/workarea/index_product.rb +4 -4
- data/app/workers/workarea/index_product_children.rb +4 -3
- data/app/workers/workarea/index_product_rule.rb +3 -2
- data/app/workers/workarea/index_search_customizations.rb +3 -2
- data/app/workers/workarea/index_skus.rb +5 -6
- data/app/workers/workarea/keep_product_index_fresh.rb +3 -5
- data/app/workers/workarea/process_import.rb +3 -3
- data/app/workers/workarea/process_search_recommendations.rb +5 -9
- data/app/workers/workarea/publish_release.rb +1 -0
- data/app/workers/workarea/save_metrics.rb +116 -0
- data/app/workers/workarea/save_order_cancellation_metrics.rb +35 -0
- data/app/workers/workarea/save_order_metrics.rb +10 -74
- data/app/workers/workarea/status_reporter.rb +2 -4
- data/app/workers/workarea/synchronize_user_metrics.rb +17 -0
- data/app/workers/workarea/update_payment_profile_email.rb +22 -0
- data/app/workers/workarea/verify_scheduled_releases.rb +4 -11
- data/config/initializers/00_configuration.rb +185 -0
- data/config/initializers/02_assets.rb +1 -0
- data/config/initializers/05_scheduled_jobs.rb +0 -7
- data/config/initializers/10_rack_middleware.rb +2 -5
- data/config/initializers/11_payment.rb +4 -0
- data/config/initializers/13_rack_attack.rb +2 -4
- data/config/initializers/14_content_block_types.rb +16 -16
- data/config/initializers/15_endpoint_monitoring.rb +3 -6
- data/config/initializers/{21_premailer.rb → 24_premailer.rb} +1 -0
- data/config/initializers/{20_i18n_js.rb → 25_i18n_js.rb} +0 -0
- data/config/locales/en.yml +13 -24
- data/lib/generators/workarea/content_block_type/templates/initializer.rb +1 -1
- data/lib/generators/workarea/install/USAGE +0 -1
- data/lib/generators/workarea/install/install_generator.rb +0 -21
- data/lib/generators/workarea/install/templates/initializer.rb.erb +1 -1
- data/lib/tasks/insights.rake +1 -0
- data/lib/tasks/migrate.rake +106 -0
- data/lib/tasks/search.rake +17 -19
- data/lib/tasks/tests.rake +1 -1
- data/lib/workarea/cache.rb +6 -35
- data/lib/workarea/changelog.rake +2 -2
- data/lib/workarea/configuration/administrable/definition.rb +42 -0
- data/lib/workarea/configuration/administrable/field.rb +79 -0
- data/lib/workarea/configuration/administrable/fieldset.rb +44 -0
- data/lib/workarea/configuration/administrable_options.rb +24 -0
- data/lib/workarea/configuration/cache_store.rb +3 -1
- data/lib/workarea/configuration/content_blocks.rb +17 -0
- data/lib/workarea/configuration/mongoid.rb +1 -4
- data/lib/workarea/configuration/session.rb +36 -0
- data/lib/workarea/configuration/sidekiq.rb +3 -1
- data/lib/workarea/configuration.rb +121 -148
- data/lib/workarea/core/engine.rb +3 -58
- data/lib/workarea/core.rb +15 -11
- data/lib/workarea/elasticsearch/document.rb +8 -15
- data/lib/workarea/ext/freedom_patches/action_view_cache_helper.rb +4 -6
- data/lib/workarea/ext/freedom_patches/active_support_duration.rb +14 -0
- data/lib/workarea/ext/freedom_patches/money.rb +11 -0
- data/lib/workarea/ext/freedom_patches/premailer.rb +6 -0
- data/lib/workarea/ext/freedom_patches/string.rb +19 -4
- data/lib/workarea/ext/mongoid/find_ordered.rb +2 -2
- data/lib/workarea/ext/mongoid/lookup_hash.rb +30 -0
- data/lib/workarea/geolocation.rb +24 -6
- data/lib/workarea/routes_constraints/super_admin.rb +1 -1
- data/lib/workarea/version.rb +3 -4
- data/lib/workarea/visit.rb +92 -0
- data/lib/workarea/warnings.rb +95 -0
- data/lib/workarea.rb +102 -3
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/fixtures/tax_rates.csv +3 -3
- data/test/generators/workarea/content_block_type_generator_test.rb +1 -1
- data/test/generators/workarea/install_generator_test.rb +0 -13
- data/test/integration/workarea/authentication_test.rb +27 -4
- data/test/integration/workarea/authorization_test.rb +5 -0
- data/test/integration/workarea/cache_varies_integration_test.rb +21 -23
- data/test/integration/workarea/monitoring_integration_test.rb +5 -10
- data/test/javascripts/duplicate_id_spec.js +1 -7
- data/test/javascripts/fixtures/{duplicate_id_fail.html.haml → duplicate_id.html.haml} +0 -1
- data/test/javascripts/form_submitting_controls_spec.js +0 -1
- data/test/lib/workarea/asset_endpoints/favicons_test.rb +11 -13
- data/test/lib/workarea/configuration/administrable/definition_test.rb +71 -0
- data/test/lib/workarea/configuration/administrable/field_test.rb +128 -0
- data/test/lib/workarea/configuration/administrable/fieldset_test.rb +78 -0
- data/test/lib/workarea/configuration/configuration_test.rb +20 -0
- data/test/lib/workarea/elasticsearch/document_test.rb +0 -20
- data/test/lib/workarea/elasticsearch/query_cache_test.rb +7 -7
- data/test/lib/workarea/ext/freedom_patches/money_test.rb +11 -0
- data/test/lib/workarea/ext/mongoid/lookup_hash_test.rb +86 -0
- data/test/lib/workarea/geolocation_test.rb +20 -0
- data/test/mailers/workarea/application_mailer_test.rb +1 -11
- data/test/middleware/workarea/query_cache_middleware_test.rb +55 -0
- data/test/models/workarea/checkout/collect_payment_test.rb +14 -6
- data/test/models/workarea/checkout_test.rb +31 -57
- data/test/models/workarea/configuration/params_test.rb +37 -0
- data/test/models/workarea/data_file/csv_test.rb +8 -73
- data/test/models/workarea/data_file/import_test.rb +31 -0
- data/test/models/workarea/data_file/json_test.rb +6 -48
- data/test/models/workarea/data_file/tax_test.rb +3 -0
- data/test/models/workarea/fulfillment/policies/download_test.rb +39 -0
- data/test/models/workarea/fulfillment/sku_test.rb +54 -0
- data/test/models/workarea/insights/best_customers_test.rb +5 -2
- data/test/models/workarea/insights/best_full_price_customers_test.rb +5 -2
- data/test/models/workarea/insights/customer_acquisition_test.rb +1 -1
- data/test/models/workarea/insights/customers_at_risk_test.rb +1 -1
- data/test/models/workarea/insights/low_aov_customers_test.rb +1 -1
- data/test/models/workarea/inventory/collection_test.rb +75 -0
- data/test/models/workarea/metrics/affinity_test.rb +85 -0
- data/test/models/workarea/metrics/product_by_week_test.rb +27 -31
- data/test/models/workarea/metrics/search_by_day_test.rb +3 -0
- data/test/models/workarea/metrics/search_by_week_test.rb +27 -31
- data/test/models/workarea/metrics/update_user_aggregations_test.rb +62 -0
- data/test/models/workarea/metrics/user_test.rb +146 -63
- data/test/models/workarea/navigation/breadcrumbs_test.rb +12 -2
- data/test/models/workarea/order/queries_test.rb +2 -0
- data/test/models/workarea/order_test.rb +44 -0
- data/test/models/workarea/payment/address_test.rb +109 -111
- data/test/models/workarea/payment/credit_card_integration_test.rb +0 -52
- data/test/models/workarea/payment/credit_card_test.rb +5 -0
- data/test/models/workarea/pricing/cache_key_test.rb +7 -1
- data/test/models/workarea/pricing/calculators/tax_calculator_test.rb +41 -1
- data/test/models/workarea/pricing/discount/collection_test.rb +27 -29
- data/test/models/workarea/pricing/discount_test.rb +22 -24
- data/test/models/workarea/pricing/item_tax_applier_test.rb +83 -0
- data/test/models/workarea/pricing/price_test.rb +9 -0
- data/test/models/workarea/pricing/request_test.rb +13 -0
- data/test/models/workarea/pricing/sku_test.rb +9 -0
- data/test/models/workarea/releasable_active_test.rb +113 -0
- data/test/models/workarea/releasable_test.rb +69 -120
- data/test/models/workarea/release/changeset_test.rb +41 -0
- data/test/models/workarea/release_jobs_test.rb +52 -0
- data/test/models/workarea/release_previewing_test.rb +43 -0
- data/test/models/workarea/release_test.rb +59 -153
- data/test/models/workarea/search/admin/content_asset_test.rb +26 -28
- data/test/models/workarea/search/order_text_test.rb +35 -0
- data/test/models/workarea/search/storefront/category_query_test.rb +81 -0
- data/test/models/workarea/search/storefront/product/categories_test.rb +10 -70
- data/test/models/workarea/search/storefront/product_test.rb +10 -11
- data/test/models/workarea/search/storefront_test.rb +1 -13
- data/test/models/workarea/segment/life_cycle_test.rb +24 -0
- data/test/models/workarea/segment/rules/browser_info_test.rb +33 -0
- data/test/models/workarea/segment/rules/geolocation_option_test.rb +16 -0
- data/test/models/workarea/segment/rules/geolocation_test.rb +49 -0
- data/test/models/workarea/segment/rules/last_order_test.rb +32 -0
- data/test/models/workarea/segment/rules/logged_in_test.rb +25 -0
- data/test/models/workarea/segment/rules/orders_test.rb +59 -0
- data/test/models/workarea/segment/rules/revenue_test.rb +59 -0
- data/test/models/workarea/segment/rules/sessions_test.rb +26 -0
- data/test/models/workarea/segment/rules/tags_test.rb +27 -0
- data/test/models/workarea/segment/rules/traffic_referrer_test.rb +31 -0
- data/test/models/workarea/segment_test.rb +80 -0
- data/test/models/workarea/segmentable_test.rb +74 -0
- data/test/models/workarea/shipping/address_test.rb +109 -111
- data/test/models/workarea/shipping/sku_test.rb +8 -12
- data/test/models/workarea/user/password_reset_test.rb +4 -12
- data/test/models/workarea/user_test.rb +13 -10
- data/test/queries/workarea/admin_search_query_wrapper_test.rb +21 -25
- data/test/queries/workarea/categorization_test.rb +49 -0
- data/test/queries/workarea/featured_categorization_test.rb +66 -0
- data/test/queries/workarea/order_cancellation_metrics_test.rb +203 -0
- data/test/queries/workarea/order_item_details_test.rb +17 -0
- data/test/queries/workarea/order_metrics_test.rb +12 -0
- data/test/queries/workarea/product_releases_test.rb +56 -0
- data/test/queries/workarea/recommendation/searches_test.rb +3 -3
- data/test/queries/workarea/recommendation/user_activity_based_test.rb +4 -4
- data/test/queries/workarea/reports/customers_test.rb +12 -8
- data/test/queries/workarea/reports/report_test.rb +4 -6
- data/test/queries/workarea/reports/sales_by_country_test.rb +18 -3
- data/test/queries/workarea/reports/sales_by_product_test.rb +28 -8
- data/test/queries/workarea/reports/sales_by_sku_test.rb +28 -8
- data/test/queries/workarea/reports/sales_by_tender_test.rb +100 -0
- data/test/queries/workarea/reports/sales_by_traffic_referrer_test.rb +6 -6
- data/test/queries/workarea/search/admin_releases_test.rb +1 -26
- data/test/queries/workarea/search/admin_search_test.rb +0 -10
- data/test/queries/workarea/search/admin_users_test.rb +2 -2
- data/test/queries/workarea/search/category_browse_test.rb +53 -0
- data/test/queries/workarea/search/facet_sorting/size_test.rb +11 -13
- data/test/queries/workarea/search/pagination_test.rb +9 -26
- data/test/queries/workarea/search/product_entries_test.rb +27 -0
- data/test/queries/workarea/search/product_search_test.rb +0 -16
- data/test/queries/workarea/search/storefront_search/response_test.rb +26 -0
- data/test/queries/workarea/search/storefront_search_test.rb +34 -36
- data/test/services/workarea/cancel_order_test.rb +27 -13
- data/test/services/workarea/copy_order_test.rb +17 -0
- data/test/services/workarea/direct_upload_test.rb +1 -46
- data/test/services/workarea/export_report_test.rb +41 -45
- data/test/services/workarea/hash_update_test.rb +12 -12
- data/test/services/workarea/packaging_test.rb +9 -11
- data/test/services/workarea/save_publishing_test.rb +23 -0
- data/test/workers/sidekiq/callbacks_test.rb +0 -22
- data/test/workers/workarea/deactivate_stale_discounts_test.rb +2 -2
- data/test/workers/workarea/index_category_changes_test.rb +5 -7
- data/test/workers/workarea/keep_product_index_fresh_test.rb +1 -1
- data/test/workers/workarea/process_import_test.rb +0 -6
- data/test/workers/workarea/process_search_recommendations_test.rb +4 -5
- data/test/workers/workarea/status_reporter_test.rb +2 -1
- data/test/workers/workarea/synchronize_user_metrics_test.rb +57 -0
- data/test/workers/workarea/update_payment_profile_email_test.rb +27 -0
- data/test/workers/workarea/verify_scheduled_releases_test.rb +0 -26
- data/workarea-core.gemspec +13 -11
- metadata +196 -92
- data/app/assets/javascripts/workarea/core/templates/ui_menu_item.jst.ejs +0 -10
- data/app/controllers/workarea/admin_guest_browsing.rb +0 -54
- data/app/middleware/workarea/rack_cache_config_middleware.rb +0 -19
- data/app/queries/workarea/search/search_suggestions.rb +0 -43
- data/app/workers/workarea/bust_discount_cache.rb +0 -16
- data/app/workers/workarea/clean_user_activity.rb +0 -11
- data/app/workers/workarea/undo_release.rb +0 -15
- data/app/workers/workarea/update_email.rb +0 -33
- data/lib/generators/workarea/docker/USAGE +0 -16
- data/lib/generators/workarea/docker/docker_generator.rb +0 -61
- data/lib/generators/workarea/docker/templates/.env.erb +0 -6
- data/lib/generators/workarea/docker/templates/Dockerfile.erb +0 -48
- data/lib/generators/workarea/docker/templates/docker-compose.yml.erb +0 -72
- data/lib/generators/workarea/docker/templates/docker-entrypoint.sh.erb +0 -6
- data/lib/generators/workarea/docker/templates/docker-sync.yml.erb +0 -8
- data/lib/generators/workarea/docker/templates/docker-wait.sh +0 -11
- data/lib/generators/workarea/docker/templates/docker.env +0 -16
- data/lib/generators/workarea/docker/templates/docker_init.rb.erb +0 -29
- data/lib/workarea/configuration/headless_chrome.rb +0 -42
- data/lib/workarea/configuration/puma.rb +0 -37
- data/lib/workarea/ext/freedom_patches/i18n_js.rb +0 -27
- data/lib/workarea/ext/freedom_patches/mongoid_localized_defaults.rb +0 -25
- data/lib/workarea/ext/jbuilder/jbuilder_cache.rb +0 -29
- data/lib/workarea/ext/referer_parser/parser.decorator +0 -43
- data/lib/workarea/queues_pauser.rb +0 -26
- data/lib/workarea/robots.rb +0 -9
- data/test/generators/workarea/docker_generator_test.rb +0 -156
- data/test/javascripts/fixtures/duplicate_id_pass.html.haml +0 -2
- data/test/lib/workarea/ext/freedom_patches/mongoid_localized_defaults_test.rb +0 -25
- data/test/lib/workarea/ext/referer_parser/parser_test.rb +0 -20
- data/test/queries/workarea/search/search_suggestions_test.rb +0 -29
- data/test/workers/workarea/undo_release_test.rb +0 -23
- data/test/workers/workarea/update_email_test.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6ddffdd6e59cf8d313af5d6e66ce27d527aba9a8d9f226697b8291b16263c00
|
4
|
+
data.tar.gz: 64a0dcf6ab8aee0fedd8a8f3e55c3ecfbcf552fc9b8e3418daa1cb5759c6dded
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 546e65d948e142a5ed31a3d57583690af677416a1ebb0368c6d0b7e36caaeb599ef80390fe9fa9c103ed0ac1747c97e5f05b0b07c05001c2da0655a396d178a2
|
7
|
+
data.tar.gz: c5aea33c89c5a53ab66133d6a9b9181bf4dda114ee1dcc55fcb4a934e58548b0e6b70993a027f2c9659846b0b866dbe12bb7d60c0263f687aa908ffc427542bb
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
WebLinc
|
2
|
+
Business Source License
|
3
|
+
|
4
|
+
Licensor: WebLinc Corporation, 22 S. 3rd Street, 2nd Floor, Philadelphia PA 19106
|
5
|
+
|
6
|
+
Licensed Work: Workarea Commerce Platform
|
7
|
+
The Licensed Work is (c) 2019 WebLinc Corporation
|
8
|
+
|
9
|
+
Additional Use Grant:
|
10
|
+
You may make production use of the Licensed Work without an additional license agreement with WebLinc so long as you do not use the Licensed Work for a Commerce Service.
|
11
|
+
|
12
|
+
A "Commerce Service" is a commercial offering that allows third parties (other than your employees and contractors) to access the functionality of the Licensed Work by creating or managing commerce functionality, the products, taxonomy, assets and/or content of which are controlled by such third parties.
|
13
|
+
|
14
|
+
For information about obtaining an additional license agreement with WebLinc, contact licensing@workarea.com.
|
15
|
+
|
16
|
+
Change Date: 2019-08-20
|
17
|
+
|
18
|
+
Change License: Version 2.0 or later of the GNU General Public License as published by the Free Software Foundation
|
19
|
+
|
20
|
+
Terms
|
21
|
+
|
22
|
+
The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
|
23
|
+
|
24
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
|
25
|
+
|
26
|
+
If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
|
27
|
+
|
28
|
+
All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
|
29
|
+
|
30
|
+
You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
|
31
|
+
|
32
|
+
Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
|
33
|
+
|
34
|
+
This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License). TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works and to refer to it using the trademark "Business Source License" as long as you comply with the Covenants of Licensor below.
|
35
|
+
|
36
|
+
Covenants of Licensor
|
37
|
+
In consideration of the right to use this License’s text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
|
38
|
+
|
39
|
+
To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
|
40
|
+
|
41
|
+
To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None."
|
42
|
+
|
43
|
+
To specify a Change Date.
|
44
|
+
|
45
|
+
Not to modify this License in any other way.
|
46
|
+
|
47
|
+
Notice
|
48
|
+
The Business Source License (this document, or the "License") is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.
|
49
|
+
|
50
|
+
For more information on the use of the Business Source License generally, please visit the Adopting and Developing Business Source License FAQ.
|
51
|
+
|
52
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
|
@@ -54,17 +54,13 @@ WORKAREA.registerModule('duplicateId', (function () {
|
|
54
54
|
}).toArray();
|
55
55
|
},
|
56
56
|
|
57
|
-
hasIdValue = function (_, element) {
|
58
|
-
return element.id !== '';
|
59
|
-
},
|
60
|
-
|
61
57
|
/**
|
62
58
|
* @method
|
63
59
|
* @name init
|
64
60
|
* @memberof WORKAREA.duplicateId
|
65
61
|
*/
|
66
62
|
init = function () {
|
67
|
-
var $elements = $('[id]')
|
63
|
+
var $elements = $('[id]'),
|
68
64
|
ids = getIdValues($elements);
|
69
65
|
|
70
66
|
if (_.isEmpty($elements) || noDuplicateIds(ids)) { return; }
|
@@ -1,42 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
'
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
'Large red sweater',
|
11
|
-
'Small blue sweater',
|
12
|
-
'Medium blue sweater',
|
13
|
-
'Large blue sweater',
|
14
|
-
'Small green sweater',
|
15
|
-
'Medium green sweater',
|
16
|
-
'Large green sweater',
|
17
|
-
'Small white sweater',
|
18
|
-
'Medium white sweater',
|
19
|
-
'Large white sweater',
|
20
|
-
'Small black sweater',
|
21
|
-
'Medium black sweater',
|
22
|
-
'Large black sweater',
|
23
|
-
'Small yellow sweater',
|
24
|
-
'Medium yellow sweater',
|
25
|
-
'Large yellow sweater'
|
26
|
-
],
|
27
|
-
|
28
|
-
/**
|
29
|
-
* @method
|
30
|
-
* @name init
|
31
|
-
* @memberof WORKAREA.styleGuideAutocompleteFields
|
32
|
-
*/
|
33
|
-
init = function ($scope) {
|
34
|
-
$('[data-style-guide-autocomplete-field]', $scope).autocomplete({
|
35
|
-
source: AUTOCOMPLETE_DATA
|
36
|
-
});
|
37
|
-
};
|
38
|
-
|
39
|
-
return {
|
40
|
-
init: init
|
41
|
-
};
|
42
|
-
}()));
|
1
|
+
throw new Error(
|
2
|
+
'WORKAREA.styleGuideAutocompleteFields: The base Storefront engine no ' +
|
3
|
+
'no longer uses this file. If you are seeing this error in the ' +
|
4
|
+
'Storefront remove the path ' +
|
5
|
+
'`workarea/core/modules/style_guide_autocomplete_fields` from the ' +
|
6
|
+
'Storefront JavaScript application manifest. If you are seeing this ' +
|
7
|
+
'error in the Admin change the aforementioned path to ' +
|
8
|
+
'`workarea/core/modules/style_guide_autocomplete_fields`.'
|
9
|
+
);
|
@@ -59,6 +59,19 @@ WORKAREA.registerModule('url', (function () {
|
|
59
59
|
return [url, queryString].join('?');
|
60
60
|
},
|
61
61
|
|
62
|
+
/**
|
63
|
+
* @method
|
64
|
+
* @name addQuery
|
65
|
+
* @memberof WORKAREA.url
|
66
|
+
*/
|
67
|
+
addToQuery = function (url, queryToAppend) {
|
68
|
+
if (_.includes(url, '?')) {
|
69
|
+
return [url, queryToAppend].join('&');
|
70
|
+
} else {
|
71
|
+
return addQuery(url, queryToAppend);
|
72
|
+
}
|
73
|
+
},
|
74
|
+
|
62
75
|
/**
|
63
76
|
* @method
|
64
77
|
* @name removeQuery
|
@@ -114,6 +127,7 @@ WORKAREA.registerModule('url', (function () {
|
|
114
127
|
return {
|
115
128
|
parse: parse,
|
116
129
|
addQuery: addQuery,
|
130
|
+
addToQuery: addToQuery,
|
117
131
|
removeQuery: removeQuery,
|
118
132
|
replaceQuery: replaceQuery,
|
119
133
|
current: current,
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Workarea
|
2
2
|
class ApplicationController < ActionController::Base
|
3
3
|
include I18n::DefaultUrlOptions
|
4
|
+
include HttpCaching
|
5
|
+
include CurrentTracking
|
6
|
+
include CurrentSegments
|
7
|
+
|
4
8
|
protect_from_forgery
|
5
9
|
|
6
10
|
before_action :set_locale
|
@@ -20,7 +24,7 @@ module Workarea
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def current_location
|
23
|
-
|
27
|
+
current_visit.geolocation
|
24
28
|
end
|
25
29
|
|
26
30
|
def view_model_options
|
@@ -12,33 +12,33 @@ module Workarea
|
|
12
12
|
|
13
13
|
def current_user
|
14
14
|
return @current_user if defined?(@current_user)
|
15
|
-
@current_user = User.find(
|
15
|
+
@current_user = User.find(session[:user_id]) rescue nil
|
16
16
|
end
|
17
17
|
|
18
18
|
def login(user)
|
19
19
|
@current_user = user
|
20
|
+
session[:user_id] = user.id.to_s
|
20
21
|
user.update_login!(request)
|
21
|
-
|
22
|
+
update_tracking!
|
22
23
|
user
|
23
24
|
end
|
24
25
|
|
25
26
|
def logout
|
26
|
-
|
27
|
+
reset_session
|
27
28
|
cookies.delete(:cache)
|
28
|
-
cookies.delete(:completed_order)
|
29
29
|
@current_user = nil
|
30
|
+
update_tracking!
|
30
31
|
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
cookies.signed[:user_id] = { value: current_user.id, expires: auth_expiry }
|
36
|
-
|
37
|
-
if current_user.admin?
|
38
|
-
cookies[:cache] = { value: 'false', expires: auth_expiry }
|
39
|
-
end
|
40
|
-
end
|
33
|
+
# TODO deprecated, remove in v3.6
|
34
|
+
def touch_auth_cookie; end
|
41
35
|
alias_method :keep_auth_alive, :touch_auth_cookie
|
36
|
+
%w(keep_auth_alive touch_auth_cookie).each do |method|
|
37
|
+
Workarea.deprecation.deprecate_methods Authentication, method => <<~eos.squish
|
38
|
+
Session is handled with Rails sessions now, you won't need either of
|
39
|
+
these methods
|
40
|
+
eos
|
41
|
+
end
|
42
42
|
|
43
43
|
def logged_in?
|
44
44
|
current_user.present? && current_user.valid_logged_in_request?(request)
|
@@ -47,6 +47,7 @@ module Workarea
|
|
47
47
|
def require_login(should_remember_location = true)
|
48
48
|
return if logged_in?
|
49
49
|
|
50
|
+
logout if current_user.present? # reset everything if invalid logged in request
|
50
51
|
flash[:info] = t('workarea.authentication.login')
|
51
52
|
remember_location if request.get? && should_remember_location
|
52
53
|
redirect_to storefront.login_path, turbolinks: false
|
@@ -62,9 +63,7 @@ module Workarea
|
|
62
63
|
end
|
63
64
|
|
64
65
|
def require_password_changes
|
65
|
-
|
66
|
-
|
67
|
-
if current_user.force_password_change?
|
66
|
+
if current_user&.force_password_change?
|
68
67
|
flash[:warning] = t('workarea.authentication.password_expired')
|
69
68
|
|
70
69
|
if request.xhr?
|
@@ -103,15 +102,5 @@ module Workarea
|
|
103
102
|
session.delete(:return_to)
|
104
103
|
redirect_to remembered || default
|
105
104
|
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def auth_expiry
|
110
|
-
if current_user.admin?
|
111
|
-
Workarea.config.admin_session_timeout.from_now
|
112
|
-
else
|
113
|
-
Workarea.config.customer_session_timeout.from_now
|
114
|
-
end
|
115
|
-
end
|
116
105
|
end
|
117
106
|
end
|
@@ -15,7 +15,7 @@ module Workarea
|
|
15
15
|
|
16
16
|
def require_admin
|
17
17
|
unless current_user.try(:admin?)
|
18
|
-
flash[:error] = '
|
18
|
+
flash[:error] = t('workarea.admin.authorization.unauthorized_action')
|
19
19
|
redirect_to storefront.root_path
|
20
20
|
return false
|
21
21
|
end
|
@@ -34,12 +34,12 @@ module Workarea
|
|
34
34
|
|
35
35
|
def authorized?
|
36
36
|
current_user.admin? && Array(required_permissions).all? do |area|
|
37
|
-
current_user.
|
37
|
+
current_user.try("#{area}_access?") || current_user.try("#{area}?")
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
def unauthorized_user
|
42
|
-
flash[:error] = '
|
42
|
+
flash[:error] = t('workarea.admin.authorization.unauthorized_area')
|
43
43
|
redirect_back fallback_location: root_path
|
44
44
|
end
|
45
45
|
end
|
@@ -7,9 +7,8 @@ module Workarea
|
|
7
7
|
return unless referrer.present?
|
8
8
|
|
9
9
|
@current_referrer ||= TrafficReferrer.new(
|
10
|
-
|
10
|
+
Workarea.referrer_parser.parse(referrer).slice(:source, :medium, :uri)
|
11
11
|
)
|
12
|
-
rescue RefererParser::InvalidUriError
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Workarea
|
2
|
+
module CurrentSegments
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include CurrentTracking
|
5
|
+
|
6
|
+
included do
|
7
|
+
delegate :override_segments, to: :current_visit
|
8
|
+
helper_method :current_segments, :override_segments
|
9
|
+
|
10
|
+
after_action :mark_segmented_content
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.segmented_content?
|
14
|
+
!!Thread.current[:segmented_content]
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.has_segmented_content!
|
18
|
+
Thread.current[:segmented_content] = true
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.reset_segmented_content
|
22
|
+
Thread.current[:segmented_content] = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def override_segments=(segments)
|
26
|
+
if segments.blank?
|
27
|
+
session.delete(:segment_ids)
|
28
|
+
return
|
29
|
+
end
|
30
|
+
|
31
|
+
session[:segment_ids] = segments.map(&:id)
|
32
|
+
current_visit.override_segments = segments
|
33
|
+
end
|
34
|
+
|
35
|
+
def current_segments
|
36
|
+
Segment.current
|
37
|
+
end
|
38
|
+
|
39
|
+
def apply_segments
|
40
|
+
Segment.with_current(current_visit&.applied_segments) { yield }
|
41
|
+
end
|
42
|
+
|
43
|
+
def mark_segmented_content
|
44
|
+
if CurrentSegments.segmented_content?
|
45
|
+
response.set_header('X-Workarea-Segmented-Content', 'true')
|
46
|
+
end
|
47
|
+
|
48
|
+
ensure
|
49
|
+
CurrentSegments.reset_segmented_content
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Workarea
|
2
|
+
module CurrentTracking
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include HttpCaching
|
5
|
+
|
6
|
+
included do
|
7
|
+
before_action :ensure_current_metrics
|
8
|
+
helper_method :current_visit, :current_metrics
|
9
|
+
|
10
|
+
delegate :current_metrics_id, :current_metrics_id=, :browser,
|
11
|
+
to: :current_visit, allow_nil: true
|
12
|
+
end
|
13
|
+
|
14
|
+
def current_visit
|
15
|
+
request.env['workarea.visit']
|
16
|
+
end
|
17
|
+
|
18
|
+
def current_metrics
|
19
|
+
current_visit.metrics
|
20
|
+
end
|
21
|
+
|
22
|
+
def update_tracking!(email: current_user&.email)
|
23
|
+
if email.blank?
|
24
|
+
cookies.delete(:email)
|
25
|
+
elsif email != cookies.signed[:email]
|
26
|
+
Metrics::User.find_or_initialize_by(id: email).merge!(current_visit&.metrics)
|
27
|
+
cookies.permanent.signed[:email] = email
|
28
|
+
end
|
29
|
+
|
30
|
+
request.env['workarea.visit'] = Visit.new(request.env)
|
31
|
+
end
|
32
|
+
|
33
|
+
# This method is mostly for tests, but could surface in an implementation.
|
34
|
+
# Since Rails doesn't set and load a session until needed, an initial
|
35
|
+
# request won't have a session ID for `current_visit` to check when loading
|
36
|
+
# metrics. This ensures there will be one.
|
37
|
+
def ensure_current_metrics
|
38
|
+
return if current_metrics_id.present? || http_caching?
|
39
|
+
|
40
|
+
# This forces Rails to initialize the session, which provides an ID for metrics
|
41
|
+
session.delete(:foo)
|
42
|
+
self.current_metrics_id = session.id
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Workarea
|
2
|
+
module HttpCaching
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
after_action :set_vary_headers
|
7
|
+
helper_method :http_caching?
|
8
|
+
end
|
9
|
+
|
10
|
+
def cache_page
|
11
|
+
unless current_user.try(:admin?)
|
12
|
+
expires_in Workarea.config.cache_expirations.http_cache, public: true if flash.blank?
|
13
|
+
request.session_options[:skip] = true
|
14
|
+
@http_caching = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def http_caching?
|
19
|
+
!!@http_caching
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def set_vary_headers
|
25
|
+
response.headers['X-Requested-With'] = request.headers['X-Requested-With'] || ''
|
26
|
+
response.headers['Vary'] = 'X-Requested-With, X-Workarea-Segments'
|
27
|
+
fresh_when(last_modified: Time.current)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -2,42 +2,31 @@ module Workarea
|
|
2
2
|
module Impersonation
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
include Authorization
|
5
|
-
include AdminGuestBrowsing
|
6
5
|
|
7
6
|
included do
|
8
7
|
helper_method :impersonating?
|
8
|
+
helper_method :admin_browsing_as_guest?
|
9
9
|
helper_method :current_admin
|
10
10
|
helper_method :current_impersonation
|
11
|
-
|
12
|
-
prepend_before_action :check_impersonation_status
|
13
11
|
end
|
14
12
|
|
15
13
|
def impersonate_user(user)
|
16
|
-
session[:admin_id] = current_user.id
|
17
|
-
|
18
|
-
cookies.signed[:user_id] = {
|
19
|
-
value: user.id,
|
20
|
-
expires: Workarea.config.customer_session_timeout.from_now
|
21
|
-
}
|
14
|
+
session[:admin_id] = current_user.id.to_s
|
15
|
+
session[:user_id] = user.id.to_s
|
22
16
|
|
23
17
|
user.mark_impersonated_by!(current_user)
|
24
18
|
@current_user = user
|
25
19
|
end
|
26
20
|
|
27
21
|
def stop_impersonation
|
28
|
-
|
29
|
-
value: current_admin.id,
|
30
|
-
expires: Workarea.config.admin_session_timeout.from_now
|
31
|
-
}
|
32
|
-
|
22
|
+
session[:user_id] = current_admin.id.to_s
|
33
23
|
session.delete(:admin_id)
|
34
24
|
end
|
35
25
|
|
36
26
|
def impersonating?(user = nil)
|
37
27
|
session[:admin_id].present? &&
|
38
|
-
|
39
|
-
|
40
|
-
(user.blank? || user.id.to_s == cookies.signed[:user_id])
|
28
|
+
session[:admin_id] != session[:user_id] &&
|
29
|
+
(user.blank? || user.id.to_s == session[:user_id])
|
41
30
|
end
|
42
31
|
|
43
32
|
def current_admin
|
@@ -50,23 +39,21 @@ module Workarea
|
|
50
39
|
end
|
51
40
|
|
52
41
|
def current_impersonation
|
53
|
-
|
54
|
-
@current_impersonation = User.find(cookies.signed[:user_id]) rescue nil
|
42
|
+
@current_impersonation ||= User.find(session[:user_id])
|
55
43
|
end
|
56
44
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
60
|
-
expires: Workarea.config.customer_session_timeout.from_now
|
61
|
-
}
|
45
|
+
def admin_browse_as_guest
|
46
|
+
session[:admin_id] = current_user.id.to_s
|
47
|
+
session.delete(:user_id)
|
62
48
|
end
|
63
49
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
50
|
+
def admin_browsing_as_guest?
|
51
|
+
session[:admin_id].present? && session[:user_id].blank?
|
52
|
+
end
|
53
|
+
|
54
|
+
def stop_admin_guest_browsing
|
55
|
+
session[:user_id] = current_admin.id.to_s
|
56
|
+
session.delete(:admin_id)
|
70
57
|
end
|
71
58
|
|
72
59
|
#
|
@@ -74,20 +61,7 @@ module Workarea
|
|
74
61
|
# validation.
|
75
62
|
#
|
76
63
|
def logged_in?
|
77
|
-
|
78
|
-
current_user.present?
|
79
|
-
else
|
80
|
-
super
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
private
|
85
|
-
|
86
|
-
def check_impersonation_status
|
87
|
-
if !(impersonating? || admin_browsing_as_guest?) && session[:admin_id].present?
|
88
|
-
session.delete(:admin_id)
|
89
|
-
session.delete(:order_id)
|
90
|
-
end
|
64
|
+
super || (impersonating? && !admin_browsing_as_guest? && current_admin.present?)
|
91
65
|
end
|
92
66
|
end
|
93
67
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Workarea
|
2
|
+
module SchemaOrgHelper
|
3
|
+
def render_schema_org(schema)
|
4
|
+
tag.script(schema.to_json.html_safe, type: 'application/ld+json')
|
5
|
+
end
|
6
|
+
|
7
|
+
def email_action_schema(target, name, description = nil)
|
8
|
+
{
|
9
|
+
'@context': 'http://schema.org',
|
10
|
+
'@type': 'EmailMessage',
|
11
|
+
'potentialAction': {
|
12
|
+
'@type': 'ViewAction',
|
13
|
+
'target': target,
|
14
|
+
'url': target,
|
15
|
+
'name': name
|
16
|
+
},
|
17
|
+
'description': description || name
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -4,13 +4,11 @@ module Workarea
|
|
4
4
|
|
5
5
|
add_template_helper Workarea::PluginsHelper
|
6
6
|
add_template_helper Workarea::ApplicationHelper
|
7
|
+
add_template_helper Workarea::SchemaOrgHelper
|
7
8
|
default from: -> (*) { Workarea.config.email_from }
|
8
9
|
|
9
10
|
def default_url_options(options = {})
|
10
|
-
|
11
|
-
super
|
12
|
-
.merge(Rails.application.config.action_mailer.default_url_options.to_h)
|
13
|
-
.merge(host: Workarea.config.host)
|
11
|
+
super.merge(host: Workarea.config.host)
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Workarea
|
2
|
+
class ApplicationMiddleware
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
request = Rack::Request.new(env)
|
9
|
+
return @app.call(env) if request.path =~ /(jpe?g|png|ico|gif|css|js)$/
|
10
|
+
|
11
|
+
setup_environment(env, request)
|
12
|
+
set_segment_request_headers(env)
|
13
|
+
status, headers, body = @app.call(env)
|
14
|
+
set_segment_response_headers(env, headers)
|
15
|
+
|
16
|
+
[status, headers, body]
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup_environment(env, request)
|
20
|
+
env['workarea.visit'] = Visit.new(env)
|
21
|
+
env['workarea.cache_varies'] = Cache::Varies.new(env['workarea.visit']).to_s
|
22
|
+
env['rack-cache.cache_key'] = Cache::RackCacheKey
|
23
|
+
env['rack-cache.force-pass'] = env['workarea.visit'].admin?
|
24
|
+
end
|
25
|
+
|
26
|
+
def set_segment_request_headers(env)
|
27
|
+
env['HTTP_X_WORKAREA_SEGMENTS'] = normalize_segment_ids(env['workarea.visit'])
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_segment_response_headers(env, headers)
|
31
|
+
headers['X-Workarea-Segments'] = normalize_segment_ids(env['workarea.visit'])
|
32
|
+
|
33
|
+
if headers['X-Workarea-Segmented-Content'] == 'true'
|
34
|
+
headers['Cache-Control'] = 'private, no-cache, max-age=0'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def normalize_segment_ids(visit)
|
41
|
+
visit.applied_segments.map(&:id).sort.join(',')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|