Repetitive generation of licenses

parent 30ddc4c8
......@@ -1007,7 +1007,7 @@ module.exports = {
if (updateStudentError) {
throw updateStudentError;
}
res.ok();
res.ok({file: {name: student.pic}});
});
} catch (updateAvatarError) {
fs.unlinkSync(newAvatarFileDescriptor);
......@@ -1016,7 +1016,7 @@ module.exports = {
});
})
.catch(function (err) {
res.badRequest("Could not find supervisor: " + err);
res.badRequest("Could not find student: " + err);
});
},
......
......@@ -557,6 +557,7 @@ module.exports = {
});
})
.catch(function (err) {
res.badRequest("Could not find supervisor: " + err);
});
},
......
......@@ -47,9 +47,8 @@ module.exports = {
toJSON: function () {
var stuPicto = this.toObject();
if (typeof stuPicto.attributes !== 'object') {
stuPicto.attributes = JSON.parse(stuPicto.attributes);
}
if (typeof stuPicto.attributes !== 'object')
stuPicto.attributes = JSON.parse(stuPicto.attributes);
stuPicto.attributes = StuPicto.getValidAttributes(stuPicto.attributes);
return stuPicto;
}
......@@ -90,7 +89,8 @@ module.exports = {
highlight: false,
color: null,
expression: null,
legend: 'none'
legend: 'none',
delete_strip_after_delivery: true
};
if (typeof attributes === 'object') {
......@@ -127,11 +127,12 @@ module.exports = {
if (typeof validAttributes.legend !== 'string') {
delete validAttributes.legend;
}
if( validAttributes.legend !== 'none' &&
validAttributes.legend !== 'normal' &&
validAttributes.legend !== 'full'){
if (!((/^(none|normal|full)$/).test(validAttributes.legend))) {
delete validAttributes.legend;
}
if (typeof validAttributes.delete_strip_after_delivery !== 'boolean') {
delete validAttributes.delete_strip_after_delivery;
}
if (typeof validAttributes.highlight !== 'boolean') {
delete validAttributes.highlight;
}
......
......@@ -67,6 +67,7 @@
"days_from_first_trie": "days from first trie",
"December": "December",
"delete": "Delete",
"delete_strip_after_delivery": "Empty strip after delivery",
"delete_template": "Delete from templates",
"description": "Description",
"device_setup": "Device setup",
......@@ -114,6 +115,7 @@
"highlight": "highlight",
"highlighted": "Highlighted",
"hours": "hours",
"how_many": "How many?",
"input_selection": "How to place a pictogram",
"instruction": "Instruction",
"instruction_begin": "Begin instruction",
......@@ -142,9 +144,10 @@
"license_expires": "License expires on ",
"license_expired": "License expired on ",
"license_invalid": "Invalid license number",
"licenses_left": "{{number}} licenses left",
"license_missing": "Account without license",
"license_number": "License number",
"licenses_created": "Licenses created",
"licenses_left": "{{number}} licenses left",
"light_up": "Light up",
"link": "Link",
"loading_pictos": "Loading pictos",
......
......@@ -67,6 +67,7 @@
"days_from_first_trie": "días desde el primer ensayo",
"December": "Diciembre",
"delete": "Eliminar",
"delete_strip_after_delivery": "Limpiar cinta tras entrega",
"delete_template": "Eliminar de plantillas",
"description": "Descripción",
"device_setup": "Configuración del dispositivo",
......@@ -114,6 +115,7 @@
"highlight": "Resaltar",
"highlighted": "Resaltado",
"hours": "horas",
"how_many": "¿Cuántas?",
"input_selection": "Cómo colocar un pictograma",
"instruction": "Instrucción",
"instruction_begin": "Primer intento",
......@@ -128,7 +130,7 @@
"June": "Junio",
"language": "Idioma",
"large": "Grande",
"large_picto": "Pictograms grandes",
"large_picto": "Pictogramas grandes",
"last_session": "Última sesión",
"legend": "Leyenda",
"legend_none":"Sin leyenda",
......@@ -145,6 +147,7 @@
"license_invalid": "Licencia inválida",
"license_number": "Número de licencia",
"license_missing": "Cuenta sin licencia",
"licenses_created": "Licencias creadas",
"light_up": "Iluminar",
"link": "Vincular",
"loading_pictos": "Cargando pictos",
......
......@@ -8,28 +8,30 @@ dashboardControllers.controller('AdminLicensesCtrl', function AdminLicensesCtrl(
// Don't show the message at the begining
$scope.showmessagesupervisor = false;
$scope.new_numbers = [];
$scope.formdatalicense = {
duration: ''
duration: 1,
repeat: 1
};
// This generates a new license and registers it in the database
$scope.create_license = function(supervisor){
$http
.post(config.backend+'/license', $scope.formdatalicense)
.success(function(data, status, headers, config) {
$scope.formdatalicense.duration = '';
$scope.new_number = data.number.substr(0,4) +
"-" + data.number.substr(4,4) +
"-" + data.number.substr(8,4) +
"-" + data.number.substr(12,4);
console.log($scope.new_number);
$scope.duration_registered = data.duration;
})
.error(function(data, status, headers, config) {
ngToast.danger({content: $translate.instant('error_general')});
console.log("Error from API: " + data.error);
});
$scope.create_licenses = function(supervisor) {
$scope.new_numbers = [];
for (var i = 0; i < $scope.formdatalicense.repeat; i++) {
$http
.post(config.backend+'/license', $scope.formdatalicense)
.success(function(data, status, headers, config) {
$scope.new_numbers.push(data.number.substr(0,4) +
"-" + data.number.substr(4,4) +
"-" + data.number.substr(8,4) +
"-" + data.number.substr(12,4));
})
.error(function(data, status, headers, config) {
ngToast.danger({content: $translate.instant('error_general')});
console.log("Error from API: " + data.error);
});
}
$scope.duration_registered = $scope.formdatalicense.duration;
};
});
......@@ -9,12 +9,18 @@
<h3 translate>licenses</h3>
<form role="form" ng-submit="create_license()">
<form role="form" ng-submit="create_licenses()">
<div class="form-group">
<label translate>duration_in_months</label>
<input type="number" class="form-control" id="setup_duration" placeholder="{{ 'duration_in_months' | translate }}" required ng-model="formdatalicense.duration" required/>
</div>
<div class="form-group">
<label translate>how_many</label>
<input type="number" class="form-control" id="setup_repeat" placeholder="{{ 'how_many' | translate }}" ng-model="formdatalicense.repeat" required/>
</div>
<div class="form-group text-center">
<button type="submit" class="btn btn-primary" translate>generate</button>
</div>
......@@ -24,8 +30,11 @@
</div>
<div class="col-md-4">
<div ng-show="new_number.length > 16" class="alert alert-info">
<p>{{ 'license_created' | translate }}: <strong>{{ new_number }}</strong></p>
<div ng-show="new_numbers.length > 0" class="alert alert-info">
<p>{{ 'licenses_created' | translate }}:</p><p>&nbsp;</p>
<div ng-repeat="number in new_numbers track by $index">
<p> <strong>{{ number }}</strong></p>
</div>
<p>{{ 'duration_in_months' | translate }}: {{ duration_registered }}</p>
</div>
</div>
......
......@@ -34,6 +34,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
var file;
var extension;
var filename;
console.log("selected!!");
for (i = 0; i < $files.length; i++) {
file = $files[i]; // { name, size, type }
......@@ -59,6 +60,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
})
.success(function (data) {
ngToast.success({ content: $translate.instant('student_updated') });
console.log(JSON.stringify(data));
$scope.studentData.pic = '/upload/studentAvatar/' + data.file.name;
});
} else {
......
......@@ -15,7 +15,7 @@
<img class="thumbnail preview" ng-src="{{studentData.pic}}" />
<!-- Fin Cambiar imagen de perfil -->
<div class="form-group">
<input type="file" class="filestyle">
<input type="file" class="filestyle" ng-file-select="onFileSelect($files)" ng-model="picFile" accept="image/*">
</div>
</div>
......@@ -33,7 +33,7 @@
<input type="password" class="form-control" id="setup_password2" placeholder="{{ 'password_confirm' | translate }}" ng-model="formUser.password_confirm"/>
</div>
<div class="form-group">
<span translate>license_number</span>:
<label translate>license_number</label>
<input type="text" id="setup_license" mask="9999-9999-9999-9999" clean="true" placeholder="{{ 'license_number' | translate }}" ng-model="formUser.license_number" required>
<br/>
<span ng-show="studentData.license && !studentData.license_expired" class="text-info">
......@@ -58,16 +58,16 @@
<div class="col-md-6">
<div class="form-group">
<span translate>name</span>:
<label translate>name</label>
<input type="text" class="form-control" id="student_personal_edit_name" placeholder="{{ 'name' | translate }}" ng-model="formUser.name" required />
</div>
<div class="form-group">
<span translate>surname</span>:
<label translate>surname</label>
<input type="text" class="form-control" id="student_personal_edit_surname" placeholder="{{ 'surname' | translate }}" ng-model="formUser.surname" required />
</div>
<div class="form-group">
<label translate>birthdate</label>
<p class="input-group">
<span translate>birthdate</span>:
<input type="text" class="form-control" datepicker-popup=" {{ 'day_format' | translate }}" ng-model="formUser.birthdate" placeholder="{{ 'birthdate' | translate }}" is-open="opened" close-text="{{'close' | translate}}" required />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="openCalendar($event)"><i class="glyphicon glyphicon-calendar"></i></button>
......@@ -80,7 +80,7 @@
<fieldset>
<div class="form-group">
<span translate>gender</span>:
<label translate>gender</label>
<select class="form-control" name="student_gender" id="student_gender" ng-model="formUser.gender" required>
<option value=" ">&nsp;</option>
<option value="F" translate>woman</option>
......@@ -88,7 +88,7 @@
</select>
</div>
<div class="form-group">
<span translate>country</span>:
<label translate>country</label>
<select class="form-control" name="student_country" id="student_country" ng-model="formUser.country" required>
<option value="ES">España</option>
<option value="US">United States</option>
......@@ -98,7 +98,7 @@
</div>
<div class="form-group">
<span translate>language</span>:
<label translate>language</label>
<select class="form-control" name="supervisor_language" id="supervisor_language" ng-model="formUser.lang">
<option value="es-es">Español</option>
<option value="en-gb">English</option>
......@@ -136,8 +136,8 @@
<form role="form" class="form">
<fieldset>
<span translate>categories</span>:
<div class="form-group">
<label translate>categories</label>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox"
......@@ -145,11 +145,11 @@
ng-model="studentData.attributes.categories"
ng-change="update_attributes()">
</span>
<label class="form-control" for="studentSetupUseCategories">{{ 'use_categories' | translate }}</label>
<span class="form-control" for="studentSetupUseCategories">{{ 'use_categories' | translate }}</span>
</div>
</div>
<span translate>picto_size</span>:
<div class="form-group">
<label translate>picto_size</label>
<div class="input-group">
<span class="input-group-addon">
<input type="radio"
......@@ -158,9 +158,9 @@
ng-model="studentData.attributes.size"
ng-change="update_attributes()">
</span>
<label class="form-control" for="studentSetupPictoSizeSmall">
<span class="form-control" for="studentSetupPictoSizeSmall">
{{ 'small_picto' | translate }}
</label>
</span>
</div>
<div class="input-group">
<span class="input-group-addon">
......@@ -170,9 +170,9 @@
ng-model="studentData.attributes.size"
ng-change="update_attributes()">
</span>
<label class="form-control" for="studentSetupPictoSizeLarge">
<span class="form-control" for="studentSetupPictoSizeLarge">
{{ 'large_picto' | translate }}
</label>
</span>
</div>
</div>
</fieldset>
......@@ -181,7 +181,7 @@
<div class="col-md-6">
<fieldset>
<span translate>feedback_picto</span>:
<label translate>feedback_picto</label>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox"
......@@ -189,7 +189,7 @@
ng-model="studentData.attributes.input_feedback.vibration"
ng-change="update_attributes()">
</span>
<label class="form-control" for="studentSetupVibrateOnTouch">{{ 'vibration' | translate }}</label>
<span class="form-control" for="studentSetupVibrateOnTouch">{{ 'vibration' | translate }}</span>
</div>
<div class="input-group">
<span class="input-group-addon">
......@@ -198,7 +198,7 @@
ng-model="studentData.attributes.input_feedback.beep"
ng-change="update_attributes()">
</span>
<label class="form-control" for="studentSetupBeepOnTouch">{{ 'beep' | translate }}</label>
<span class="form-control" for="studentSetupBeepOnTouch">{{ 'beep' | translate }}</span>
</div>
<div class="input-group">
<span class="input-group-addon">
......@@ -207,7 +207,7 @@
ng-model="studentData.attributes.input_feedback.read"
ng-change="update_attributes()">
</span>
<label class="form-control" for="studentSetupReadOnTouch">{{ 'read_picto' | translate }}</label>
<span class="form-control" for="studentSetupReadOnTouch">{{ 'read_picto' | translate }}</span>
</div>
<div class="input-group">
<span class="input-group-addon">
......@@ -216,9 +216,20 @@
ng-model="studentData.attributes.input_feedback.highlight"
ng-change="update_attributes()">
</span>
<label class="form-control" for="studentSetupHighlightOnTouch">
<span class="form-control" for="studentSetupHighlightOnTouch">
{{ 'highlight' | translate }}
</label>
</span>
</div>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox"
id="studentSetupDeleteStripAfterDelivery"
ng-model="studentData.attributes.input_feedback.delete_strip_after_delivery"
ng-change="update_attributes()">
</span>
<span class="form-control" for="studentSetupDeleteStripAfterDelivery">
{{ 'delete_strip_after_delivery' | translate }}
</span>
</div>
</fieldset>
<!-- DISABLED, NOT IMPLEMENTED YET
......
......@@ -110,6 +110,12 @@ html {
}
/* Sticky footer: pie de página con idiomas*/
div.footer-space {
height: 67px;
width: 100%;
clear: both;
}
div.languages{
position: absolute;
bottom: 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment