Compare commits

...

5 Commits

Author SHA1 Message Date
Tykayn 9cfb974c27 handle creation of mixed subset of datechoice 2022-02-10 11:02:03 +01:00
Tykayn e488b76a2d up essai 2022-02-10 10:41:31 +01:00
Tykayn 110ef9fc7a hop up script 2022-02-10 10:32:13 +01:00
Tykayn 38fdbf8e85 add essai route 2022-02-10 10:23:06 +01:00
Tykayn 46d6d21c6b up debug message in poll creation 2022-02-10 09:53:24 +01:00
109 changed files with 623 additions and 569 deletions

0
.env.test Normal file → Executable file
View File

1
.gitignore vendored
View File

@ -40,4 +40,5 @@ public/*
###< symfony/phpunit-bridge ###
node_modules
funky-framadate-front/*
funky-framadate-front

0
.gitlab-ci.yml Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

View File

@ -28,20 +28,22 @@ https://framagit.org/framasoft/framadate/funky-framadate-front
user_homepageget_default GET ANY ANY /user/
user_homepage_polls_send_by_email GET ANY ANY /user/{email}/polls/send-by-email
poll_index GET ANY ANY /poll/
poll_new GET|POST ANY ANY /poll/new
poll_show GET ANY ANY /poll/{id}
poll_new POST ANY ANY /poll/new
poll_show GET ANY ANY /poll/id/{id}
poll_edit GET|POST ANY ANY /poll/{id}/edit
poll_delete DELETE ANY ANY /poll/{id}
api_get_poll_comment GET ANY ANY /api/v1/comment/poll/{id}/comments
api_new_comment POST ANY ANY /api/v1/comment/poll/{id}/comment
api_poll_comments_delete DELETE ANY ANY /api/v1/comment/poll/{id}/comments
api_essai GET ANY ANY /api/v1/poll/essai
api_get_all_polls GET ANY ANY /api/v1/poll/
api_get_poll GET ANY ANY /api/v1/poll/{customUrl}
api_get_owner_poll GET ANY ANY /api/v1/poll/owner/{owner_email}/
api_get_protected_poll GET ANY ANY /api/v1/poll/{customUrl}/pass/{md5}
api_get_admin_poll GET ANY ANY /api/v1/polladmin/{admin_key}
api_update_poll PUT ANY ANY /api/v1/poll/{customUrl}/update/{token}
api_new_poll POST ANY ANY /api/v1/poll/
api_app_api_v1_poll_newpoll POST ANY ANY /api/v1/poll/
api_app_api_v1_poll_newpoll.1 POST ANY ANY /api/v1/poll_new_poll
api_test-mail-poll GET ANY ANY /api/v1/poll/mail/test-mail-poll/{emailChoice}
api_poll_delete DELETE ANY ANY /api/v1/poll/{admin_key}
api_check_slug_is_unique GET ANY ANY /api/v1/poll/slug/{customUrl}

0
assets/styles/app.scss Normal file → Executable file
View File

0
assets/styles/pages/_global.scss Normal file → Executable file
View File

0
assets/styles/pages/_home.scss Normal file → Executable file
View File

0
assets/styles/pages/libs.scss Normal file → Executable file
View File

0
composer-setup.php Normal file → Executable file
View File

0
composer.json Normal file → Executable file
View File

0
composer.lock generated Normal file → Executable file
View File

0
config/bundles.php Normal file → Executable file
View File

0
config/graphql/types/Apartment.types.yaml Normal file → Executable file
View File

0
config/graphql/types/Query.types.yaml Normal file → Executable file
View File

0
config/packages/cache.yaml Normal file → Executable file
View File

0
config/packages/dev/debug.yaml Normal file → Executable file
View File

0
config/packages/dev/jms_serializer.yaml Normal file → Executable file
View File

0
config/packages/dev/mailer.yaml Normal file → Executable file
View File

0
config/packages/dev/swiftmailer.yaml Normal file → Executable file
View File

0
config/packages/dev/web_profiler.yaml Normal file → Executable file
View File

0
config/packages/doctrine.yaml Normal file → Executable file
View File

0
config/packages/doctrine_migrations.yaml Normal file → Executable file
View File

0
config/packages/fos_rest.yaml Normal file → Executable file
View File

0
config/packages/framework.yaml Normal file → Executable file
View File

0
config/packages/jms_serializer.yaml Normal file → Executable file
View File

0
config/packages/mailer.yaml Normal file → Executable file
View File

0
config/packages/nelmio_api_doc.yaml Normal file → Executable file
View File

0
config/packages/nelmio_cors.yaml Normal file → Executable file
View File

0
config/packages/prod/doctrine.yaml Normal file → Executable file
View File

0
config/packages/prod/jms_serializer.yaml Normal file → Executable file
View File

0
config/packages/prod/mailer.yml Normal file → Executable file
View File

0
config/packages/prod/monolog.yaml Normal file → Executable file
View File

0
config/packages/prod/routing.yaml Normal file → Executable file
View File

0
config/packages/routing.yaml Normal file → Executable file
View File

0
config/packages/sensio_framework_extra.yaml Normal file → Executable file
View File

0
config/packages/swiftmailer.yaml Normal file → Executable file
View File

0
config/packages/test/doctrine.yaml Normal file → Executable file
View File

0
config/packages/test/framework.yaml Normal file → Executable file
View File

0
config/packages/test/swiftmailer.yaml Normal file → Executable file
View File

0
config/packages/test/twig.yaml Normal file → Executable file
View File

0
config/packages/test/web_profiler.yaml Normal file → Executable file
View File

0
config/packages/twig.yaml Normal file → Executable file
View File

0
config/preload.php Normal file → Executable file
View File

0
config/routes.yaml Normal file → Executable file
View File

0
config/routes/annotations.yaml Normal file → Executable file
View File

0
config/routes/dev/framework.yaml Normal file → Executable file
View File

0
config/routes/dev/web_profiler.yaml Normal file → Executable file
View File

0
config/routes/nelmio_api_doc.yaml Normal file → Executable file
View File

0
config/services.yaml Normal file → Executable file
View File

0
doc/SCHEMA:framadate_api.uml Normal file → Executable file
View File

0
doc/apache2/dev.conf Normal file → Executable file
View File

0
doc/apache2/dev_php_fpm.conf Normal file → Executable file
View File

0
doc/database_creation.md Normal file → Executable file
View File

0
doc/framadate_api.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 192 KiB

After

Width:  |  Height:  |  Size: 192 KiB

0
doc/framadate_api.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 147 KiB

After

Width:  |  Height:  |  Size: 147 KiB

0
doc/migration.md Normal file → Executable file
View File

0
doc/php-8-install.md Normal file → Executable file
View File

0
front_update.sh Normal file → Executable file
View File

0
migrations/.gitignore vendored Normal file → Executable file
View File

0
migrations/Version20210419202522.php Normal file → Executable file
View File

0
migrations/Version20210518212646.php Normal file → Executable file
View File

0
phpunit.xml.dist Normal file → Executable file
View File

0
public/index.php Normal file → Executable file
View File

0
src/Controller/.gitignore vendored Normal file → Executable file
View File

0
src/Controller/EmailsController.php Normal file → Executable file
View File

5
src/Controller/PollController.php Normal file → Executable file
View File

@ -6,6 +6,7 @@ use App\Entity\Poll;
use App\Form\PollType;
use App\Repository\PollRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -34,7 +35,7 @@ class PollController extends AbstractController {
}
/**
* @Route("/new", name="poll_new", methods={"GET","POST"})
* @Route("/new", name="poll_new", methods={"POST"})
*/
public function new( Request $request ): Response {
$poll = new Poll();
@ -58,7 +59,7 @@ class PollController extends AbstractController {
/**
* on cherche un sondage par son url personnalisée
* @Route("/{id}", name="poll_show", methods={"GET"})
* @Route("/id/{id}", name="poll_show", methods={"GET"})
*/
public function show( $id ): Response {
$repository = $this->getDoctrine()->getRepository( Poll::class );

0
src/Controller/api/v1/CommentController.php Normal file → Executable file
View File

114
src/Controller/api/v1/PollController.php Normal file → Executable file
View File

@ -10,7 +10,6 @@ use App\Repository\PollRepository;
use DateTime;
use FOS\RestBundle\Controller\Annotations\Delete;
use FOS\RestBundle\Controller\Annotations\Get;
use FOS\RestBundle\Controller\Annotations\Post;
use FOS\RestBundle\Controller\Annotations\Put;
use FOS\RestBundle\Controller\Annotations\Route;
use JMS\Serializer\SerializerInterface;
@ -25,14 +24,33 @@ use Symfony\Component\HttpFoundation\Response;
* @package App\Controller
* @Route("/api/v1/poll",name="api_")
*/
class PollController extends EmailsController {
class PollController extends EmailsController
{
/**
* @Route(
* "/essai",
* name = "essai",
* methods={"GET"}
* )
* @param Request $request
* essai poll
* @return JsonResponse
*/
public function essai(Request $request): JsonResponse
{
$data = $request->getContent();
$data = json_decode($data, true);
return $this->json(["message" => 'essai', 'data' => $data], 400);
}
/**
* @Get(
* path = "/",
* name = "get_all_polls"
* )
*/
public function getAllPollsAction( PollRepository $pollRepository ): Response {
public function getAllPollsAction(PollRepository $pollRepository): Response
{
$data = $pollRepository->findAll();
@ -62,7 +80,7 @@ class PollController extends EmailsController {
}
/**
* get a poll config by its custom URL, we do not want polls to be reachable by their numeric id
* get a poll config by its public custom URL, we do not want polls to be reachable by their numeric id
* @Get(
* path = "/{customUrl}",
* name = "get_poll"
@ -77,7 +95,8 @@ class PollController extends EmailsController {
SerializerInterface $serializer,
$customUrl,
Request $request
) {
)
{
$repository = $this->getDoctrine()->getRepository(Poll::class);
$poll = $repository->findOneByCustomUrl($customUrl);
@ -116,7 +135,8 @@ class PollController extends EmailsController {
*
* @return JsonResponse
*/
public function notFoundPoll( $id ): Response {
public function notFoundPoll($id): Response
{
return $this->json([
'message' => $id . ' : poll not found',
],
@ -132,7 +152,8 @@ class PollController extends EmailsController {
*
* @return JsonResponse|Response
*/
function getOwnerPolls( $owner_email , LoggerInterface $logger ) {
function getOwnerPolls($owner_email, LoggerInterface $logger)
{
$repository = $this->getDoctrine()->getRepository(Owner::class);
$owner = $repository->findOneByEmail($owner_email);
if (!$owner) {
@ -165,7 +186,8 @@ class PollController extends EmailsController {
*
* @return JsonResponse|Response
*/
function getProtectedPoll( $customUrl, $md5, SerializerInterface $serializer ) {
function getProtectedPoll($customUrl, $md5, SerializerInterface $serializer)
{
$repository = $this->getDoctrine()->getRepository(Poll::class);
$poll = $repository->findOneByCustomUrl($customUrl);
@ -193,7 +215,9 @@ class PollController extends EmailsController {
/**
* as an administrator of a poll, get a poll config by its custom URL, we do not want polls to be reachable by their numeric id
* as an administrator of a poll,
* get a poll config by its custom URL,
* we do not want polls to be reachable by their numeric id
* @Get(
* path = "admin/{admin_key}",
* name = "get_admin_poll",
@ -204,7 +228,8 @@ class PollController extends EmailsController {
*
* @return JsonResponse|Response
*/
function getAdminPoll( $admin_key, $md5, SerializerInterface $serializer ) {
function getAdminPoll($admin_key, $md5, SerializerInterface $serializer)
{
$repository = $this->getDoctrine()->getRepository(Poll::class);
$poll = $repository->findOneByAdminKey($admin_key);
@ -224,7 +249,8 @@ class PollController extends EmailsController {
* @param $serializer
* @return Response
*/
function returnPollData( $poll, $serializer ) {
function returnPollData($poll, $serializer)
{
$jsonResponse = $serializer->serialize($poll, 'json');
$response = new Response($jsonResponse);
@ -245,7 +271,8 @@ class PollController extends EmailsController {
Poll $poll,
string $token,
Request $request
) {
)
{
if ($poll->getAdminKey() !== $token) {
return $this->json([
'message' => 'you are NOT allowed to update the poll ' . $poll->getTitle(),
@ -264,27 +291,33 @@ class PollController extends EmailsController {
200);
}
/**
* @Post(
* path = "/",
* name = "new_poll",
* requirements = {"creator"="\w+"}
* @Route(
* "/",
* "_new_poll",
* methods={"POST"}
* )
* @param Request $request
* create a new poll
* @return JsonResponse
*/
public function newPollAction( Request $request ) {
public function newPoll(Request $request): JsonResponse
{
$data = $request->getContent();
$data = json_decode($data, true);
// search for existing custom url, which must be unique
if (!isset($data) || !isset($data['custom_url'])) {
return $this->json(["message" => 'NOPE, pas de data ou de custom url'], 403);
}
$custom_url = $data['custom_url'];
$repository = $this->getDoctrine()->getRepository(Poll::class);
$poll = $repository->findOneByCustomUrl($custom_url);
if ($poll) {
throw new \JsonException( 'NOPE, ce sondage existe déjà: ' . $custom_url );
return $this->json(["message" => 'NOPE, ce sondage existe déjà: ' . $custom_url], 403);
}
$newpoll = new Poll();
@ -292,7 +325,7 @@ class PollController extends EmailsController {
->setModificationPolicy(isset($data['modification_policy']) ? $data['modification_policy'] : 'everybody')
->setTitle($data['title'])
->setKind($data['kind'])
->setCustomUrl( $data[ 'custom_url' ] );
->setCustomUrl($custom_url);
if (count($data['allowed_answers'])) {
// TODO check this one
$newpoll->setAllowedAnswers($data['allowed_answers']);
@ -346,10 +379,11 @@ class PollController extends EmailsController {
$newpoll->setPassword($data['password']);
}
$choices_debug = '';
// text kind of answers, dates are below
if ($data['kind'] == 'text') {
// manage choices
$choices = $data[ 'choices' ];
$choices = $data['choicesText'];
foreach ($choices as $c) {
$newChoice = new Choice();
$newChoice
@ -362,21 +396,33 @@ class PollController extends EmailsController {
elseif ($data['kind'] == 'date') {
$choices = $data['dateChoices'];
$choices_debug .= '\n debug count recieved' . count($choices);
if (isset($data['hasSeveralHours']) && $data['hasSeveralHours'] == true) {
// different hours spans make more choices
foreach ($choices as $c) {
$choices_debug .= '\n c ' . $c['literal'];
$currentDate = $c['literal'];
$timeSlicesOfThisChoice = $c['timeSlices'];
foreach ( $timeSlicesOfThisChoice as $t ) {
if (count($timeSlicesOfThisChoice)) {
foreach ($timeSlicesOfThisChoice as $t) {
$choices_debug .= '\n timeSlicesOfThisChoice ' . $t['literal'];
$newChoice = new Choice();
$newChoice
->setPoll($newpoll)
->setName($currentDate . ' >>> ' . $t['literal']);
$em->persist( $newChoice );
$newpoll->addChoice($newChoice);
$em->persist($newChoice);
$em->persist($newpoll);
}
} else {
$newChoice = new Choice();
$newChoice
->setPoll($newpoll)
->setName($currentDate);
$newpoll->addChoice($newChoice);
$em->persist($newChoice);
$em->persist($newpoll);
}
}
@ -413,10 +459,9 @@ class PollController extends EmailsController {
$this->sendCreationMailAction($foundOwner, $newpoll);
$newChoices = $newpoll->display()[ 'choices' ];
return $this->json([
'message' => 'you created the poll ' . $newpoll->getCustomUrl() . $precision,
'message' => 'you created the poll ' . $newpoll->getCustomUrl() . ' ' . $precision,
'debug' => $choices_debug,
'id' => $newpoll->getId(),
'poll' => $newpoll->displayForAdmin(),
'password_protected' => is_string($newpoll->getPassword()),
@ -444,7 +489,8 @@ class PollController extends EmailsController {
// public function sendCreationMailAction( Owner $admin_user, Poll $poll, \Swift_Mailer $mailer) {
public function testSendCreationMailAction(
$emailChoice = 'tktest_commentateur@tktest.com'
) {
)
{
$em = $this->getDoctrine()->getRepository(Poll::class);
$foundPoll = $em->findOneByCustomUrl('dessin-anime');
$em = $this->getDoctrine()->getRepository(Owner::class);
@ -470,7 +516,8 @@ class PollController extends EmailsController {
public
function deletePollAction(
$admin_key
) {
)
{
$emPoll = $this->getDoctrine()->getRepository(Poll::class);
$found = $emPoll->findOneByAdminKey($admin_key);
@ -499,7 +546,8 @@ class PollController extends EmailsController {
* name = "check_slug_is_unique",
* )
*/
public function checkSlugIsUniqueAction( string $customUrl ) {
public function checkSlugIsUniqueAction(string $customUrl)
{
$emPoll = $this->getDoctrine()->getRepository(Poll::class);
$found = $emPoll->findOneByCustomUrl($customUrl);
$elaborated_message_version = false;
@ -546,7 +594,8 @@ class PollController extends EmailsController {
*
* @return JsonResponse|Response
*/
public function getAdministrationConfig( SerializerInterface $serializer, $token ) {
public function getAdministrationConfig(SerializerInterface $serializer, $token)
{
$emPoll = $this->getDoctrine()->getRepository(Poll::class);
$pollFound = $emPoll->findOneByAdminKey($token);
@ -584,7 +633,8 @@ class PollController extends EmailsController {
*
* @return JsonResponse|Response
*/
public function getExpiredPollsCleanup( $token ) {
public function getExpiredPollsCleanup($token)
{
if ($token !== 'superCaligistriixpirlidouciousse') {
return $this->json([

0
src/Controller/api/v1/VoteController.php Normal file → Executable file
View File

0
src/DataFixtures/CommentFixtures.php Normal file → Executable file
View File

0
src/DataFixtures/VotesStacksFixtures.php Normal file → Executable file
View File

0
src/Entity/.gitignore vendored Normal file → Executable file
View File

View File

@ -306,8 +306,6 @@ class Poll
// handle sub time slices
if (count($boom) == 2) {
if (!isset($grouped_dates[$boom[0]])) {
$grouped_dates[$boom[0]] = [

0
src/Form/PollType.php Normal file → Executable file
View File

0
src/GraphQL/Resolver/ApartmentResolver.php Normal file → Executable file
View File

0
src/Kernel.php Normal file → Executable file
View File

0
src/Repository/.gitignore vendored Normal file → Executable file
View File

0
src/Service/MailService.php Normal file → Executable file
View File

0
symfony.lock Normal file → Executable file
View File

0
templates/admin/index.html.twig Normal file → Executable file
View File

0
templates/default/index.html.twig Normal file → Executable file
View File

0
templates/email-base-plaintext.html.twig Normal file → Executable file
View File

0
templates/email-base.html.twig Normal file → Executable file
View File

0
templates/emails/comment-notification.html.twig Normal file → Executable file
View File

0
templates/emails/partial/admin_link.html.twig Normal file → Executable file
View File

0
templates/emails/partial/poll.html.twig Normal file → Executable file
View File

0
templates/emails/partial/public_link.html.twig Normal file → Executable file
View File

0
templates/emails/vote-notification.html.twig Normal file → Executable file
View File

0
templates/migration/index.html.twig Normal file → Executable file
View File

0
templates/owner/index.html.twig Normal file → Executable file
View File

0
templates/pages/funky.html.twig Normal file → Executable file
View File

0
templates/pages/home.html.twig Normal file → Executable file
View File

0
templates/pages/migration.html.twig Normal file → Executable file
View File

0
templates/poll/_delete_form.html.twig Normal file → Executable file
View File

0
templates/poll/_form.html.twig Normal file → Executable file
View File

0
templates/poll/edit.html.twig Normal file → Executable file
View File

0
templates/poll/index.html.twig Normal file → Executable file
View File

0
templates/poll/new.html.twig Normal file → Executable file
View File

0
templates/poll/show.html.twig Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More