Skip to content

Commit

Permalink
Merge branch 'dev' for release 2.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainbx committed Jan 22, 2019
2 parents 82adca5 + 8e3b387 commit c73f942
Show file tree
Hide file tree
Showing 182 changed files with 15,124 additions and 18,150 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
# XLSX exports
/exports/*

# Archives of cLosed accounting periods
/accounting/*

.DS_Store

Expand Down
10 changes: 8 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
Metrics/LineLength:
Max: 125
Max: 130
Metrics/MethodLength:
Max: 30
Metrics/CyclomaticComplexity:
Max: 9
Metrics/PerceivedComplexity:
Max: 9
Metrics/AbcSize:
Max: 42
Max: 45
Metrics/ClassLength:
Max: 200
Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent
Style/RegexpLiteral:
EnforcedStyle: slashes
Style/EmptyElse:
EnforcedStyle: empty
Style/ClassAndModuleChildren:
EnforcedStyle: compact
Style/AndOr:
EnforcedStyle: conditionals
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog Fab Manager

## v2.8.2 2019 January 22

- Removed ability to disable invoicing for an user
- Fixed a missing translation in plan form
- Fix a bug: error handling on password recovery
- Fix a bug: error handling on machine attachment upload
- Fix a bug: first day of week is ignored in statistics custom filter
- Fix a bug: rails DSB locale is invalid
- Fix a bug: unable to delete an admin who has changed a setting
- Fix a bug: unable to create/edit a plan of 12 months or 52 weeks
- Fix a bug: Unable to search in user autocomplete fields
- Fix a bug: Invalid translation in new partner modal
- Improved user autocompletion when using multiple words
- Refactored frontend invoices translations
- Updated RailRoady 1.4.0 to 1.5.3
- [TODO DEPLOY] `bundle install`

## v2.8.1 2019 January 02

- Fix ES upgrade: when docker-compose file is using ${PWD}, the ES config volume is attached to the wrong container
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ GEM
rack
rack-test (0.6.3)
rack (>= 1.0)
railroady (1.4.0)
railroady (1.5.3)
rails (4.2.11)
actionmailer (= 4.2.11)
actionpack (= 4.2.11)
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,14 @@ This procedure is not easy to follow so if you don't need to write some code for
- **Please note**: Your password length must be between 8 and 128 characters, otherwise db:seed will be rejected. This is configured in [config/initializers/devise.rb](config/initializers/devise.rb)

```bash
# for dev
rake db:create
rake db:migrate
ADMIN_EMAIL='youradminemail' ADMIN_PASSWORD='youradminpassword' rake db:seed
rake fablab:es_build_stats
# for tests
RAILS_ENV=test rake db:create
RAILS_ENV=test rake db:migrate
```

14. Create the pids folder used by Sidekiq. If you want to use a different location, you can configure it in `config/sidekiq.yml`
Expand Down Expand Up @@ -252,6 +256,9 @@ environment.
rake db:migrate
ADMIN_EMAIL='youradminemail' ADMIN_PASSWORD='youradminpassword' rake db:seed
rake fablab:es_build_stats
# for tests
RAILS_ENV=test rake db:create
RAILS_ENV=test rake db:migrate
```

11. Start the application and visit `localhost:3000` on your browser to check that it works:
Expand Down
74 changes: 39 additions & 35 deletions app/assets/javascripts/controllers/admin/invoices.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
* @param invoice {Object} invoice inherited from angular's $resource
*/
$scope.generateAvoirForInvoice = function (invoice) {
// open modal
// open modal
const modalInstance = $uibModal.open({
templateUrl: '<%= asset_path "admin/invoices/avoirModal.html" %>',
controller: 'AvoirModalController',
Expand All @@ -119,7 +119,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
$scope.invoices.unshift(res.avoir);
return Invoice.get({ id: invoice.id }, function (data) {
invoice.has_avoir = data.has_avoir;
return growl.success(_t('refund_invoice_successfully_created'));
return growl.success(_t('invoices.refund_invoice_successfully_created'));
});
});
};
Expand Down Expand Up @@ -193,10 +193,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
modalInstance.result.then(function (model) {
Setting.update({ name: 'invoice_reference' }, { value: model }, function (data) {
$scope.invoice.reference.model = model;
growl.success(_t('invoice_reference_successfully_saved'));
growl.success(_t('invoices.invoice_reference_successfully_saved'));
}
, function (error) {
growl.error(_t('an_error_occurred_while_saving_invoice_reference'));
growl.error(_t('invoices.an_error_occurred_while_saving_invoice_reference'));
console.error(error);
});
});
Expand Down Expand Up @@ -231,24 +231,24 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
Setting.update({ name: 'invoice_code-value' }, { value: result.model }, function (data) {
$scope.invoice.code.model = result.model;
if (result.active) {
return growl.success(_t('invoicing_code_succesfully_saved'));
return growl.success(_t('invoices.invoicing_code_succesfully_saved'));
}
}
, function (error) {
growl.error(_t('an_error_occurred_while_saving_the_invoicing_code'));
growl.error(_t('invoices.an_error_occurred_while_saving_the_invoicing_code'));
return console.error(error);
});

