Compare commits

..

284 Commits

Author SHA1 Message Date
Transifex-Openfoodnetwork
a1a2a66d21 Updating translations for config/locales/fr.yml [skip ci] 2017-08-21 06:20:59 +10:00
Transifex-Openfoodnetwork
0117e2e8b5 Updating translations for config/locales/es.yml [skip ci] 2017-08-19 02:22:36 +10:00
Continuous Integration
2650dc209e Merge remote-tracking branch 'origin/master' into HEAD 2017-08-12 20:52:20 +10:00
Enrico Stano
58d7d8f016 Merge pull request #1753 from coopdevs/complete-seed-data
Complete seed data to purchase to Enterprise 2
2017-08-11 15:42:03 +02:00
Enrico Stano
1fbb4b25d1 Merge pull request #1746 from oeoeaio/fix-flash-error-color
Fix styling of error flash in admin section
2017-08-11 11:45:31 +02:00
Continuous Integration
b43b92dcfd Merge remote-tracking branch 'origin/master' into HEAD 2017-08-11 18:16:25 +10:00
Pau Perez
649c25622a Add doc to method 2017-08-11 14:41:02 +10:00
Pau Perez
1f2820f6d4 Add #delivery? in ShippingMethod 2017-08-11 14:41:02 +10:00
Pau Perez
22f018f2bc Fix all specs of LastUsedAddress 2017-08-11 14:41:02 +10:00
Pau Perez
8c5ac4cb23 Fix extra empty line reported by rubocop 2017-08-10 11:35:26 +02:00
Lynne
b9ff5674af Correction for Transifex name mismatch 2017-08-04 16:18:57 +01:00
Lynne
f0968109c6 Copy transifex updates to en-GB 2017-08-03 20:33:26 +01:00
Transifex-Openfoodnetwork
eeb41ccfdd Updating translations for config/locales/en_GB.yml [skip ci] 2017-08-04 04:30:40 +10:00
Continuous Integration
587a53d36d Merge remote-tracking branch 'origin/master' into HEAD 2017-08-04 03:56:40 +10:00
Transifex-Openfoodnetwork
ec7b7e0391 Updating translations for config/locales/sv.yml [skip ci] 2017-08-03 17:43:53 +10:00
Pau Perez
7f982c0c90 Complete seed data to purchase to Enterprise 2 2017-08-02 13:11:41 +02:00
Rob Harrington
6c71ef8760 Fix styling of error flash in admin section 2017-08-02 19:50:18 +10:00
Enrico Stano
936355d54b Merge pull request #1681 from coopdevs/release-notes-in-template
Add release notes section in github template
2017-08-02 10:59:30 +02:00
Enrico Stano
07620c2e62 Merge pull request #1707 from oeoeaio/mirror-db-session-data
Exclude session data when mirroring data
2017-08-02 10:45:46 +02:00
Maikel Linke
686a8f3af9 Add legacy and default values for LOCALE
This makes sure there is a value in `config.i18n.available_locales` so
that i18n-js doesn't crash.
2017-08-02 10:44:55 +10:00
Maikel Linke
199bfe531e Correct typo in comment 2017-08-02 10:01:12 +10:00
Julius Pabrinkis
e4627fe0d0 Update README 2017-08-02 09:57:33 +10:00
Julius Pabrinkis
ec6a365227 Add test coverage for switching language in darkswarm and admin 2017-08-02 09:57:33 +10:00
Julius Pabrinkis
c6f6f5bc55 Adapt karma js tests for i18n-js 2017-08-02 09:57:33 +10:00
Julius Pabrinkis
5166a3d958 Add available_locales config feature 2017-08-02 09:57:33 +10:00
Julius Pabrinkis
9429695e15 Add i18n helper for controllers to switch language by params 2017-08-02 09:57:32 +10:00
Julius Pabrinkis
f396d30747 Render i18n-js config inside darkswarm and admin layouts 2017-08-02 09:57:32 +10:00
Julius Pabrinkis
2637574c93 Require new i18n-js translations in darkswarm and admin 2017-08-02 09:57:32 +10:00
Julius Pabrinkis
d2ba4650e5 Add temporary i18n-js workaround for Spree translations until upgrade 2017-08-02 09:57:32 +10:00
Julius Pabrinkis
3adb13e62c Add i18n-js gem 2017-08-02 09:57:32 +10:00
Transifex-Openfoodnetwork
f69d86ab8f Updating translations for config/locales/nb.yml [skip ci] 2017-07-31 20:50:37 +10:00
Rob Harrington
7c0feab08f Fix #1526: add descriptions for reports *before* they are filtered 2017-07-28 17:15:57 +10:00
Matt-Yorkley
ea784d6362 Invoice date and translation adjustments 2017-07-28 16:34:43 +10:00
Maikel
6e57f917d2 Merge pull request #1736 from oeoeaio/fix-zeus-crash
Fix zeus issue caused by location of iframe_test.html
2017-07-28 16:31:41 +10:00
Maikel Linke
ba97f61c9e Move translations into right scope 2017-07-28 15:23:18 +10:00
Maikel Linke
c5eca68d79 Remove unused translation 2017-07-28 15:23:18 +10:00
Maikel Linke
92814162dc Remove unused translation 2017-07-28 15:23:18 +10:00
Maikel Linke
44374e8499 Display "+1 More" correctly 2017-07-28 15:23:18 +10:00
Rob Harrington
2ca04bb84e Revert translations of LettuceShare report headers 2017-07-28 12:07:58 +10:00
Rob Harrington
66a85bb99f Revert translations of Xero report headers 2017-07-28 12:07:52 +10:00
Rob Harrington
9f6931ba18 Move embedded shopfronts iframe view into spec/support/views
Was causing issues with zeus where it was (in spec/dummy)
Didn't get to the bottom of what was happening, this was
just a quick, simple and zero-cost solution
2017-07-28 11:54:48 +10:00
Rob Harrington
8fe6800151 Add documentation to the top of mirror_db script 2017-07-27 12:58:54 +10:00
Rob Harrington
e86122cb3e Exclude session data when mirroring data
Probably a better long term solution would be to add a job to clean
up old session data on the server, but this is a quick & dirty fix
to speed mirroring up on a slow connection.
2017-07-27 12:58:54 +10:00
Laura Turk
7641dcc1be Add media query to panepadding mixin 2017-07-26 16:29:44 +10:00
Leta Keane
8648070a05 Add disabled class to shopfront property selectors 2017-07-26 15:46:00 +10:00
Matt-Yorkley
5200937165 Safari/iOS iframe issue fix 2017-07-26 13:56:36 +10:00
Matt-Yorkley
6215777986 Shopfront review adjustments 2017-07-26 13:56:36 +10:00
Matt-Yorkley
0eb4c7f7ba Require https for embedding sites 2017-07-26 13:56:36 +10:00
Matt-Yorkley
782a812596 Basic Embedded Shopfronts 2017-07-26 13:56:36 +10:00
Matt-Yorkley
113f6565be Enable iframes for embedded shopfronts 2017-07-26 13:56:36 +10:00
Maikel Linke
b1452f097d Add spanish translations manually
A change in the Transifex API made the automated commit fail. Hence
doing it manually here.
2017-07-26 13:38:35 +10:00
Transifex-Openfoodnetwork
6384b5abb3 Updating translations for config/locales/fr.yml [skip ci] 2017-07-26 13:38:35 +10:00
Transifex-Openfoodnetwork
2c14ed848f Updating translations for config/locales/nb.yml [skip ci] 2017-07-26 13:38:35 +10:00
Maikel Linke
5dfac10599 Mention upgrade_bundler.sh in README 2017-07-26 13:37:42 +10:00
Maikel Linke
250062bd2f Upgrade bundler according to Gemfile.lock on CI 2017-07-26 13:37:42 +10:00
Maikel Linke
3f2299e52e Add script to upgrade bundler to Gemfile version
Useful to sync your bundler version or the CI bundler version with the
rest of the team.
2017-07-26 13:37:42 +10:00
Rob Harrington
327753b7ca Remove zeus and guard-zeus from the bundle
Having guard-zeus specified as a dependency is problematic because
it also pulls in the zeus gem as a dependency. This makes it impo-
ssible to update or switch zeus versions locally without affecting
other developers.

The maintainers of zeus say that it is designed to be installed and
run outside of the bundle: https://github.com/burke/zeus
2017-07-26 13:36:58 +10:00
Matt-Yorkley
ba447b547d Order tooltip localisation 2017-07-26 13:36:16 +10:00
Matt-Yorkley
8ebd49ec0f Company number localisation 2017-07-26 13:35:46 +10:00
Maikel Linke
155a2574bb Fix typo to display email address 2017-07-21 12:17:14 +10:00
Maikel Linke
b8c2e54194 Fix i18n key and spec 2017-07-21 12:17:14 +10:00
Maikel Linke
9f243e6d3c Fix title of /admin/content/edit
Spree uses the global i18n key `contents` to print the title. A previous
change made that an object containing other i18n keys which was then
displayed as title.

This change moves the i18n content to the scope of the view where they
are displayed.
2017-07-21 12:17:13 +10:00
Maikel Linke
ece8d8b518 Fix typo to display "Producer signup page" 2017-07-21 12:17:13 +10:00
Maikel Linke
0624c49a4f Fix typo to display "Tax Rates" report 2017-07-21 12:17:13 +10:00
Maikel Linke
71742a80b5 Make two more strings translatable 2017-07-21 12:17:13 +10:00
Maikel Linke
f4b1667005 Replace global translations by local ones 2017-07-21 12:17:13 +10:00
Maikel Linke
e5c9845b10 Remove duplicate haml code 2017-07-21 12:17:13 +10:00
Maikel Linke
d3fc89f42a Unify haml code for colouring 2017-07-21 12:17:13 +10:00
Maikel Linke
9c6454b47a Remove duplicated code
A label was accidentally inserted twice. Also removed some duplicate
translation.
2017-07-21 12:17:13 +10:00
Maikel Linke
7d2484c8bf Remove superfluous string interpolation 2017-07-21 12:17:13 +10:00
Maikel Linke
9723c8b82b Move translation into the right place
The dashboard couldn't find a translation, because it is in the spree
namespace.

Also simplified the translation using the `count` feature.
2017-07-21 12:17:13 +10:00
Julius Pabrinkis
8b2b51d511 Fix code style for Rubocop 2017-07-21 12:17:13 +10:00
Julius Pabrinkis
872a150c7d Refactor some translations to use interpolation 2017-07-21 12:17:13 +10:00
Julius Pabrinkis
3a0c0fd638 Fix failing tests 2017-07-21 12:17:12 +10:00
Julius Pabrinkis
739d06cf03 Extract translations from javascript 2017-07-21 12:17:12 +10:00
Julius Pabrinkis
9fa7a30c7e Fix failing tests and extract validation message Procs into methods 2017-07-21 12:17:12 +10:00
Julius Pabrinkis
ba0b17e168 Extract translations from controllers 2017-07-21 12:17:12 +10:00
Julius Pabrinkis
5caaec8ef3 Extract translations from mailers and helpers 2017-07-21 12:17:12 +10:00
Julius Pabrinkis
9971c9f923 Extract translations from models 2017-07-21 12:17:12 +10:00
Julius Pabrinkis
974099747b Fix failing specs after text extraction 2017-07-21 12:17:12 +10:00
Julius Pabrinkis
1920ee7e88 Extract translations from serializers and overrides 2017-07-21 12:17:12 +10:00
Julius Pabrinkis
55b2c19b64 Extract translations from lib folder 2017-07-21 12:17:12 +10:00
Julius Pabrinkis
60060a7017 Start admin/reports extract translations 2017-07-21 12:17:12 +10:00
Julius Pabrinkis
ef488133e8 Add missing translations from files list. 2017-07-21 12:17:12 +10:00
clairezed
5c66a2fc9d Fix wrong key replacement for producer_shop_description_text 2017-07-21 11:15:03 +10:00
clairezed
5f8890e963 update producers pack translation key from sell_description_text to producer_shop_description_text 2017-07-21 11:15:03 +10:00
clairezed
58c463497a #1541 fixing wrong translation key in producers packs 2017-07-21 11:15:03 +10:00
Rob Harrington
3bb6d68adf Exclude node_modules from rubocop analysis
I don't need to see offences for node modules when I run rubocop locally
2017-07-21 11:06:16 +10:00
Duende13
705295049e Improved test for variant serializer 2017-07-21 10:18:55 +10:00
Duende13
a07fd854f6 New test for variant serializer 2017-07-21 10:18:55 +10:00
Duende13
b2bae242d9 Sorting variants by name_to_display and unit_value. Issue 1604. 2017-07-21 10:18:55 +10:00
Maikel Linke
1a57a0b3ca Revert changes in fr.yml 2017-07-19 09:46:23 +10:00
François Turbelin
a0595bc45a Add missing translations on views 2017-07-19 09:45:11 +10:00
Enrico Stano
8853340fa1 Merge pull request #1655 from oeoeaio/update-eventmachine
Bump eventmachine version to resolve openssl issue on macOS
2017-07-13 13:04:28 +02:00
Enrico Stano
bde3fa4ce6 Merge pull request #1671 from coopdevs/multiline-method-calls
Use indented style for multiline method calls
2017-07-12 18:40:34 +02:00
Pau Perez
cee24dcca7 Use indented style for multiline method calls
This enables the Rubocop's Style/MultilineMethodCallIndentation cop with
indentend enforced style. Which makes you split multiline method calls like:

  orders = Spree::Order
    .an_scope
    .another_scope
    .where(id: list_of_ids)

