Customize welcome text from room and OU
This commit is contained in:
@@ -26,7 +26,7 @@ El saludo usa `Bienvenido/ubicado` para `Male` y `Bienvenida/ubicada` para
|
|||||||
neutral `Te damos la bienvenida` y `Ubicación:`. El texto secundario sigue estas
|
neutral `Te damos la bienvenida` y `Ubicación:`. El texto secundario sigue estas
|
||||||
reglas:
|
reglas:
|
||||||
|
|
||||||
1. Con `location` y OU: `Estás ubicado en la Sala de Inmersión del Centro de Experiencia Digital.`
|
1. Con `location` y OU: `Acceso al Aula Flexible del Centro de Experiencia Digital.`
|
||||||
2. Con sólo uno de los datos: muestra únicamente el dato disponible.
|
2. Con sólo uno de los datos: muestra únicamente el dato disponible.
|
||||||
3. Sin ambos: el texto adaptado `Bienvenido/Bienvenida al Laboratorio...`; sin
|
3. Sin ambos: el texto adaptado `Bienvenido/Bienvenida al Laboratorio...`; sin
|
||||||
sexo disponible, la forma neutral `Acceso al Laboratorio de Cómputo de Ingeniería.`
|
sexo disponible, la forma neutral `Acceso al Laboratorio de Cómputo de Ingeniería.`
|
||||||
|
|||||||
@@ -170,10 +170,10 @@ function Get-DirectoryWelcomeMetadata {
|
|||||||
function Get-SpanishArticle {
|
function Get-SpanishArticle {
|
||||||
param([Parameter(Mandatory)][string]$Value)
|
param([Parameter(Mandatory)][string]$Value)
|
||||||
|
|
||||||
if ($Value -match '^(Sala|Aula|Facultad|Unidad|Biblioteca|Oficina|Coordinaci.n)\b') {
|
if ($Value -match '^(Sala|Facultad|Unidad|Biblioteca|Oficina|Coordinaci.n)\b') {
|
||||||
return 'la'
|
return 'la'
|
||||||
}
|
}
|
||||||
if ($Value -match '^(Laboratorio|Centro|Edificio|Campus|Taller|Auditorio)\b') {
|
if ($Value -match '^(Aula|Laboratorio|Centro|Edificio|Campus|Taller|Auditorio)\b') {
|
||||||
return 'el'
|
return 'el'
|
||||||
}
|
}
|
||||||
return $null
|
return $null
|
||||||
@@ -202,9 +202,17 @@ function Get-WelcomeLocationText {
|
|||||||
if ($Room -and $OuName) {
|
if ($Room -and $OuName) {
|
||||||
$roomArticle = Get-SpanishArticle -Value $Room
|
$roomArticle = Get-SpanishArticle -Value $Room
|
||||||
$ouArticle = Get-SpanishArticle -Value $OuName
|
$ouArticle = Get-SpanishArticle -Value $OuName
|
||||||
$roomPhrase = if ($roomArticle) { "$roomArticle $Room" } else { $Room }
|
$roomPhrase = if ($roomArticle -eq 'el') {
|
||||||
|
"al $Room"
|
||||||
|
}
|
||||||
|
elseif ($roomArticle) {
|
||||||
|
"a $roomArticle $Room"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
"a $Room"
|
||||||
|
}
|
||||||
$ouPhrase = if ($ouArticle -eq 'el') { "del $OuName" } elseif ($ouArticle) { "de $ouArticle $OuName" } else { "de $OuName" }
|
$ouPhrase = if ($ouArticle -eq 'el') { "del $OuName" } elseif ($ouArticle) { "de $ouArticle $OuName" } else { "de $OuName" }
|
||||||
return "$located $roomPhrase $ouPhrase."
|
return "Acceso $roomPhrase $ouPhrase."
|
||||||
}
|
}
|
||||||
if ($Room) {
|
if ($Room) {
|
||||||
$article = Get-SpanishArticle -Value $Room
|
$article = Get-SpanishArticle -Value $Room
|
||||||
|
|||||||
@@ -12,15 +12,20 @@ $lookup = $ast.Find({
|
|||||||
}, $true)
|
}, $true)
|
||||||
|
|
||||||
function Invoke-WelcomeFixture {
|
function Invoke-WelcomeFixture {
|
||||||
param($DirectoryGender, [string]$ExplicitGender)
|
param(
|
||||||
|
$DirectoryGender,
|
||||||
|
[string]$ExplicitGender,
|
||||||
|
[string]$DirectoryLocation = 'Sala de pruebas',
|
||||||
|
[string]$DirectoryOu = 'Laboratorio'
|
||||||
|
)
|
||||||
|
|
||||||
# Replace only the external directory lookup. Execute the actual script,
|
# Replace only the external directory lookup. Execute the actual script,
|
||||||
# including its validated parameters, metadata assignment and JPEG renderer.
|
# including its validated parameters, metadata assignment and JPEG renderer.
|
||||||
$fixtureJson = [pscustomobject]@{
|
$fixtureJson = [pscustomobject]@{
|
||||||
DisplayName = 'Usuario de prueba'
|
DisplayName = 'Usuario de prueba'
|
||||||
Gender = $DirectoryGender
|
Gender = $DirectoryGender
|
||||||
Location = 'Sala de pruebas'
|
Location = $DirectoryLocation
|
||||||
OrganizationalUnit = 'Laboratorio'
|
OrganizationalUnit = $DirectoryOu
|
||||||
} | ConvertTo-Json -Compress
|
} | ConvertTo-Json -Compress
|
||||||
$fixtureFunction = 'function Get-DirectoryWelcomeMetadata { param($UserName, $MachineName); ConvertFrom-Json ''' +
|
$fixtureFunction = 'function Get-DirectoryWelcomeMetadata { param($UserName, $MachineName); ConvertFrom-Json ''' +
|
||||||
$fixtureJson.Replace("'", "''") + ''' }'
|
$fixtureJson.Replace("'", "''") + ''' }'
|
||||||
@@ -69,4 +74,11 @@ Describe 'Welcome wallpaper with AD metadata' {
|
|||||||
It 'honors an explicit gender over directory metadata' {
|
It 'honors an explicit gender over directory metadata' {
|
||||||
(Invoke-WelcomeFixture -DirectoryGender 'Female' -ExplicitGender 'Male').WelcomeHeading | Should Be 'Bienvenido,'
|
(Invoke-WelcomeFixture -DirectoryGender 'Female' -ExplicitGender 'Male').WelcomeHeading | Should Be 'Bienvenido,'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
It 'renders the flexible classroom and immediate OU as an access label' {
|
||||||
|
$result = Invoke-WelcomeFixture -DirectoryGender $null `
|
||||||
|
-DirectoryLocation 'Aula Flexible' `
|
||||||
|
-DirectoryOu 'Centro de Experiencia Digital'
|
||||||
|
$result.LocationText | Should Be 'Acceso al Aula Flexible del Centro de Experiencia Digital.'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user