return Setting.update({ name: 'invoice_code-active' }, { value: result.active ? 'true' : 'false' }, function (data) {
$scope.invoice.code.active = result.active;
if (result.active) {
return growl.success(_t('code_successfully_activated'));
return growl.success(_t('invoices.code_successfully_activated'));
} else {
return growl.success(_t('code_successfully_disabled'));
return growl.success(_t('invoices.code_successfully_disabled'));
}
}
, function (error) {
growl.error(_t('an_error_occurred_while_activating_the_invoicing_code'));
growl.error(_t('invoices.an_error_occurred_while_activating_the_invoicing_code'));
return console.error(error);
});
});
Expand Down Expand Up @@ -277,10 +277,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
return modalInstance.result.then(function (model) {
Setting.update({ name: 'invoice_order-nb' }, { value: model }, function (data) {
$scope.invoice.number.model = model;
return growl.success(_t('order_number_successfully_saved'));
return growl.success(_t('invoices.order_number_successfully_saved'));
}
, function (error) {
growl.error(_t('an_error_occurred_while_saving_the_order_number'));
growl.error(_t('invoices.an_error_occurred_while_saving_the_order_number'));
return console.error(error);
});
});
Expand All @@ -301,11 +301,15 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
},
active () {
return $scope.invoice.VAT.active;
},
history () {
return Setting.get({ name: 'invoice_VAT-rate', history: true }).$promise;
}
},
controller: ['$scope', '$uibModalInstance', 'rate', 'active', function ($scope, $uibModalInstance, rate, active) {
controller: ['$scope', '$uibModalInstance', 'rate', 'active', 'history', function ($scope, $uibModalInstance, rate, active, history) {
$scope.rate = rate;
$scope.isSelected = active;
$scope.history = history.setting.history;

$scope.ok = function () { $uibModalInstance.close({ rate: $scope.rate, active: $scope.isSelected }); };
return $scope.cancel = function () { $uibModalInstance.dismiss('cancel'); };
Expand All @@ -316,24 +320,24 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
Setting.update({ name: 'invoice_VAT-rate' }, { value: result.rate + '' }, function (data) {
$scope.invoice.VAT.rate = result.rate;
if (result.active) {
return growl.success(_t('VAT_rate_successfully_saved'));
return growl.success(_t('invoices.VAT_rate_successfully_saved'));
}
}
, function (error) {
growl.error(_t('an_error_occurred_while_saving_the_VAT_rate'));
growl.error(_t('invoices.an_error_occurred_while_saving_the_VAT_rate'));
return console.error(error);
});

return Setting.update({ name: 'invoice_VAT-active' }, { value: result.active ? 'true' : 'false' }, function (data) {
$scope.invoice.VAT.active = result.active;
if (result.active) {
return growl.success(_t('VAT_successfully_activated'));
return growl.success(_t('invoices.VAT_successfully_activated'));
} else {
return growl.success(_t('VAT_successfully_disabled'));
return growl.success(_t('invoices.VAT_successfully_disabled'));
}
}
, function (error) {
growl.error(_t('an_error_occurred_while_activating_the_VAT'));
growl.error(_t('invoices.an_error_occurred_while_activating_the_VAT'));
return console.error(error);
});
});
Expand All @@ -346,10 +350,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
const parsed = parseHtml($scope.invoice.text.content);
return Setting.update({ name: 'invoice_text' }, { value: parsed }, function (data) {
$scope.invoice.text.content = parsed;
return growl.success(_t('text_successfully_saved'));
return growl.success(_t('invoices.text_successfully_saved'));
}
, function (error) {
growl.error(_t('an_error_occurred_while_saving_the_text'));
growl.error(_t('invoices.an_error_occurred_while_saving_the_text'));
return console.error(error);
});
};
Expand All @@ -361,10 +365,10 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
const parsed = parseHtml($scope.invoice.legals.content);
return Setting.update({ name: 'invoice_legals' }, { value: parsed }, function (data) {
$scope.invoice.legals.content = parsed;
return growl.success(_t('address_and_legal_information_successfully_saved'));
return growl.success(_t('invoices.address_and_legal_information_successfully_saved'));
}
, function (error) {
growl.error(_t('an_error_occurred_while_saving_the_address_and_the_legal_information'));
growl.error(_t('invoices.an_error_occurred_while_saving_the_address_and_the_legal_information'));
return console.error(error);
});
};
Expand Down Expand Up @@ -418,9 +422,9 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
return Setting.update(
{ name: 'invoice_logo' },
{ value: $scope.invoice.logo.base64 },
function (data) { growl.success(_t('logo_successfully_saved')); },
function (data) { growl.success(_t('invoices.logo_successfully_saved')); },
function (error) {
growl.error(_t('an_error_occurred_while_saving_the_logo'));
growl.error(_t('invoices.an_error_occurred_while_saving_the_logo'));
return console.error(error);
}
);
Expand Down Expand Up @@ -498,7 +502,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
*/
Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModalInstance', 'invoice', 'Invoice', 'growl', '_t',
function ($scope, $uibModalInstance, invoice, Invoice, growl, _t) {
/* PUBLIC SCOPE */
/* PUBLIC SCOPE */

// invoice linked to the current refund
$scope.invoice = invoice;
Expand All @@ -515,11 +519,11 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal

// Possible refunding methods
$scope.avoirModes = [
{ name: _t('none'), value: 'none' },
{ name: _t('by_cash'), value: 'cash' },
{ name: _t('by_cheque'), value: 'cheque' },
{ name: _t('by_transfer'), value: 'transfer' },
{ name: _t('by_wallet'), value: 'wallet' }
{ name: _t('invoices.none'), value: 'none' },
{ name: _t('invoices.by_cash'), value: 'cash' },
{ name: _t('invoices.by_cheque'), value: 'cheque' },
{ name: _t('invoices.by_transfer'), value: 'transfer' },
{ name: _t('invoices.by_wallet'), value: 'wallet' }
];

// If a subscription was took with the current invoice, should it be canceled or not
Expand All @@ -542,36 +546,36 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal
$scope.openDatePicker = function ($event) {
$event.preventDefault();
$event.stopPropagation();
return $scope.datePicker.opened = true;
$scope.datePicker.opened = true;
};

/**
* Validate the refunding and generate a refund invoice
*/
$scope.ok = function () {
// check that at least 1 element of the invoice is refunded
// check that at least 1 element of the invoice is refunded
$scope.avoir.invoice_items_ids = [];
for (let itemId in $scope.partial) {
const refundItem = $scope.partial[itemId];
if (refundItem) { $scope.avoir.invoice_items_ids.push(parseInt(itemId)); }
}

if ($scope.avoir.invoice_items_ids.length === 0) {
return growl.error(_t('you_must_select_at_least_one_element_to_create_a_refund'));
return growl.error(_t('invoices.you_must_select_at_least_one_element_to_create_a_refund'));
} else {
return Invoice.save(
{ avoir: $scope.avoir },
function (avoir) { // success
$uibModalInstance.close({ avoir, invoice: $scope.invoice });
},
function (err) { // failed
growl.error(_t('unable_to_create_the_refund'));
growl.error(_t('invoices.unable_to_create_the_refund'));
}
);
}
};

/**q
/**
* Cancel the refund, dismiss the modal window
*/
$scope.cancel = function () { $uibModalInstance.dismiss('cancel'); };
Expand All @@ -592,7 +596,7 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal
});

