Skip to content
Merged

Bugs #538

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/V1Module/presenters/AsyncJobsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use App\Exceptions\ForbiddenRequestException;
use App\Exceptions\BadRequestException;
use Doctrine\Common\Collections\Criteria;
use SortDirection;
use Exception;
use DateTime;

Expand Down Expand Up @@ -129,7 +130,7 @@ public function actionList(?int $ageThreshold, ?bool $includeScheduled)
Criteria::expr()->eq('scheduledAt', null)
)
);
$criteria->orderBy(['createdAt' => 'ASC']);
$criteria->orderBy(['createdAt' => SortDirection::Ascending]);
$jobs = $this->asyncJobs->matching($criteria)->toArray();

$jobs = array_filter($jobs, function ($job) {
Expand Down
1 change: 0 additions & 1 deletion app/V1Module/presenters/EmailVerificationPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\V1Module\Presenters;

use App\Helpers\MetaFormats\Attributes\Post;
use App\Exceptions\ForbiddenRequestException;
use App\Helpers\EmailVerificationHelper;
use App\Security\Identity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public function checkPreSubmit(string $exerciseId)
* @throws ExerciseConfigException
* @throws BadRequestException
*/
#[Post("files", new VArray())]
#[Post("files", new VArray(new VUuid()), "Files of the reference solution", required: true)]
#[Path("exerciseId", new VUuid(), "identifier of exercise", required: true)]
public function actionPreSubmit(string $exerciseId)
{
Expand Down Expand Up @@ -420,7 +420,7 @@ public function checkSubmit(string $exerciseId)
* @throws BadRequestException
*/
#[Post("note", new VString(), "Description of this particular reference solution, for example used algorithm")]
#[Post("files", new VMixed(), "Files of the reference solution", nullable: true)]
#[Post("files", new VArray(new VUuid()), "Files of the reference solution", required: true)]
#[Post("runtimeEnvironmentId", new VMixed(), "ID of runtime for this solution", nullable: true)]
#[Post("solutionParams", new VMixed(), "Solution parameters", required: false, nullable: true)]
#[Path("exerciseId", new VUuid(), "Identifier of the exercise", required: true)]
Expand Down
4 changes: 2 additions & 2 deletions app/V1Module/presenters/UserCalendarsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\V1Module\Presenters;

use App\Helpers\MetaFormats\Attributes\Post;
use App\Helpers\MetaFormats\Attributes\Path;
use App\Helpers\MetaFormats\Validators\VString;
use App\Helpers\MetaFormats\Validators\VUuid;
Expand All @@ -25,6 +24,7 @@
use Eluceo\iCal\Domain\Entity\Calendar;
use Eluceo\iCal\Presentation\Factory\CalendarFactory;
use Eluceo\iCal\Domain\ValueObject;
use SortDirection;

/**
* User iCal management endpoints
Expand Down Expand Up @@ -187,7 +187,7 @@ public function checkUserCalendars(string $id)
public function actionUserCalendars(string $id)
{
$user = $this->users->findOrThrow($id);
$calendars = $this->userCalendars->findBy(['user' => $user], ['createdAt' => 'DESC']);
$calendars = $this->userCalendars->findBy(['user' => $user], ['createdAt' => SortDirection::Descending]);
$this->sendSuccessResponse($calendars);
}

Expand Down
2 changes: 1 addition & 1 deletion app/V1Module/security/PolicyRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private function findPolicyOrThrow($subject, $policyName): IPermissionPolicy
{
if ($subject !== null) {
foreach ($this->policies as $policy) {
// se need this search due to entity inheritance (TODO: find a better way in the future)
// we need this search due to entity inheritance (TODO: find a better way in the future)
$associatedClass = $policy->getAssociatedClass();
if ($subject instanceof $associatedClass && method_exists($policy, $policyName)) {
return $policy;
Expand Down
7 changes: 4 additions & 3 deletions app/commands/ExportDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SortDirection;

/**
* Export data from database into Doctrine Fixtures. Exported data are stored in
Expand Down Expand Up @@ -126,7 +127,7 @@ private function exportHardwareGroups(string $fixtureDir)
$content[self::PARAMETERS_KEY] = [];
$content[HardwareGroup::class] = [];

foreach ($this->hardwareGroups->findBy([], ["id" => "ASC"]) as $group) {
foreach ($this->hardwareGroups->findBy([], ['id' => SortDirection::Ascending]) as $group) {
/** @var HardwareGroup $group */

$constructArr = [];
Expand Down Expand Up @@ -156,7 +157,7 @@ private function exportRuntimes($fixtureDir)
$content[self::PARAMETERS_KEY] = [];
$content[RuntimeEnvironment::class] = [];

foreach ($this->runtimeEnvironments->findBy([], ["id" => "ASC"]) as $runtime) {
foreach ($this->runtimeEnvironments->findBy([], ['id' => SortDirection::Ascending]) as $runtime) {
/** @var RuntimeEnvironment $runtime */

$constructArr = [];
Expand Down Expand Up @@ -199,7 +200,7 @@ private function exportPipelines($fixtureDir)
$pipelines = [];

$index = 0;
foreach ($this->pipelines->findBy(["author" => null], ["name" => "ASC"]) as $pipeline) {
foreach ($this->pipelines->findBy(['author' => null], ['name' => SortDirection::Ascending]) as $pipeline) {
/** @var Pipeline $pipeline */

$index++;
Expand Down
4 changes: 2 additions & 2 deletions app/commands/SwaggerAnnotator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
)]
class SwaggerAnnotator extends Command
{
private static $autogeneratedAnnotationFilePath = 'app/V1Module/presenters/_autogenerated_annotations_temp.php';
private static string $annotationsFile = __DIR__ . '/../V1Module/presenters/_autogenerated_annotations_temp.php';

protected function execute(InputInterface $input, OutputInterface $output): int
{
try {
// create a temporary file containing transpiled annotations usable by the external library (Swagger-PHP)
$fileBuilder = new TempAnnotationFileBuilder(self::$autogeneratedAnnotationFilePath);
$fileBuilder = new TempAnnotationFileBuilder(self::$annotationsFile);
$fileBuilder->startClass('__Autogenerated_Annotation_Controller__', '1.0', 'ReCodEx API');

// get all routes of the api
Expand Down
18 changes: 9 additions & 9 deletions app/commands/SwaggerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use OpenApi\Generator;
use OpenApi\Builder;

/**
* Command that consumes a temporary file containing endpoint annotations and generates a swagger documentation.
Expand All @@ -18,23 +18,23 @@
)]
class SwaggerGenerator extends Command
{
private static string $annotationsFile = __DIR__ . '/../V1Module/presenters/_autogenerated_annotations_temp.php';

protected function execute(InputInterface $input, OutputInterface $output): int
{
$path = __DIR__ . '/../V1Module/presenters/_autogenerated_annotations_temp.php';

// check if file exists
if (!file_exists($path)) {
if (!file_exists(self::$annotationsFile)) {
$output->writeln("Error in SwaggerGenerator: Temp annotation file not found.");
return Command::FAILURE;
}

$generator = new Generator();
$openapi = $generator->generate([$path]);

$output->writeln($openapi->toYaml());
$builder = new Builder();
$builder->addSource(self::$annotationsFile);
$result = $builder->build();
$output->writeln($result->toYaml());

// delete the temp file
unlink($path);
unlink(self::$annotationsFile);

return Command::SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion app/config/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ acl:
asyncJob: App\Security\ACL\IAsyncJobPermissions
plagiarism: App\Security\ACL\IPlagiarismPermissions
policies:
_: App\Security\Policies\GenericPermissionPolicy
GENERIC: App\Security\Policies\GenericPermissionPolicy
group: App\Security\Policies\GroupPermissionPolicy
instance: App\Security\Policies\InstancePermissionPolicy
user: App\Security\Policies\UserPermissionPolicy
Expand Down
122 changes: 53 additions & 69 deletions app/helpers/Emails/EmailHelper/email_cs.latte
Original file line number Diff line number Diff line change
@@ -1,76 +1,60 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{$subject}</title>
<style>
a {
font-weight: bold;
color: #595959;
border-bottom: 1px solid #cfcfcf;
text-decoration: none;
}

hr {
color: #cbd9dc;
background-color: #cbd9dc;
}

p {
color: #000;
}
</style>
<meta charset="utf-8">
<title>{$subject}</title>
<style>
body {
margin: 0;
padding: 30px;
font: 12pt Calibri, Arial, sans-serif;
}
article {
border: 2px solid #222d32;
padding: 2px;
}
header {
font-size: 20pt;
padding: 0.5em;
font-weight: bold;
color: white;
background: no-repeat center right #222d32 url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjUwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwKSIgZD0ibTAgMGgzNzR2MTIwaC0zNzR2LTEyMHoiIGZpbGw9IiM4QUM2NUEiLz4KPHBhdGggdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMjUzLDEyNikiIGQ9Im0wIDBoMTIxdjI0OGgtMTIxdi0yNDh6IiBmaWxsPSIjOEFDNjU5Ii8+CjxwYXRoIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEyNiwxMjYpIiBkPSJtMCAwaDEyMXYyNDhoLTEyMXYtMjQ4eiIgZmlsbD0iIzhBQzY1OSIvPgo8cGF0aCB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLDM4MCkiIGQ9Im0wIDBoMTIwdjEyMGgtMTIwYzEuMDQ4Ny0xLjA0NDggNTYuMjE3LTU3LjQ3OCA1OC01OS0xLjQwMzUtMi40MTc5LTU4LTU5LjIzMi01OC02MXoiIGZpbGw9IiM4OWM3NWEiLz4KPHBhdGggdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMzgwKSIgZD0ibTAgMGgxMjBzLTU3LjU1MSA1OC42MDUtNTggNTljMC43MzA1OCAwLjUxNzkxIDM4LjYyNCA0MC4wNDIgNTggNjB2MWgtMTIwdi0xMjAiIGZpbGw9IiM4YWM3NWEiLz4KPC9zdmc+Cg==');
background-size: auto 70%;
background-position-x: calc(100% - 0.5em);
}
main {
padding: 1em;
}
footer {
background: #f8f8f8;
border-top: 1px solid #cbd9dc;
padding: 1em;
position: relative;
}
footer img {
position: absolute;
right: 1em;
top: 50%;
transform: translateY(-50%);
}
a {
font-weight: bold;
color: #595959;
}
</style>
</head>
<body style="margin: 0;">
<div style="padding: 30px 0; font-family: Arial, sans-serif; font-size: 10pt;">
<table style="margin: 0 auto;" align="center">
<tr>
<td style="padding: 0 !important;">
<table style="width: 600px; margin: 0 auto; background: #fff; border: 1px solid #cbd9dc;" align="center"
cellspacing="0" cellpadding="0">
<tr>
<td style="background: #222D32; color: #ecf0f5; font-weight: bold; padding: 20px;">
<h2 style="margin: 0;">{$subject}</h2>
</td>
<td style="background: #222D32; margin: 0; padding: 10px 20px 10px 0;text-align: right;">
<img style="width: 50px; border: none;" src="{$apiUrl|trim:"/"}/emails/img/logo_only.png"
alt="ReCodEx">
</td>
</tr>

<tr>
<td style="padding: 20px;" colspan="2">
<div style="word-wrap: break-word; width: 580px;">
{$message|noescape}
</div>
{if $showSettingsInfo}
<hr>
<p>
Pokud nechcete dostávat tento typ oznámení, upravte prosím svoje nastavení uživatelského
účtu.
</p>
{/if}
</td>
</tr>
<tr style="background: #f8f8f8; margin: 0; padding: 0; text-align: left; overflow: hidden;">
<td style="margin: 0; padding: 20px;">
<p style="margin: 0; padding: 0;">
Programujte zodpovědně,<br>ReCodEx Team<br>
<a href="{$footerUrl}">{$footerUrl}</a>
</p>
</td>
<td style="margin: 0; padding: 20px; text-align: right;">
<a href="{$githubUrl}" style="width: 30px; height: 30px; padding-left: 10px; border: none;"
target=_blank>
<img style="border: none;" src="{$apiUrl|trim:"/"}/emails/img/github.png" width="30"
height="30" alt="Github">
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<body>
<article>
<header>{$subject}</header>
<main>{$message|noescape}</main>
<footer>
{if $showSettingsInfo}
<p>Pokud nechcete dostávat tento typ oznámení, upravte prosím svoje nastavení uživatelského účtu.</p>
{/if}
Programujte s radostí, <a href="{$footerUrl}">Váš ReCodEx</a>
<a href="{$githubUrl}" target=_blank><img src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