From bf203766679eab351dbe4e95a99db526958a3d46 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Thu, 4 Apr 2019 15:40:28 +0200 Subject: [PATCH 01/11] Add Delayed Job Web for superadmins only This adds https://github.com/ejschmitt/delayed_job_web to enable async job management such as retries, removal of failed jobs, etc. Only superadmins can access this web UI though. Therefore any sysadmin that needs to use it should have access to the appropriate instance superadmin credentials in Bitwarden. --- Gemfile | 1 + Gemfile.lock | 12 ++++++++++++ config/routes/admin.rb | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/Gemfile b/Gemfile index 374f59ac6a..9232a45e47 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,7 @@ gem 'jwt', '~> 2.1' gem 'delayed_job_active_record' gem 'daemons' +gem 'delayed_job_web' # Fix bug in simple_form preventing collection_check_boxes usage within form_for block # When merged, revert to upstream gem diff --git a/Gemfile.lock b/Gemfile.lock index d2498638ed..48fe062c13 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -277,6 +277,11 @@ GEM delayed_job_active_record (4.1.3) activerecord (>= 3.0, < 5.3) delayed_job (>= 3.0, < 5) + delayed_job_web (1.4.3) + activerecord (> 3.0.0) + delayed_job (> 2.0.3) + rack-protection (>= 1.5.5) + sinatra (>= 1.4.4) devise (2.2.8) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1) @@ -599,6 +604,8 @@ GEM rack (>= 0.4) rack-mini-profiler (0.10.7) rack (>= 1.2.0) + rack-protection (1.5.5) + rack rack-rewrite (1.5.1) rack-ssl (1.3.4) rack @@ -710,6 +717,10 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) + sinatra (1.4.6) + rack (~> 1.4) + rack-protection (~> 1.4) + tilt (>= 1.3, < 3) skylight (1.7.2) activesupport (>= 3.0.0) spinjs-rails (1.4) @@ -802,6 +813,7 @@ DEPENDENCIES debugger-linecache deface! delayed_job_active_record + delayed_job_web diffy eventmachine (>= 1.2.3) factory_bot_rails diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 1f55f8d154..f79a3eb742 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -1,5 +1,10 @@ Openfoodnetwork::Application.routes.draw do namespace :admin do + + authenticated :spree_user, -> user { user.has_spree_role?('admin') } do + mount DelayedJobWeb, at: '/delayed_job' + end + resources :bulk_line_items resources :order_cycles do From aa3f0ac577a9594699b038416ff3e8eefa418bca Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Thu, 4 Apr 2019 15:51:37 +0200 Subject: [PATCH 02/11] Reuse #superadmin? in Delayed Job Web route This moves #superadmin? to the user decorator so it can be reused outside FeatureFlags. --- app/models/feature_flags.rb | 12 ++---------- app/models/spree/user_decorator.rb | 8 ++++++++ config/routes/admin.rb | 2 +- spec/models/feature_flags_spec.rb | 4 ++-- spec/models/spree/user_spec.rb | 18 ++++++++++++++++++ 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/app/models/feature_flags.rb b/app/models/feature_flags.rb index 096ef44fcc..70dcf1c04d 100644 --- a/app/models/feature_flags.rb +++ b/app/models/feature_flags.rb @@ -11,25 +11,17 @@ class FeatureFlags # # @return [Boolean] def product_import_enabled? - superadmin? + user.superadmin? end # Checks whether the "Enterprise Fee Summary" is enabled for the specified user # # @return [Boolean] def enterprise_fee_summary_enabled? - superadmin? + user.superadmin? end private attr_reader :user - - # Checks whether the specified user is a superadmin, with full control of the - # instance - # - # @return [Boolean] - def superadmin? - user.has_spree_role?('admin') - end end diff --git a/app/models/spree/user_decorator.rb b/app/models/spree/user_decorator.rb index dec0309d2b..7b43d39b90 100644 --- a/app/models/spree/user_decorator.rb +++ b/app/models/spree/user_decorator.rb @@ -74,6 +74,14 @@ Spree.user_class.class_eval do credit_cards.where(is_default: true).first end + # Checks whether the specified user is a superadmin, with full control of the + # instance + # + # @return [Boolean] + def superadmin? + has_spree_role?('admin') + end + private def limit_owned_enterprises diff --git a/config/routes/admin.rb b/config/routes/admin.rb index f79a3eb742..e46ef5917a 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -1,7 +1,7 @@ Openfoodnetwork::Application.routes.draw do namespace :admin do - authenticated :spree_user, -> user { user.has_spree_role?('admin') } do + authenticated :spree_user, -> user { user.superadmin? } do mount DelayedJobWeb, at: '/delayed_job' end diff --git a/spec/models/feature_flags_spec.rb b/spec/models/feature_flags_spec.rb index 6b9380b879..b2ca275648 100644 --- a/spec/models/feature_flags_spec.rb +++ b/spec/models/feature_flags_spec.rb @@ -7,7 +7,7 @@ describe FeatureFlags do describe '#product_import_enabled?' do context 'when the user is superadmin' do before do - allow(user).to receive(:has_spree_role?).with('admin') { true } + allow(user).to receive(:superadmin?) { true } end it 'returns true' do @@ -17,7 +17,7 @@ describe FeatureFlags do context 'when the user is not superadmin' do before do - allow(user).to receive(:has_spree_role?).with('admin') { false } + allow(user).to receive(:superadmin?) { false } end it 'returns false' do diff --git a/spec/models/spree/user_spec.rb b/spec/models/spree/user_spec.rb index 7169930489..801d9ef9a7 100644 --- a/spec/models/spree/user_spec.rb +++ b/spec/models/spree/user_spec.rb @@ -162,4 +162,22 @@ describe Spree.user_class do end end end + + describe '#superadmin?' do + let(:user) { create(:user) } + + context 'when the user has an admin spree role' do + before { user.spree_roles << Spree::Role.create(name: 'admin') } + + it 'returns true' do + expect(user.superadmin?).to eq(true) + end + end + + context 'when the user does not have an admin spree role' do + it 'returns false' do + expect(user.superadmin?).to eq(false) + end + end + end end From fde3d72a6677fcb34e36279b5f3f7aace9f8360b Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Tue, 9 Apr 2019 00:18:48 +1000 Subject: [PATCH 03/11] Updating translations for config/locales/en_GB.yml --- config/locales/en_GB.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/en_GB.yml b/config/locales/en_GB.yml index 06177a0bc0..7093ade553 100644 --- a/config/locales/en_GB.yml +++ b/config/locales/en_GB.yml @@ -2842,6 +2842,8 @@ en_GB: title: "Distribution" distributor: "Distributor:" order_cycle: "Order cycle:" + line_item_adjustments: "Line Item Adjustments" + order_adjustments: "Order Adjustments" order_total: "Order Total" overview: products: From 029e8eb848cda9f42dbef6553cd63105e07fccc2 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Tue, 9 Apr 2019 20:50:31 +1000 Subject: [PATCH 05/11] Updating translations for config/locales/de_DE.yml --- config/locales/de_DE.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/locales/de_DE.yml b/config/locales/de_DE.yml index 077e10a65a..3b2cc74e47 100644 --- a/config/locales/de_DE.yml +++ b/config/locales/de_DE.yml @@ -2841,6 +2841,9 @@ de_DE: title: "Verteilung" distributor: "Verteiler:" order_cycle: "Bestellzyklus:" + line_item_adjustments: "Anpassungen der Werbebuchung" + order_adjustments: "Bestellanpassungen" + order_total: "Auftrag insgesamt" overview: products: active_products: From b6989c6d6e73b2efa94b8693ead84c5e8c3bc0cf Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Fri, 12 Apr 2019 01:05:30 +1000 Subject: [PATCH 06/11] Updating translations for config/locales/nl_BE.yml --- config/locales/nl_BE.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/config/locales/nl_BE.yml b/config/locales/nl_BE.yml index c36c6645e7..0860e54c21 100644 --- a/config/locales/nl_BE.yml +++ b/config/locales/nl_BE.yml @@ -1198,7 +1198,9 @@ nl_BE: menu_5_title: "Over" menu_5_url: "http://www.openfoodnetwork.org/" menu_6_title: "Connecteer je " + menu_6_url: "https://openfoodnetwork.org/au/connect/" menu_7_title: "Ontdek" + menu_7_url: "https://openfoodnetwork.org/au/learn/" logo: "Logo (640x130)" logo_mobile: "Logo Mobiel (75x26)" logo_mobile_svg: "Logo Mobiel (SVG)" @@ -2586,6 +2588,7 @@ nl_BE: fee_placement: "invulplaats voor de commissie " fee_calculated_on_transfer_through_name: "Berekening van de commissie op verdracht door" tax_category_name: "Belastingcategorie" + total_amount: "$$ SUM" html: header: fee_type: "Sprookjesachtig type" @@ -2595,6 +2598,7 @@ nl_BE: fee_placement: "invulplaats van de commissie " fee_calculated_on_transfer_through_name: "Berekening van de commissie op verdracht door" tax_category_name: "Belastingcategorie" + total_amount: "$$ SUM" invalid_filter_parameters: "De filters voor dit verslag zijn ongeldig." order: "Bestelling" distribution: "Distributie" @@ -2631,6 +2635,7 @@ nl_BE: back_to_orders_list: Terug naar de bestellingslijst select_stock: "Selecteer voorraad" location: "Locatie" + count_on_hand: "Count On Hand" quantity: "Kwantiteit" package_from: "pakje van " item_description: "Artikelbeschrijving" @@ -2665,6 +2670,8 @@ nl_BE: new_payment: "Nieuwe betaling" configurations: "configuraties " general_settings: "Algemene instellingen" + site_name: "Website Naam" + site_url: "website URL" default_seo_title: "Standaardtitel SEO" default_meta_description: "Standaard Meta Beschrijving" default_meta_keywords: "Standaard Meta Sleutelwoorden " @@ -2677,9 +2684,11 @@ nl_BE: currency_settings: "Gebruikte munt" currency_symbol_position: Zet "muntsymbool voor of na het bedrag?" currency_thousands_separator: "Valuta met scheiding van duizenden" + hide_cents: "Verberg centen" display_currency: "Munt tonen" choose_currency: "Munt kiezen " mail_method_settings: "instellingen mailwijze " + general: "Algemeen" enable_mail_delivery: "Mogelijk de mail te leveren" send_mails_as: "Stuur mail als" smtp_send_all_emails_as_from_following_address: "Stuur alle mails als van het volgend adres" @@ -2690,13 +2699,18 @@ nl_BE: smtp: "SMTP" smtp_domain: "SMTP Domein" smtp_mail_host: "SMPT Mail Host" + smtp_port: "SMTP Port" + secure_connection_type: "Secure Connection Type" + smtp_authentication_type: "SMTP Authentication Type" smtp_username: "SMPT Gebruikersnaam" smtp_password: "SMPT Wachtwoord" image_settings: "Beeldinstellingen " image_settings_warning: "Logos regeneren als de paperclips stylen bijgewerkt worden. Paperclip harken gebruiken :opfrissen:logos CLASS=Spree::Image om het doen. " attachment_default_style: Bijlagestijl attachment_default_url: "Standaard Band met URL" + attachment_path: "Pad bijlagen" attachment_styles: "Paperclipstijlen" + attachment_url: "URL bijlagen" add_new_style: "Een nieuwe stijl toevoegen" image_settings_updated: "Beeldinstellingen zijn met succes bijgewerkt." tax_categories: "Belastingcategorieën" @@ -2715,8 +2729,17 @@ nl_BE: new_zone: "Nieuwe zone" default_tax: "Standaard BTW " default_tax_zone: "Standaard BTW zone " + country_based: "Land gebaseerd" + state_based: "Provincie gebaseerd" + countries: "Landen" + listing_countries: "Listing Landen" iso_name: "ISO Naam" + states_required: "Staten Vereist" + editing_country: "Editing Land" + back_to_countries_list: "Terug naar landenlijst" + states: "Provincies" abbreviation: "Afkortingen " + new_state: "Nieuw Provincie" payment_methods: "Betalingsmethode" new_payment_method: "Nieuwe betalingswijze" provider: "Leverancier" @@ -2771,6 +2794,7 @@ nl_BE: bulk_order_management: "Beheer van bulkorders" subscriptions: "Abonnementen" products: "Producten" + option_types: "Optietypen" properties: "Eigenschappen" prototypes: "Prototypes " variant_overrides: "Inventarisatie" @@ -2821,6 +2845,8 @@ nl_BE: title: "Distributie" distributor: "Verdeler" order_cycle: "Bestelcyclus" + line_item_adjustments: "Regelitems aanpassen" + order_adjustments: "Orden aanpassingen" order_total: "Totaal bestelling" overview: products: From 45ca63e751a87a6056fe3eb8ac7270eb063eb5b6 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Fri, 12 Apr 2019 01:14:59 +1000 Subject: [PATCH 07/11] Updating translations for config/locales/fr_BE.yml --- config/locales/fr_BE.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/config/locales/fr_BE.yml b/config/locales/fr_BE.yml index f471a9c2f1..9a59c7b8be 100644 --- a/config/locales/fr_BE.yml +++ b/config/locales/fr_BE.yml @@ -88,6 +88,7 @@ fr_BE: cloned_order_cycle_name: "Copie de %{order_cycle}" validators: date_time_string_validator: + not_string_error: "doit être une chaîne" invalid_format_error: "doit être valide " integer_array_validator: not_array_error: "doit être un array" @@ -2592,6 +2593,7 @@ fr_BE: fee_placement: "Emplacement commission" fee_calculated_on_transfer_through_name: "Calcul de la commission sur cession par" tax_category_name: "TVA applicable" + total_amount: "€€ SOMME" html: header: fee_type: "Type de marge" @@ -2601,6 +2603,7 @@ fr_BE: fee_placement: "Emplacement commission" fee_calculated_on_transfer_through_name: "Calcul de la commission sur cession par" tax_category_name: "TVA applicable" + total_amount: "€€ SOMME" invalid_filter_parameters: "Les filtres sélectionnés pour ce rapport ne sont pas valides." order: "Commandes à venir" distribution: "Distribution" @@ -2637,6 +2640,7 @@ fr_BE: back_to_orders_list: 'Retour vers la liste des commandes ' select_stock: "Selectionner stock" location: "Site" + count_on_hand: "Compté à la main" quantity: "Nb commandé" package_from: "colis provenant de " item_description: "Description de l'article " @@ -2671,6 +2675,8 @@ fr_BE: new_payment: "Nouveau paiement" configurations: "Configurations" general_settings: "Réglages Généraux" + site_name: "Nom du site" + site_url: "Site URL" default_seo_title: "Titre SEO par défaut" default_meta_description: "Meta Description par défaut" default_meta_keywords: "Meta Mots-clés par défaut" @@ -2681,10 +2687,13 @@ fr_BE: check_for_spree_alerts: "Attention aux alertes en série " currency_decimal_mark: "Devise à la décimale " currency_settings: "Devise " + currency_symbol_position: Mettez "symbole monétaire avant ou après le montant en euros?" currency_thousands_separator: "Devise avec séparateur de mille" + hide_cents: "Masquer les cents" display_currency: "Afficher devise " choose_currency: "Choisir devise " mail_method_settings: "Paramètres du moyen mail" + general: "Généralement" enable_mail_delivery: "Possible de livrer le mail" send_mails_as: "Envoyer les mails comme " smtp_send_all_emails_as_from_following_address: "Envoyer tous les mails comme de l'adresse suivante." @@ -2695,13 +2704,18 @@ fr_BE: smtp: "SMTP" smtp_domain: "Domaine SMPT" smtp_mail_host: "SMPT Serveur mail" + smtp_port: "SMTP Port" + secure_connection_type: "Type de connexion sécurisée" + smtp_authentication_type: "Type d'authentification SMTP" smtp_username: " SMPT Nom d’utilisateur " smtp_password: "SMPT Mot de passe" image_settings: "Paramètres image" image_settings_warning: "Il est nécessaire de régénérer des logos lors de la mise à jour des styles de trombones . Utiliser ratisser trombone:rafraîchir:logos CLASS=Spree::Image pour faire ceci. " attachment_default_style: Style Pièces jointes attachment_default_url: "Joint à URL par défaut" + attachment_path: "Pièces jointes liés" attachment_styles: "Styles trombones" + attachment_url: "URL lié" add_new_style: "Ajouter un nouveau style " image_settings_updated: "Paramètres Image mis à jour avec succès." tax_categories: "TVA applicable" @@ -2720,9 +2734,17 @@ fr_BE: new_zone: "Nouvelle zone " default_tax: "TVA par défaut" default_tax_zone: "Zone TVA par défaut" + country_based: "Basé sur le pays" + state_based: "Basé sur la Province" + countries: "Pays" + listing_countries: "Liste des pays" iso_name: "Nom ISO" + states_required: "Provinces requises" + editing_country: "Pays d'édition" back_to_countries_list: "Retouner vers la liste des pays" + states: "Province" abbreviation: "Abréviation" + new_state: "Nouvelle Province" payment_methods: "Méthodes de paiement" new_payment_method: "Nouvelle méthode de paiement" provider: "Fournisseur" @@ -2828,6 +2850,8 @@ fr_BE: title: "Distribution" distributor: "Distributeur : " order_cycle: "Cycle de vente : " + line_item_adjustments: "Ajustements d'élément de ligne" + order_adjustments: "Ajustement de commandes" order_total: "Total commande " overview: products: From 418d80bdc09fd338de8ba8834459d8e594bab4f3 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Mon, 15 Apr 2019 17:05:00 +1000 Subject: [PATCH 08/11] Updating translations for config/locales/ca.yml --- config/locales/ca.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 8825827c56..b0a23d0832 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -2841,6 +2841,8 @@ ca: title: "Distribució" distributor: "Distribuïdora:" order_cycle: "Cicle de comanda:" + line_item_adjustments: "Ajustaments de la línia de comanda" + order_adjustments: "Ajustaments de comandes" order_total: "Total comanda" overview: products: From 10c917a693fd638195f918b13a620dfcba217e85 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Mon, 15 Apr 2019 17:08:06 +1000 Subject: [PATCH 09/11] Updating translations for config/locales/ca.yml --- config/locales/ca.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/ca.yml b/config/locales/ca.yml index b0a23d0832..410c1903a7 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -1427,7 +1427,7 @@ ca: email_signoff: "Salut," email_signature: "Equip %{sitename}" email_confirm_customer_greeting: "Hola %{name}," - email_confirm_customer_intro_html: "Gràcies per comprar a %{distributor} ." + email_confirm_customer_intro_html: "Gràcies per comprar a %{distributor}." email_confirm_customer_number_html: "Confirmació de la comanda # %{number} " email_confirm_customer_details_html: "Aquests són els detalls de la teva comanda de %{distributor} :" email_confirm_customer_signoff: "Salutacions cordials," From 1b01c44ce4e1d88c4b29222e1a31dde063102ec5 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Mon, 15 Apr 2019 19:12:19 +1000 Subject: [PATCH 10/11] Updating translations for config/locales/es.yml --- config/locales/es.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/es.yml b/config/locales/es.yml index 17ba43eb59..4fe8532810 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -2842,6 +2842,8 @@ es: title: "Distribución" distributor: "Distribuidora:" order_cycle: "Ciclo de pedido:" + line_item_adjustments: "Ajustes de artículo" + order_adjustments: "Ajustes de pedido" order_total: "Total del pedido" overview: products: