summaryrefslogtreecommitdiff
path: root/app/views/users
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-31 15:55:43 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-31 15:55:43 +0200
commit464dd4266bdc433805010b5dca428f4cb75c2a81 (patch)
tree47fdf4f065960d49da015eafdf56cb817dcf9ea4 /app/views/users
parent5f17f421b176d48ef556fb379f59bbb7d284b48e (diff)
Group user accounts by role
Replaces the two-way admin/user split with four groups ordered by capability: administration, Redaktion, editors, alumni. alumni takes precedence over capability in role_group, so a retired admin appears at the bottom rather than the top. Forms now offer the three roles as checkboxes rather than a single admin checkbox, with a trailing hidden blank so an empty set can be posted, and user_params permits roles only for admins. Three create buttons prefill the common combinations.
Diffstat (limited to 'app/views/users')
-rw-r--r--app/views/users/_user.html.erb13
-rw-r--r--app/views/users/edit.html.erb14
-rw-r--r--app/views/users/index.html.erb55
-rw-r--r--app/views/users/new.html.erb14
-rw-r--r--app/views/users/show.html.erb6
5 files changed, 67 insertions, 35 deletions
diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb
index 9c6466a2..04884be8 100644
--- a/app/views/users/_user.html.erb
+++ b/app/views/users/_user.html.erb
@@ -1,11 +1,16 @@
1<% users.each do |user| %> 1<% users.each do |user| %>
2<tr> 2<tr>
3 <td class="user_login"><%= user.login %></td> 3 <td class="user_login"><%= user.login %></td>
4 <td><%= link_to "show", user_path(user) %></td> 4 <td class="user_roles">
5 <% if current_user.admin? || current_user == user %> 5 <% if user.roles.any? %>
6 <td> 6 <%= user.role_labels.join(", ") %>
7 <%= link_to "edit", edit_user_path(user) %> 7 <% else %>
8 <span class="field_hint"><%= t(".no_roles") %></span>
9 <% end %>
8 </td> 10 </td>
11 <td><%= link_to t("admin.common.show"), user_path(user) %></td>
12 <% if current_user.admin? || current_user == user %>
13 <td><%= link_to t("admin.common.edit"), edit_user_path(user) %></td>
9 <td> 14 <td>
10 <%= button_to user_path(user), method: :delete, 15 <%= button_to user_path(user), method: :delete,
11 form: { data: { confirm: t(".confirm_destroy", :login => user.login) }, class: 'button_to destructive' } do %> 16 form: { data: { confirm: t(".confirm_destroy", :login => user.login) }, class: 'button_to destructive' } do %>
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
index 9df93815..ad2e0891 100644
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -21,8 +21,18 @@
21 <div class="layout_row_content"><%= f.password_field :password_confirmation, :autocomplete => "new-password" %></div> 21 <div class="layout_row_content"><%= f.password_field :password_confirmation, :autocomplete => "new-password" %></div>
22 22
23 <% if current_user.admin? %> 23 <% if current_user.admin? %>
24 <div class="layout_row_label"><%= t("users.labels.admin") %></div> 24 <div class="layout_row_label"><%= t("users.labels.roles") %></div>
25 <div class="layout_row_content"><%= f.check_box :admin %></div> 25 <div class="layout_row_content">
26 <% User::ROLES.each do |role| %>
27 <label class="role_choice">
28 <%= check_box_tag "user[roles][]", role, @user.roles.include?(role),
29 :id => "user_roles_#{role}" %>
30 <%= t("users.roles.#{role}") %>
31 <span class="field_hint"><%= t("users.role_hints.#{role}") %></span>
32 </label>
33 <% end %>
34 <%= hidden_field_tag "user[roles][]", "" %>
35 </div>
26 <% end %> 36 <% end %>
27 37
28 <div class="layout_row_label"></div> 38 <div class="layout_row_label"></div>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
index 0a003cb1..854811a2 100644
--- a/app/views/users/index.html.erb
+++ b/app/views/users/index.html.erb
@@ -1,27 +1,32 @@
1<h1><%= t(".admins") %></h1> 1<h1><%= t(".title") %></h1>
2<%= link_to new_user_path(admin: true), class: 'action_button' do %> 2
3 <%= icon("plus", library: "tabler", "aria-hidden": true) %> <%= t(".create_admin") %> 3<p class="button_row">
4<% end %> 4 <% UsersController::ROLE_PRESETS.each_key do |preset| %>
5<table class="user_table"> 5 <%= link_to new_user_path(:preset => preset), class: 'action_button' do %>
6 <tr class="header"> 6 <%= icon("plus", library: "tabler", "aria-hidden": true) %>
7 <th><%= t("users.labels.login") %></th> 7 <%= t(".create_#{preset}") %>
8 <th></th> 8 <% end %>
9 <th></th> 9 <% end %>
10 <th></th> 10</p>
11 </tr>
12 <%= render :partial => "user", :locals => {:users => @users[:admin] ||= []} %>
13</table>
14 11
15<h1><%= t(".users") %></h1> 12<% UsersController::GROUP_ORDER.each do |group| %>
16<%= link_to new_user_path, class: 'action_button' do %> 13 <% members = @users[group] || [] %>
17 <%= icon("plus", library: "tabler", "aria-hidden": true) %> <%= t(".create_user") %> 14 <h2 class="user_group_heading <%= "user_group_alumni" if group == :alumni %>">
15 <%= t(".group_#{group}") %>
16 <span class="dashboard_widget_meta"><%= members.size %></span>
17 </h2>
18 <% if members.any? %>
19 <table class="user_table <%= "user_table_alumni" if group == :alumni %>">
20 <tr class="header">
21 <th><%= t("users.labels.login") %></th>
22 <th><%= t("users.labels.roles") %></th>
23 <th></th>
24 <th></th>
25 <th></th>
26 </tr>
27 <%= render :partial => "user", :locals => { :users => members } %>
28 </table>
29 <% else %>
30 <p class="field_hint"><%= t(".group_empty") %></p>
31 <% end %>
18<% end %> 32<% end %>
19<table class="user_table">
20 <tr class="header">
21 <th><%= t("users.labels.login") %></th>
22 <th></th>
23 <th></th>
24 <th></th>
25 </tr>
26 <%= render :partial => "user", :locals => {:users => @users[:user] ||= []} %>
27</table>
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
index 776e6e96..8d99fd92 100644
--- a/app/views/users/new.html.erb
+++ b/app/views/users/new.html.erb
@@ -21,8 +21,18 @@
21 <div class="layout_row_label"><%= t("users.labels.confirm") %></div> 21 <div class="layout_row_label"><%= t("users.labels.confirm") %></div>
22 <div class="layout_row_content"><%= f.password_field :password_confirmation %></div> 22 <div class="layout_row_content"><%= f.password_field :password_confirmation %></div>
23 23
24 <div class="layout_row_label"><%= t("users.labels.admin") %></div> 24 <div class="layout_row_label"><%= t("users.labels.roles") %></div>
25 <div class="layout_row_content"><%= f.check_box :admin %></div> 25 <div class="layout_row_content">
26 <% User::ROLES.each do |role| %>
27 <label class="role_choice">
28 <%= check_box_tag "user[roles][]", role, @user.roles.include?(role),
29 :id => "user_roles_#{role}" %>
30 <%= t("users.roles.#{role}") %>
31 <span class="field_hint"><%= t("users.role_hints.#{role}") %></span>
32 </label>
33 <% end %>
34 <%= hidden_field_tag "user[roles][]", "" %>
35 </div>
26 36
27 <div class="layout_row_label"></div> 37 <div class="layout_row_label"></div>
28 <div class="layout_row_content"><%= f.submit t("admin.common.create") %></div> 38 <div class="layout_row_content"><%= f.submit t("admin.common.create") %></div>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index 44976800..a320e53e 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -19,7 +19,9 @@
19 <div class="layout_row_label"><%= t("users.labels.email") %></div> 19 <div class="layout_row_label"><%= t("users.labels.email") %></div>
20 <div class="layout_row_content"><%= @user.email %></div> 20 <div class="layout_row_content"><%= @user.email %></div>
21 21
22 <div class="layout_row_label"><%= t("users.labels.admin") %></div> 22 <div class="layout_row_label"><%= t("users.labels.roles") %></div>
23 <div class="layout_row_content"><%= @user.admin ? t("admin.common.yes") : t("admin.common.no") %></div> 23 <div class="layout_row_content">
24 <%= @user.roles.any? ? @user.role_labels.join(", ") : t("users.no_roles") %>
25 </div>
24 </div> 26 </div>
25</div> 27</div>