Skip to content

Commit 9c9155a

Browse files
authored
Remove the user sync button and related code (#1168)
1 parent 8599e24 commit 9c9155a

4 files changed

Lines changed: 0 additions & 31 deletions

File tree

app/controllers/users_controller.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,6 @@ def update
9797
redirect_to @user
9898
end
9999

100-
def refresh_user_list
101-
authorize User
102-
103-
users_json.each do |user_json|
104-
find_or_create_user(user_json)
105-
end
106-
107-
users_not_in_json = User.active.in_amber.where.not(uid: users_json.pluck('id')).where.not(name: 'Streepsysteem Flux')
108-
users_not_in_json.each(&:archive!)
109-
110-
redirect_to users_path
111-
end
112-
113100
def search
114101
authorize User
115102

@@ -165,11 +152,6 @@ def update_with_sofia_account # rubocop:disable Metrics/AbcSize, Metrics/MethodL
165152

166153
private
167154

168-
def users_json
169-
JSON.parse(RestClient.get("#{Rails.application.config.x.amber_api_url}/api/v1/users?filter[group]=Leden",
170-
'Authorization' => "Bearer #{api_token}"))['data']
171-
end
172-
173155
def find_or_create_user(user_json) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
174156
fields = user_json['attributes']
175157
u = User.find_or_initialize_by(uid: user_json['id'])

app/policies/user_policy.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ def index?
33
user&.treasurer? || user&.renting_manager? || user&.main_bartender?
44
end
55

6-
def refresh_user_list?
7-
user&.treasurer?
8-
end
9-
106
def search?
117
index?
128
end

app/views/users/index.html.erb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@
2727
<% if Rails.application.config.x.amber_api_host.present? %>
2828
<div class="d-flex justify-content-between align-items-center">
2929
<h3><%= Rails.application.config.x.site_association %> gebruikers</h3>
30-
<% if policy(User).refresh_user_list? %>
31-
<span>
32-
<%= link_to refresh_user_list_users_path, class: 'btn btn-primary btn-sm me-1' do %>
33-
<i class="fas fa-arrows-rotate"></i>
34-
<span class="d-none d-md-inline ms-1">Synchroniseer gebruikers</span>
35-
<% end %>
36-
</span>
37-
<% end %>
3830
</div>
3931
<users-table :users="amber_users" class="mb-5"></users-table>
4032
<% end %>

config/routes.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
resources :users, only: %i[index show create update] do
2323
collection do
24-
get :refresh_user_list
2524
post :search
2625
end
2726
member do

0 commit comments

Comments
 (0)