From 1a79ffba18f5d3bdf418e354644fb40e475614c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Benavente?= Date: Sat, 9 Mar 2024 17:58:29 -0300 Subject: [PATCH] Allow moderators to edit other users' profiles Progress towards #61 --- app/controllers/users_controller.rb | 3 ++- app/views/users/show.haml | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 563b738b..31bed0e9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3,7 +3,8 @@ class UsersController < ApplicationController include RankingsHelper before_action :authenticate_user!, :except => [:show, :stats] - before_action :authenticate_admin, :except => [:show, :stats, :update_locale] + before_action :authenticate_admin, :except => [:show, :stats, :update_locale, :edit] + before_action :authenticate_mod, :only => [:edit] def members @users = User.all diff --git a/app/views/users/show.haml b/app/views/users/show.haml index 36f093f7..446e2d1f 100644 --- a/app/views/users/show.haml +++ b/app/views/users/show.haml @@ -70,7 +70,7 @@ %a#general-tab.nav-link.active{"aria-controls" => "general", "aria-selected" => "true", "data-toggle" => "tab", href: "#general", role: "tab"}= t("users.tabs.title") %li.nav-item %a#stats-tab.nav-link{"aria-controls" => "stats", "aria-selected" => "false", "data-toggle" => "tab", href: "#stats", role: "tab"}= t("users.tabs.stats") - - if user_is_admin? + - if user_is_mod? %li.nav-item %a#admin-tab.nav-link{"aria-controls" => "admin", "aria-selected" => "false", "data-toggle" => "tab", href: "#admin", role: "tab"}= t("users.tabs.admin") .tab-content @@ -230,7 +230,7 @@ = number_to_percentage(@user.stats.participation_rate * 100, :precision => 1) %small = t("users.stats.overall-stats.participation") - - if user_is_admin? + - if user_is_mod? #admin.tab-pane.fade{:"aria-labelledby" => "admin-tab", :role => "tabpanel"} = form_for(@user, html: { method: :put }) do |f| = f.fields_for :profile do |profile|