It also autofixes the current violations and updates the
rubocop_todo.yml
2017-07-12 10:40:53 +02:00
Pau Perez
c1789c4833 Add release notes section in github template
Hopefully, this will make it easier for Kirsten to fill in the release
notes from all the pull requests included in a release.
2017-07-12 08:26:45 +02:00
Maikel
6fbf902562 Merge pull request #1680 from mkllnk/entreprise-typo
Correct typo raised by Sergi
2017-07-12 15:14:06 +10:00
Maikel Linke
dc0da6f7b7 Correct typo raised by Sergi 2017-07-12 14:40:44 +10:00
Pau Perez
385847d7da Doc why FinalizeAccount uses order objects
Read the top-level class documentation for the details.
2017-07-12 11:49:04 +10:00
Rob Harrington
9d7f63db42 Bump eventmachine version to resolve openssl issue on macOS 2017-07-12 11:42:15 +10:00
Pau Perez
d0c6292e9d Add github template for pull requests 2017-07-07 13:56:12 +10:00
Matt-Yorkley
994023ec10 Update codeclimate version 2017-07-06 18:15:24 +10:00
Pau Perez
1028b49719 Stop using Order#shipment as it will be deprecated
Spree 2.0 adds a deprecation warning to it and Spree 2.1 removes it.
2017-07-05 16:33:04 +10:00
Maikel Linke
b7f99c3185 Merge branch 'transifex' 2017-06-30 16:28:08 +10:00
Rob Harrington
ce85027b79 Update rubocop_todo.yml using rubocop 0.49.1 2017-06-29 10:47:56 +10:00
Rob Harrington
94b6a61665 Bump rubocop to latest version (0.49.1) 2017-06-29 10:47:56 +10:00
Rob Harrington
f84acf44f3 Disable scss-lint for CodeClimate
Until we can tweak #1393 to work with CodeClimate
2017-06-28 18:09:03 +10:00
Diogo Matsubara
386d651678 Fix #1611 (Rephrase error message for people logging in with an existing user email)
update test to use new rspec syntax
2017-06-28 15:35:21 +10:00
Matt-Yorkley
23a6e2dd8f Changed modal redirect behaviour 2017-06-28 14:35:17 +10:00
Transifex-Openfoodnetwork
6c69eebcbf Updating translations for config/locales/nb.yml [skip ci] 2017-06-27 05:41:31 +10:00
Rob Harrington
d8a158c56d Rubocop: Update comment on Rails/DynamicFindBy, justifying Enabled: false 2017-06-24 13:37:47 +10:00
Rob Harrington
dfda30f4cb Rubocop: Regenerate rubocop_todo.yml using --exclude-limit 100 2017-06-24 13:33:57 +10:00
Rob Harrington
d26970d04c Rubocop: Move Style/ClassAndModuleChildren back to rubocop_todo.yml 2017-06-24 12:59:03 +10:00
Transifex-Openfoodnetwork
63e453e2c7 Updating translations for config/locales/fr.yml [skip ci] 2017-06-23 18:09:39 +10:00
Rob Harrington
c7ed27286a Rubocop: Correct Lint/ParenthesesAsGroupedExpression offences 2017-06-23 17:02:20 +10:00
Rob Harrington
e5340cb53a Rubocop: Correct Lint/UselessAssignment offences, disable for /spec in main config 2017-06-23 16:49:08 +10:00
Rob Harrington
7079952f6b Add rubocop to development group in gemfile 2017-06-23 16:49:08 +10:00
Rob Harrington
f79dcaba15 Rubocop: Add Rails cops to config and todo 2017-06-23 16:49:08 +10:00
Rob Harrington
33a1d97d5e Rubocop: Disable Style/ClassAndModuleChildren in main config 2017-06-23 16:49:08 +10:00
Rob Harrington
28ea23965b Rubocop: Correct Lint/AmbiguousOperator offences 2017-06-23 16:49:08 +10:00
Rob Harrington
fbdbbb980f Rubocop: Disable Lint/AmbiguousBlockAssociation in main config 2017-06-23 16:49:08 +10:00
Rob Harrington
fc5b339e2a Rubocop: Correct Lint/DuplicateMethods offences 2017-06-23 16:49:08 +10:00
Rob Harrington
4acb3f1962 Rubocop: Use Relaxed.Ruby.Style as starting point for settings
Updated .rubocop_todo.yml
2017-06-23 16:49:08 +10:00
Rob Harrington
7bb58342fc Rubocop: Auto-correct Style/EmptyLineBetweenDefs offences 2017-06-23 16:49:08 +10:00
Rob Harrington
b277ff03ea Rubocop: Auto-correct Style/TrailingBlankLines offences 2017-06-23 16:49:07 +10:00
Rob Harrington
5061d0c4cd Rubocop: Tweak config, and add todo file 2017-06-23 16:49:07 +10:00
Continuous Integration
931a5be162 Merge remote-tracking branch 'origin/master' into HEAD 2017-06-22 13:19:25 +10:00
Maikel Linke
e437cba155 Make style flexible for all sizes of logos
Trying to support logos that are big. But logos that are too small
should not be stretched either, better small than ugly.

Remove static size declaration from HTML template since it doesn't
reflect the logo size.

Unfortunately, there are other CSS files that are in conflict. The file
mail/email.css.scss defines this globally:

    img {
      max-width: 100%;
    }
2017-06-16 16:49:43 +10:00
Maikel Linke
ec53d9df7a Merge tag 'v1.8.11' into transifex 2017-06-15 09:59:59 +10:00
Maikel Linke
3330e9b219 Init registration form with default country 2017-06-14 16:47:02 +10:00
Maikel Linke
884743ce97 Filter countries without states for registration 2017-06-14 16:47:01 +10:00
Maikel Linke
b482d1e57c Spec current behaviour of country selector
The enterprise sign-up form shows invalid countries without states and
does not choose the default country. See:

https://github.com/openfoodfoundation/openfoodnetwork/issues/1330
2017-06-14 16:47:01 +10:00
Maikel Linke
78f5002be5 Separate variant names by spaces
To enable the search for the beginning of a variant name, they need to
be separated.

See: https://github.com/openfoodfoundation/openfoodnetwork/pull/1545
2017-06-14 16:37:46 +10:00
Maikel Linke
a42799dff4 Initialise product.variant_names
Not initialising `product.variant_names` causes it to become the string
"undefinedVariant1Variant2" while it should just be "Variant1Variant2".

This mistake did not matter when `variant_names` was just used to search
for a sub-string. A recent change to search only for the beginning of a
word, caused this to fail.

See: https://github.com/openfoodfoundation/openfoodnetwork/pull/1545
2017-06-14 16:28:55 +10:00
Maikel Linke
1196cd7df4 Add style guide to the source locale
There has been a lack of rules how to structure our locale en.yml. This
is a start to document some guidelines which can evolve over time.

Rules can be discussed in the community forum or in pull requests. Once
there is a strong agreement, we should add it to this guide.
2017-06-14 15:20:01 +10:00
Enrico Stano
3c1eae1f47 Do not blindly clear the whole Rails cache 2017-06-09 10:32:57 +10:00
Matt-Yorkley
ba27d63f9c Fix logo sizing 2017-06-06 13:59:42 +01:00
Julius Pabrinkis
0083733c4c #1471 Do no let long producers' name go under icon 2017-06-02 16:29:43 +10:00
Julius Pabrinkis
a1ffc869f3 Refactor code by suggestion to use RegExp and add tests coverage 2017-06-02 15:42:35 +10:00
Rhodri Karim
7a07e8fa16 Issue 1233: product filter should only match if name begins withs search term 2017-06-02 15:42:35 +10:00
enricostano
699da16049 Remove unused spec support method 2017-05-31 15:22:30 +10:00
sseerrggii
18c7b03f3d Add plurals 2017-05-26 16:51:29 +10:00
Rob Harrington
8b560e6cee Cleaning up angular variant units controllers a little bit 2017-05-24 15:05:33 +10:00
Matt-Yorkley
7974ac45f2 Add unit description placeholder 2017-05-24 15:05:33 +10:00
Matt-Yorkley
41b5cf10dd Quick testing update 2017-05-24 15:05:33 +10:00
Matt-Yorkley
b6955cb98c Updated variant feature spec 2017-05-24 15:05:33 +10:00
Matt-Yorkley
6c36c269c8 Product Edit UX adjustments 2017-05-24 15:05:33 +10:00
Pierre de Lacroix
b879ea5a96 add comments 2017-05-24 14:37:54 +10:00
Pierre de Lacroix
a6ed4a2c6a fix bad return value
in method Spree::Adjustment#find_closest_tax_rates_from_included_tax
2017-05-24 14:37:54 +10:00
Pierre de Lacroix
6972822c49 fix escaping problems on ticket view 2017-05-24 13:35:59 +10:00
Pierre de Lacroix
db63f30a76 cosmetic fixes to the ticket view 2017-05-24 13:35:59 +10:00
Rob Harrington
848193434b Show item single_display_amount instead of variant price in order details table
Also has the effect of taking the inventory price into account (since it is stored against the line item price)
2017-05-19 17:27:04 +10:00
stveep
570f0344da Remove unused method in wrong controller ^_^ 2017-05-19 16:14:22 +10:00
stveep
38c25c412f Remove duplicated spec, better error message suppression, fix shipping test to wait correctly 2017-05-19 16:14:22 +10:00
stveep
3b4ffe1f70 Suppress line item validation error for newly-created orders 2017-05-19 16:10:06 +10:00
stveep
4699c654fc Fix feature specs for new 'new admin order' flow 2017-05-19 16:10:06 +10:00
stveep
c1c5d00f45 Add new view to set distribution, ensure the scoped variant single item price is used. 2017-05-19 16:10:06 +10:00
stveep
220693f4e3 Starting alternative flow for new manual order 2017-05-19 16:06:43 +10:00
stveep
fcce858ea4 Fix OC with override factory 2017-05-19 16:06:43 +10:00
stveep
1f9698f7a2 Test to reproduce bug with overridden price not being displayed when an order is added manually 2017-05-19 16:06:43 +10:00
Rob Harrington
1766da9d60 Adding ng-cloak directive to changeable orders banner 2017-05-19 15:54:55 +10:00
Rob Harrington
15ee62aaa8 Fixing race condition on link click in spec/features/consumer/shops_spec.rb 2017-05-19 13:29:47 +10:00
Rob Harrington
6fc4a297a0 Fixing race condition on link click in spec/features/consumer/shopping/products_spec.rb 2017-05-19 13:15:30 +10:00
Rob Harrington
74d8dc48b4 Rewriting shopfront alert regarding changeable orders to be dynamic 2017-05-18 15:35:07 +10:00
Rob Harrington
b6f4ce373e Preloading variants for VariantOverride.indexed 2017-05-18 15:34:22 +10:00
Rob Harrington
c9f186f48f Fixing SlideOutUp animation for darkswarm 2017-05-18 15:33:14 +10:00
Rob Harrington
daab0dfd7a Refactor: Splitting changeable_order_from_number out into separate method 2017-05-17 12:38:17 +10:00
Rob Harrington
22b5dafad2 Further tweaks to LineItemsController 2017-05-17 12:27:29 +10:00
Transifex-Openfoodnetwork
110f74eee8 Updating translations for config/locales/es.yml [skip ci] 2017-05-12 20:49:15 +10:00
Rob Harrington
61cb78fc93 Tweaks to LineItemsController, renaming #index to #bought 2017-05-12 16:29:15 +10:00
Rob Harrington
38d3b446cc Removing unused #tag_list method on VariantSerializer 2017-05-12 16:11:16 +10:00
Rob Harrington
e47e10d267 Removing n+1 query from #items_bought_by_user 2017-05-12 16:11:16 +10:00
Rob Harrington
77c8c85775 Memoizing the result of OrdersController#order_to_update 2017-05-12 16:11:16 +10:00
Rob Harrington
fab6d70832 Changeable orders only returns orders if the shop allows changes 2017-05-12 16:11:16 +10:00
Rob Harrington
9586666248 Updating translation for allow_changes option 2017-05-12 16:11:16 +10:00
Continuous Integration
f5ab9a3445 Merge remote-tracking branch 'origin/master' into HEAD 2017-05-12 10:39:06 +10:00
Continuous Integration
1ac8c85113 Merge remote-tracking branch 'origin/master' into HEAD 2017-05-12 09:55:25 +10:00
Rob Harrington
56c2350d36 Updating enterprise fees on completed order from OrdersController#update 2017-05-10 12:04:32 +10:00
Transifex-Openfoodnetwork
6eafed00f5 Updating translations for config/locales/fr.yml [skip ci] 2017-05-05 21:35:28 +10:00
Transifex-Openfoodnetwork
74661c0b77 Updating translations for config/locales/nb.yml [skip ci] 2017-05-05 18:10:25 +10:00
Rob Harrington
c4fbcb19d0 Only show Admin & Handling fees once on completed order form 2017-05-05 15:28:01 +10:00
Rob Harrington
08e391856c Ask user to confirm cancellation of order 2017-05-05 15:17:14 +10:00
Rob Harrington
8c8b40c5a8 Showing order cycle close time on banner when multiple open orders are present 2017-05-05 14:20:57 +10:00
Rob Harrington
c3eda435eb Hiding 'Back to Cart' and 'Back to Store' buttons on completed orders when distributor does not match cart 2017-05-05 14:20:57 +10:00
Rob Harrington
5eadb33db9 Using changes_allowed? to authorize cancellation of line_items 2017-05-05 14:20:57 +10:00
Rob Harrington
f977a05b08 Fixing broken spec for fetching list of bought items as json 2017-05-05 14:20:57 +10:00
Rob Harrington
217eda8362 Shipping and payment fees are updated for completed orders when the order changes 2017-05-05 14:20:57 +10:00
Rob Harrington
579f3bf90a Changing quantity and deleting line_items of completed orders works with inventory where present 2017-05-05 14:20:57 +10:00
Rob Harrington
348ab81c42 Overriding #increment! using variant overrides 2017-05-05 14:20:57 +10:00
Rob Harrington
3df629bc6e Prevent users from removing the final line item of an order, suggest cancelling instead 2017-05-05 14:20:57 +10:00
Rob Harrington
07b2f0a7c2 Showing banner for distributor of order on order summary, regardless of current_distributor 2017-05-05 14:20:57 +10:00
Rob Harrington
c0445d46f3 Changeable orders ignores cancelled orders 2017-05-05 14:20:57 +10:00
Rob Harrington
6c90b4e6d0 Adding alert to order summary, notifying user of remaining time to make changes 2017-05-05 14:20:57 +10:00
Rob Harrington
e79a23a554 Disabling save button on order page until changes are made to the order 2017-05-05 14:20:57 +10:00
Rob Harrington
314ccc2f27 Ensuring that #items_bought_by_user doesn't return items from cancelled orders 2017-05-05 14:20:57 +10:00
Rob Harrington
68c8759af1 Count of items in cart form looks is consistent with rest of UI (ie. uses quantities) 2017-05-05 14:20:57 +10:00
Rob Harrington
314e9a4f15 Open shopfront existing orders flash link in a new window 2017-05-05 14:20:57 +10:00
Rob Harrington
0029a1b6cf Ensure order adjustments are displayed in edit form for customers 2017-05-05 14:20:57 +10:00
Rob Harrington
bfcde72855 Use explicit format for dates on front-end account page 2017-05-05 14:20:57 +10:00
Rob Harrington
3d0ada803f Test presence of 'Edit' link for previous orders in cart 2017-05-05 14:20:57 +10:00
Rob Harrington
840c936a6f OrderSerializer#changes_allowed_until returns 'Not allowed' unless changes are allowed 2017-05-05 14:20:57 +10:00
Rob Harrington
7ea74ccf4a Order confirmation redirects 'Back to Cart' if cart is non-empty 2017-05-05 14:20:57 +10:00
Rob Harrington
b55036e165 Adding alert to shopfront to alert user to presence of orders open for editing 2017-05-05 14:20:57 +10:00
Rob Harrington
47011e11ff order_cycle.items_bought_by_user actually scopes to the current distributor 2017-05-05 14:20:57 +10:00
Rob Harrington
ae28d7a96b Adding a link in cart to allow user to edit existing + open orders for same OC 2017-05-05 14:20:57 +10:00
Rob Harrington
0dd8959bf7 Use an actual completed order for OrdersController#order_to_update spec 2017-05-05 14:20:57 +10:00
Rob Harrington
316b0915e4 Just display the date that orders can be changed until
No fancy moment.js stuff
2017-05-05 14:20:57 +10:00
Rob Harrington
e21bfd95f4 Renaming order.editable? to order.changes_allowed? 2017-05-05 14:20:57 +10:00
Rob Harrington
893331c7bb Adding 'Open Orders' section to the top of customer accounts page 2017-05-05 14:20:57 +10:00
Rob Harrington
b94bcd697f Restructuring customer accounts spec 2017-05-05 14:19:32 +10:00
Rob Harrington
b0ff7ca767 Making accounts page orders listing full-width 2017-05-05 14:19:32 +10:00
Rob Harrington
493a537f2c Making out-of-stock products in the cart more visible 2017-05-05 14:19:32 +10:00
Rob Harrington
cda43f075b Moving bought items listing up into main section of cart 2017-05-05 14:19:32 +10:00
Rob Harrington
5d9f92eaa7 Adding 'Cancel Order' button to order confimation interface 2017-05-05 14:19:32 +10:00
Rob Harrington
c6afa1849c Basic routing for front-end OrdersController#cancel action 2017-05-05 14:19:32 +10:00
Rob Harrington
eec3a21c89 Allow editing of completed orders from confirmation page where distributor allows it 2017-05-05 14:19:32 +10:00
Rob Harrington
768240a5ba Reorganising darkswarm order views into partials 2017-05-05 14:19:32 +10:00
Rob Harrington
5af8668560 Rewriting Spree::Taxons.distributed_taxons for better performance 2017-05-05 14:19:32 +10:00
Rob Harrington
630b8a2577 Add OrdersController#order_to_update method, to allow updating a complete order where appropriate 2017-05-05 14:19:32 +10:00
Maikel Linke
12a6f652ad Warn when allowing guest orders and order changes 2017-05-05 14:19:32 +10:00
Maikel Linke
db4a528ba3 Update shipment to re-calculate included tax
And re-create tax charges on the order. (untested)
2017-05-05 14:19:32 +10:00
Maikel Linke
479c7ba24b Update transaction fees of completed orders
The adjustments associated to incomplete payments are re-calculated when
a line item is removed from a completed order.
2017-05-05 14:19:32 +10:00
Maikel Linke
1f08729df3 Update shipping fees after removing item
After removing an item from a completed order, update the shipping fees
of all shipments that are pending or ready (not completed).
2017-05-05 14:19:32 +10:00
Maikel Linke
811671661e Remove item from dropdown cart after deletion 2017-05-05 14:19:32 +10:00
Maikel Linke
936df71d0d Link to bought products on cart page
The checkout page was just linking to the cart page, but not scrolling
down.
2017-05-05 14:19:32 +10:00
Maikel Linke
f3f6714472 Add message about previous orders on checkout page
The message appears if the user ordered before within the same order
cycle and the shop allows to change previous orders.
2017-05-05 14:19:32 +10:00
Maikel Linke
3bce2eb7b5 Rename translation key checkout to avoid conflicts
A top-level translation key `checkout` can't co-exist with translation
keys in the path `checkout`. Moving the old key to
`shared.menu.cart.checkout` avoids conflicts. It also structures the
locale better by view.
2017-05-05 14:19:32 +10:00
Maikel Linke
bf05866f92 Change headline of already ordered items 2017-05-05 14:19:32 +10:00
Maikel Linke
219ad4a3a7 Reload bought products after choosing order cycle 2017-05-05 14:19:32 +10:00
Maikel Linke
a7d8028d5a Add retry: 3 to intermittently failing spec 2017-05-05 14:19:32 +10:00
Maikel Linke
d49469a3e6 Show bought items only if changes are allowed
An enterprise can decide to allow changes to orders in open order
cycles. The items of these orders are then displayed in the shopping
cart and can be removed on the cart edit page.
2017-05-05 14:19:32 +10:00
Maikel Linke
4835ef067f Add feature to remove line items from open order cycle
- Add JS controller to send delete requests.
- Add resource controller to destroy items.
- Add authorisation check to abilities.
- Update fees after removing line item.
2017-05-05 14:19:32 +10:00
Maikel Linke
4112c3cc75 Set auth token for all JS HTTP requests 2017-05-05 14:19:32 +10:00
Maikel Linke
0fe4030d71 Display bought items only if present 2017-05-05 14:19:32 +10:00
Maikel Linke
e8d2d4d96f Display already bought items in edit cart view 2017-05-05 14:19:32 +10:00
Maikel Linke
88c3f414fb Handle missing order in cart 2017-05-05 14:18:20 +10:00
Maikel Linke
c0d6b68233 Apply some style guidelines to older code 2017-05-05 14:18:20 +10:00
Maikel Linke
65f62c42b9 Display products already ordered in this oc
Github issue #1083, part of standing orders.

