Skip to content

Commit 7967c94

Browse files
authored
manual vote refill (#1200)
1 parent 052947f commit 7967c94

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

app/controllers/admin/users_controller.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ def show
4141
@flipper_flags = Flipper.features
4242
end
4343

44+
def refill
45+
@vote_queue = @user.user_vote_queue || @user.build_user_vote_queue.tap(&:save!)
46+
47+
begin
48+
count = @vote_queue.refill_queue!(params[:count].to_i)
49+
flash[:success] = "refilled w/ #{count} votes"
50+
redirect_to admin_user_path(@user)
51+
rescue => e
52+
redirect_to admin_user_path, notice: e.message
53+
end
54+
end
55+
4456
def internal_notes
4557
@user.internal_notes = params[:internal_notes]
4658
@user.create_activity("edit_internal_notes", params: { note: params[:internal_notes] })

app/views/admin/users/show.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,11 @@
558558
<div class="agrid">
559559
<%= button_to "🥸 impersonate?", impersonate_admin_user_path(@user), class: 'abtn secondary' %>
560560

561+
<%= form_with url: refill_admin_user_path(@user) do |f| %>
562+
<%= f.number_field :count, placeholder: "count", value: 5, style: "padding: 0.5em; border-radius: 6px; border: 1px solid var(--color-border); background: var(--color-darker); color: var(--color-text);" %>
563+
<%= f.submit "refill votes", class: 'abtn primary' %>
564+
<% end %>
565+
561566
<% if @user.freeze_shop_activity? %>
562567
<%= button_to "defrost (allow shop activity again)", defrost_admin_user_path(@user), class: 'abtn primary' %>
563568
<% else %>

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ def self.matches?(request)
469469
post :grant_fraud_reviewer
470470
post :revoke_fraud_reviewer
471471
post :flip
472+
post :refill
472473
end
473474
end
474475
resources :projects, only: [ :show ] do

0 commit comments

Comments
 (0)