if (invoice.stripe) {
return $scope.avoirModes.push({ name: _t('online_payment'), value: 'stripe' });
return $scope.avoirModes.push({ name: _t('invoices.online_payment'), value: 'stripe' });
}
};

Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/controllers/admin/statistics.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ Application.Controllers.controller('StatisticsController', ['$scope', '$state',
minDate: null,
maxDate: moment().toDate(),
options: {
startingDay: 1
startingDay: Fablab.weekStartingDay
}
} // France: the week starts on monday
}
};

// available custom filters
Expand Down
10 changes: 5 additions & 5 deletions app/assets/javascripts/controllers/application.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco
$scope.user.organization = orga;
// display errors
angular.forEach(error.data.errors, function (v, k) {
angular.forEach(function (v, err) {
angular.forEach(v, function (err) {
$scope.alerts.push({
msg: k + ': ' + err,
type: 'danger'
Expand Down Expand Up @@ -175,9 +175,9 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco

return $scope.changePassword = function () {
$scope.alerts = [];
return $http.put('/users/password.json', { user: $scope.user }).success(function () { $uibModalInstance.close(); }).error(function (data) {
angular.forEach(data.errors, function (v, k) {
angular.forEach(function (v, err) {
return $http.put('/users/password.json', { user: $scope.user }).then(function () { $uibModalInstance.close(); }).catch(function (data) {
angular.forEach(data.data.errors, function (v, k) {
angular.forEach(v, function (err) {
$scope.alerts.push({
msg: k + ': ' + err,
type: 'danger'
Expand Down Expand Up @@ -400,7 +400,7 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco
$scope.user = { email: '' };
return $scope.sendReset = function () {
$scope.alerts = [];
return $http.post('/users/password.json', { user: $scope.user }).success(function () { $uibModalInstance.close(); }).error(function () {
return $http.post('/users/password.json', { user: $scope.user }).then(function () { $uibModalInstance.close(); }).catch(function () {
$scope.alerts.push({
msg: _t('your_email_address_is_unknown'),
type: 'danger'
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/controllers/machines.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MachinesController {
if ((content.id == null)) {
$scope.alerts = [];
angular.forEach(content, function (v, k) {
angular.forEach(function (v, err) {
angular.forEach(v, function (err) {
$scope.alerts.push({
msg: k + ': ' + err,
type: 'danger'
Expand Down
7 changes: 6 additions & 1 deletion app/assets/stylesheets/modules/invoice.scss
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,9 @@
border-radius: 5px;
font-size: small;
}
}
}

.no-user-label {
font-style: italic;
color: #5a5a5a;
}
Loading

0 comments on commit c73f942

Please sign in to comment.