For now, just display already bought products within the same order
cycle in the popup cart view. The edit cart view should follow. Later,
it should be possible to remove items as well.
2017-05-05 14:18:20 +10:00
Maikel Linke
fe7bd5e2cd Serialise tag_list only for variant overrides
Don't try to call tag_list on just variants since that will fail.

Normally, all variants of `current_order` should be extended to
VariantOverrides of the current order cycle. But in development
environment, it can happen that the variants are reloaded without being
extended again.
2017-05-05 14:18:20 +10:00
Maikel Linke
e1b40142b8 Remove unused translations 2017-05-05 14:18:20 +10:00
Maikel Linke
963b4617a9 Add allow-order-changes option to enterprise 2017-05-05 14:18:20 +10:00
Maikel Linke
95ddfc4e40 Merge tag 'v1.8.10' into transifex 2017-05-05 12:28:16 +10:00
François Turbelin
01746ed470 Add missing translations on views 2017-05-04 21:33:17 +02:00
Julius Pabrinkis
f25e3bc6f7 Implement with_currency rspec helper for money amounts 2017-05-04 18:02:38 +01:00
Julius Pabrinkis
e63f1c2991 Refactor time and currency symbol getters 2017-05-03 12:59:16 +01:00
Lynne
29e2886b05 Update contributing.md
Include link to discourse post: How to raise a github issue
2017-05-03 11:50:07 +01:00
Julius Pabrinkis
a97bcf74de Use more simple getter to retrieve currency symbol 2017-05-03 11:25:37 +01:00
Julius Pabrinkis
1e6f4aa73d Restore bundler version 2017-05-03 11:25:37 +01:00
Julius Pabrinkis
7c7933f8bb Use local time zone in tests instead of hardcoded 2017-05-03 11:25:37 +01:00
Julius Pabrinkis
dc69c6e825 Use currency symbol from config in tests 2017-05-03 11:25:37 +01:00
Julius Pabrinkis
41e91765ca Add capybara-screenshot gem for integration tests debugging 2017-05-03 11:25:37 +01:00
Julius Pabrinkis
19569f9316 #1291 Fix dropdown font-size not to zoom in iOS 2017-05-03 10:57:23 +01:00
Maikel Linke
d91c3d1241 Format reset password instructions like Spree 2017-05-03 11:06:48 +10:00
Maikel Linke
b302deb7a3 Add UserMailer specs adapted from Spree code 2017-05-03 11:06:48 +10:00
François Turbelin
2fae467e9a Translate ResetPasswordConfirmation mail 2017-05-03 11:06:48 +10:00
Transifex-Openfoodnetwork
6a5e4bb592 Updating translations for config/locales/sv.yml [skip ci] 2017-04-30 23:38:53 +10:00
Em-AK
c72d17dc83 Run karma task only in test environment
and fails otherwise, as it needs the defaults defined in test environment
2017-04-28 11:28:24 +10:00
Em-AK
78ffdec693 Force english locale in test environment 2017-04-28 11:28:24 +10:00
Pierre de Lacroix
49c19a1d6a update wkhtmltopdf-binary and wicked_pdf 2017-04-27 18:38:47 +10:00
Pierre de Lacroix
e854eb0426 add tests
for methods Spree::Order#tax_adjustment_totals
and Spree::Adjustment#find_closest_tax_rate_from_included_tax
2017-04-27 17:32:36 +10:00
Pierre de Lacroix
4a9c17cb28 better tax aggregation 2017-04-27 17:32:36 +10:00
Matt-Yorkley
0d1547f439 Require OC ready_for in simple OC UI 2017-04-21 09:34:50 +10:00
Matt-Yorkley
fa5ed529cb Added OC form validation 2017-04-21 09:32:49 +10:00
Matt-Yorkley
accb3076e9 Updated translations 2017-04-21 09:32:49 +10:00
Matt-Yorkley
a4e4e1ec68 Require OC name 2017-04-21 09:32:49 +10:00
Transifex-Openfoodnetwork
507e12adba Updating translations for config/locales/fr.yml [skip ci] 2017-04-20 22:05:19 +10:00
Maikel Linke
4809237ecc Fast fail set_order_cycles if distributor not ready 2017-04-19 14:28:17 +10:00
Maikel Linke
81877fedb6 Remove useless andand called on scope 2017-04-19 14:28:17 +10:00
Matt-Yorkley
1f2c6f2a85 Ensure shops display as closed when not configured for sales
squashme

squashme

squash

squash

squash
2017-04-19 14:28:17 +10:00
Matt-Yorkley
4fe5e60967 Updated controller stub to pass test 2017-04-19 14:28:17 +10:00
Matt-Yorkley
f4eb9cb790 Hubs display as closed when not configured for payment or shipping 2017-04-19 14:28:16 +10:00
Maikel Linke
775f9b3ada Move text from view to locale (i18n) 2017-04-12 10:06:53 +10:00
Maikel Linke
188b33921c Remove test entry in locale 2017-04-12 09:56:24 +10:00
Maikel Linke
20c033317f Remove unnecessary string interpolation from view 2017-04-12 09:49:24 +10:00
Matt-Yorkley
e7a5d063ac Update simple OC form 2017-04-12 09:41:40 +10:00
Matt-Yorkley
1fda781d7e Set maxlength on OC displayname field 2017-04-12 09:41:39 +10:00
Matt-Yorkley
45fc801a08 Added tooltips to OC form 2017-04-12 09:41:39 +10:00
Transifex-Openfoodnetwork
5fa45c0716 Updating translations for config/locales/es.yml [skip ci] 2017-04-08 01:22:10 +10:00
Maikel Linke
21337a5b50 Merge tag 'v1.8.9' into transifex 2017-04-06 10:36:14 +10:00
Maikel Linke
ec36a843cf Merge tag 'v1.8.8' into transifex 2017-04-06 10:31:26 +10:00
Transifex-Openfoodnetwork
e99dbaf4d8 Updating translations for config/locales/es.yml [skip ci] 2017-04-05 19:40:18 +10:00
Transifex-Openfoodnetwork
6defb09d2e Updating translations for config/locales/fr.yml [skip ci] 2017-03-21 09:03:15 +11:00
Transifex-Openfoodnetwork
2774c09d7a Updating translations for config/locales/nb.yml [skip ci] 2017-03-20 07:10:53 +11:00
408 changed files with 13793 additions and 2385 deletions

View File

@@ -1,11 +1,9 @@
engines:
rubocop:
enabled: true
exclude_fingerprints:
- ac41db8d4ec4cbf508c353d9b65a024f
- 8e3b6322aef5be9f38700b3fd0cd347e
channel: rubocop-0-48
scss-lint:
enabled: true
enabled: false
ratings:
paths:
- app/**

28
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,28 @@
#### What? Why?
[Explain why is this change needed and the solution you propose. Provide
context for others to understand it]
#### What should we test?
[List which features should be tested and how]
#### Release notes
[In case this should be present in the release notes, please write them or
remove this section otherwise]
#### How is this related to the Spree upgrade?
[Any known conflicts with the Spree Upgrade? explain them or remove this section
otherwise]
#### Discourse thread
[Is there a discussion about this in Discourse? add the link if so or remove
this section otherwise]
#### Dependencies
[Does this PR depend on another one? add the link of so or remove this section
otherwise]

View File

@@ -1,4 +1,9 @@
inherit_from:
- .rubocop_todo.yml
AllCops:
TargetRubyVersion: 2.1
TargetRailsVersion: 3.2
Include:
- '**/Rakefile'
- '**/config.ru'
@@ -6,24 +11,169 @@ AllCops:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'spec/**/*'
- 'vendor/**/*'
- 'node_modules/**/*'
- !ruby/regexp /old_and_unused\.rb$/
Documentation:
# OFN SETTINGS
# Cop settings that have been agreed upon by the OFN community
Rails:
Enabled: true
Style/Documentation:
Enabled: false
Style/EmptyLinesAroundClassBody:
Style/StringLiterals:
Enabled: false
Style/BracesAroundHashParameters:
Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
# TEMPORARY/CONTESTED SETTINGS
# These are still to be decided upon, but recommended for inclusion by
# oeoeaio after scrutinising offenses the codebase
# Don't think this is a big issue, mostly picking up RPSEC scope definitions
# with lamdas and RSpec '.to change{}' blocks
Lint/AmbiguousBlockAssociation:
Enabled: false
# Heaps of offences (> 100) in specs, mostly in situations where two or more
# instances of a model are required, but only one is referenced. Difficult to
# fix without making the spec look messy or rewriting it.
# Should definitely fix at some point.
Lint/UselessAssignment:
Exclude:
- spec/**/*
# AFAIK, there is no good alternative to dynamic matchers until we upgrade
# to Rails 4 and can use #find_by. If there is a better approach, let's do it.
Rails/DynamicFindBy:
Enabled: false
# This should be the programmer's discretion, perhaps we should review all of
# the uses of it an make specific exceptions though.
Rails/SkipsModelValidations:
Enabled: false
# Relaxed.Ruby.Style SETTINGS
# These styles are a starting point for the conversation around conventions
# They should be removed or tweaked and moved above as decisions are made
# NOTE: Cops which did not fail at the time of writing were removed
Layout/DotPosition:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styledotposition
Layout/SpaceBeforeBlockBraces:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces
Layout/SpaceInsideParens:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens
Style/Alias:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylealias
Style/BlockDelimiters:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters
Style/CommentAnnotation:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylecommentannotation
Style/DoubleNegation:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styledoublenegation
Style/FormatString:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styleformatstring
Style/IfUnlessModifier:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier
Style/Lambda:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylelambda
Style/MultilineBlockChain:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain
Style/NegatedIf:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylenegatedif
Style/NegatedWhile:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile
Style/ParallelAssignment:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styleparallelassignment
Style/PercentLiteralDelimiters:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters
Style/Semicolon:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylesemicolon
Style/SingleLineMethods:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
Style/TrailingCommaInArguments:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styletrailingcommainarguments
Style/TrailingCommaInLiteral:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styletrailingcommainliteral
Style/WordArray:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#stylewordarray
Lint/AmbiguousRegexpLiteral:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral
Lint/AssignmentInCondition:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
Metrics/AbcSize:
Enabled: false
Metrics/BlockNesting:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/LineLength:
Enabled: false
Max: 120
MethodLength:
Metrics/MethodLength:
Enabled: false
StringLiterals:
Metrics/ParameterLists:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false

