mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
[bug] after disabling a group, its associated plans are hidden from the interface
+ validate server-side that there's no more user in the group to disable
This commit is contained in:
parent
668eb43959
commit
de1cc2013a
@ -3,6 +3,7 @@
|
||||
- Ability to configure and export the accounting data to the ACD accounting software
|
||||
- Compute the VAT per item in each invoices, instead of globally
|
||||
- Fix a bug: invoices with total = 0, are marked as paid on site even if paid by card
|
||||
- Fix a bug: after disabling a group, its associated plans are hidden from the interface
|
||||
- Fix a bug: in case of unexpected server error during stripe payment process, the confirm button is not unlocked
|
||||
- [TODO DEPLOY] `rake db:migrate`
|
||||
|
||||
|
@ -36,8 +36,7 @@
|
||||
<tbody>
|
||||
<tr ng-repeat="plan in plans | filterDisabled:planFiltering | orderBy:orderPlans"
|
||||
ng-class="{'disabled-line' : plan.disabled && planFiltering === 'all'}"
|
||||
ng-init="group = getGroupFromId(groups, plan.group_id)"
|
||||
ng-hide="group.disabled">
|
||||
ng-init="group = getGroupFromId(groups, plan.group_id)">
|
||||
<td>{{getPlanType(plan.type)}}</td>
|
||||
<td>{{plan.base_name}}</td>
|
||||
<td>{{ plan.interval | planIntervalFilter:plan.interval_count }}</td>
|
||||
@ -47,4 +46,4 @@
|
||||
<td><button type="button" class="btn btn-default" ui-sref="app.admin.plans.edit({id:plan.id})"><i class="fa fa-pencil-square-o"></i></button> <button type="button" class="btn btn-danger" ng-click="deletePlan(plans, plan.id)"><i class="fa fa-trash"></i></button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
@ -1,3 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Group is way to bind users with prices. Different prices can be defined for each plan/reservable, for each group
|
||||
class Group < ActiveRecord::Base
|
||||
has_many :plans
|
||||
has_many :users
|
||||
@ -12,15 +15,21 @@ class Group < ActiveRecord::Base
|
||||
friendly_id :name, use: :slugged
|
||||
|
||||
validates :name, :slug, presence: true
|
||||
validates :disabled, inclusion: { in: [false] }, if: :group_has_users?
|
||||
|
||||
after_create :create_prices
|
||||
after_create :create_statistic_subtype
|
||||
after_update :update_statistic_subtype, if: :name_changed?
|
||||
after_update :disable_plans, if: :disabled_changed?
|
||||
|
||||
def destroyable?
|
||||
users.empty? and plans.empty?
|
||||
end
|
||||
|
||||
def group_has_users?
|
||||
users.count.positive?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_prices
|
||||
@ -60,4 +69,10 @@ class Group < ActiveRecord::Base
|
||||
subtype.label = name
|
||||
subtype.save!
|
||||
end
|
||||
|
||||
def disable_plans
|
||||
plans.each do |plan|
|
||||
plan.update_attributes(disabled: disabled)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -53,13 +53,13 @@ class Plan < ActiveRecord::Base
|
||||
|
||||
def create_machines_prices
|
||||
Machine.all.each do |machine|
|
||||
Price.create(priceable: machine, plan: self, group_id: self.group_id, amount: 0)
|
||||
Price.create(priceable: machine, plan: self, group_id: group_id, amount: 0)
|
||||
end
|
||||
end
|
||||
|
||||
def create_spaces_prices
|
||||
Space.all.each do |space|
|
||||
Price.create(priceable: space, plan: self, group_id: self.group_id, amount: 0)
|
||||
Price.create(priceable: space, plan: self, group_id: group_id, amount: 0)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user