mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Convert admin/registrations datatable to AJAX-backed
Supercedes https://github.com/openSUSE/osem/pull/2031 . Note: * "Questions" modals have been dropped from this view; questions are no longer asked on registration, since Surveys(PR#1100) were added.
This commit is contained in:
parent
eea05d649c
commit
d7a0936dd7
4 changed files with 167 additions and 63 deletions
56
app/datatables/registration_datatable.rb
Normal file
56
app/datatables/registration_datatable.rb
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RegistrationDatatable < AjaxDatatablesRails::Base
|
||||
def_delegator :@view, :edit_admin_conference_registration_path
|
||||
|
||||
def view_columns
|
||||
@view_columns ||= {
|
||||
id: { source: 'Registration.id', cond: :eq },
|
||||
name: { source: 'User.name' },
|
||||
roles: { source: 'Role.name' },
|
||||
email: { source: 'User.email' },
|
||||
accepted_code_of_conduct: { source: 'Registration.accepted_code_of_conduct', searchable: false },
|
||||
arrival: { source: 'Registration.arrival', searchable: false },
|
||||
departure: { source: 'Registration.departure', searchable: false },
|
||||
actions: { source: 'Registration.id', searchable: false, orderable: false }
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def conference
|
||||
@conference ||= options[:conference]
|
||||
end
|
||||
|
||||
def conference_role_titles(record)
|
||||
record.roles.collect do |role|
|
||||
role.name.titleize if role.resource == conference
|
||||
end.compact
|
||||
end
|
||||
|
||||
def data
|
||||
records.map do |record|
|
||||
{
|
||||
id: record.id,
|
||||
name: record.user.name,
|
||||
roles: conference_role_titles(record.user),
|
||||
email: record.email,
|
||||
accepted_code_of_conduct: !!record.accepted_code_of_conduct, # rubocop:disable Style/DoubleNegation
|
||||
arrival: record.arrival&.utc,
|
||||
departure: record.departure&.utc,
|
||||
questions: {},
|
||||
edit_url: edit_admin_conference_registration_path(conference, record),
|
||||
DT_RowId: record.id
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def get_raw_records # rubocop:disable Naming/AccessorMethodName
|
||||
conference.registrations.includes(user: :roles).references(:users, :roles).distinct
|
||||
end
|
||||
|
||||
# override upstream santitation, which converts everything to strings
|
||||
def sanitize(records)
|
||||
records
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue