Merge branch 'master' into 2-0-stable-Apr15

This commit is contained in:
luisramos0
2019-04-16 21:14:11 +01:00
13 changed files with 108 additions and 13 deletions

View File

@@ -38,6 +38,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

View File

@@ -269,6 +269,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)
@@ -593,6 +598,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
@@ -705,6 +712,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)
@@ -797,6 +808,7 @@ DEPENDENCIES
debugger-linecache
deface (= 1.0.0)
delayed_job_active_record
delayed_job_web
diffy
eventmachine (>= 1.2.3)
factory_bot_rails

View File

@@ -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

View File

@@ -72,6 +72,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

View File

@@ -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 <strong> %{distributor} </ strong>."
email_confirm_customer_intro_html: "Gràcies per comprar a <strong> %{distributor}."
email_confirm_customer_number_html: "Confirmació de la comanda <strong> # %{number} </strong>"
email_confirm_customer_details_html: "Aquests són els detalls de la teva comanda de <strong> %{distributor} </ strong>:"
email_confirm_customer_signoff: "Salutacions cordials,"
@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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 dutilisateur "
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:

View File

@@ -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:

View File

@@ -1,5 +1,10 @@
Openfoodnetwork::Application.routes.draw do
namespace :admin do
authenticated :spree_user, -> user { user.superadmin? } do
mount DelayedJobWeb, at: '/delayed_job'
end
resources :bulk_line_items
resources :order_cycles do

View File

@@ -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

View File

@@ -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