Reputation management

master
E. Almqvist 3 years ago
parent ed18ca2384
commit 9b241f5027
  1. 1
      src/TODO.md
  2. 15
      src/app.rb
  3. 11
      src/views/admin/users/edit.slim

@ -1,5 +1,4 @@
# TODO # TODO
- Reputation management (Admin panel)
- Auction posting (single image) - Auction posting (single image)
- Auction views - Auction views
---------------- ----------------

@ -331,6 +331,21 @@ post "/admin/users/setmoney" do
redirect back redirect back
end end
post "/admin/users/setreputation" do
user = get_current_user
auth_denied unless user.admin?
id = params[:user_id].to_i
reputation = params[:reputation].to_f
target = User.find_by_id(id)
target.reputation = reputation
flash[:success] = "Set users reputation to '#{reputation}'."
redirect back
end
# ADMIN ROLE MANAGEMENT # ADMIN ROLE MANAGEMENT
def role_check(id) def role_check(id)
no_go_away if ROLE_IDS.include? id no_go_away if ROLE_IDS.include? id

@ -74,3 +74,14 @@
input type="number" name="money" value="#{user.balance}" min="0" input type="number" name="money" value="#{user.balance}" min="0"
input type="submit" value="Set money" input type="submit" value="Set money"
article.card.border
h2 Set reputation
.form-container
form action="/admin/users/setreputation" method="post"
label Amount
input type="hidden" name="user_id" value="#{user.id}"
input type="number" name="reputation" value="#{user.reputation}" min="#{MIN_REP}" max="#{MAX_REP}"
input type="submit" value="Set reputation"

Loading…
Cancel
Save