Adjust filter for platform_admin user search and update views
This commit is contained in:

committed by
Sebastian Serth

parent
02c65af034
commit
998a12e6bc
@ -66,7 +66,7 @@ class User < ApplicationRecord
|
|||||||
|
|
||||||
def self.ransackable_attributes(auth_object)
|
def self.ransackable_attributes(auth_object)
|
||||||
if auth_object.admin?
|
if auth_object.admin?
|
||||||
%w[name email external_id consumer_id role]
|
%w[name email external_id consumer_id platform_admin]
|
||||||
else
|
else
|
||||||
%w[name external_id]
|
%w[name external_id]
|
||||||
end
|
end
|
||||||
|
@ -15,8 +15,7 @@ h1 = ExternalUser.model_name.human(count: 2)
|
|||||||
= f.search_field(:external_id_cont, class: 'form-control', placeholder: t('activerecord.attributes.external_user.external_id'))
|
= f.search_field(:external_id_cont, class: 'form-control', placeholder: t('activerecord.attributes.external_user.external_id'))
|
||||||
.row
|
.row
|
||||||
.col-auto
|
.col-auto
|
||||||
= f.label(:role_eq, t('activerecord.attributes.external_user.role'), class: 'visually-hidden form-label')
|
= f.select :platform_admin_true, [[t('shared.admin_filter.only'), 1], [t('shared.admin_filter.none'), 0]], { include_blank: t('shared.admin_filter.all'), selected: params[:q] ? params[:q][:platform_admin_true] : '' }
|
||||||
= f.select(:role_eq, User::ROLES.map { |role| [t("users.roles.#{role}"), role] }, { include_blank: true }, class: 'form-control', prompt: t('activerecord.attributes.external_user.role'))
|
|
||||||
.col-auto.mt-3.mt-lg-0
|
.col-auto.mt-3.mt-lg-0
|
||||||
= f.label(:consumer_id_eq, t('activerecord.attributes.external_user.consumer'), class: 'visually-hidden form-label')
|
= f.label(:consumer_id_eq, t('activerecord.attributes.external_user.consumer'), class: 'visually-hidden form-label')
|
||||||
= f.collection_select(:consumer_id_eq, Consumer.with_external_users, :id, :name, class: 'form-control', include_blank: true, prompt: t('activerecord.attributes.external_user.consumer') )
|
= f.collection_select(:consumer_id_eq, Consumer.with_external_users, :id, :name, class: 'form-control', include_blank: true, prompt: t('activerecord.attributes.external_user.consumer') )
|
||||||
|
@ -6,7 +6,7 @@ h1 = @user.displayname
|
|||||||
code
|
code
|
||||||
= @user.external_id
|
= @user.external_id
|
||||||
= row(label: 'external_user.consumer', value: link_to_if(policy(@user.consumer).show?, @user.consumer, @user.consumer))
|
= row(label: 'external_user.consumer', value: link_to_if(policy(@user.consumer).show?, @user.consumer, @user.consumer))
|
||||||
= row(label: 'external_user.role', value: t("users.roles.#{@user.role}"))
|
= row(label: 'external_user.platform_admin', value: @user.platform_admin?)
|
||||||
|
|
||||||
h4.mt-4 = link_to(t('.exercise_statistics'), statistics_external_user_path(@user)) if policy(@user).statistics?
|
h4.mt-4 = link_to(t('.exercise_statistics'), statistics_external_user_path(@user)) if policy(@user).statistics?
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
.mb-3
|
.mb-3
|
||||||
= f.label(:name, class: 'form-label')
|
= f.label(:name, class: 'form-label')
|
||||||
= f.text_field(:name, class: 'form-control', required: true)
|
= f.text_field(:name, class: 'form-control', required: true)
|
||||||
.mb-3
|
.form-check
|
||||||
= f.label(:role, class: 'form-label')
|
label.form-check-label
|
||||||
= f.select(:role, User::ROLES.map { |role| [t("users.roles.#{role}"), role] }, {selected: @user.role || 'teacher'}, class: 'form-control')
|
= f.check_box(:platform_admin, class: 'form-check-input')
|
||||||
|
= f.label(:platform_admin, t('activerecord.attributes.external_user.platform_admin'), class: 'form-label')
|
||||||
.actions = render('shared/submit_button', f: f, object: @user)
|
.actions = render('shared/submit_button', f: f, object: @user)
|
||||||
|
@ -8,23 +8,21 @@ h1 = InternalUser.model_name.human(count: 2)
|
|||||||
= f.label(:email_cont, t('activerecord.attributes.internal_user.email'), class: 'visually-hidden form-label')
|
= f.label(:email_cont, t('activerecord.attributes.internal_user.email'), class: 'visually-hidden form-label')
|
||||||
= f.search_field(:email_cont, class: 'form-control', placeholder: t('activerecord.attributes.internal_user.email'))
|
= f.search_field(:email_cont, class: 'form-control', placeholder: t('activerecord.attributes.internal_user.email'))
|
||||||
.col-auto
|
.col-auto
|
||||||
= f.label(:role_eq, t('activerecord.attributes.internal_user.role'), class: 'visually-hidden form-label')
|
= f.select :platform_admin_true, [[t('shared.admin_filter.only'), 1], [t('shared.admin_filter.none'), 0]], { include_blank: t('shared.admin_filter.all'), selected: params[:q] ? params[:q][:platform_admin_true] : '' }
|
||||||
= f.select(:role_eq, User::ROLES.map { |role| [t("users.roles.#{role}"), role] }, {}, class: 'form-control', prompt: t('activerecord.attributes.internal_user.role'))
|
|
||||||
|
|
||||||
.table-responsive
|
.table-responsive
|
||||||
table.table.mt-4
|
table.table.mt-4
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
th = t('activerecord.attributes.internal_user.name')
|
th = t('activerecord.attributes.internal_user.name')
|
||||||
th = t('activerecord.attributes.internal_user.consumer')
|
th = t('activerecord.attributes.internal_user.consumer')
|
||||||
th = t('activerecord.attributes.internal_user.role')
|
th = t('activerecord.attributes.internal_user.platform_admin')
|
||||||
th colspan=3 = t('shared.actions')
|
th colspan=3 = t('shared.actions')
|
||||||
tbody
|
tbody
|
||||||
- @users.each do |user|
|
- @users.each do |user|
|
||||||
tr
|
tr
|
||||||
td = link_to_if(policy(user).show?, user.name, user)
|
td = link_to_if(policy(user).show?, user.name, user)
|
||||||
td = user.consumer ? link_to_if(policy(user.consumer).show?, user.consumer, user.consumer) : empty
|
td = user.consumer ? link_to_if(policy(user.consumer).show?, user.consumer, user.consumer) : empty
|
||||||
td = t("users.roles.#{user.role}")
|
td = symbol_for(user.platform_admin?)
|
||||||
td = link_to(t('shared.show'), user) if policy(user).show?
|
td = link_to(t('shared.show'), user) if policy(user).show?
|
||||||
td = link_to(t('shared.edit'), edit_internal_user_path(user)) if policy(user).edit?
|
td = link_to(t('shared.edit'), edit_internal_user_path(user)) if policy(user).edit?
|
||||||
td = link_to(t('shared.destroy'), user, data: {confirm: t('shared.confirm_destroy')}, method: :delete) if policy(user).destroy?
|
td = link_to(t('shared.destroy'), user, data: {confirm: t('shared.confirm_destroy')}, method: :delete) if policy(user).destroy?
|
||||||
|
@ -5,7 +5,7 @@ h1
|
|||||||
= row(label: 'internal_user.email', value: @user.email)
|
= row(label: 'internal_user.email', value: @user.email)
|
||||||
= row(label: 'internal_user.name', value: @user.name)
|
= row(label: 'internal_user.name', value: @user.name)
|
||||||
= row(label: 'internal_user.consumer', value: @user.consumer ? link_to_if(policy(@user.consumer).show?, @user.consumer, @user.consumer) : nil)
|
= row(label: 'internal_user.consumer', value: @user.consumer ? link_to_if(policy(@user.consumer).show?, @user.consumer, @user.consumer) : nil)
|
||||||
= row(label: 'internal_user.role', value: t("users.roles.#{@user.role}"))
|
= row(label: 'internal_user.platform_admin', value: @user.platform_admin?)
|
||||||
= row(label: 'internal_user.activated', value: @user.activated?)
|
= row(label: 'internal_user.activated', value: @user.activated?)
|
||||||
|
|
||||||
= row(label: 'codeharbor_link.profile_label', value: @user.codeharbor_link.nil? ? link_to(t('codeharbor_link.new'), new_codeharbor_link_path, class: 'btn btn-secondary') : link_to(t('codeharbor_link.edit'), edit_codeharbor_link_path(@user.codeharbor_link), class: 'btn btn-secondary'))
|
= row(label: 'codeharbor_link.profile_label', value: @user.codeharbor_link.nil? ? link_to(t('codeharbor_link.new'), new_codeharbor_link_path, class: 'btn btn-secondary') : link_to(t('codeharbor_link.edit'), edit_codeharbor_link_path(@user.codeharbor_link), class: 'btn btn-secondary'))
|
||||||
|
@ -58,7 +58,7 @@ de:
|
|||||||
email: E-Mail
|
email: E-Mail
|
||||||
external_id: Externe ID
|
external_id: Externe ID
|
||||||
name: Name
|
name: Name
|
||||||
role: Rolle
|
platform_admin: Platform Admin
|
||||||
file:
|
file:
|
||||||
content: Inhalt
|
content: Inhalt
|
||||||
feedback_message: Feedback-Nachricht
|
feedback_message: Feedback-Nachricht
|
||||||
@ -95,7 +95,7 @@ de:
|
|||||||
name: Name
|
name: Name
|
||||||
password: Passwort
|
password: Passwort
|
||||||
password_confirmation: Passwort-Bestätigung
|
password_confirmation: Passwort-Bestätigung
|
||||||
role: Rolle
|
platform_admin: Platform Admin
|
||||||
request_for_comments:
|
request_for_comments:
|
||||||
comments: Kommentare
|
comments: Kommentare
|
||||||
exercise: Aufgabe
|
exercise: Aufgabe
|
||||||
@ -843,6 +843,10 @@ de:
|
|||||||
new: Hinzufügen
|
new: Hinzufügen
|
||||||
new_model: '%{model} hinzufügen'
|
new_model: '%{model} hinzufügen'
|
||||||
number: Nummer
|
number: Nummer
|
||||||
|
admin_filter:
|
||||||
|
only: Plattform-Administratoren
|
||||||
|
none: Reguläre Nutzer:innen
|
||||||
|
all: Alle Nutzer:innen
|
||||||
object_cloned: '%{model} wurde erfolgreich dupliziert.'
|
object_cloned: '%{model} wurde erfolgreich dupliziert.'
|
||||||
object_created: '%{model} wurde erfolgreich erstellt.'
|
object_created: '%{model} wurde erfolgreich erstellt.'
|
||||||
object_destroyed: '%{model} wurde erfolgreich gelöscht.'
|
object_destroyed: '%{model} wurde erfolgreich gelöscht.'
|
||||||
@ -877,10 +881,7 @@ de:
|
|||||||
percentage: Prozentzahl
|
percentage: Prozentzahl
|
||||||
siblings: Dazugehörige Abgaben
|
siblings: Dazugehörige Abgaben
|
||||||
users:
|
users:
|
||||||
roles:
|
platform_admin: Plattform Administrator
|
||||||
admin: Administrator
|
|
||||||
learner: Lernender
|
|
||||||
teacher: Lehrer
|
|
||||||
will_paginate:
|
will_paginate:
|
||||||
next_label: 'Nächste Seite →'
|
next_label: 'Nächste Seite →'
|
||||||
page_gap: '…'
|
page_gap: '…'
|
||||||
|
@ -58,7 +58,7 @@ en:
|
|||||||
email: Email
|
email: Email
|
||||||
external_id: External ID
|
external_id: External ID
|
||||||
name: Name
|
name: Name
|
||||||
role: Role
|
platform_admin: Platform Admin
|
||||||
file:
|
file:
|
||||||
content: Content
|
content: Content
|
||||||
feedback_message: Feedback Message
|
feedback_message: Feedback Message
|
||||||
@ -95,7 +95,7 @@ en:
|
|||||||
name: Name
|
name: Name
|
||||||
password: Password
|
password: Password
|
||||||
password_confirmation: Passwort Confirmation
|
password_confirmation: Passwort Confirmation
|
||||||
role: Role
|
platform_admin: Platform Admin
|
||||||
request_for_comments:
|
request_for_comments:
|
||||||
comments: Comments
|
comments: Comments
|
||||||
exercise: Exercise
|
exercise: Exercise
|
||||||
@ -843,6 +843,10 @@ en:
|
|||||||
new: Add
|
new: Add
|
||||||
new_model: 'Add %{model}'
|
new_model: 'Add %{model}'
|
||||||
number: Number
|
number: Number
|
||||||
|
admin_filter:
|
||||||
|
only: Platform admins
|
||||||
|
none: Regular users
|
||||||
|
all: All users
|
||||||
object_cloned: '%{model} has successfully been duplicated.'
|
object_cloned: '%{model} has successfully been duplicated.'
|
||||||
object_created: '%{model} has successfully been created.'
|
object_created: '%{model} has successfully been created.'
|
||||||
object_destroyed: '%{model} has successfully been deleted.'
|
object_destroyed: '%{model} has successfully been deleted.'
|
||||||
@ -877,10 +881,7 @@ en:
|
|||||||
percentage: Percentage
|
percentage: Percentage
|
||||||
siblings: Associated Submissions
|
siblings: Associated Submissions
|
||||||
users:
|
users:
|
||||||
roles:
|
platform_admin: Platform Admin
|
||||||
admin: Administrator
|
|
||||||
learner: Learner
|
|
||||||
teacher: Teacher
|
|
||||||
will_paginate:
|
will_paginate:
|
||||||
next_label: 'Next Page →'
|
next_label: 'Next Page →'
|
||||||
page_gap: '…'
|
page_gap: '…'
|
||||||
|
Reference in New Issue
Block a user