Skip to content

Commit

Permalink
Merge pull request #686 from portabilis/portabilis-patch-2019-12-02
Browse files Browse the repository at this point in the history
[2.2] Portabilis patch 02/12/2019
  • Loading branch information
edersoares committed Dec 2, 2019
2 parents 501815a + aaf07e5 commit 1d363cd
Show file tree
Hide file tree
Showing 93 changed files with 3,719 additions and 1,521 deletions.
19 changes: 19 additions & 0 deletions app/Contracts/CopyRegistrationData.php
@@ -0,0 +1,19 @@
<?php

namespace App\Contracts;

use App\Models\LegacyRegistration;

interface CopyRegistrationData
{
/**
* @param LegacyRegistration $newRegistration
* @param LegacyRegistration $oldRegistration
*
* @return void
*/
public function copy(
LegacyRegistration $newRegistration,
LegacyRegistration $oldRegistration
);
}
28 changes: 28 additions & 0 deletions app/Events/RegistrationEvent.php
@@ -0,0 +1,28 @@
<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class RegistrationEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;

public $registration;

/**
* Create a new event instance.
*
* @return void
*/
public function __construct($registration)
{
$this->registration = $registration;
}
}
13 changes: 13 additions & 0 deletions app/Exceptions/Transfer/MissingAbsenceType.php
@@ -0,0 +1,13 @@
<?php

namespace App\Exceptions\Transfer;

class MissingAbsenceType extends TransferException
{
public function __construct()
{
$message = 'O tipo de presença da regra de avaliação é inválido';

parent::__construct($message);
}
}
13 changes: 13 additions & 0 deletions app/Exceptions/Transfer/MissingDescriptiveOpinionType.php
@@ -0,0 +1,13 @@
<?php

namespace App\Exceptions\Transfer;

class MissingDescriptiveOpinionType extends TransferException
{
public function __construct()
{
$message = 'O tipo de parecer da regra de avaliação é inválido';

parent::__construct($message);
}
}
13 changes: 13 additions & 0 deletions app/Exceptions/Transfer/StagesAreNotSame.php
@@ -0,0 +1,13 @@
<?php

namespace App\Exceptions\Transfer;

class StagesAreNotSame extends TransferException
{
public function __construct()
{
$message = 'As escolas ou turmas trabalham com quantidade de etapas diferentes.';

parent::__construct($message);
}
}
10 changes: 10 additions & 0 deletions app/Exceptions/Transfer/TransferException.php
@@ -0,0 +1,10 @@
<?php

namespace App\Exceptions\Transfer;

use Exception;

class TransferException extends Exception
{

}
17 changes: 17 additions & 0 deletions app/Http/Controllers/OpenPrivateUrlController.php
@@ -0,0 +1,17 @@
<?php

namespace App\Http\Controllers;

use App\Services\UrlPresigner;
use Illuminate\Http\Request;
use Redirect;

class OpenPrivateUrlController extends Controller
{
public function open(Request $request, UrlPresigner $urlPresigner)
{
$presignedUrl = $urlPresigner->getPresignedUrl($request->url);

return Redirect::away($presignedUrl);
}
}
50 changes: 50 additions & 0 deletions app/Listeners/AcceptTransferRequestListener.php
@@ -0,0 +1,50 @@
<?php

namespace App\Listeners;

use App\Services\TransferRegistrationDataService;

class AcceptTransferRequestListener
{
/**
* @var TransferRegistrationDataService
*/
private $service;

/**
* @param TransferRegistrationDataService $service
*/
public function __construct(TransferRegistrationDataService $service)
{
$this->service = $service;
}

/**
* Handle the event.
*
* @param object $event
*
* @return void
*/
public function handle($event)
{
$transfer = $this->service->getTransfer($event->registration);

if (empty($transfer)) {
return;
}

$this->acceptTransferRequest($transfer, $event->registration);
}

/**
* @param $transfer
* @param $newRegistration
*/
private function acceptTransferRequest($transfer, $newRegistration)
{
$transfer->update([
'ref_cod_matricula_entrada' => $newRegistration->cod_matricula
]);
}
}
38 changes: 38 additions & 0 deletions app/Listeners/CopyTransferDataListener.php
@@ -0,0 +1,38 @@
<?php

