Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Findeton committed Apr 4, 2024
1 parent 2bdb38a commit b7cc18b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
43 changes: 43 additions & 0 deletions avAdmin/admin-directives/create/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,48 @@ angular.module('avAdmin')
}
});

function checkTrustees(el) {
logInfo($i18next.t('avAdmin.create.checkingTrustees', {title: el.title}));
var deferred = $q.defer();
var auths = el.authorities || [];
if (el.director) {
auths.push(el.director);
}

if (0 === auths.length) {
logError($i18next.t('avAdmin.create.errors.election-auths-missing', {title: el.title}));
deferred.reject();
} else {
ElectionsApi
.authoritiesStatus()
.then(function (trustees) {
var hasError = false;
for (var i = 0; i < auths.length; i++) {
var auth = auths[i];
if (!trustees[auth]) {
logError($i18next.t('avAdmin.create.errors.election-auth-not-found', {title: el.title, auth: auth}));
hasError = true;
continue;
}
if ('ok' !== trustees[auth].state) {
logError($i18next.t('avAdmin.create.errors.election-auth-error', {title: el.title, auth: auth, message: trustees[auth].message}));
hasError = true;
continue;
}
}
if (hasError) {
deferred.reject();
} else {
deferred.resolve();
}
})
.catch(deferred.reject);
}


return deferred.promise;
}

function createAuthEvent(el) {
console.log("creating auth event for election " + el.title);
var deferred = $q.defer();
Expand Down Expand Up @@ -1264,6 +1306,7 @@ angular.module('avAdmin')

var promise = deferred.promise;
promise = promise
.then(checkTrustees)
.then(createAuthEvent)
.then(registerElection)
.then(function(election) {
Expand Down
4 changes: 4 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@
"create": {
"summary": "Summary: creating __num__ elections",
"summary__plural": "Summary: creating __num__ elections",
"checkingTrustees": "Checking trustees status for election __title__",
"create": "Create the elections",
"creating": "Creating the authentication for election __title__",
"setChildrenElectionInfo": "Setting the children election info for election (id: __id__) __title__",
Expand All @@ -942,6 +943,9 @@
"confirmEdit": "Finish edit"
},
"errors": {
"election-auths-missing": "Election '__eltitle__': Missing trustees",
"election-auth-not-found": "Election '__eltitle__': Trustee not found '__auth__'",
"election-auth-error": "Election '__eltitle__': Trustee '__auth__' has invalid status '__message__'",
"lambda-live-preview-parent-children": "Missing election IDs for a parent-children election",
"election-is-array-questions": "Election '__eltitle__': list of questions is not an array",
"election-lambda-success-action-url-mode": "Election '__eltitle__': invalid success action url",
Expand Down
4 changes: 4 additions & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@
"create": {
"summary": "Resumen: creando __num__ votaciones",
"summary__plural": "Resumen: creando __num__ votaciones",
"checkingTrustees": "Checking trustees status for election __title__",
"create": "Crear las votaciones",
"create__plural": "Crear las votaciones",
"creating": "Creando la autenticación de la votación __title__",
Expand All @@ -822,6 +823,9 @@
"livePreview": "Previsualización en vivo"
},
"errors": {
"election-auths-missing": "Election '__eltitle__': Faltan autoridades",
"election-auth-not-found": "Election '__eltitle__': Autoridad no encontrada '__auth__'",
"election-auth-error": "Election '__eltitle__': Autoridad '__auth__' tiene un estado inválido '__message__'",
"lambda-live-preview-parent-children": "Faltan ID de la votación para una votación padre-hijos",
"election-is-array-questions": "Votación '__eltitle__': la lista de pregunta no es un array",
"election-lambda-success-action-url-mode": "Votación '__eltitle__': url de redirección en 'Acción de éxito' inválida",
Expand Down

0 comments on commit b7cc18b

Please sign in to comment.