forked from External/greenlight
GRN2-xx: Switch the relation between users and roles to make queries cleaner and faster (#1299)
* First steps * Fixes in account creation flow * Fixed most testcases * more test fixes * Fixed more test cases * Passing tests and rubocop * Added rake task to remove rooms
This commit is contained in:
@ -14,7 +14,7 @@
|
||||
%>
|
||||
|
||||
<div class="list-group list-group-transparent mb-0">
|
||||
<% highest_role = current_user.highest_priority_role %>
|
||||
<% highest_role = current_user.role %>
|
||||
<% highest_role.name %>
|
||||
<% if highest_role.get_permission("can_manage_users") || highest_role.name == "super_admin" %>
|
||||
<%= link_to admins_path, class: "list-group-item list-group-item-action dropdown-item #{"active" if active_page == "index"}" do %>
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<% current_role = current_user.highest_priority_role%>
|
||||
<% current_role = current_user.role%>
|
||||
<div class="col-lg-3 mb-4">
|
||||
<div class="list-group list-group-transparent mb-0">
|
||||
<div id="rolesSelect" data-url="<%= admin_roles_order_path %>">
|
||||
|
@ -13,21 +13,6 @@
|
||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
%>
|
||||
|
||||
<%
|
||||
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
|
||||
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
|
||||
# This program is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free Software
|
||||
# Foundation; either version 3.0 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
# You should have received a copy of the GNU Lesser General Public License along
|
||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
%>
|
||||
|
||||
<% if @role.nil? %>
|
||||
<%= render "admins/components/manage_users_tags" %>
|
||||
<% else %>
|
||||
@ -89,11 +74,10 @@
|
||||
<td class="user-email"><%= user.email && user.email != "" ? user.email : user.username%></td>
|
||||
<td><%= user.provider %></td>
|
||||
<td class="text-center">
|
||||
<% roles = user.roles().pluck(:name) %>
|
||||
<%= render "admins/components/admins_role", role: user.highest_priority_role %>
|
||||
<%= render "admins/components/admins_role", role: user.role %>
|
||||
</td>
|
||||
<td>
|
||||
<% if !roles.include?("super_admin") %>
|
||||
<% if !user.has_role?("super_admin") %>
|
||||
<div class="item-action dropdown">
|
||||
<a href="javascript:void(0)" data-toggle="dropdown" class="icon">
|
||||
<i class="fas fa-ellipsis-v px-4"></i>
|
||||
@ -106,14 +90,14 @@
|
||||
<button class="delete-user dropdown-item" data-path="<%= delete_user_path(user_uid: user.uid, permanent: "true") %>" data-toggle="modal" data-target="#deleteAccountModal">
|
||||
<i class="dropdown-icon fas fa-skull-crossbones"></i> <%= t("administrator.users.settings.perm_delete") %>
|
||||
</button>
|
||||
<% elsif roles.include?("denied") %>
|
||||
<% elsif user.has_role?("denied") %>
|
||||
<%= button_to admin_unban_path(user_uid: user.uid), class: "dropdown-item", "data-disable": "" do %>
|
||||
<i class="dropdown-icon fas fa-lock-open"></i> <%= t("administrator.users.settings.unban") %>
|
||||
<% end %>
|
||||
<button class= "delete-user dropdown-item" data-path="<%= delete_user_path(user_uid: user.uid) %>" data-delete="temp-delete" data-toggle="modal" data-target="#deleteAccountModal">
|
||||
<i class="dropdown-icon fas fa-user-minus"></i> <%= t("administrator.users.settings.delete") %>
|
||||
</button>
|
||||
<% elsif roles.include?("pending") %>
|
||||
<% elsif user.has_role?("pending") %>
|
||||
<%= button_to admin_approve_path(user_uid: user.uid), class: "dropdown-item", "data-disable": "" do %>
|
||||
<i class="dropdown-icon far fa-check-circle"></i> <%= t("administrator.users.settings.approve") %>
|
||||
<% end %>
|
||||
|
@ -38,7 +38,7 @@
|
||||
<i class="fas fa-home pr-1 "></i><span class="d-none d-sm-inline-block"><%= t("header.dropdown.home") %></span>
|
||||
<% end %>
|
||||
|
||||
<% if current_user.highest_priority_role.get_permission("can_create_rooms") %>
|
||||
<% if current_user.role.get_permission("can_create_rooms") %>
|
||||
<% all_rec_page = params[:controller] == "users" && params[:action] == "recordings" ? "active" : "" %>
|
||||
<%= link_to get_user_recordings_path(current_user), class: "px-3 mx-1 mt-1 header-nav #{all_rec_page}" do %>
|
||||
<i class="fas fa-video pr-1"></i><span class="d-none d-sm-inline-block"><%= t("header.all_recordings") %></span>
|
||||
@ -62,7 +62,7 @@
|
||||
<%= link_to edit_user_path(current_user), class: "dropdown-item" do %>
|
||||
<i class="dropdown-icon fas fa-id-card mr-3"></i><%= t("header.dropdown.settings") %>
|
||||
<% end %>
|
||||
<% highest_role = current_user.highest_priority_role %>
|
||||
<% highest_role = current_user.role %>
|
||||
<% if highest_role.get_permission("can_manage_users") || highest_role.name == "super_admin" %>
|
||||
<%= link_to admins_path, class: "dropdown-item" do %>
|
||||
<i class="dropdown-icon fas fa-user-tie mr-3"></i><%= t("header.dropdown.account_settings") %>
|
||||
|
@ -13,7 +13,7 @@
|
||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
%>
|
||||
|
||||
<%= form_for @user, url: update_user_path, method: :patch do |f| %>
|
||||
<%= form_for @user, url: update_user_path, method: :post do |f| %>
|
||||
<%= hidden_field_tag :setting, "account" %>
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
@ -38,28 +38,21 @@
|
||||
<%= f.label t("settings.account.language"), class: "form-label" %>
|
||||
<%= f.select :language, language_options, {}, { class: "form-control custom-select" } %>
|
||||
|
||||
<% current_user_role = current_user.highest_priority_role %>
|
||||
<br>
|
||||
<br>
|
||||
<%= f.label t("settings.account.roles"), class: "form-label" %>
|
||||
<div id="role-tag-container" class="tags mb-1">
|
||||
<% @user.roles.by_priority.each do |role| %>
|
||||
<span id="<%= "user-role-tag_#{role.id}" %>" style="<%= "background-color: #{role_colour(role)};border-color: #{role_colour(role)};" %>" class="tag user-role-tag">
|
||||
<%= translated_role_name(role) %>
|
||||
<% if (current_user_role.get_permission("can_manage_users") || current_user_role.name == "super_admin") && (role.priority > current_user_role.priority || current_user_role.name == "admin") %>
|
||||
<a data-role-id="<%= role.id %>" class="tag-addon clear-role">
|
||||
<i data-role-id="<%= role.id %>" class="fas fa-times"></i>
|
||||
</a>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if current_user_role.get_permission("can_manage_users") || current_user_role.name == "super_admin" %>
|
||||
<% provider = Rails.configuration.loadbalanced_configuration ? current_user.provider : "greenlight" %>
|
||||
<%= f.select :roles, Role.editable_roles(@user_domain).map{|role| [translated_role_name(role), role.id, {'data-colour' => role_colour(role)}]}.unshift(["", nil, {'data-colour' => nil}]), {disabled: disabled_roles(@user)}, { class: "form-control custom-select", id: "role-select-dropdown" } %>
|
||||
<% end %>
|
||||
<%= f.hidden_field :role_ids, id: "user_role_ids", value: @user.roles.by_priority.pluck(:id).uniq %>
|
||||
<%= f.label t("settings.account.roles"), class: "form-label mt-5" %>
|
||||
|
||||
<% if current_user.role.get_permission("can_manage_users") %>
|
||||
<select id="role-dropdown" class="selectpicker show-tick" >
|
||||
<% role_options.each do |role| %>
|
||||
<option value="<%=role.id%>"><%= translated_role_name(role) %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
|
||||
<%= f.hidden_field :role_id, id: "user_role_id", value: @user.role.id %>
|
||||
<% else %>
|
||||
<span style="<%= "background-color: #{role_colour(@user.role)};border-color: #{role_colour(@user.role)};" %>" class="tag custom-role-tag">
|
||||
<%= translated_role_name(@user.role) %>
|
||||
</span>
|
||||
<% end %>
|
||||
<%= f.label t("settings.account.image"), class: "form-label mt-5" %>
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
|
Reference in New Issue
Block a user