namespace App\Listeners;

use App\Exceptions\Transfer\MissingDescriptiveOpinionType;
use App\Exceptions\Transfer\StagesAreNotSame;
use App\Services\TransferRegistrationDataService;

class CopyTransferDataListener
{
/**
* @var TransferRegistrationDataService
*/
protected $service;

/**
* @param TransferRegistrationDataService $service
*/
public function __construct(TransferRegistrationDataService $service)
{
$this->service = $service;
}

/**
* Handle the event.
*
* @param object $event
*
* @throws MissingDescriptiveOpinionType
* @throws StagesAreNotSame
*
* @return void
*/
public function handle($event)
{
$this->service->transferData($event->registration);
}
}
9 changes: 9 additions & 0 deletions app/Models/LegacyDiscipline.php
Expand Up @@ -3,6 +3,7 @@
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class LegacyDiscipline extends Model
{
Expand Down Expand Up @@ -62,4 +63,12 @@ public function getEducacensoCodeAttribute()
{
return $this->codigo_educacenso;
}

/**
* @return BelongsTo
*/
public function knowledgeArea()
{
return $this->belongsTo(LegacyKnowledgeArea::class, 'area_conhecimento_id');
}
}
37 changes: 37 additions & 0 deletions app/Models/LegacyDisciplineAbsence.php
@@ -0,0 +1,37 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class LegacyDisciplineAbsence extends Model
{
/**
* @var string
*/
protected $table = 'modules.falta_componente_curricular';

/**
* @var array
*/
protected $fillable = [
'falta_aluno_id',
'componente_curricular_id',
'quantidade',
'etapa',
];

/**
* @var bool
*/
public $timestamps = false;

/**
* @return BelongsTo
*/
public function studentAbsence()
{
return $this->belongsTo(LegacyStudentAbsence::class, 'falta_aluno_id');
}
}
23 changes: 23 additions & 0 deletions app/Models/LegacyDisciplineDependence.php
@@ -0,0 +1,23 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class LegacyDisciplineDependence extends Model
{
/**
* @var string
*/
protected $table = 'pmieducar.disciplina_dependencia';

/**
* @var string
*/
protected $primaryKey = 'cod_disciplina_dependencia';

/**
* @var bool
*/
public $timestamps = false;
}
38 changes: 38 additions & 0 deletions app/Models/LegacyDisciplineDescriptiveOpinion.php
@@ -0,0 +1,38 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class LegacyDisciplineDescriptiveOpinion extends Model
{
/**
* @var string
*/
protected $table = 'modules.parecer_componente_curricular';

/**
* @var array
*/
protected $fillable = [
'parecer_aluno_id',
'componente_curricular_id',
'parecer',
'etapa',
];

/**
* @var bool
*/
public $timestamps = false;


/**
* @return BelongsTo
*/
public function studentDescriptiveOpinion()
{
return $this->belongsTo(LegacyStudentDescriptiveOpinion::class, 'parecer_aluno_id');
}
}
9 changes: 8 additions & 1 deletion app/Models/LegacyDisciplineScore.php
Expand Up @@ -20,7 +20,14 @@ class LegacyDisciplineScore extends Model
* @var array
*/
protected $fillable = [
'nota_aluno_id', 'componente_curricular_id', 'etapa',
'nota_aluno_id',
'componente_curricular_id',
'nota',
'nota_arredondada',
'etapa',
'nota_recuperacao',
'nota_original',
'nota_recuperacao_especifica'
];

/**
Expand Down

0 comments on commit 1d363cd

Please sign in to comment.