2202
.rubocop_todo.yml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,9 @@ env:
- CI_NODE_INDEX=3
- CI_NODE_INDEX=4 KARMA="true" GITHUB_DEPLOY="true"
before_install:
- ./script/upgrade_bundler.sh
before_script:
- cp config/database.travis.yml config/database.yml
- cp config/application.yml.example config/application.yml

View File

@@ -1,3 +1,6 @@
See this here post on raising a github issue:
https://community.openfoodnetwork.org/t/how-to-raise-a-github-issue/912
# Contributing
We love pull requests from everyone. Here are some instructions for

View File

@@ -4,6 +4,7 @@ ruby "2.1.5"
gem 'rails', '3.2.21'
gem 'rails-i18n', '~> 3.0.0'
gem 'i18n', '~> 0.6.11'
gem 'i18n-js', '~> 3.0.0'
# Patched version. See http://rubysec.com/advisories/CVE-2015-5312/.
gem 'nokogiri', '>= 1.6.7.1'
@@ -115,7 +116,6 @@ end
group :test do
gem 'webmock'
# See spec/spec_helper.rb for instructions
#gem 'perftools.rb'
end
@@ -127,7 +127,12 @@ group :development do
gem 'guard-livereload'
gem 'rack-livereload'
gem 'guard-rails'
gem 'guard-zeus'
gem 'guard-rspec'
gem 'parallel_tests'
gem 'rubocop', '>= 0.49.1'
# 1.0.9 fixed openssl issues on macOS https://github.com/eventmachine/eventmachine/issues/602
# While we don't require this gem directly, no dependents forced the upgrade to a version
# greater than 1.0.9, so we just required the latest available version here.
gem 'eventmachine', '>= 1.2.3'
end

View File

@@ -165,6 +165,7 @@ GEM
angularjs-rails (1.5.5)
ansi (1.4.2)
arel (3.0.3)
ast (2.3.0)
atomic (1.1.99)
awesome_nested_set (2.1.5)
activerecord (>= 3.0.0)
@@ -257,7 +258,7 @@ GEM
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.5.3)
erubis (2.7.0)
eventmachine (1.0.8)
eventmachine (1.2.3)
excon (0.45.4)
execjs (2.6.0)
factory_girl (3.3.0)
@@ -407,9 +408,6 @@ GEM
guard-rspec (4.0.4)
guard (>= 2.1.1)
rspec (~> 2.14)
guard-zeus (0.0.1)
guard
zeus
haml (4.0.4)
tilt
highline (1.6.11)
@@ -419,6 +417,8 @@ GEM
multi_json (~> 1.0)
multi_xml
i18n (0.6.11)
i18n-js (3.0.0)
i18n (~> 0.6, >= 0.6.6)
immigrant (0.1.6)
activerecord (>= 3.0)
foreigner (>= 1.2.1)
@@ -477,9 +477,11 @@ GEM
activesupport (>= 3.0.0)
cocaine (~> 0.5.3)
mime-types
parallel (1.4.1)
parallel_tests (1.3.7)
parallel (1.11.2)
parallel_tests (2.14.1)
parallel
parser (2.4.0.0)
ast (~> 2.2)
paypal-sdk-core (0.2.10)
multi_json (~> 1.0)
xml-simple
@@ -494,6 +496,7 @@ GEM
polyamorous (0.5.0)
activerecord (~> 3.0)
polyglot (0.3.5)
powerpack (0.1.1)
pry (0.9.12.2)
coderay (~> 1.0.5)
method_source (~> 0.8)
@@ -531,8 +534,10 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rainbow (2.2.2)
rake
raindrops (0.13.0)
rake (11.1.2)
rake (11.3.0)
ransack (0.7.2)
actionpack (~> 3.0)
activerecord (~> 3.0)
@@ -578,7 +583,14 @@ GEM
rspec-mocks (~> 2.14.0)
rspec-retry (0.4.2)
rspec-core
ruby-progressbar (1.7.1)
rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
rubyzip (1.2.0)
safe_yaml (0.9.5)
sass (3.3.14)
@@ -620,6 +632,7 @@ GEM
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicode-display_width (1.3.0)
unicorn (4.9.0)
kgio (~> 2.6)
rack
@@ -643,14 +656,11 @@ GEM
whenever (0.9.2)
activesupport (>= 2.3.4)
chronic (>= 0.6.3)
wicked_pdf (0.11.0)
rails
wkhtmltopdf-binary (0.9.9.3)
wicked_pdf (1.1.0)
wkhtmltopdf-binary (0.12.3.1)
xml-simple (1.1.4)
xpath (2.0.0)
nokogiri (~> 1.3)
zeus (0.15.4)
method_source (>= 0.6.7)
PLATFORMS
ruby
@@ -680,6 +690,7 @@ DEPENDENCIES
deface!
delayed_job_active_record
diffy
eventmachine (>= 1.2.3)
factory_girl_rails
figaro
foreigner
@@ -693,9 +704,9 @@ DEPENDENCIES
guard-livereload
guard-rails
guard-rspec
guard-zeus
haml
i18n (~> 0.6.11)
i18n-js (~> 3.0.0)
immigrant
jquery-migrate-rails
jquery-rails
@@ -724,6 +735,7 @@ DEPENDENCIES
roo (~> 2.7.0)
rspec-rails
rspec-retry
rubocop (>= 0.49.1)
sass (~> 3.3)
sass-rails (~> 3.2.3)
shoulda-matchers
@@ -750,4 +762,4 @@ RUBY VERSION
ruby 2.1.5p273
BUNDLED WITH
1.14.3
1.15.2

View File

@@ -47,4 +47,3 @@ end
#watch(%r{^spec/acceptance/(.+)\.feature$})
#watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
#end

View File

