Commit 7fdf78f9 authored by Ασπασία Κατσή's avatar Ασπασία Κατσή

Merge branch 'mergeschools' into 'develop'

Mergeschools

See merge request itminedu/e-epal!290
parents ea380f5b 20dd7d3f
......@@ -426,5 +426,13 @@ epal.ministry.report-small-classest:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\ReportsCreator::makeReportSmallClasses'
requirements:
_user_is_logged_in: 'TRUE'
epal.undomergeall:
path: '/epal/undomergeall'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\SmallClassDistribution::UndoMergeAll'
requirements:
_user_is_logged_in: 'TRUE'
\ No newline at end of file
......@@ -367,15 +367,17 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
$mergedSchools = reset($mergedSchool);
if ($mergedSchools)
{
$list[] = array(
'id' => $schoolid,
'idnew' => $mergedSchools -> epal_id -> entity ->id(),
'name' => $object->name->value,
'namenew' => $mergedSchools -> epal_id ->entity->get('name')->value,
);
{
$indnew = $mergedSchools -> epal_id -> entity ->id();
if ($schoolid != $indnew )
{
$list[] = array(
'id' => $schoolid,
'idnew' => $indnew,
'name' => $object->name->value,
'namenew' => $mergedSchools -> epal_id ->entity->get('name')->value,
);
}
}
}
......@@ -387,14 +389,17 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
$mergedSchools = reset($mergedSchool);
if ($mergedSchools)
{
$indnew = $mergedSchools -> epal_id -> entity ->id();
if ($schoolid != $indnew )
{
$list[] = array(
'id' => $schoolid,
'idnew' => $mergedSchools -> epal_id -> entity ->id(),
'idnew' => $idnew,
'name' => $object->name->value,
'namenew' => $mergedSchools -> epal_id ->entity->get('name')->value,
);
}
}
......@@ -407,15 +412,17 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
$mergedSchools = reset($mergedSchool);
if ($mergedSchools)
{
$indnew = $mergedSchools -> epal_id -> entity ->id();
if ($schoolid != $indnew )
{
$list[] = array(
'id' => $schoolid,
'idnew' => $mergedSchools -> epal_id -> entity ->id(),
'idnew' => $idnew,
'name' => $object->name->value,
'namenew' => $mergedSchools -> epal_id ->entity->get('name')->value,
);
);
}
}
}
......@@ -427,15 +434,17 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
$mergedSchools = reset($mergedSchool);
if ($mergedSchools)
{
$indnew = $mergedSchools -> epal_id -> entity ->id();
if ($schoolid != $indnew )
{
$list[] = array(
'id' => $schoolid,
'idnew' => $mergedSchools -> epal_id -> entity ->id(),
'idnew' => $indnew,
'name' => $object->name->value,
'namenew' => $mergedSchools -> epal_id ->entity->get('name')->value,
);
}
}
}
......@@ -665,7 +674,86 @@ public function findMergingSchoolsforUndo(Request $request, $classId, $sector, $
}
}
public function UndoMergeAll(Request $request)
{
if (!$request->isMethod('POST')) {
return $this->respondWithStatus([
"message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED);
}
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$selectionId = $user->init->value;
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole) {
if ( ($tmpRole === 'regioneduadmin') || ($tmpRole === 'eduadmin')) {
$userRole = $tmpRole;
}
}
if ($userRole === '') {
return $this->respondWithStatus([
'error_code' => 4003,
"message" => t("1")
], Response::HTTP_FORBIDDEN);
} elseif ($userRole === 'regioneduadmin') {
$schools = $this->entityTypeManager
->getStorage('eepal_school')
->loadByProperties(array('region_edu_admin_id' => $selectionId));
} elseif ($userRole === 'eduadmin') {
$schools = $this->entityTypeManager
->getStorage('eepal_school')
->loadByProperties(array('edu_admin_id' => $selectionId));
} else {
$schools = [];
}
if ($schools) {
foreach ($schools as $object) {
$old_schoolid = $object->id() ;
if ($userRole == 'regioneduadmin')
$recordsforundomerge = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('initial_epal_id' => $old_schoolid ));
else
$recordsforundomerge = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('initial_epal_id' => $old_schoolid, 'merging_role' => 'eduadmin'));
if ($recordsforundomerge)
{
foreach ($recordsforundomerge as $recordsforundomerges)
{
$recordsforundomerges->set('initial_epal_id', 0);
$recordsforundomerges->set('epal_id', $old_schoolid);
$recordsforundomerges->set('merging_role', null);
$recordsforundomerges->save();
}
}
}
return $this->respondWithStatus([
'error_code' => '0' ,
], Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'error_code' => '1002',
], Response::HTTP_BAD_REQUEST);
}
} else {
return $this->respondWithStatus([
'error_code' => '1003',
], Response::HTTP_FORBIDDEN);
}
}
}
......@@ -42,13 +42,13 @@ use Drupal\user\UserInterface;
* "uid" = "user_id",
* "langcode" = "langcode",
* "status" = "status",
* "drupaluser_id" = "drupaluser_id",
* "name" = "name",
* "surname" = "surname",
* "taxis_taxid" = "taxis_taxid",
* "requesttoken" = "requesttoken",
* "accesstoken" = "accesstoken",
* "authtoken" = "authtoken",
* "drupaluser_id" = "drupaluser_id",
* "name" = "name",
* "surname" = "surname",
* "taxis_taxid" = "taxis_taxid",
* "requesttoken" = "requesttoken",
* "accesstoken" = "accesstoken",
* "authtoken" = "authtoken",
* },
* links = {
* "canonical" = "/admin/structure/epal_users/{epal_users}",
......@@ -323,13 +323,13 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['drupaluser_id'] = BaseFieldDefinition::create('entity_reference')
$fields['drupaluser_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Id χρήστη Drupal'))
->setDescription(t('Δώσε το id του αντίστοιχου Drupal User.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setRequired(true)
->setRequired(true)
// ->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -350,7 +350,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->setDisplayConfigurable('view', TRUE);
$fields['taxis_userid'] = BaseFieldDefinition::create('string')
$fields['taxis_userid'] = BaseFieldDefinition::create('string')
->setLabel(t('User id χρήστη από taxis'))
->setDescription(t('Δώσε το user id του χρήστη από taxis.'))
->setSettings(array(
......@@ -370,14 +370,14 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['taxis_taxid'] = BaseFieldDefinition::create('string')
$fields['taxis_taxid'] = BaseFieldDefinition::create('string')
->setLabel(t('Tax id χρήστη'))
->setDescription(t('Δώσε το tax id / ΑΦΜ του χρήστη.'))
->setSettings(array(
'max_length' => 400,
'text_processing' => 0,
))
->setRequired(true)
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -398,7 +398,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
'max_length' => 1000,
'text_processing' => 0,
))
->setRequired(true)
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -412,14 +412,14 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['surname'] = BaseFieldDefinition::create('string')
$fields['surname'] = BaseFieldDefinition::create('string')
->setLabel(t('Επώνυμο χρήστη'))
->setDescription(t('Δώσε το επώνυμο του χρήστη.'))
->setSettings(array(
'max_length' => 1000,
'text_processing' => 0,
))
->setRequired(true)
->setRequired(true)
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
......@@ -433,7 +433,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['fathername'] = BaseFieldDefinition::create('string')
$fields['fathername'] = BaseFieldDefinition::create('string')
->setLabel(t('Όνομα πατέρα χρήστη'))
->setDescription(t('Δώσε το όνομα του πατέρα του χρήστη.'))
->setSettings(array(
......@@ -453,7 +453,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['mothername'] = BaseFieldDefinition::create('string')
$fields['mothername'] = BaseFieldDefinition::create('string')
->setLabel(t('Όνομα μητέρας χρήστη'))
->setDescription(t('Δώσε το όνομα της μητέρας χρήστη.'))
->setSettings(array(
......@@ -537,7 +537,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->setDescription(t('A boolean indicating whether the email verification code was verified.'))
->setDefaultValue(FALSE);
$fields['accesstoken'] = BaseFieldDefinition::create('string')
$fields['accesstoken'] = BaseFieldDefinition::create('string')
->setLabel(t('Access-Token από taxis'))
->setDescription(t('Access-Token από taxis.'))
->setSettings(array(
......@@ -577,7 +577,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['authtoken'] = BaseFieldDefinition::create('string')
$fields['authtoken'] = BaseFieldDefinition::create('string')
->setLabel(t('Authorization Token'))
->setDescription(t('Authorization Token που δημιουργείται από την εφαρμογή.'))
->setSettings(array(
......@@ -637,17 +637,17 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['timelogin'] = BaseFieldDefinition::create('timestamp')
$fields['timelogin'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('timeLogin'))
->setDescription(t('timeLogin.'))
;
$fields['timeregistration'] = BaseFieldDefinition::create('timestamp')
$fields['timeregistration'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('timeRegistration'))
->setDescription(t('timeRegistration.'))
;
$fields['timetokeninvalid'] = BaseFieldDefinition::create('integer')
$fields['timetokeninvalid'] = BaseFieldDefinition::create('integer')
->setLabel(t('Χρόνος σε min'))
->setDescription(t('Χρόνος σε min μετά τον οποίο γίνεται το token ανενεργό.'))
->setSettings(array(
......@@ -666,7 +666,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['userip'] = BaseFieldDefinition::create('string')
$fields['userip'] = BaseFieldDefinition::create('string')
->setLabel(t('userIP'))
->setDescription(t('userIP.'))
->setSettings(array(
......@@ -686,7 +686,7 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Epal users is published.'))
->setDefaultValue(TRUE);
......@@ -702,4 +702,4 @@ class EpalUsers extends ContentEntityBase implements EpalUsersInterface {
return $fields;
}
}
}
\ No newline at end of file
......@@ -155,7 +155,9 @@ class CBController extends ControllerBase
$taxis_userid = null;
$trx = $this->connection->startTransaction();
$oauth = new OAuth($this->consumer_key, $this->consumer_secret, OAUTH_SIG_METHOD_PLAINTEXT, OAUTH_AUTH_TYPE_URI);
//$oauth->disableSSLChecks();
// $oauth->enableDebug();
$oauth->setToken($authToken, $this->requestTokenSecret);
$accessToken = $oauth->getAccessToken($this->access_token_url, '', $authVerifier);
......
......@@ -106,6 +106,7 @@ class OAuthLogin extends ControllerBase
try {
$oauth = new OAuth($this->consumer_key, $this->consumer_secret, OAUTH_SIG_METHOD_PLAINTEXT, OAUTH_AUTH_TYPE_URI);
//$oauth->disableSSLChecks();
$oauth->enableDebug();
......
......@@ -88,7 +88,7 @@ import { FormBuilder, FormGroup } from "@angular/forms";
<div [hidden]="SectorActiveforBClass !== SectorNames$.id">
<div *ngFor="let CoursesforMerges$ of School$ | async; let j=index; let isOdd=odd;
let isEven=even" class="row list-group-item isclickable"
[class.oddout]="isOdd" [class.evenout]="isEven" style="margin: 0px 2px 0px 2px;"
[class.oddout]="isOdd" [class.evenout]="isEven" style="font-size: 0.8em; margin: 0px 2px 0px 2px;"
(click)="setActiveSchoolforBClass(CoursesforMerges$.id)"
(click)="findmergingcourse(CoursesforMerges$.id,2,SectorNames$.id, 0)">
......@@ -141,9 +141,9 @@ import { FormBuilder, FormGroup } from "@angular/forms";
<div [hidden]="regionActive !== SectorNames$.id" >
<div *ngFor="let Courses$ of Specialit$ | async; let j=index; let isOdd=odd; let isEven=even" style=" font-weight: bold;">
<div *ngFor="let Courses$ of Specialit$ | async; let j=index; let isOdd=odd; let isEven=even" style="font-size: 0.8em; font-weight: bold;">
<li class="list-group-item isclickable" (click)="setActiveSpecial(SectorNames$.id, Courses$.id)"
[class.oddnew]="isOdd" [class.evennew]="isEven" [class.selectednew]="courseActive === Courses$.id" >
[class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="courseActive === Courses$.id" >
<div class="col-md-12">{{Courses$.name}}</div>
</li>
......@@ -153,7 +153,7 @@ import { FormBuilder, FormGroup } from "@angular/forms";
let k=index; let isOdd=odd; let isEven=even"
class="row list-group-item isclickable"
[class.oddout]="isOdd" [class.evenout]="isEven"
style="margin: 0px 2px 0px 2px;"
style="margin: 0px 2px 0px 2px; "
(click)="setActiveCourses(CoursesforMerges$.id)"
(click)="findmergingcourse(CoursesforMerges$.id,3,SectorNames$.id, Courses$.id)">
<div class="col-md-8" style=" font-weight: bold;" >{{CoursesforMerges$.name}}</div>
......
This diff is collapsed.
......@@ -1121,7 +1121,7 @@ export class HelperDataService implements OnInit, OnDestroy {
UndoMerge(firstid, secondid, classId, sector, speciality)
{
console.log(firstid, secondid, classId, sector, speciality,"undo");
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
......@@ -1143,4 +1143,31 @@ export class HelperDataService implements OnInit, OnDestroy {
});
}
UndoMergAll()
{
let firstid = 1;
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
});
let headers = new Headers({
"Content-Type": "application/json",
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
this.http.post(`${AppSettings.API_ENDPOINT}/epal/undomergeall`, { firstid: firstid }, options)
.map(response => response.json())
.subscribe(data => {
resolve(data);
},
error => {
reject("Error undo merge");
});
});
}
}
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 to comment