diff --git a/src/TODO.md b/src/TODO.md index 8d3ab10..81c9889 100644 --- a/src/TODO.md +++ b/src/TODO.md @@ -1,5 +1,4 @@ # TODO - - Reputation management (Admin panel) - Auction posting (single image) - Auction views ---------------- diff --git a/src/app.rb b/src/app.rb index c53a288..9bc1a4b 100755 --- a/src/app.rb +++ b/src/app.rb @@ -331,6 +331,21 @@ post "/admin/users/setmoney" do redirect back 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 def role_check(id) no_go_away if ROLE_IDS.include? id diff --git a/src/views/admin/users/edit.slim b/src/views/admin/users/edit.slim index cd440fe..4e43b00 100644 --- a/src/views/admin/users/edit.slim +++ b/src/views/admin/users/edit.slim @@ -74,3 +74,14 @@ input type="number" name="money" value="#{user.balance}" min="0" 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"