@@ -54,6 +54,7 @@ First, check your dependencies: Ensure that you have Ruby 2.1.5 installed:
Install the project's gem dependencies:
cd openfoodnetwork
./script/upgrade_bundler.sh
bundle install
Configure the site:
@@ -98,6 +99,17 @@ The site is configured to use
startup time while Rails loads. See the Zeus github page for
usage instructions.
Once [npm dependencies are
installed](https://github.com/openfoodfoundation/openfoodnetwork/wiki/Karma), AngularJS tests can be run with:
./script/karma run
If you want karma to automatically rerun the tests on file modification, use:
./script/karma start
### Multilingual
Do not forget to run `rake tmp:cache:clear` after locales are updated to reload I18n js translations.
## Credits

View File

@@ -48,7 +48,7 @@
//= require textAngular-rangy.min.js
//= require textAngular-sanitize.min.js
//= require textAngular.min.js
//= require darkswarm/i18n.js
//= require i18n/translations
//= require darkswarm/i18n.translate.js

View File

@@ -14,8 +14,8 @@ angular.module("admin.businessModelConfiguration").controller "BusinessModelConf
$scope.cappedBill()
$scope.capReached = ->
return "No" if !$scope.cap? || Number($scope.cap) == 0
if $scope.bill() >= Number($scope.cap) then "Yes" else "No"
return t('no') if !$scope.cap? || Number($scope.cap) == 0
if $scope.bill() >= Number($scope.cap) then t('yes') else t('no')
$scope.includedTax = ->
return 0 if !$scope.taxRate? || Number($scope.taxRate) == 0

View File

@@ -21,7 +21,7 @@ angular.module("admin.customers").directive 'newCustomerDialog', ($compile, $tem
if response.data.errors
scope.errors.push(error) for error in response.data.errors
else
scope.errors.push("Sorry! Could not create '#{scope.email}'")
scope.errors.push(t('js.customers.could_not_create') + " '#{scope.email}'")
return
# Compile modal template
@@ -35,4 +35,4 @@ angular.module("admin.customers").directive 'newCustomerDialog', ($compile, $tem
if CurrentShop.shop.id
template.dialog('open')
else
alert('Please select a shop first')
alert(t('js.customers.select_shop'))

View File

@@ -2,7 +2,7 @@ angular.module('admin.enterpriseFees').directive 'spreeDeleteResource', ->
(scope, element, attrs) ->
if scope.enterprise_fee.id
url = '/admin/enterprise_fees/' + scope.enterprise_fee.id
html = '<a href="' + url + '" class="delete-resource icon_link icon-trash no-text" data-action="remove" data-confirm="Are you sure?" url="' + url + '"></a>'
html = '<a href="' + url + '" class="delete-resource icon_link icon-trash no-text" data-action="remove" data-confirm="' + t('are_you_sure') + '" url="' + url + '"></a>'
#var html = '<a href="'+url+'" class="delete-resource" data-confirm="Are you sure?"><img alt="Delete" src="/assets/admin/icons/delete.png" /> Delete</a>';
element.append html
return

View File

@@ -30,27 +30,27 @@ angular.module("admin.enterprises").controller 'enterprisesCtrl', ($scope, $q, E
$scope.producerTextFor = (enterprise) ->
switch enterprise.is_primary_producer
when true
"Producer"
t('js.enterprises.producer')
else
"Non-Producer"
t('js.enterprises.non_producer')
$scope.packageTextFor = (enterprise) ->
switch enterprise.is_primary_producer
when true
switch enterprise.sells
when "none"
"Profile"
t('js.profile')
when "own"
"Shop"
t('js.shop')
when "any"
"Hub"
t('js.hub')
else
"Choose"
t('js.choose')
else
switch enterprise.sells
when "none"
"Profile"
t('js.profile')
when "any"
"Hub"
t('js.hub')
else
"Choose"
t('js.choose')

View File

@@ -14,7 +14,7 @@ angular.module("admin.enterprises").controller 'indexPanelCtrl', ($scope, Enterp
, (response) ->
$scope.saving = false
if response.status == 422 && response.data.errors?
message = 'Please resolve the following errors:\n'
message = t('js.resolve_errors') + ':\n'
for attr, msg of response.data.errors
message += "#{attr} #{msg}\n"
alert(message)

View File

@@ -19,16 +19,16 @@ angular.module("admin.enterprises").factory 'PermalinkChecker', ($q, $http) ->
if data.length > @MAX_PERMALINK_LENGTH || !data.match(/^[\w-]+$/)
deferredRequest.resolve
permalink: permalink
available: "Error"
available: t('js.error')
else
deferredRequest.resolve
permalink: data
available: "Available"
available: t('available')
).error (data,status) =>
if status == 409
deferredRequest.resolve
permalink: data
available: "Unavailable"
available: t('js.unavailable')
else
# Something went wrong or request was aborted
deferredRequest.reject()

View File

@@ -21,16 +21,16 @@ angular.module("admin.indexUtils").factory "pendingChanges", ($q, resources, Sta
submitAll: (form=null) =>
all = []
@errors = []
StatusMessage.display('progress', "Saving...")
StatusMessage.display('progress', t('js.saving'))
for id, objectChanges of @pendingChanges
for attrName, change of objectChanges
all.push @submit(change)
$q.all(all).then =>
if @errors.length == 0
StatusMessage.display('success', "All changes saved successfully")
StatusMessage.display('success', t('js.all_changes_saved_successfully'))
form.$setPristine() if form?
else
StatusMessage.display('failure', "Oh no! I was unable to save your changes")
StatusMessage.display('failure', t('js.oh_no'))
all
submit: (change) ->

View File

@@ -10,7 +10,7 @@ angular.module("admin.indexUtils").factory "SpreeApiAuth", ($q, $http, SpreeApiK
deferred.resolve()
.error (response) ->
error = response?.error || "You are unauthorised to access this page."
error = response?.error || t('js.unauthorized')
deferred.reject(error)
deferred.promise

View File

@@ -51,13 +51,13 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
$scope.$watch 'bulk_order_form.$dirty', (newVal, oldVal) ->
if newVal == true
StatusMessage.display 'notice', "You have unsaved changes"
StatusMessage.display 'notice', t('js.unsaved_changes')
$scope.submit = ->
if $scope.bulk_order_form.$valid
StatusMessage.display 'progress', "Saving..."
StatusMessage.display 'progress', t('js.saving')
$q.all(LineItems.saveAll()).then(->
StatusMessage.display 'success', "All changes saved"
StatusMessage.display 'success', t('js.all_changes_saved')
$scope.bulk_order_form.$setPristine()
).catch ->
StatusMessage.display 'failure', t "unsaved_changes_error"

View File

@@ -12,7 +12,10 @@ angular.module('admin.orderCycles')
$scope.StatusMessage = StatusMessage
$scope.$watch 'order_cycle_form.$dirty', (newValue) ->
StatusMessage.display 'notice', 'You have unsaved changes' if newValue
StatusMessage.display 'notice', t("admin.unsaved_changes") if newValue
$scope.$watch 'order_cycle_form.$valid', (isValid) ->
StatusMessage.setValidation(isValid)
$scope.loaded = ->
Enterprise.loaded && EnterpriseFee.loaded && OrderCycle.loaded
@@ -81,7 +84,7 @@ angular.module('admin.orderCycles')
$scope.submit = ($event, destination) ->
$event.preventDefault()
StatusMessage.display 'progress', "Saving..."
StatusMessage.display 'progress', t('js.saving')
OrderCycle.create(destination)
$scope.cancel = (destination) ->

View File

@@ -13,7 +13,10 @@ angular.module('admin.orderCycles')
$scope.StatusMessage = StatusMessage
$scope.$watch 'order_cycle_form.$dirty', (newValue) ->
StatusMessage.display 'notice', 'You have unsaved changes' if newValue
StatusMessage.display 'notice', t("admin.unsaved_changes") if newValue
$scope.$watch 'order_cycle_form.$valid', (isValid) ->
StatusMessage.setValidation(isValid)
$scope.loaded = ->
Enterprise.loaded && EnterpriseFee.loaded && OrderCycle.loaded
@@ -84,11 +87,11 @@ angular.module('admin.orderCycles')
$scope.submit = (destination) ->
$event.preventDefault()
StatusMessage.display 'progress', "Saving..."
StatusMessage.display 'progress', t('js.saving')
$scope.submit = ($event, destination) ->
$event.preventDefault()
StatusMessage.display 'progress', "Saving..."
StatusMessage.display 'progress', t('js.saving')
OrderCycle.update(destination, $scope.order_cycle_form)
$scope.cancel = (destination) ->

View File

@@ -8,7 +8,10 @@ angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl"
$scope.enterprise_fees = EnterpriseFee.index(coordinator_id: ocInstance.coordinator_id)
$scope.$watch 'order_cycle_form.$dirty', (newValue) ->
StatusMessage.display 'notice', 'You have unsaved changes' if newValue
StatusMessage.display 'notice', t("admin.unsaved_changes") if newValue
$scope.$watch 'order_cycle_form.$valid', (isValid) ->
StatusMessage.setValidation(isValid)
$scope.init = (enterprises) ->
enterprise = enterprises[Object.keys(enterprises)[0]]
@@ -46,7 +49,7 @@ angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl"
$scope.submit = ($event, destination) ->
$event.preventDefault()
StatusMessage.display 'progress', "Saving..."
StatusMessage.display 'progress', t('js.saving')
OrderCycle.mirrorIncomingToOutgoingProducts()
OrderCycle.create(destination)

View File

@@ -10,7 +10,10 @@ angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl",
$scope.init()
$scope.$watch 'order_cycle_form.$dirty', (newValue) ->
StatusMessage.display 'notice', 'You have unsaved changes' if newValue
StatusMessage.display 'notice', t("admin.unsaved_changes") if newValue
$scope.$watch 'order_cycle_form.$valid', (isValid) ->
StatusMessage.setValidation(isValid)
$scope.loaded = ->
Enterprise.loaded && EnterpriseFee.loaded && OrderCycle.loaded
@@ -39,7 +42,7 @@ angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl",
$scope.submit = ($event, destination) ->
$event.preventDefault()
StatusMessage.display 'progress', "Saving..."
StatusMessage.display 'progress', t('js.saving')
OrderCycle.mirrorIncomingToOutgoingProducts()
OrderCycle.update(destination, $scope.order_cycle_form)

View File

@@ -165,13 +165,13 @@ angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, S
if destination?
$window.location = destination
else
StatusMessage.display 'success', 'Your order cycle has been updated.'
StatusMessage.display 'success', t('js.order_cycles.update_success')
else
console.log('Failed to update order cycle')
confirmNoDistributors: ->
if @order_cycle.outgoing_exchanges.length == 0
confirm 'There are no distributors in this order cycle. This order cycle will not be visible to customers until you add one. Would you like to continue saving this order cycle?'
confirm t('js.order_cycles.no_distributors')
else
true

View File

@@ -1,8 +1,7 @@
angular.module("ofn.admin").controller "ImportOptionsFormCtrl", ($scope, $rootScope, ProductImportService) ->
$scope.toggleResetAbsent = () ->
confirmed = confirm 'This will set stock level to zero on all products for this \n' +
'enterprise that are not present in the uploaded file.' if $scope.resetAbsent
confirmed = confirm t('js.product_import.confirmation') if $scope.resetAbsent
if confirmed or !$scope.resetAbsent
ProductImportService.updateResetAbsent($scope.supplierId, $scope.resetCount, $scope.resetAbsent)

View File

@@ -0,0 +1,24 @@
angular.module("admin.products").controller "editUnitsCtrl", ($scope, VariantUnitManager) ->
$scope.product =
variant_unit: angular.element('#variant_unit').val()
variant_unit_scale: angular.element('#variant_unit_scale').val()
$scope.variant_unit_options = VariantUnitManager.variantUnitOptions()
if $scope.product.variant_unit == 'items'
$scope.variant_unit_with_scale = 'items'
else
$scope.variant_unit_with_scale = $scope.product.variant_unit + '_' + $scope.product.variant_unit_scale
$scope.setFields = ->
if $scope.variant_unit_with_scale == 'items'
variant_unit = 'items'
variant_unit_scale = null
else
options = $scope.variant_unit_with_scale.split('_')
variant_unit = options[0]
variant_unit_scale = options[1]
$scope.product.variant_unit = variant_unit
$scope.product.variant_unit_scale = variant_unit_scale

View File

@@ -0,0 +1,14 @@
angular.module("admin.products").controller "variantUnitsCtrl", ($scope, VariantUnitManager, $timeout) ->
$scope.unitName = (scale, type) ->
VariantUnitManager.getUnitName(scale, type)
$scope.scale = angular.element('#product_variant_unit_scale').val()
$scope.updateValue = ->
unit_value_human = angular.element('#unit_value_human').val()
$scope.unit_value = unit_value_human * $scope.scale
variant_unit_value = angular.element('#variant_unit_value').val()
$scope.unit_value_human = variant_unit_value / $scope.scale
$timeout -> $scope.updateValue()

View File

@@ -24,7 +24,7 @@ angular.module("admin.resources").factory "Customers", ($q, InfoDialog, RequestM
if errors?
InfoDialog.open 'error', errors[0]
else
InfoDialog.open 'error', "Could not delete customer: #{customer.email}"
InfoDialog.open 'error', t('js.resources.could_not_delete_customer') + ": #{customer.email}"
index: (params) ->
@clear()

View File

@@ -1,6 +1,6 @@
angular.module("ofn.admin").factory "ofnConfirmHandler", (pendingChanges, $compile, $q) ->
return (scope, callback) ->
template = "<div id='dialog-div' style='padding: 10px'><h6>Unsaved changes currently exist, save now or ignore?</h6></div>"
template = "<div id='dialog-div' style='padding: 10px'><h6>" + t('js.services.unsaved_changes_message') + "</h6></div>"
dialogDiv = $compile(template)(scope)
return ->
if pendingChanges.changeCount(pendingChanges.pendingChanges) > 0

View File

@@ -26,7 +26,7 @@ angular.module("ofn.admin").factory 'EnterpriseRelationships', ($http, enterpris
permission_presentation: (permission) ->
switch permission
when "add_to_order_cycle" then "add to order cycle"
when "manage_products" then "manage products"
when "edit_profile" then "edit profile"
when "create_variant_overrides" then "add products to inventory"
when "add_to_order_cycle" then t('js.services.add_to_order_cycle')
when "manage_products" then t('js.services.manage_products')
when "edit_profile" then t('js.services.edit_profile')
when "create_variant_overrides" then t('js.services.add_products_to_inventory')

View File

@@ -2,7 +2,7 @@ angular.module("admin.tagRules").controller "TagRulesCtrl", ($scope, $http, $fil
$scope.tagGroups = enterprise.tag_groups
$scope.defaultTagGroup = enterprise.default_tag_group
$scope.visibilityOptions = [ { id: "visible", name: "VISIBLE" }, { id: "hidden", name: "NOT VISIBLE" } ]
$scope.visibilityOptions = [ { id: "visible", name: t('js.tag_rules.visible') }, { id: "hidden", name: t('js.tag_rules.not_visible') } ]
$scope.updateRuleCounts = ->
index = $scope.defaultTagGroup.rules.length
@@ -57,4 +57,4 @@ angular.module("admin.tagRules").controller "TagRulesCtrl", ($scope, $http, $fil
.success ->
tagGroup.rules.splice(index, 1)
$scope.updateRuleCounts()
$scope.enterprise_form.$setDirty()
$scope.enterprise_form.$setDirty()

View File

@@ -9,10 +9,10 @@ angular.module("admin.tagRules").directive 'newTagRuleDialog', ($compile, $templ
scope.ruleTypes = [
# { id: "DiscountOrder", name: 'Apply a discount to orders' }
{ id: "FilterProducts", name: 'Show or Hide variants in my shopfront' }
{ id: "FilterShippingMethods", name: 'Show or Hide shipping methods at checkout' }
{ id: "FilterPaymentMethods", name: 'Show or Hide payment methods at checkout' }
{ id: "FilterOrderCycles", name: 'Show or Hide order cycles in my shopfront' }
{ id: "FilterProducts", name: t('js.tag_rules.show_hide_variants') }
{ id: "FilterShippingMethods", name: t('js.tag_rules.show_hide_shipping') }
{ id: "FilterPaymentMethods", name: t('js.tag_rules.show_hide_payment') }
{ id: "FilterOrderCycles", name: t('js.tag_rules.show_hide_order_cycles') }
]
scope.ruleType = scope.ruleTypes[0].id

View File

@@ -11,6 +11,14 @@ angular.module("admin.utils").factory "StatusMessage", ($timeout) ->
text: ""
style: {}
invalidMessage: ""
setValidation: (isValid) ->
if isValid
StatusMessage.invalidMessage = ''
else
StatusMessage.invalidMessage = t("admin.form_invalid")
active: ->
@statusMessage.text != ''

View File

@@ -15,11 +15,11 @@ angular.module("admin.variantOverrides").controller "AdminVariantOverridesCtrl",
$scope.currentView = -> Views.currentView
$scope.views = Views.setViews
inventory: { name: "Inventory Products", visible: true }
hidden: { name: "Hidden Products", visible: false }
new: { name: "New Products", visible: false }
inventory: { name: t('js.variant_overrides.inventory_products'), visible: true }
hidden: { name: t('js.variant_overrides.hidden_products'), visible: false }
new: { name: t('js.variant_overrides.new_products'), visible: false }
$scope.bulkActions = [ name: "Reset Stock Levels To Defaults", callback: 'resetStock' ]
$scope.bulkActions = [ name: t('js.variant_overrides.reset_stock_levels'), callback: 'resetStock' ]
$scope.columns = Columns.columns
@@ -52,22 +52,22 @@ angular.module("admin.variantOverrides").controller "AdminVariantOverridesCtrl",
$scope.displayDirty = ->
if DirtyVariantOverrides.count() > 0
num = if DirtyVariantOverrides.count() == 1 then "one override" else "#{DirtyVariantOverrides.count()} overrides"
StatusMessage.display 'notice', "Changes to #{num} remain unsaved."
num = if DirtyVariantOverrides.count() == 1 then t('js.variant_overrides.one_override') else "#{DirtyVariantOverrides.count()} " + t('js.variant_overrides.overrides')
StatusMessage.display 'notice', t('js.variant_overrides.changes_to') + ' ' + num + ' ' + t('js.variant_overrides.remain_unsaved')
else
StatusMessage.clear()
$scope.update = ->
if DirtyVariantOverrides.count() == 0
StatusMessage.display 'alert', 'No changes to save.'
StatusMessage.display 'alert', t('js.variant_overrides.no_changes_to_save')
else
StatusMessage.display 'progress', 'Saving...'
StatusMessage.display 'progress', t('js.saving')
DirtyVariantOverrides.save()
.success (updatedVos) ->
DirtyVariantOverrides.clear()
VariantOverrides.updateIds updatedVos
$scope.variant_overrides_form.$setPristine()
StatusMessage.display 'success', 'Changes saved.'
StatusMessage.display 'success', t('js.changes_saved')
VariantOverrides.updateData updatedVos # Refresh page data
.error (data, status) ->
StatusMessage.display 'failure', $scope.updateError(data, status)
@@ -75,32 +75,32 @@ angular.module("admin.variantOverrides").controller "AdminVariantOverridesCtrl",
$scope.updateError = (data, status) ->
if status == 401
"I couldn't get authorisation to save those changes, so they remain unsaved."
t('js.variant_overrides.no_authorisation')
else if status == 400 && data.errors?
errors = []
for field, field_errors of data.errors
errors = errors.concat field_errors
errors = errors.join ', '
"I had some trouble saving: #{errors}"
t('js.variant_overrides.some_trouble', {errors: errors})
else
"Oh no! I was unable to save your changes."
t('js.oh_no')
$scope.resetStock = ->
if DirtyVariantOverrides.count() > 0
StatusMessage.display 'alert', 'Save changes first.'
StatusMessage.display 'alert', t('js.save_changes_first')
$timeout ->
$scope.displayDirty()
, 3000 # 3 second delay
else
return unless $scope.hub_id?
StatusMessage.display 'progress', 'Changing on hand stock levels...'
StatusMessage.display 'progress', t('js.variant_overrides.changing_on_hand_stock')
$http
method: "POST"
url: "/admin/variant_overrides/bulk_reset"
data: { hub_id: $scope.hub_id }
.success (updatedVos) ->
VariantOverrides.updateData updatedVos
StatusMessage.display 'success', 'Stocks reset to defaults.'
StatusMessage.display 'success', t('js.variant_overrides.stock_reset')
.error (data, status) ->
$timeout -> StatusMessage.display 'failure', $scope.updateError(data, status)

View File

@@ -16,7 +16,7 @@
#= require ../shared/angular-local-storage.js
#= require ../shared/angular-slideables.js
#= require angularjs-file-upload
#= require i18n/translations
#= require angular-rails-templates
#= require_tree ../templates

View File

@@ -1,8 +1,8 @@
$ ->
if ($ 'form#update-cart').is('*')
($ 'form#update-cart a.delete').show().one 'click', ->
($ this).parents('.line-item').first().find('input.line_item_quantity').val 0
($ this).parents('form').first().submit()
if $('form#update-cart').is('*') || $('form#update-order').is('*')
$('form#update-cart a.delete, form#update-order a.delete').show().one 'click', ->
$(this).parents('.line-item').first().find('input.line_item_quantity').val 0
$(this).parents('form').first().submit()
false
($ 'form#update-cart').submit ->

View File

@@ -0,0 +1,12 @@
Darkswarm.controller "EditBoughtOrderController", ($scope, $resource, Cart) ->
$scope.showBought = false
$scope.deleteLineItem = (id) ->
params = {id: id}
success = (response) ->
$(".line-item-" + id).remove()
Cart.removeFinalisedLineItem(id)
fail = (error) ->
console.log error
$resource("/line_items/:id").delete(params, success, fail)

View File

@@ -10,7 +10,7 @@ Darkswarm.controller "OrderCycleCtrl", ($scope, $timeout, OrderCycle) ->
$("#order_cycle_id").trigger("openTrigger")
Darkswarm.controller "OrderCycleChangeCtrl", ($scope, $timeout, OrderCycle, Products, Variants, Cart) ->
Darkswarm.controller "OrderCycleChangeCtrl", ($scope, $timeout, OrderCycle, Products, Variants, Cart, ChangeableOrdersAlert) ->
# Track previous order cycle id for use with revertOrderCycle()
$scope.previous_order_cycle_id = OrderCycle.order_cycle.order_cycle_id
$scope.$watch 'order_cycle.order_cycle_id', (newValue, oldValue)->
@@ -30,3 +30,5 @@ Darkswarm.controller "OrderCycleChangeCtrl", ($scope, $timeout, OrderCycle, Prod
Variants.clear()
Cart.clear()
Products.update()
Cart.reloadFinalisedLineItems()
ChangeableOrdersAlert.reload()

View File

@@ -5,7 +5,20 @@ Darkswarm.controller "RegistrationCtrl", ($scope, RegistrationService, Enterpris
$scope.steps = ['details', 'contact', 'type', 'about', 'images', 'social']
$scope.countries = availableCountries
# Filter countries without states since the form requires a state to be selected.
# Consider changing the form to require a state only if a country requires them (Spree option).
# Invalid countries still need to be filtered (better server-side).
$scope.countries = availableCountries.filter (country) ->
country.states.length > 0
$scope.countriesById = $scope.countries.reduce (obj, country) ->
obj[country.id] = country
obj
, {}
$scope.setDefaultCountry = (id) ->
country = $scope.countriesById[id]
$scope.enterprise.country = country if country
$scope.countryHasStates = ->
$scope.enterprise.country.states.length > 0

View File

@@ -11,8 +11,7 @@ window.Darkswarm = angular.module("Darkswarm", ["ngResource",
'angularFileUpload',
'angularSlideables'
]).config ($httpProvider, $tooltipProvider, $locationProvider, $anchorScrollProvider) ->
$httpProvider.defaults.headers.post['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content')
$httpProvider.defaults.headers.put['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content')
$httpProvider.defaults.headers['common']['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content')
$httpProvider.defaults.headers['common']['X-Requested-With'] = 'XMLHttpRequest'
$httpProvider.defaults.headers.common.Accept = "application/json, text/javascript, */*"

View File

@@ -0,0 +1,5 @@
Darkswarm.directive "changeableOrdersAlert", (ChangeableOrdersAlert) ->
restrict: "C"
scope: true
link: (scope, element, attrs) ->
scope.alert = ChangeableOrdersAlert

View File

@@ -0,0 +1,9 @@
Darkswarm.directive "confirmLinkClick", ($window) ->
restrict: 'A'
scope:
confirmMsg: '@confirmLinkClick'
link: (scope, elem, attr) ->
elem.bind 'click', (event) ->
unless confirm(scope.confirmMsg)
event.preventDefault()
event.stopPropagation()

View File

@@ -6,7 +6,11 @@ Darkswarm.directive "ofnOnHand", ->
# In cases where this field gets its value from the HTML element rather than the model,
# initialise the model with the HTML value.
if scope.$eval(attr.ngModel) == undefined
ngModel.$setViewValue elem.val()
# Don't dirty the model when we do this
setDirty = ngModel.$setDirty
ngModel.$setDirty = angular.noop
ngModel.$setViewValue(elem.val())
ngModel.$setDirty = setDirty
ngModel.$parsers.push (viewValue) ->
on_hand = parseInt(attr.ofnOnHand)

View File

@@ -5,4 +5,4 @@ Darkswarm.filter 'products', (Matcher) ->
return products if text == ""
products.filter (product) =>
propertiesToMatch = [product.name, product.variant_names, product.supplier.name, product.primary_taxon.name]
Matcher.match propertiesToMatch, text
Matcher.matchBeginning propertiesToMatch, text

View File

@@ -1,9 +0,0 @@
<%# Defines a global I18n object containing the language of the current locale %>
<%
# Invalidate this asset if locale changes.
Dir[Rails.root.join('config', 'locales', "#{I18n.default_locale}.yml").to_s].each do |f|
depend_on(f)
end
%>
<%- I18n.backend.send(:init_translations) unless I18n.backend.initialized? %>
window.I18n = <%= I18n.backend.send(:translations)[I18n.default_locale].with_indifferent_access.to_json.html_safe %>

View File

@@ -1,17 +1,11 @@
# Old aliases before i18n-js was introduced.
# TODO - delete it after everything is moved to i18n-js
# Declares the translation function t.
# You can use translate('login') or t('login') in Javascript.
window.translate = (key, options = {}) ->
unless 'I18n' of window
console.log 'The I18n object is undefined. Cannot translate text.'
return key
dict = I18n
parts = key.split '.'
while (parts.length)
part = parts.shift()
return key unless part of dict
dict = dict[part]
text = dict
for name, value of options
text = text.split("%{#{name}}").join(value)
text
I18n.t(key, options)
window.t = window.translate

View File

@@ -25,9 +25,7 @@ Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location, Redir
isActive: Navigation.isActive
close: ->
if location.pathname in ["/", "/checkout"]
Navigation.navigate "/"
else
if location.pathname in ["/register", "/register/auth"]
Loading.message = t 'going_back_to_home_page'
location.hash = ""
location.pathname = "/"

View File

@@ -1,4 +1,4 @@
Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $rootScope, localStorageService)->
Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $rootScope, $resource, localStorageService) ->
# Handles syncing of current cart/order state to server
new class Cart
dirty: false
@@ -6,11 +6,15 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $roo
update_enqueued: false
order: CurrentOrder.order
line_items: CurrentOrder.order?.line_items || []
line_items_finalised: CurrentOrder.order?.finalised_line_items || []
constructor: ->
for line_item in @line_items
line_item.variant.line_item = line_item
Variants.register line_item.variant
for line_item in @line_items_finalised
line_item.variant.line_item = line_item
Variants.extend line_item.variant
adjust: (line_item) =>
line_item.total_price = line_item.variant.price_with_fees * line_item.quantity
@@ -115,3 +119,15 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $roo
clear: ->
@line_items = []
localStorageService.clearAll() # One day this will have to be moar GRANULAR
removeFinalisedLineItem: (id) =>
@line_items_finalised = @line_items_finalised.filter (item) ->
item.id != id
reloadFinalisedLineItems: =>
@line_items_finalised = []
$resource("/line_items/bought").query (items) =>
for line_item in items
line_item.variant.line_item = line_item
Variants.extend line_item.variant
@line_items_finalised = items

View File

@@ -0,0 +1,14 @@
Darkswarm.factory 'ChangeableOrdersAlert', ($http) ->
new class ChangeableOrdersAlert
html: ''
visible: true
constructor: ->
@reload()
reload: ->
$http.get('/shop/changeable_orders_alert').then (response) =>
@html = response.data.trim()
close: =>
@visible = false

View File

@@ -1,7 +1,14 @@
Darkswarm.factory "Matcher", ->
# Match text fragment in an array of strings.
new class Matcher
# Match text fragment in an array of strings.
match: (properties, text)->
properties.some (prop)->
prop ||= ""
prop.toLowerCase().indexOf(text.toLowerCase()) != -1
# Return true if text occurs at the beginning of any word present in an array of strings
matchBeginning: (properties, text) ->
text = text.trim()
regexp = new RegExp("(?:^|[\\s-])#{text}", "i")
properties.some (prop) -> (prop || "").search(regexp) >= 0

View File

@@ -3,10 +3,12 @@ Darkswarm.factory 'Orders', (orders_by_distributor, currencyConfig, CurrentHub,
constructor: ->
# Populate Orders.orders from json in page.
@orders_by_distributor = orders_by_distributor
@changeable_orders = []
@currency_symbol = currencyConfig.symbol
for distributor in @orders_by_distributor
@updateRunningBalance(distributor.distributed_orders)
@findChangeableOrders(distributor.distributed_orders)
@updateRunningBalance(distributor.distributed_orders)
updateRunningBalance: (orders) ->
@@ -14,3 +16,7 @@ Darkswarm.factory 'Orders', (orders_by_distributor, currencyConfig, CurrentHub,
balances = orders.slice(i,orders.length).map (o) -> parseFloat(o.outstanding_balance)
running_balance = balances.reduce (a,b) -> a+b
order.running_balance = running_balance.toFixed(2)
findChangeableOrders: (orders) ->
for order in orders when order.changes_allowed
@changeable_orders.push(order)

View File

@@ -42,9 +42,10 @@ Darkswarm.factory 'Products', ($resource, Enterprises, Dereferencer, Taxons, Pro
registerVariants: ->
for product in @products
if product.variants
product.variant_names = ""
product.variants = for variant in product.variants
variant = Variants.register variant
if product.name != variant.name_to_display
product.variant_names += variant.name_to_display
product.variant_names += variant.name_to_display + " "
variant.product = product
variant

View File

@@ -6,4 +6,4 @@
{{ message }}
.action-buttons.text-center
%button{ ng: { click: "close()" } }
OK
= t(:ok)

View File

@@ -7,7 +7,7 @@
'ng-model' => 'exchange.select_all_variants',
'ng-change' => 'setExchangeVariants(exchange, incomingExchangeVariantsFor(exchange.enterprise_id), exchange.select_all_variants)',
'id' => 'order_cycle_outgoing_exchange_{{ $parent.$index }}_select_all_variants' }
Select all
= t('admin.select_all')
.exchange-products
-# Scope product list based on permissions the current user has to view variants in this exchange

View File

@@ -7,7 +7,7 @@
'ng-model' => 'exchange.select_all_variants',
'ng-change' => 'setExchangeVariants(exchange, suppliedVariants(exchange.enterprise_id), exchange.select_all_variants)',
'id' => 'order_cycle_incoming_exchange_{{ $index }}_select_all_variants' }
Select all
= t('admin.select_all')
.exchange-products
-# No need to scope product list based on permissions, because if an incoming exchange is visible,
@@ -36,7 +36,7 @@
'ofn-sync-distributions' => '{{ product.master_id }}',
'id' => 'order_cycle_incoming_exchange_{{ $parent.$index }}_variants_{{ product.master_id }}',
'ng-disabled' => '!order_cycle.editable_variants_for_incoming_exchanges.hasOwnProperty(exchange.enterprise_id) || order_cycle.editable_variants_for_incoming_exchanges[exchange.enterprise_id].indexOf(product.master_id) < 0' }
Obsolete master
= t('admin.obsolete_master')
.exchange-product-variant{'ng-repeat' => 'variant in product.variants'}
%label

View File

@@ -1,5 +1,6 @@
.row.exchange-tags
.sixteen.columns.alpha.omega
%span.text-normal Tags
%span.text-normal
= t('admin.tags')
%br
%tags-with-translation.fullwidth{ object: 'object' }

View File

@@ -1,6 +1,9 @@
#save-bar.animate-show{ ng: { show: 'dirty || persist || StatusMessage.active()' } }
.container
.eight.columns.alpha
%h5#status-message{ ng: { style: 'StatusMessage.statusMessage.style' } }
%h5#status-message{ ng: { show: "StatusMessage.invalidMessage == ''", style: 'StatusMessage.statusMessage.style' } }
{{ StatusMessage.statusMessage.text || "&nbsp;" }}
%h5#status-message{ ng: { show: "StatusMessage.invalidMessage !== ''" }, style: 'color: #da5354' }
{{ StatusMessage.invalidMessage || "&nbsp;" }}
.eight.columns.omega.text-right{ ng: { transclude: true } }

View File

@@ -1,4 +1,4 @@
%div{ ng: { show: "data.length > limit" } }
%input{ type: 'button', value: t(:show_more), ng: { click: 'limit = limit + increment' } }
or
%input{ type: 'button', value: t(:show_more_with_more, num: '{{ data.length - limit }}'), ng: { click: 'limit = data.length' } }
%input{ type: 'button', value: t(:show_all_with_more, num: '{{ data.length - limit }}'), ng: { click: 'limit = data.length' } }

View File

@@ -7,4 +7,5 @@
id: "enterprise_tag_rules_attributes_{{tagGroup.startIndex + $index}}_preferred_matched_order_cycles_visibility",
name: "enterprise[tag_rules_attributes][{{tagGroup.startIndex + $index}}][preferred_matched_order_cycles_visibility]",
ng: { value: "'hidden'", if: "rule.is_default" } }
%span.text-normal{ ng: { if: "rule.is_default" } } not visible
%span.text-normal{ ng: { if: "rule.is_default" } }
=t(:not_visible)

View File

@@ -7,4 +7,5 @@
id: "enterprise_tag_rules_attributes_{{tagGroup.startIndex + $index}}_preferred_matched_payment_methods_visibility",
name: "enterprise[tag_rules_attributes][{{tagGroup.startIndex + $index}}][preferred_matched_payment_methods_visibility]",
ng: { value: "'hidden'", if: "rule.is_default" } }
%span.text-normal{ ng: { if: "rule.is_default" } } not visible
%span.text-normal{ ng: { if: "rule.is_default" } }
= t(:not_visible)

View File

@@ -7,4 +7,5 @@
id: "enterprise_tag_rules_attributes_{{tagGroup.startIndex + $index}}_preferred_matched_variants_visibility",
name: "enterprise[tag_rules_attributes][{{tagGroup.startIndex + $index}}][preferred_matched_variants_visibility]",
ng: { value: "'hidden'", if: "rule.is_default" } }
%span.text-normal{ ng: { if: "rule.is_default" } } not visible
%span.text-normal{ ng: { if: "rule.is_default" } }
= t(:not_visible)

View File

@@ -7,4 +7,6 @@
id: "enterprise_tag_rules_attributes_{{tagGroup.startIndex + $index}}_preferred_matched_shipping_methods_visibility",
name: "enterprise[tag_rules_attributes][{{tagGroup.startIndex + $index}}][preferred_matched_shipping_methods_visibility]",
ng: { value: "'hidden'", if: "rule.is_default" } }
%span.text-normal{ ng: { if: "rule.is_default" } } not visible
%span.text-normal{ ng: { if: "rule.is_default" } }
= t(:not_visible)

View File

@@ -11,7 +11,7 @@
%span.filter-shopfront.property-selectors.pad-top
%ul.inline-block
%li{"ng-repeat" => "property in enterprise.supplied_properties"}
%a.button.tiny{"ng-bind" => "property.presentation"}
%a.button.tiny.disabled{"ng-bind" => "property.presentation"}
.about-container.pad-top
%img.enterprise-logo{"ng-src" => "{{::enterprise.logo}}", "ng-if" => "::enterprise.logo"}

View File

@@ -5,7 +5,7 @@
%li.more
%a.dropdown{ data: { dropdown: "{{ 'show-more-' + selectorName }}" }, ng: { class: "{active: selectedOverFlowSelectors().length > 0}" } }
%span
+ {{ overFlowSelectors().length }} more
= t('js.more_items', count: "{{ overFlowSelectors().length }}")
%i.ofn-i_052-point-down
.f-dropdown.text-right.content{ ng: { attr: { id: "{{ 'show-more-' + selectorName }}" } } }
%ul

View File

@@ -0,0 +1,3 @@
form[name="enterprise_form"] div.row.warning {
color: #DA7F52;
}

View File

@@ -28,8 +28,8 @@ text-angular .ta-editor {
left: 275px;
}
span.error, div.error {
color: #DA5354;
span.error, div.error:not(.flash) {
color: #DA5354;
}
/* Fix conflict between Spree and elRTE's styles */
@@ -74,6 +74,9 @@ form.order_cycle {
margin-bottom: 0.5em;
}
}
.icon-question-sign {
font-size: 18px;
}
table.exchanges {
tr td.active {
width: 20px;
@@ -113,6 +116,14 @@ form.order_cycle {
margin-right: 2em;
}
}
.collection-details {
input {
width: 90%
}
span {
font-size: 1rem
}
}
}
.coordinator-fees {
margin-top: 1em;

View File

@@ -19,7 +19,7 @@
height: 100px
width: 100px
margin-right: 12px
location
@include headingFont
@media all and (max-width: 768px)
@@ -30,7 +30,7 @@
margin-top: 0
@media all and (max-width: 768px)
margin-bottom: 8px
ordercycle
text-align: right
@@ -47,24 +47,26 @@
p
max-width: 100%
float: right
form.custom
form.custom
text-align: right
& > strong
line-height: 2.5
font-size: 1.29em
padding-right: 14px
@media all and (max-width: 768px)
select
select
width: inherit
display: inline-block
border-width: 1px
border-color: #999
color: #666
font-size: 1em
font-size: 1em
margin-bottom: 0
padding: 8px 20px 8px 12px
@media all and (max-width: 768px)
font-size: 0.875em
@media screen and (-webkit-min-device-pixel-ratio:0)
font-size: 16px
closing
@include headingFont
@media all and (max-width: 768px)

View File

@@ -1,16 +1,14 @@
@import "branding";
@import "mixins";
.account-summary {
color: #4a4a4a;
}
.orders {
@include sidepaddingSm;
@include panepadding;
padding-top: 10px;
h3 {
padding-top: 2em;
}
margin-top: 50px;
margin-bottom: 100px;
a {
color: $clr-brick;
@@ -26,6 +24,12 @@
height: auto;
}
.active_table_row {
h3 {
margin-top: 0.5em;
}
}
i.ofn-i_059-producer, i.ofn-i_060-producer-reversed {
font-size: 3rem;
display: inline-block;
@@ -61,6 +65,7 @@
.transaction-group {}
table {
width: 100%;
border-radius: 0.5em 0.5em 0 0;
tr:nth-of-type(even) {

View File

@@ -33,7 +33,9 @@
@-webkit-keyframes slideOutUp {
0% {
opacity: 1;
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0);
}
@@ -46,10 +48,18 @@
@keyframes slideOutUp {
0% {
opacity: 1;
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0);
}
100% {
opacity: 0;
-webkit-transform: translateY(-20px);
-ms-transform: translateY(-20px);
transform: translateY(-20px);
}
}
@-webkit-keyframes fadeIn {

View File

@@ -6,23 +6,25 @@
background-color: #e1f0f5
padding: 1em
width: 100%
border: none
color: inherit
checkout
display: block
@media all and (max-width: 640px)
&.row .row
@media all and (max-width: 640px)
&.row .row
margin-left: 0
margin-right: 0
orderdetails
.button, table
width: 100%
@media all and (max-width: 640px)
@media all and (max-width: 640px)
form.edit_order
border: 1px solid $disabled-bright
margin-bottom: 2rem
#details, #billing, #shipping, #payment
border: 0
margin: 1em 0
@@ -34,20 +36,20 @@ checkout
margin: 0
padding: 0.65em
background: #f7f7f7
.label
.label
font-size: 1em
padding: 0.3rem 0.35rem 0.275rem
// Logic to turn on & off the alerts for success against each fieldset
label, label.alert, label.success, &.valid label.alert, &.dirty label.success
label, label.alert, label.success, &.valid label.alert, &.dirty label.success
display: none
&.dirty label.alert
&.dirty label.alert
display: inline
&.dirty.valid label.alert
display: none
&.dirty.valid label.alert
display: none
&.valid label.success
display: inline
@@ -60,7 +62,7 @@ checkout
text-align: left
// Logic to swap out up / down accordion icons
//Foundation overrides
//Foundation overrides
dd > a
@include csstrans
background: $disabled-light !important
@@ -68,7 +70,7 @@ checkout
dd > a:hover
background: $disabled-v-dark !important
color: white
dd
span.accordion-up
display: none
@@ -79,4 +81,3 @@ checkout
display: inline
span.accordion-down
display: none

View File

@@ -0,0 +1,71 @@
body.embedded {
nav.top-bar {
ul.left, ul.center, ul.right li.current_hub {
display: none;
}
ul.right {
width: auto !important;
li {
float: left;
line-height: 4.6875rem;
height: 4.6875rem;
vertical-align: top;
}
li.powered-by {
display: inline-block;
}
}
&.show-for-large-up {
display: inherit !important;
}
&.show-for-medium-down {
display: none !important;
}
}
footer {
display: none;
}
}
nav.top-bar ul.right li.powered-by {
display: none;
margin-right: 0.4rem;
opacity: 0.6;
img {
height: 1.8em;
margin: 0px 0.4em 0.4em 0px;
}
span, a {
font-family: "Oswald", sans-serif;
font-size: 1rem;
font-weight: 300;
color: #555;
padding: 0 !important;
}
a:hover {
color: #000;
}
}
.blocked-cookies {
text-align: center;
margin-bottom: 0 !important;
&.hidden {
display: none;
}
a.button.allow {
background-color: rgba(0,0,0,0.25);
margin-bottom: 0.4em;
&:hover {
background-color: rgba(0,0,0,0.35);
}
}
}

View File

@@ -117,6 +117,13 @@ nav {
padding: 9px 0 0 9px;
}
.top-bar .ofn-logo img {
height: auto;
width: auto;
max-height: 51px;
max-width: 250px;
}
.left-off-canvas-menu {
background-color: white;
}

View File

@@ -15,6 +15,10 @@
@mixin panepadding {
padding-top: 100px;
padding-bottom: 100px;
@media all and (max-width: 640px) {
padding-top: 25px;
}
}
@mixin paneWhiteText {

View File

@@ -32,6 +32,11 @@
color: $clr-turquoise;
}
.vertical-align-middle {
display: flex;
align-items: center;
}
a {
&:hover, &:active, &:focus {
color: $clr-turquoise-bright;

View File

@@ -110,6 +110,10 @@
}
}
.alert-box.changeable-orders-alert {
margin-bottom: 0px;
}
.alert-box.shopfront-message {
border: 2px solid $clr-turquoise;
border-radius: 5px;

View File

@@ -72,11 +72,35 @@
// Shopping cart
#cart-detail {
.cart-item-delete {
a.delete {
.cart-item-delete, .bought-item-delete {
a {
font-size: 1.125em;
}
}
.out-of-stock {
color: $clr-brick;
}
button, .button {
margin: 0;
}
.toggle-bought {
cursor: pointer;
}
tr.bought td {
color: $med-grey;
h5 {
color: $med-grey;
}
.already-confirmed {
float: right;
}
}
}
.item-thumb-image {
@@ -90,9 +114,3 @@
height: 36px;
}
}
#edit-cart {
button, .button {
margin: 0;
}
}

View File

@@ -15,11 +15,11 @@ class Admin::AccountsAndBillingSettingsController < Spree::Admin::BaseController
def start_job
if @update_account_invoices_job || @finalize_account_invoices_job
flash[:error] = "A task is already running, please wait until it has finished"
flash[:error] = I18n.t(:accounts_and_billing_task_already_running_error)
else
new_job = "#{params[:job][:name]}".camelize.constantize.new
Delayed::Job.enqueue new_job
flash[:success] = "Task Queued"
flash[:success] = I18n.t(:accounts_and_billing_start_task_notice)
end
redirect_to_edit

View File

@@ -1,12 +1,12 @@
module Admin
class ContentsController < Spree::Admin::BaseController
def edit
@preference_sections = [{name: 'Header', preferences: [:logo, :logo_mobile, :logo_mobile_svg]},
{name: 'Home page', preferences: [:home_hero, :home_show_stats]},
{name: 'Producer signup page', preferences: [:producer_signup_pricing_table_html, :producer_signup_case_studies_html, :producer_signup_detail_html]},
{name: 'Hub signup page', preferences: [:hub_signup_pricing_table_html, :hub_signup_case_studies_html, :hub_signup_detail_html]},
{name: 'Group signup page', preferences: [:group_signup_pricing_table_html, :group_signup_case_studies_html, :group_signup_detail_html]},
{name: 'Footer and External Links', preferences: [:footer_logo,
@preference_sections = [{name: I18n.t('admin.contents.edit.header'), preferences: [:logo, :logo_mobile, :logo_mobile_svg]},
{name: I18n.t('admin.contents.edit.home_page'), preferences: [:home_hero, :home_show_stats]},
{name: I18n.t('admin.contents.edit.producer_signup_page'), preferences: [:producer_signup_pricing_table_html, :producer_signup_case_studies_html, :producer_signup_detail_html]},
{name: I18n.t('admin.contents.edit.hub_signup_page'), preferences: [:hub_signup_pricing_table_html, :hub_signup_case_studies_html, :hub_signup_detail_html]},
{name: I18n.t('admin.contents.edit.group_signup_page'), preferences: [:group_signup_pricing_table_html, :group_signup_case_studies_html, :group_signup_detail_html]},
{name: I18n.t('admin.contents.edit.footer_and_external_links'), preferences: [:footer_logo,
:footer_facebook_url, :footer_twitter_url, :footer_instagram_url, :footer_linkedin_url, :footer_googleplus_url, :footer_pinterest_url,
:footer_email, :community_forum_url, :footer_links_md, :footer_about_url, :footer_tos_url]}]
end
@@ -21,7 +21,7 @@ module Admin
# Save any uploaded images
ContentConfig.save
flash[:success] = t(:successfully_updated, :resource => "Your content")
flash[:success] = t(:successfully_updated, :resource => I18n.t('admin.contents.edit.your_content'))
redirect_to main_app.edit_admin_content_path
end

View File

@@ -35,7 +35,7 @@ module Admin
if params.key? :enterprise_id
redirect_path = main_app.admin_enterprise_fees_path(enterprise_id: params[:enterprise_id])
end
redirect_to redirect_path, :notice => 'Your enterprise fees have been updated.'
redirect_to redirect_path, :notice => I18n.t(:enterprise_fees_update_notice)
else
render :index
@@ -49,7 +49,7 @@ module Admin
product_distribution = ProductDistribution.where(:enterprise_fee_id => @object).first
if product_distribution
p = product_distribution.product
error = "That enterprise fee cannot be deleted as it is referenced by a product distribution: #{p.id} - #{p.name}."
error = I18n.t(:enterprise_fees_destroy_error, id: p.id, name: p.name)
respond_with(@object) do |format|
format.html do

View File

@@ -52,7 +52,6 @@ module Admin
@owner_email = @enterprise_group.andand.owner.andand.email || ""
end
def collection
EnterpriseGroup.by_position
end

View File

@@ -57,7 +57,7 @@ module Admin
def register
if params[:sells] == 'unspecified'
flash[:error] = "Please select a package"
flash[:error] = I18n.t(:enterprise_register_package_error)
return render :welcome, layout: "spree/layouts/bare_admin"
end
@@ -68,10 +68,10 @@ module Admin
end
if @enterprise.update_attributes(attributes)
flash[:success] = "Congratulations! Registration for #{@enterprise.name} is complete!"
flash[:success] = I18n.t(:enterprise_register_success_notice, enterprise: @enterprise.name)
redirect_to admin_path
else
flash[:error] = "Could not complete registration for #{@enterprise.name}"
flash[:error] = I18n.t(:enterprise_register_error, enterprise: @enterprise.name)
render :welcome, layout: "spree/layouts/bare_admin"
end
end
@@ -80,19 +80,19 @@ module Admin
@enterprise_set = EnterpriseSet.new(collection, params[:enterprise_set])
touched_enterprises = @enterprise_set.collection.select(&:changed?)
if @enterprise_set.save
flash[:success] = "Enterprises updated successfully"
flash[:success] = I18n.t(:enterprise_bulk_update_success_notice)
# 18-3-2015: It seems that the form for this action sometimes loads bogus values for
# the 'sells' field, and submitting that form results in a bunch of enterprises with
# values that have mysteriously changed. This statement is here to help debug that
# issue, and should be removed (along with its display in index.html.haml) when the
# issue has been resolved.
flash[:action] = "Updated #{pluralize(touched_enterprises.count, 'enterprise')}: #{touched_enterprises.map(&:name).join(', ')}"
flash[:action] = "#{I18n.t(:updated)} #{pluralize(touched_enterprises.count, 'enterprise')}: #{touched_enterprises.map(&:name).join(', ')}"
redirect_to main_app.admin_enterprises_path
else
@enterprise_set.collection.select! { |e| touched_enterprises.include? e }
flash[:error] = 'Update failed'
flash[:error] = I18n.t(:enterprise_bulk_update_error)
render :index
end
end

View File

@@ -45,7 +45,7 @@ module Admin
if @order_cycle.save
OpenFoodNetwork::OrderCycleFormApplicator.new(@order_cycle, spree_current_user).go!
flash[:notice] = 'Your order cycle has been created.'
flash[:notice] = I18n.t(:order_cycles_create_notice)
format.html { redirect_to admin_order_cycles_path }
format.json { render :json => {:success => true} }
else
@@ -64,7 +64,7 @@ module Admin
# Only update apply exchange information if it is actually submmitted
OpenFoodNetwork::OrderCycleFormApplicator.new(@order_cycle, spree_current_user).go!
end
flash[:notice] = 'Your order cycle has been updated.' if params[:reloading] == '1'
flash[:notice] = I18n.t(:order_cycles_update_notice) if params[:reloading] == '1'
format.html { redirect_to main_app.edit_admin_order_cycle_path(@order_cycle) }
format.json { render :json => {:success => true} }
else
@@ -76,7 +76,7 @@ module Admin
def bulk_update
@order_cycle_set = params[:order_cycle_set] && OrderCycleSet.new(params[:order_cycle_set])
if @order_cycle_set.andand.save
redirect_to main_app.admin_order_cycles_path, :notice => 'Order cycles have been updated.'
redirect_to main_app.admin_order_cycles_path, notice: I18n.t(:order_cycles_bulk_update_notice)
else
render :index
end
@@ -85,14 +85,14 @@ module Admin
def clone
@order_cycle = OrderCycle.find params[:id]
@order_cycle.clone!
redirect_to main_app.admin_order_cycles_path, :notice => "Your order cycle #{@order_cycle.name} has been cloned."
redirect_to main_app.admin_order_cycles_path, notice: I18n.t(:order_cycles_clone_notice, name: @order_cycle.name)
end
# Send notifications to all producers who are part of the order cycle
def notify_producers
Delayed::Job.enqueue OrderCycleNotificationJob.new(params[:id].to_i)
redirect_to main_app.admin_order_cycles_path, :notice => 'Emails to be sent to producers have been queued for sending.'
redirect_to main_app.admin_order_cycles_path, notice: I18n.t(:order_cycles_email_to_producers_notice)
end
@@ -100,10 +100,10 @@ module Admin
def collection
ocs = if params[:as] == "distributor"
OrderCycle.ransack(params[:q]).result.
involving_managed_distributors_of(spree_current_user).order('updated_at DESC')
involving_managed_distributors_of(spree_current_user).order('updated_at DESC')
elsif params[:as] == "producer"
OrderCycle.ransack(params[:q]).result.
involving_managed_producers_of(spree_current_user).order('updated_at DESC')
involving_managed_producers_of(spree_current_user).order('updated_at DESC')
else
OrderCycle.ransack(params[:q]).result.accessible_by(spree_current_user)
end
@@ -115,7 +115,7 @@ module Admin
end
def collection_actions
[:index]
[:index, :bulk_update]
end
private
@@ -138,12 +138,12 @@ module Admin
available_coordinators = permitted_coordinating_enterprises_for(@order_cycle).select(&:confirmed?)
case available_coordinators.count
when 0
flash[:error] = "None of your enterprises have permission to coordinate an order cycle"
flash[:error] = I18n.t(:order_cycles_no_permission_to_coordinate_error)
redirect_to main_app.admin_order_cycles_path
when 1
@order_cycle.coordinator = available_coordinators.first
else
flash[:error] = "You don't have permission to create an order cycle coordinated by that enterprise" if params[:coordinator_id]
flash[:error] = I18n.t(:order_cycles_no_permission_to_create_error) if params[:coordinator_id]
render :set_coordinator
end
end
@@ -153,7 +153,7 @@ module Admin
yield
rescue ActiveRecord::InvalidForeignKey
redirect_to main_app.admin_order_cycles_url
flash[:error] = "That order cycle has been selected by a customer and cannot be deleted. To prevent customers from accessing it, please close it instead."
flash[:error] = I18n.t(:order_cycles_no_permission_to_delete_error)
end
end
@@ -179,9 +179,5 @@ module Admin
def ams_prefix_whitelist
[:basic]
end
def collection_actions
[:index, :bulk_update]
end
end
end

View File

@@ -25,7 +25,7 @@ class Admin::ProductImportController < Spree::Admin::BaseController
def validate_upload_presence
unless params[:file] || (params[:filepath] && File.exist?(params[:filepath]))
redirect_to '/admin/product_import', notice: 'File not found or could not be opened'
redirect_to '/admin/product_import', notice: I18n.t(:product_import_file_not_found_notice)
return
end
end
@@ -39,7 +39,7 @@ class Admin::ProductImportController < Spree::Admin::BaseController
def check_spreadsheet_has_data(importer)
unless importer.item_count
redirect_to '/admin/product_import', notice: 'No data found in spreadsheet'
redirect_to '/admin/product_import', notice: I18n.t(:product_import_no_data_in_spreadsheet_notice)
return
end
end
@@ -59,4 +59,4 @@ class Admin::ProductImportController < Spree::Admin::BaseController
def model_class
ProductImporter
end
end
end

View File

@@ -4,7 +4,6 @@ module Admin
"#{controller_name.classify}".constantize
end
# URL helpers
def new_object_url(options = {})
if parent_data.present?

View File

@@ -12,7 +12,6 @@ module Admin
def index
end
def bulk_update
# Ensure we're authorised to update all variant overrides
@vo_set.collection.each { |vo| authorize! :update, vo }

View File

@@ -11,10 +11,10 @@ module Api
def accessible
@order_cycles = if params[:as] == "distributor"
OrderCycle.ransack(params[:q]).result.
involving_managed_distributors_of(current_api_user).order('updated_at DESC')
involving_managed_distributors_of(current_api_user).order('updated_at DESC')
elsif params[:as] == "producer"
OrderCycle.ransack(params[:q]).result.
involving_managed_producers_of(current_api_user).order('updated_at DESC')
involving_managed_producers_of(current_api_user).order('updated_at DESC')
else
OrderCycle.ransack(params[:q]).result.accessible_by(current_api_user)
end

View File

@@ -3,6 +3,8 @@ require 'open_food_network/referer_parser'
class ApplicationController < ActionController::Base
protect_from_forgery
prepend_before_filter :restrict_iframes
include EnterprisesHelper
helper CssSplitter::ApplicationHelper
@@ -18,13 +20,74 @@ class ApplicationController < ActionController::Base
end
end
def shopfront_session
session[:safari_fix] = true
render 'shop/shopfront_session', layout: false
end
def enable_embedded_styles
session[:embedded_shopfront] = true
render json: {}, status: 200
end
def disable_embedded_styles
session.delete :embedded_shopfront
session.delete :shopfront_redirect
render json: {}, status: 200
end
protected
def after_sign_in_path_for(resource_or_scope)
return session[:shopfront_redirect] if session[:shopfront_redirect]
stored_location_for(resource_or_scope) || signed_in_root_path(resource_or_scope)
end
def after_sign_out_path_for(_resource_or_scope)
session[:shopfront_redirect] ? session[:shopfront_redirect] : root_path
end
private
def restrict_iframes
response.headers['X-Frame-Options'] = 'DENY'
response.headers['Content-Security-Policy'] = "frame-ancestors 'none'"
end
def enable_embedded_shopfront
whitelist = Spree::Config[:embedded_shopfronts_whitelist]
return unless Spree::Config[:enable_embedded_shopfronts] && whitelist.present?
return if request.referer && URI(request.referer).scheme != 'https' && !Rails.env.test?
response.headers.delete 'X-Frame-Options'
response.headers['Content-Security-Policy'] = "frame-ancestors #{whitelist}"
check_embedded_request
set_embedded_layout
end
def check_embedded_request
return unless params[:embedded_shopfront]
# Show embedded shopfront CSS
session[:embedded_shopfront] = true
# Get shopfront slug and set redirect path
if params[:controller] == 'enterprises' && params[:action] == 'shop' && params[:id]
slug = params[:id]
session[:shopfront_redirect] = '/' + slug + '/shop?embedded_shopfront=true'
end
end
def set_embedded_layout
return unless session[:embedded_shopfront]
@shopfront_layout = 'embedded'
end
def action
params[:action].to_sym
end
def require_distributor_chosen
unless @distributor = current_distributor
redirect_to spree.root_path
@@ -62,7 +125,6 @@ class ApplicationController < ActionController::Base
end
end
# All render calls within the block will be performed with the specified format
# Useful for rendering html within a JSON response, particularly if the specified
# template or partial then goes on to render further partials without specifying

View File

@@ -8,6 +8,7 @@ class BaseController < ApplicationController
include Spree::Core::ControllerHelpers::Order
include Spree::Core::ControllerHelpers::RespondWith
include I18nHelper
include EnterprisesHelper
include OrderCyclesHelper
@@ -17,14 +18,19 @@ class BaseController < ApplicationController
# include Spree::ProductsHelper so that method is available on the controller
include Spree::ProductsHelper
before_filter :set_locale
before_filter :check_order_cycle_expiry
private
def set_order_cycles
unless @distributor.ready_for_checkout?
@order_cycles = OrderCycle.where('false')
return
end
@order_cycles = OrderCycle.with_distributor(@distributor).active
.order(@distributor.preferred_shopfront_order_cycle_order)
.order(@distributor.preferred_shopfront_order_cycle_order)
applicator = OpenFoodNetwork::TagRuleApplicator.new(@distributor, "FilterOrderCycles", current_customer.andand.tag_list)
applicator.filter!(@order_cycles)

View File

@@ -9,6 +9,7 @@ class CheckoutController < Spree::CheckoutController
prepend_before_filter :require_distributor_chosen
skip_before_filter :check_registration
before_filter :enable_embedded_shopfront
include OrderCyclesHelper
include EnterprisesHelper
@@ -88,7 +89,7 @@ class CheckoutController < Spree::CheckoutController
def check_order_for_phantom_fees
phantom_fees = @order.adjustments.joins('LEFT OUTER JOIN spree_line_items ON spree_line_items.id = spree_adjustments.source_id').
where("originator_type = 'EnterpriseFee' AND source_type = 'Spree::LineItem' AND spree_line_items.id IS NULL")
where("originator_type = 'EnterpriseFee' AND source_type = 'Spree::LineItem' AND spree_line_items.id IS NULL")
if phantom_fees.any?
Bugsnag.notify(RuntimeError.new("Phantom Fees"), {
@@ -123,7 +124,6 @@ class CheckoutController < Spree::CheckoutController
false
end
def update_failed
clear_ship_address
respond_to do |format|
@@ -168,8 +168,8 @@ class CheckoutController < Spree::CheckoutController
customer_preferred_bill_address, customer_preferred_ship_address = @order.customer.bill_address, @order.customer.ship_address if @order.customer
@order.bill_address ||= customer_preferred_bill_address ||= preferred_bill_address || last_used_bill_address || Spree::Address.default
@order.ship_address ||= customer_preferred_ship_address ||= preferred_ship_address || last_used_ship_address || Spree::Address.default
@order.bill_address ||= customer_preferred_bill_address || preferred_bill_address || last_used_bill_address || Spree::Address.default
@order.ship_address ||= customer_preferred_ship_address || preferred_ship_address || last_used_ship_address || Spree::Address.default
end
def after_payment

View File

@@ -30,7 +30,6 @@ class DiscourseSsoController < ApplicationController
def sso_url
secret = discourse_sso_secret!
discourse_url = discourse_url!
sso = Discourse::SingleSignOn.parse(request.query_string, secret)
sso.email = spree_current_user.email
sso.username = spree_current_user.login

View File

@@ -10,6 +10,7 @@ class EnterprisesController < BaseController
before_filter :check_stock_levels, only: :shop
before_filter :clean_permalink, only: :check_permalink
before_filter :enable_embedded_shopfront
respond_to :js, only: :permalink_checker

View File

@@ -1,6 +1,8 @@
class HomeController < BaseController
layout 'darkswarm'
before_filter :enable_embedded_shopfront
def index
if ContentConfig.home_show_stats
@num_distributors = Enterprise.is_distributor.activated.visible.count

View File

@@ -0,0 +1,48 @@
class LineItemsController < BaseController
respond_to :json
before_filter :load_line_item, only: :destroy
def bought
respond_with bought_items, each_serializer: Api::LineItemSerializer
end
def destroy
authorize! :destroy, @line_item
destroy_with_lock @line_item
respond_with(@line_item)
end
private
def load_line_item
@line_item = Spree::LineItem.find_by_id(params[:id])
not_found unless @line_item
end
# List all items the user already ordered in the current order cycle
def bought_items
return [] unless current_order_cycle && spree_current_user && current_distributor
current_order_cycle.items_bought_by_user(spree_current_user, current_distributor)
end
def unauthorized
status = spree_current_user ? 403 : 401
render nothing: true, status: status and return
end
def not_found
render nothing: true, status: 404 and return
end
def destroy_with_lock(item)
order = item.order
order.with_lock do
item.destroy
order.update_shipping_fees!
order.update_payment_fees!
order.update_distribution_charge!
order.create_tax_charge!
end
end
end

View File

@@ -1,6 +1,8 @@
class ProducersController < BaseController
layout 'darkswarm'
before_filter :enable_embedded_shopfront
def index
end
end

View File

@@ -2,8 +2,8 @@ require 'open_food_network/cached_products_renderer'
class ShopController < BaseController
layout "darkswarm"
before_filter :require_distributor_chosen
before_filter :set_order_cycles
before_filter :require_distributor_chosen, :set_order_cycles, except: :changeable_orders_alert
before_filter :enable_embedded_shopfront
def show
redirect_to main_app.enterprise_shop_path(current_distributor)
@@ -37,6 +37,10 @@ class ShopController < BaseController
end
end
def changeable_orders_alert
render layout: false
end
private
def filtered_json(products_json)

View File

@@ -1,6 +1,8 @@
class ShopsController < BaseController
layout 'darkswarm'
before_filter :enable_embedded_shopfront
def index
end
end

View File

@@ -23,12 +23,11 @@ module Spree
@tax_rate_id = tr_yielding_matching_tax || tr_valid_for_order
if tr_yielding_matching_tax.nil?
@adjustment.errors.add :tax_rate_id, "^Please check that the tax rate for this adjustment is correct."
@adjustment.errors.add :tax_rate_id, I18n.t(:adjustments_tax_rate_error)
end
end
end
def set_included_tax
if params[:tax_rate_id].present?
tax_rate = TaxRate.find params[:tax_rate_id]

View File

@@ -1,6 +1,9 @@
require 'spree/core/controller_helpers/respond_with_decorator'
Spree::Admin::BaseController.class_eval do
include I18nHelper
before_filter :set_locale
before_filter :warn_invalid_order_cycles
# Warn the user when they have an active order cycle with hubs that are not ready
@@ -51,13 +54,9 @@ Spree::Admin::BaseController.class_eval do
distributor_names = distributors.map(&:name).join ', '
if distributors.count > 1
"The hubs #{distributor_names} are listed in an active order cycle, " +
"but do not have valid shipping and payment methods. " +
"Until you set these up, customers will not be able to shop at these hubs."
I18n.t(:active_distributors_not_ready_for_checkout_message_plural, distributor_names: distributor_names)
else
"The hub #{distributor_names} is listed in an active order cycle, " +
"but does not have valid shipping and payment methods. " +
"Until you set these up, customers will not be able to shop at this hub."
I18n.t(:active_distributors_not_ready_for_checkout_message_singular, distributor_names: distributor_names)
end
end

View File

@@ -12,6 +12,9 @@ Spree::Admin::OrdersController.class_eval do
before_filter :load_distribution_choices, only: [:new, :edit, :update]
# Ensure that the distributor is set for an order when
before_filter :ensure_distribution, only: :new
# After updating an order, the fees should be updated as well
# Currently, adding or deleting line items does not trigger updating the
# fees! This is a quick fix for that.
@@ -109,9 +112,9 @@ Spree::Admin::OrdersController.class_eval do
# Replaced this search to filter orders to only show those distributed by current user (or all for admin user)
@search.result.includes([:user, :shipments, :payments]).
distributed_by_user(spree_current_user).
page(params[:page]).
per(params[:per_page] || Spree::Config[:orders_per_page])
distributed_by_user(spree_current_user).
page(params[:page]).
per(params[:per_page] || Spree::Config[:orders_per_page])
end
end
@@ -131,4 +134,16 @@ Spree::Admin::OrdersController.class_eval do
ocs.closed +
ocs.undated
end
def ensure_distribution
unless @order
@order = Spree::Order.new
@order.generate_order_number
@order.save!
end
unless @order.distribution_set?
render 'set_distribution', locals: { order: @order }
end
end
end

Some files were not shown because too many files have changed in this diff Show More