Compare commits
No commits in common. "master" and "develop" have entirely different histories.
@ -3,7 +3,6 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Announcement;
|
||||
use App\Entity\Employee;
|
||||
use App\Form\AnnouncementType;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
@ -77,13 +76,17 @@ final class AnnouncementController extends AbstractController
|
||||
#[Route('/new', name: 'app_announcement_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request,): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
/*$user = $this->getUser();
|
||||
|
||||
if (!$user instanceof Employee) {
|
||||
$this->addFlash('error', "Vous n'etes pas autorisé à faire cette action.");
|
||||
return $this->redirectToRoute('app_index');
|
||||
}
|
||||
$company = $user->getCompany();
|
||||
if (in_array('ROLE_EMPLOYEE', $user->getRoles())) {
|
||||
$company = $user->getCompany();
|
||||
|
||||
if (!$company)
|
||||
{
|
||||
echo "Compétez votre profile avant de créer une annonce";
|
||||
$this->redirectToRoute('app_user_edit',['id' => $user->getId(),]);
|
||||
}
|
||||
}*/
|
||||
|
||||
$announcement = new Announcement();
|
||||
$form = $this->createForm(AnnouncementType::class, $announcement);
|
||||
@ -92,7 +95,6 @@ final class AnnouncementController extends AbstractController
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$announcement->setCreationDate(new \DateTime());
|
||||
$announcement->setStatus('notVerified');
|
||||
$announcement->setCompany($company);
|
||||
$this->entityManager->persist($announcement);
|
||||
$this->entityManager->flush();
|
||||
|
||||
@ -102,7 +104,6 @@ final class AnnouncementController extends AbstractController
|
||||
return $this->render('announcement/new.html.twig', [
|
||||
'announcement' => $announcement,
|
||||
'form' => $form,
|
||||
'company' => $company,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -99,10 +99,8 @@ class InternFavoriteController extends AbstractController
|
||||
public function addFavorite(Announcement $announcement,): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
if (!$user instanceof Intern) {
|
||||
throw new AccessDeniedHttpException('Seuls les stagiaires peuvent ajouter aux favoris.');
|
||||
}
|
||||
|
||||
// Vérifier si l'intern a déjà ce favori
|
||||
$existingFavorite = $this->entityManager->getRepository(InternFavorite::class)->findOneBy([
|
||||
'announcement' => $announcement,
|
||||
'intern' => $user,
|
||||
|
@ -13,7 +13,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
class ProfileController extends AbstractController
|
||||
@ -51,19 +50,12 @@ class ProfileController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('profile/{id}/edit', name: 'app_profile_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, UserApp $userApp, UserPasswordHasherInterface $passwordHasher): Response
|
||||
public function edit(Request $request, UserApp $userApp,): Response
|
||||
{
|
||||
$form = $this->createForm(UserAppType::class, $userApp);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$plainPassword = $form->get('password')->getData();
|
||||
|
||||
if (!empty($plainPassword)) {
|
||||
$hashedPassword = $passwordHasher->hashPassword($userApp, $plainPassword);
|
||||
$userApp->setPassword($hashedPassword);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_profile', [], Response::HTTP_SEE_OTHER);
|
||||
|
@ -4,6 +4,7 @@ namespace App\Form;
|
||||
|
||||
use App\Entity\Announcement;
|
||||
use App\Entity\Company;
|
||||
use App\Entity\Status;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
@ -17,6 +18,10 @@ class AnnouncementType extends AbstractType
|
||||
$builder
|
||||
->add('title')
|
||||
->add('description')
|
||||
->add('company', EntityType::class, [
|
||||
'class' => Company::class,
|
||||
'choice_label' => 'name',
|
||||
])
|
||||
->add('date', TextType::class, [
|
||||
'label' => 'Date de stage',
|
||||
'required' => true,
|
||||
|
@ -4,7 +4,6 @@ namespace App\Form;
|
||||
|
||||
use App\Entity\UserApp;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
@ -14,19 +13,12 @@ class UserAppType extends AbstractType
|
||||
{
|
||||
$builder
|
||||
->add('nickname')
|
||||
->add('password')
|
||||
->add('firstName')
|
||||
->add('lastName')
|
||||
->add('tel')
|
||||
->add('address')
|
||||
->add('mail')
|
||||
->add('password', PasswordType::class, [
|
||||
'mapped' => false,
|
||||
'required' => false,
|
||||
'attr' => [
|
||||
'autocomplete' => 'new-password'
|
||||
],
|
||||
'label' => 'Nouveau mot de passe',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -43,17 +43,15 @@
|
||||
<span class="text-green-500 font-semibold">Validée</span>
|
||||
{% endif %}
|
||||
|
||||
{% if 'ROLE_INTERN' in app.user.roles %}
|
||||
<form method="post" action="{{ path('app_favorite_toggle', {id: announcement.id}) }}">
|
||||
<button type="submit" class="text-xl">
|
||||
{% if announcement.id in favorites %}
|
||||
⭐
|
||||
{% else %}
|
||||
☆
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
<form method="post" action="{{ path('app_favorite_toggle', {id: announcement.id}) }}">
|
||||
<button type="submit" class="text-xl">
|
||||
{% if announcement.id in favorites %}
|
||||
⭐
|
||||
{% else %}
|
||||
☆
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h2 class="text-3xl font-semibold mb-2">{{ announcement.title }}</h2>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
{% block body %}
|
||||
<div class="container mx-auto p-6">
|
||||
<h1 class="text-3xl font-bold mb-4">Créer une Annonce pour {{ company.name }}</h1>
|
||||
<h1 class="text-3xl font-bold mb-4">Créer une Annonce</h1>
|
||||
|
||||
{{ form_start(form) }}
|
||||
<div class="mb-4">
|
||||
@ -19,6 +19,10 @@
|
||||
{{ form_label(form.date) }}
|
||||
{{ form_widget(form.date, {'attr': {'class': 'form-input w-full p-2 rounded border'}}) }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
{{ form_label(form.company) }}
|
||||
{{ form_widget(form.company, {'attr': {'class': 'form-input w-full p-2 rounded border'}}) }}
|
||||
</div>
|
||||
<button type="submit" class="bg-teal-500 text-white px-4 py-2 rounded">
|
||||
Créer l'annonce
|
||||
</button>
|
||||
|
@ -59,16 +59,6 @@
|
||||
<i class="fas fa-paper-plane"></i> Candidater à cette offre
|
||||
</button>
|
||||
</form>
|
||||
<!-- Vérifier si c'est un favori -->
|
||||
<form method="post" action="{{ path(isFavorite ? 'app_favorite_remove' : 'app_favorite_add', {id: announcement.id}) }}">
|
||||
<button type="submit" class="text-yellow-500">
|
||||
{% if isFavorite %}
|
||||
⭐ Retirer des favoris
|
||||
{% else %}
|
||||
☆ Ajouter aux favoris
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if 'ROLE_ADMIN' in app.user.roles %}
|
||||
@ -88,7 +78,18 @@
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
<!-- Vérifier si c'est un favori -->
|
||||
<form method="post" action="{{ path(isFavorite ? 'app_favorite_remove' : 'app_favorite_add', {id: announcement.id}) }}">
|
||||
<button type="submit" class="text-yellow-500">
|
||||
{% if isFavorite %}
|
||||
⭐ Retirer des favoris
|
||||
{% else %}
|
||||
☆ Ajouter aux favoris
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Bouton de retour à la liste -->
|
||||
|
@ -16,11 +16,7 @@
|
||||
{{ form_row(form.tel, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
|
||||
{{ form_row(form.address, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
|
||||
{{ form_row(form.mail, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
|
||||
{{ form_row(form.password, {
|
||||
'attr': {'class': 'w-full p-3 border rounded-md'},
|
||||
'label': 'Mot de passe (laissez vide pour ne pas changer)',
|
||||
}) }}
|
||||
|
||||
{{ form_row(form.password, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
|
||||
</div>
|
||||
<div class="mt-6">
|
||||
{{ form_widget(form) }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user