Add Wanted Page + fixs

This commit is contained in:
Xbird
2022-10-31 14:09:53 +00:00
parent 2084db1309
commit 9d46a9c561
12 changed files with 124 additions and 8 deletions

4
.env
View File

@@ -19,6 +19,6 @@ MAILER_SENDER=noreply@vision
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7&charset=utf8mb4"
DATABASE_URL="postgresql://symfony:ChangeMe@127.0.0.1:5432/app?serverVersion=13&charset=utf8"
DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7&charset=utf8mb4"
# DATABASE_URL="postgresql://symfony:ChangeMe@127.0.0.1:5432/app?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###

View File

@@ -43,6 +43,7 @@ security:
- { path: ^/verify/password, roles: PUBLIC_ACCESS }
- { path: ^/reset-password, roles: PUBLIC_ACCESS }
- { path: ^/share, roles: PUBLIC_ACCESS }
- { path: ^/wanted, roles: PUBLIC_ACCESS }
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/directory/history, roles: ROLE_ADMIN }
- { path: ^/, roles: IS_AUTHENTICATED_REMEMBERED } #IS_AUTHENTICATED_REMEMBERED= user is logged, with form or with cookie

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221031135251 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE directory ADD wanted_public_display TINYINT(1) DEFAULT \'0\' NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE directory DROP wanted_public_display');
}
}

View File

@@ -85,7 +85,8 @@ class GroupController extends AbstractController
}
if (
$User->getMainRank()->getPower() >= $currentUser->getMainRank()->getPower()
null != $User->getMainRank()
&& $User->getMainRank()->getPower() >= $currentUser->getMainRank()->getPower()
&& !$currentUser->getAdminMode()
) {
$this->addFlash('danger', 'alert_error_cant_fire_superior_or_same_rank');

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Controller;
use App\Repository\DirectoryRepository;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class WantedController extends AbstractController
{
#[Route('/wanted', name: 'app_wanted')]
public function index(DirectoryRepository $DirectoryRepository): Response
{
return $this->render('wanted/index.html.twig', [
'controller_name' => 'WantedController',
'wanted' =>
$DirectoryRepository->list()->notDead()->wanted()->wantedPublicDisplay()->getResult(),
'shared' => true
]);
}
}

View File

@@ -421,6 +421,12 @@ class Directory
*/
private $wantedDisplay = true;
/**
* @ORM\Column(type="boolean", options={"default":"0"})
* @Gedmo\Versioned
*/
private $wantedPublicDisplay = false;
/**
* @ORM\OneToMany(targetEntity=Infringement::class, mappedBy="directory", orphanRemoval=true)
* @ORM\OrderBy({"createdAt" = "DESC"})
@@ -709,9 +715,9 @@ class Directory
}
/**
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $backImageFile
*/
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $backImageFile
*/
public function setBackImageFile(?File $backImageFile = null): void
{
$this->backImageFile = $backImageFile;
@@ -748,7 +754,7 @@ class Directory
return $this->backImageSize;
}
/**
/**
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $leftImageFile
*/
@@ -1358,6 +1364,18 @@ class Directory
return $this;
}
public function getWantedPublicDisplay(): ?bool
{
return $this->wantedPublicDisplay;
}
public function setWantedPublicDisplay(bool $wantedPublicDisplay): self
{
$this->wantedPublicDisplay = $wantedPublicDisplay;
return $this;
}
/**
* @return Collection|Infringement[]
*/

View File

@@ -68,6 +68,7 @@ class DirectoryType extends AbstractType
->add('wanted', null, ['label' => 'form_label_wanted'])
->add('wantedReason', null, ['label' => 'form_label_wantedReason', 'help' => 'form_help_wantedReason'])
->add('wantedDisplay', null, ['label' => 'form_label_wantedDisplay'])
->add('wantedPublicDisplay', null, ['label' => 'form_label_wantedPublicDisplay'])
;
}

View File

@@ -83,6 +83,12 @@ class DirectoryRepository extends ServiceEntityRepository
return $this;
}
public function wantedPublicDisplay()
{
$this->qb->andWhere('d.wantedPublicDisplay = 1');
return $this;
}
public function wantedNotDisplay()
{
$this->qb->andWhere('d.wantedDisplay = 0');

View File

@@ -0,0 +1,34 @@
{% extends 'base.html.twig' %}
{% block title %}{% trans %}title_wanted{% endtrans %}{% endblock %}
{% block body %}
{% if wanted %}
<div class="row p-5">
{% for i in wanted %}
{% set path_directories_uploads = 'uploads/directories' %}
{% if i.faceImageSize != 0 %}{% set faceImage = path_directories_uploads ~ '/' ~ i.faceImageName
%}{% else %}{% set faceImage = 'img/nophoto.jpg' %}{% endif %}
<div class="col-sm-6">
<div class="card prod-p-card background-pattern">
<div class="card-body">
<div class="row align-items-center m-b-0">
<div class="col">
<h6 class="m-b-5">{% trans %}title_wanted{% endtrans %}</h6>
<h3 class="m-b-0">{{i.fullname}}</h3>
</div>
<div class="col-auto">
<a data-toggle="lightbox" data-gallery="wanted"
data-caption="{% trans %}title_wanted{% endtrans %}: {{ i.fullname }}"
href="{{ asset(faceImage) }}"><img class="img-fluid"
style="max-height: 100px;" src="{{ asset(faceImage) }}"
alt="{{ i.fullname}}"></a>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% endblock %}

View File

@@ -363,6 +363,7 @@ form_label_vehicle_type: Vehicle type
form_label_versus: Versus
form_label_wanted: This person is wanted
form_label_wantedDisplay: Display wanted card on homepage
form_label_wantedPublicDisplay: Show on public wanted page
form_label_wantedReason: Reason for searching for this person
form_placeholder_email: Email
form_placeholder_firstname: First name

View File

@@ -363,6 +363,7 @@ form_label_vehicle_type: Type de véhicule
form_label_versus: Contre
form_label_wanted: Cette personne est recherchée
form_label_wantedDisplay: Afficher la recherche sur l'accueil
form_label_wantedPublicDisplay: Afficher la recherche sur la page publique
form_label_wantedReason: Raison de la recherche de cette personne
form_placeholder_email: Email
form_placeholder_firstname: Prénom

View File

@@ -1,3 +1,3 @@
{
"version": "0.2.17"
"version": "0.2.18"
}