...
  View open merge request
Commits (5)
......@@ -15,19 +15,24 @@ class LanguageSkill < ApplicationRecord
where.not(id: native_language.id)
}
def self.languages
@languages ||= I18n.t('language_names').merge(I18n.t('language_names_customizations'))
.map { |key, lang| [lang, key.to_s] }.sort
end
def self.native_language
native_languages.first || LanguageSkill.new
end
def self.language_name(language)
return '' if language.blank?
I18n.t("language_names.#{language}")
class << self
def languages
@languages ||= I18n.t('language_names').merge(I18n.t('language_names_customizations'))
.map { |key, lang| [lang, key.to_s] }.sort
end
def native_language
native_languages.first || LanguageSkill.new
end
def language_name(language)
return '' if language.blank?
I18n.t("language_names.#{language}")
end
def native_and_human_readable
german_first.map(&:full_language_skills)
end
end
def language_name
......@@ -37,5 +42,5 @@ class LanguageSkill < ApplicationRecord
def full_language_skills
level_human = level? ? I18n.t(level, scope: [:language_level]) : ''
[language_name, level_human].reject(&:blank?).join(', ') if language?
end
end
end
......@@ -24,8 +24,8 @@ tr id=dom_id(client)
br
td= nationality_name(client.nationality)
td.language-skill-index
- [client.language_skills.german, client.language_skills.native_languages].flatten.each do |language|
span= language.full_language_skills
- client.language_skills.native_and_human_readable.each do |language_readable|
span= language_readable
td= client.goals
td= client.interests
- if policy(Client).superadmin_privileges?
......
......@@ -25,8 +25,11 @@ cell_types = [
:string, # 13
:string, # 14
:string, # 15
:time, # 16
:time # 17
:string, # 16
:string, # 17
:string, # 18
:time, # 19
:time # 20
]
cell_styles = [
......@@ -46,8 +49,11 @@ cell_styles = [
standard_format, # 13
standard_format, # 14
standard_format, # 15
date_time_format, # 16
date_time_format # 17
standard_format, # 16
standard_format, # 17
standard_format, # 18
date_time_format, # 19
date_time_format # 20
]
wb.add_worksheet(name: t('clients_xlsx')) do |sheet|
......@@ -68,10 +74,14 @@ wb.add_worksheet(name: t('clients_xlsx')) do |sheet|
t_attr(:education), # 13
t_attr(:entry_date), # 14
t_attr(:acceptance), # 15
t_attr(:created_at), # 16
t_attr(:updated_at) # 17
t_attr(:involved_authority), # 16
t_attr(:language_skills), # 17
t_attr(:goals), # 18
t_attr(:created_at), # 19
t_attr(:updated_at) # 20
]
sheet.add_row header_row, type: :string, style: col_header
clients.each do |client|
salutation = t("salutation.#{client.salutation}") if client.salutation?
......@@ -93,8 +103,11 @@ wb.add_worksheet(name: t('clients_xlsx')) do |sheet|
client.education, # 13
client.entry_date, # 14
t("acceptance.#{client.acceptance}"), # 15
client.created_at.in_time_zone, # 16
client.updated_at.in_time_zone # 17
client.involved_authority, # 16
client.language_skills.native_and_human_readable.join("\r"), # 17
client.goals, # 18
client.created_at.in_time_zone, # 19
client.updated_at.in_time_zone # 20
]
sheet.add_row body_row, types: cell_types, style: cell_styles
end
......
......@@ -3,7 +3,7 @@ require 'selenium/webdriver'
Capybara.register_driver :chrome_headless do |app|
chrome_options = {
chromeOptions: { args: %w[headless disable-gpu no-sandbox window-size=1600x2000] }
chromeOptions: { args: %w[headless disable-gpu no-sandbox window-size=1600x2000], w3c: false }
}
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(chrome_options)
Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities)
......
......@@ -17,17 +17,17 @@ class ClientsXlsxExportTest < ActionDispatch::IntegrationTest
assert_xls_cols_equal(wb, 1, 0, 'id', 'Anrede', 'Nachname', 'Vorname', 'Strasse',
'Adresszusatz', 'PLZ', 'Ort', 'Telefonnummer', 'Telefonnummer 2', 'Mailadresse',
'Jahrgang', 'Nationalität', 'Beruf oder Ausbildung im Herkunftsland',
'Einreisedatum', 'Prozess', 'Erstellt am', 'Aktualisiert am')
'Einreisedatum', 'Prozess', 'Fallführende Stelle', 'Sprachkenntnisse', 'Inhalte der Begleitung', 'Erstellt am', 'Aktualisiert am')
assert_equal client.id.to_s, wb.cell(2, 1).to_s
assert_xls_cols_equal(wb, 2, 1, I18n.t("salutation.#{client.salutation}"),
client.contact.last_name, client.contact.first_name, client.contact.street,
client.contact.extended, client.contact.postal_code, client.contact.city,
client.contact.primary_phone, client.contact.secondary_phone, client.contact.primary_email,
client.birth_year&.year, nationality_name(client.nationality), client.education,
client.entry_date, I18n.t(".acceptance.#{client.acceptance}"))
assert_equal 2.days.ago.to_date, wb.cell(2, 17).to_date
assert_equal 2.days.ago.to_date, wb.cell(2, 18).to_date
client.entry_date, I18n.t(".acceptance.#{client.acceptance}"), client.involved_authority, '', client.goals)
assert_equal 2.days.ago.to_date, wb.cell(2, 20).to_date
assert_equal 2.days.ago.to_date, wb.cell(2, 21).to_date
end
test 'clients xls export is not paginated' do
......
......@@ -203,7 +203,7 @@ class ClientsTest < ApplicationSystemTestCase
create :client, language_skills: [
create(:language_skill, language: 'DE', level: 'good'),
create(:language_skill, language: 'IT', level: 'native_speaker'),
create(:language_skill, language: 'FR', level: 'fluent')
create(:language_skill, language: 'FR', level: 'good')
]
login_as @superadmin
visit clients_path
......