mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
action de test pour template de mail
This commit is contained in:
parent
3f2ac02b65
commit
c796db6d7c
@ -31,6 +31,8 @@ class DefaultController extends AbstractController {
|
||||
*/
|
||||
public function sendPollsToUser( $email, \Swift_Mailer $mailer ) {
|
||||
$repository = $this->getDoctrine()->getRepository( Owner::class );
|
||||
|
||||
// find user by email
|
||||
$founduser = $repository->findOneBy( [ 'email' => $email ] );
|
||||
|
||||
if ( $founduser ) {
|
||||
@ -68,9 +70,6 @@ class DefaultController extends AbstractController {
|
||||
],
|
||||
400 );
|
||||
}
|
||||
// find user by email
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ use FOS\RestBundle\Controller\Annotations\Post;
|
||||
use FOS\RestBundle\Controller\Annotations\Put;
|
||||
use FOS\RestBundle\Controller\Annotations\Route;
|
||||
use JMS\Serializer\SerializerBuilder;
|
||||
use Swift_Message;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -137,7 +138,7 @@ class PollController extends AbstractController {
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function newPollAction( Request $request ) {
|
||||
public function newPollAction( Request $request, \Swift_Mailer $mailer ) {
|
||||
|
||||
$data = $request->getContent();
|
||||
|
||||
@ -225,6 +226,8 @@ class PollController extends AbstractController {
|
||||
$precision = 'from an existing user : ' . $foundOwner->getEmail();
|
||||
}
|
||||
|
||||
$this->sendCreationMailAction( $foundOwner, $newpoll, $mailer );
|
||||
|
||||
return $this->json( [
|
||||
'message' => 'you created a poll ' . $precision,
|
||||
'poll' => $newpoll,
|
||||
@ -237,6 +240,51 @@ class PollController extends AbstractController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get(
|
||||
* path = "/mail/test-mail-poll",
|
||||
* name = "test-mail-poll",
|
||||
* )
|
||||
*
|
||||
* send the creation mail to owner
|
||||
*
|
||||
* @param Owner $admin_user
|
||||
* @param Poll $poll
|
||||
* @param \Swift_Mailer $mailer
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
// public function sendCreationMailAction( Owner $admin_user, Poll $poll, \Swift_Mailer $mailer) {
|
||||
public function sendCreationMailAction( \Swift_Mailer $mailer ) {
|
||||
|
||||
$em = $this->getDoctrine()->getRepository( Owner::class );
|
||||
$admin_user = $em->find( 1 );
|
||||
$poll = $admin_user->getPolls()[ 0 ];
|
||||
|
||||
$templateVars = [
|
||||
'owner' => $admin_user,
|
||||
'poll' => $poll,
|
||||
'url' => $poll->getCustomUrl(),
|
||||
'title' => 'Création de sondage - ' . $poll->getTitle(),
|
||||
'email_template' => 'emails/creation-mail.html.twig',
|
||||
];
|
||||
|
||||
$message = ( new Swift_Message( 'Framadate - mes sondages' ) )
|
||||
->setFrom( 'ne-pas-repondre@framadate-api.cipherbliss.com' )
|
||||
->setTo( $admin_user->getEmail() )
|
||||
->setBody(
|
||||
$this->renderView(
|
||||
$templateVars[ 'email_template' ],
|
||||
$templateVars
|
||||
)
|
||||
);
|
||||
|
||||
// send email
|
||||
// return $mailer->send( $message );
|
||||
return $this->render( $templateVars[ 'email_template' ], $templateVars );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Delete(
|
||||
|
@ -3,13 +3,14 @@ Ce message ne doit PAS être diffusé aux sondés. Il est réservé à l'auteur
|
||||
<br>
|
||||
Vous pouvez modifier ce sondage à l'adresse suivante :
|
||||
<br>
|
||||
<a href="{{ url }}">{{ url }}</a>
|
||||
{% include 'partial/admin_link.html.twig' %}
|
||||
<br>
|
||||
Pour partager votre sondage aux participants, utilisez son lien d'accès public.
|
||||
<br>
|
||||
|
||||
{% if is_password_protected %}
|
||||
{% if poll.password %}
|
||||
Ce sondage est protégé par un mot de passe, n'oubliez pas de le communiquer à vos participants.
|
||||
Vous pouvez changer ce mot de passe via l'administration.
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
|
@ -1,11 +1,28 @@
|
||||
{#[Framadate][Pour diffusion aux sondés] Sondage: TESSSSSSSSSST#}
|
||||
Ceci est le message qui doit être envoyé aux sondés.<br>
|
||||
{% extends 'email-base.html.twig' %}
|
||||
{% block content %}
|
||||
|
||||
|
||||
Suite à la création de votre sondage {{ title }} vous recevez deux emails afin de ne pas transmettre par erreur aux sondés le lien d'administration de votre sondage.
|
||||
Ce mail est le premier, comportant le message qui doit être envoyé aux sondés.<br>
|
||||
|
||||
Vous pouvez maintenant transmettre ce message à toutes les personnes susceptibles de participer au vote.<br>
|
||||
|
||||
<br>
|
||||
<fieldset>
|
||||
|
||||
<blockquote>
|
||||
<i>
|
||||
|
||||
{{ owner.pseudo }} ( {{ owner.email }} ) vient de créer un sondage intitulé : " <strong>{{ title }}"</strong>.
|
||||
<br>
|
||||
<br>
|
||||
hah vient de créer un sondage intitulé : "{{ title }}".<br>
|
||||
Merci de bien vouloir participer au sondage à l'adresse suivante :<br>
|
||||
<a href="{{ url }}">
|
||||
{{ url }}
|
||||
</a>
|
||||
|
||||
</i>
|
||||
{% include 'emails/partial/public_link.html.twig' %}
|
||||
|
||||
</blockquote>
|
||||
</fieldset>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -1,5 +1,10 @@
|
||||
{#[Framadate][expiration] Sondage: TESSSSSSSSSST#}
|
||||
{% extends 'email-base.html.twig' %}
|
||||
{% block content %}
|
||||
|
||||
|
||||
Ce sondage va bientôt expirer dans 1 jour, il ne sera plus possible d'y voter.
|
||||
Dans 31 jours il sera supprimé. Vous pouvez exporter ses données à tout moment en vous rendant à ce lien pour l'administrer:
|
||||
|
||||
<a href="{{ url }}">{{ url }}</a>
|
||||
{% endblock %}
|
||||
|
@ -15,55 +15,10 @@
|
||||
</div>
|
||||
<hr>
|
||||
<ul style="list-style-type: none">
|
||||
{% for p in polls %}
|
||||
{% for poll in polls %}
|
||||
<li class="poll-element" style="border: solid 1px #ccc; padding: 1em; margin-top: 1em;">
|
||||
|
||||
<strong>
|
||||
{{ p.title }}
|
||||
</strong>
|
||||
|
||||
|
||||
<br>
|
||||
<div class="creation">
|
||||
créé le {{ p.creationDate| date('Y m d ') }}
|
||||
</div>
|
||||
<div class="creation">
|
||||
expirera le {{ p.expiracyDate| date('Y m d ') }}
|
||||
</div>
|
||||
<span class="votes-count">
|
||||
{{ p.stacksOfVotes |length }} votes
|
||||
</span>
|
||||
<span class="votes-count">
|
||||
{{ p.comments |length }} commentaires
|
||||
</span>
|
||||
{% if p.password |length %}
|
||||
(accès avec mot de passe)
|
||||
{% else %}
|
||||
{% endif %}
|
||||
|
||||
<br>
|
||||
|
||||
<div class="public">
|
||||
<span>
|
||||
lien à donner aux votants:
|
||||
</span>
|
||||
{% if p.customUrl |length %}
|
||||
<a href="{{ BASE_URL }}/poll/{{ p.customUrl }}">
|
||||
{{ BASE_URL }}/poll/{{ p.customUrl }}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ BASE_URL }}/poll/{{ p.customUrl }}">
|
||||
{{ BASE_URL }}/poll/{{ p.id }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="admin">
|
||||
<span>
|
||||
administration:
|
||||
</span>
|
||||
<a href="{{ BASE_URL }}/poll/{{ p.id }}/admin/{{ p.adminKey }}">{{ BASE_URL }}
|
||||
/admin/{{ p.adminKey }}</a>
|
||||
</div>
|
||||
{% include 'emails/partial/poll.html.twig' %}
|
||||
|
||||
|
||||
</li>
|
||||
|
2
templates/emails/partial/admin_link.html.twig
Normal file
2
templates/emails/partial/admin_link.html.twig
Normal file
@ -0,0 +1,2 @@
|
||||
<a href="{{ BASE_URL }}/poll/{{ poll.id }}/admin/{{ poll.adminKey }}">{{ BASE_URL }}
|
||||
/admin/{{ poll.adminKey }}</a>
|
39
templates/emails/partial/poll.html.twig
Normal file
39
templates/emails/partial/poll.html.twig
Normal file
@ -0,0 +1,39 @@
|
||||
<div class="poll">
|
||||
<h1>
|
||||
Sondage {{ poll.title }}
|
||||
</h1>
|
||||
|
||||
|
||||
<br>
|
||||
<div class="creation">
|
||||
créé le {{ poll.creationDate| date('Y m d ') }}
|
||||
</div>
|
||||
<div class="creation">
|
||||
expirera le {{ poll.expiracyDate| date('Y m d ') }}
|
||||
</div>
|
||||
<span class="votes-count">
|
||||
{{ poll.stacksOfVotes |length }} votes
|
||||
</span>
|
||||
<span class="votes-count">
|
||||
{{ poll.comments |length }} commentaires
|
||||
</span>
|
||||
{% if poll.password |length %}
|
||||
(accès avec mot de passe)
|
||||
{% else %}
|
||||
{% endif %}
|
||||
|
||||
<br>
|
||||
|
||||
<div class="public">
|
||||
<span>
|
||||
lien à donner aux votants:
|
||||
</span>
|
||||
{% include 'public_link.html.twig' %}
|
||||
</div>
|
||||
<div class="admin">
|
||||
<span>
|
||||
administration:
|
||||
</span>
|
||||
{% include 'admin_link.html.twig' %}
|
||||
</div>
|
||||
</div>
|
11
templates/emails/partial/public_link.html.twig
Normal file
11
templates/emails/partial/public_link.html.twig
Normal file
@ -0,0 +1,11 @@
|
||||
<span class="public-link">
|
||||
{% if poll.customUrl |length %}
|
||||
<a href="{{ BASE_URL }}/#/vote/poll/key/{{ poll.customUrl }}">
|
||||
{{ BASE_URL }}/#/vote/poll/key/{{ poll.customUrl }}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ BASE_URL }}/#/vote/poll/id/{{ poll.id }}">
|
||||
{{ BASE_URL }}/#/vote/poll/id/{{ poll.id }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</span>
|
Loading…
Reference in New Issue
Block a user