Skip to content

Commit 4b5a0f5

Browse files
authored
Add user credit warning for sofia_account provider (#1167)
* add user credit warning for sofia_account provider * also send insuficent credit mail * check against arrays
1 parent 9c9155a commit 4b5a0f5

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

app/controllers/orders_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def allowed_filters
8080
def send_insufficient_credit_mail?(user, old_credit)
8181
return false if user.nil?
8282

83-
user.provider == 'amber_oauth2' && user.credit.negative? && old_credit.positive?
83+
user.provider.in?(%w[amber_oauth2 sofia_account]) && user.credit.negative? && old_credit.positive?
8484
end
8585

8686
def permitted_attributes

app/models/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def minor
7171
end
7272

7373
def insufficient_credit
74-
provider == 'amber_oauth2' and credit.negative?
74+
provider.in?(%w[amber_oauth2 sofia_account]) && credit.negative?
7575
end
7676

7777
def can_order(activity = nil)

app/views/users/show.html.erb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,11 @@
152152
</div>
153153
<p class="card-text d-none d-md-block">
154154
<%= 'Rechten zijn afhankelijk van de rollen die een gebruiker in het streepsysteem heeft. ' %>
155-
<%= 'Rollen worden bepaald aan de hand van de groepen waar een gebruiker lid van is in de Alpha website.' %>
156-
155+
<% if Rails.application.config.x.amber_api_url.present? %>
156+
<%= 'Rollen worden bepaald aan de hand van de groepen waar een gebruiker lid van is in de gekoppelde website.' %>
157+
<% else %>
158+
<%= 'Rollen kunnen geconfigureerd worden via de console van de serviceprovider.' %>
159+
<% end %>
157160
</p>
158161
<% if @user.roles_users.any? %>
159162
<ul class="mb-1">
-7.42 KB
Binary file not shown.

0 commit comments

Comments
 (0)