issue #640 fixed

parent 5d101f73
...@@ -405,6 +405,11 @@ module.exports = { ...@@ -405,6 +405,11 @@ module.exports = {
var students = []; var students = [];
async.each(stuSups, async.each(stuSups,
function(stuSup, cb) { function(stuSup, cb) {
// Filter logically deleted students
if (stuSup.student.office == null)
cb();
var student = stuSup.student; var student = stuSup.student;
student.supervision = req.token.office ? 2 : 1; student.supervision = req.token.office ? 2 : 1;
VStuLastInstruction.findOne({student: student.id}) VStuLastInstruction.findOne({student: student.id})
......
...@@ -504,7 +504,6 @@ module.exports = { ...@@ -504,7 +504,6 @@ module.exports = {
if (err || !student) if (err || !student)
throw err; throw err;
// set office to NULL to unlink it
student.office = null; student.office = null;
student.save(function(err, saved) { student.save(function(err, saved) {
if (err) return cb(err); if (err) return cb(err);
......
...@@ -250,6 +250,7 @@ ...@@ -250,6 +250,7 @@
"state_spontaneous": "Spontaneous", "state_spontaneous": "Spontaneous",
"state_supervised": "Supervised", "state_supervised": "Supervised",
"student_added": "Student added", "student_added": "Student added",
"student_already_exists": "A student with that username already exists, please try with another one",
"student_deleted": "Student deleted", "student_deleted": "Student deleted",
"student_not_added": "Student not added", "student_not_added": "Student not added",
"student_not_deleted": "Student not deleted", "student_not_deleted": "Student not deleted",
......
...@@ -251,6 +251,7 @@ ...@@ -251,6 +251,7 @@
"state_spontaneous": "Espontáneo", "state_spontaneous": "Espontáneo",
"state_supervised": "Guiado", "state_supervised": "Guiado",
"student_added": "Estudiante añadido", "student_added": "Estudiante añadido",
"student_already_exists": "Ya existe un estudiante con ese nombre de usuario. Por favor, inténtelo de nuevo con algo diferente.",
"student_deleted": "Estudiante eliminado", "student_deleted": "Estudiante eliminado",
"student_not_added": "Estudiante no añadido", "student_not_added": "Estudiante no añadido",
"student_not_deleted": "No se ha podido eliminar el estudiante", "student_not_deleted": "No se ha podido eliminar el estudiante",
......
...@@ -121,7 +121,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl( ...@@ -121,7 +121,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
// between the new element created and the form fields // between the new element created and the form fields
$scope.resetForm(); $scope.resetForm();
// Show the add form to new adding // Hide the add form to new adding
$scope.hidestudentadd = true; $scope.hidestudentadd = true;
// Update counters // Update counters
...@@ -130,14 +130,17 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl( ...@@ -130,14 +130,17 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
}) })
.error(function (err) { .error(function (err) {
var errorMessage = 'student_not_added'; var errorMessage = 'student_not_added';
console.log(err);
if (typeof err == "string" && err.search("Maximum number of enrolments reached") > 0) if (typeof err == "string" && err.search("Maximum number of enrolments reached") > 0)
errorMessage = 'max_licenses_reached'; errorMessage = 'max_licenses_reached';
if (typeof err == "string" && err.search("already exists") > 0)
errorMessage = 'student_already_exists';
else if (err && err.status === 400) else if (err && err.status === 400)
errorMessage = 'invalid_fields'; errorMessage = 'invalid_fields';
ngToast.danger({ content: $translate.instant(errorMessage) }); ngToast.danger({ content: $translate.instant(errorMessage) });
$scope.hidestudentadd = true;
}); });
}; };
......
...@@ -11,12 +11,11 @@ ...@@ -11,12 +11,11 @@
<!-- Add Student button and Search row --> <!-- Add Student button and Search row -->
<div class="row"> <div class="row">
<div class="col-xs-3"> <div class="col-xs-3">
<p class="text-left"> <p class="text-left" ng-hide="!user.isSupAdmin || !num_licenses_left || !hidestudentadd">
<a ng-click="resetForm(); hidestudentadd = false" class="btn btn-success btn-sm" role="button"> <a ng-click="resetForm(); hidestudentadd = false" class="btn btn-success btn-sm" role="button">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {{ 'add_student' | translate }} <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> {{ 'add_student' | translate }}
</a> </a>
</p> </p>
<!-- <button type="button" class="btn btn-success btn-circle btn-lg" ng-click="resetForm(); hidestudentadd = false" title="{{'add'|translate}}" ng-hide="!user.isSupAdmin || !num_licenses_left"><i class="glyphicon glyphicon-plus"></i></button> -->
</div> </div>
<div class="col-xs-6 input-group"> <div class="col-xs-6 input-group">
<input type="text" ng-model="search_students" id="search_students" placeholder="{{ 'filter' | translate }}" class="form-control" aria-describedby="basic-addon2"> <input type="text" ng-model="search_students" id="search_students" placeholder="{{ 'filter' | translate }}" class="form-control" aria-describedby="basic-addon2">
...@@ -37,7 +36,7 @@ ...@@ -37,7 +36,7 @@
</div> </div>
</td> </td>
<td> <td>
<h4>{{student.name}} {{student.surname}}</h4> <h4>{{student.surname}}, {{student.name}}</h4>
</td> </td>
<td> <td>
<p> <span> {{student.current_method | translate}} </span> <br /> <span class="text-muted">{{student.current_instruction | translate}}</span> </p> <p> <span> {{student.current_method | translate}} </span> <br /> <span class="text-muted">{{student.current_instruction | translate}}</span> </p>
......
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