1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00

fixture with polls and owner

This commit is contained in:
Baptiste Lemoine 2019-11-05 17:22:30 +01:00
parent 85f643bcce
commit 452083c74c
4 changed files with 305 additions and 87 deletions

View File

@ -131,4 +131,23 @@ class DefaultController extends AbstractController {
] );
}
public function deletePollAction() {
return $this->json( [
'message' => 'boom',
] );
}
public function deletePollCommentsAction() {
return $this->json( [
'message' => 'boom',
] );
}
public function deletePollVotesAction() {
return $this->json( [
'message' => 'boom',
] );
}
}

View File

@ -2,21 +2,65 @@
namespace App\DataFixtures;
use App\Entity\Owner;
use App\Entity\Poll;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
class AppPollFixtures extends Fixture {
public function load( ObjectManager $manager ) {
$owner = new Owner();
$owner->setEmail( 'tktest@tktest.com' )
->setPseudo( 'tk_TEST' );
// $product = new Product();
$poll = new Poll();
$poll->setTitle( 'démo sondage de texte' );
$poll->setKind( 'text' );
$poll->setDescription( 'description du sondage' );
$poll->setAdminKey( 'dskjfsfdljkdsjlkdsfkjdsjdlkfs' );
$poll->setModificationPolicy( 'nobody' );
$poll->setCreationDate( new \DateTime() );
$poll->setExpiracyDate( new \DateTime( ( time() + 3600 * 24 ) ) );
$poll->setExpiracyDate( new \DateTime() );
$poll->setMailOnVote( true );
$poll->setOwner( $owner );
$owner->addPoll( $poll );
$manager->persist( $poll );
$poll = new Poll();
$poll->setTitle( 'démo sondage de texte 2' );
$poll->setDescription( 'description du sondage 2' );
$poll->setKind( 'date' );
$poll->setAdminKey( 'dskjfsfdljkdsjlkdsfkjdsjdlkfs' );
$poll->setModificationPolicy( 'self' );
$poll->setMailOnComment( true );
$poll->setCreationDate( new \DateTime() );
$poll->setExpiracyDate( new \DateTime() );
$poll->setOwner( $owner );
$owner->addPoll( $poll );
$manager->persist( $poll );
$poll = new Poll();
$poll->setTitle( 'accès restreint sondage de texte' );
$poll->setKind( 'text' );
$poll->setPassword( md5( 'mot_de_passe_super' ) );
$poll->setModificationPolicy( 'everybody' );
$poll->setDescription( 'description du sondage' );
$poll->setAdminKey( 'dskjfsfdljkdsjlkdsfkjdsjdlkfs' );
$poll->setCreationDate( new \DateTime() );
$poll->setExpiracyDate( new \DateTime() );
$poll->setMailOnComment( true );
$poll->setMailOnVote( true );
$poll->setOwner( $owner );
$owner->addPoll( $poll );
$manager->persist( $poll );
$manager->persist( $owner );
$manager->flush();
}
}

View File

@ -21,6 +21,20 @@ class Poll {
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $customUrl;
/**
* vote restricted by a password
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $password;
/**
* @ORM\Column(type="string", length=1000)
*/
private $description;
/**
* @ORM\Column(type="datetime")
@ -43,89 +57,218 @@ class Poll {
* @ORM\Column(type="string", length=255)
*/
private $adminKey;
/**
* kind of poll, text or date
* @ORM\Column(type="string", length=255)
*/
private $kind;
/**
* kind of way the people can modify the poll
* everybody - can modify votes
* self - one can only modify its own vote
* nobody - no one can modify the votes (excepted admin), pray to have it right at first
* @ORM\Column(type="string", length=255)
*/
private $modificationPolicy;
/**
* send a mail on a new comment
* @ORM\Column(type="boolean", nullable=true)
*/
private $mailOnComment;
/**
* send a mail on a new vote
* @ORM\Column(type="boolean", nullable=true)
*/
private $mailOnVote;
/**
* hide publicly results
* @ORM\Column(type="boolean", nullable=true)
*/
private $hideResults;
/**
* show publicly results even if there is a password to access the vote
* @ORM\Column(type="boolean", nullable=true)
*/
private $showResultEvenIfPasswords;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Vote", mappedBy="poll", orphanRemoval=true)
*/
private $votes;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Vote", mappedBy="poll", orphanRemoval=true)
*/
private $votes;
public function __construct()
{
$this->votes = new ArrayCollection();
}
public function __construct() {
$this->votes = new ArrayCollection();
}
public function getId(): ?int {
return $this->id;
}
return $this->id;
}
public function getTitle(): ?string {
return $this->title;
}
return $this->title;
}
public function setTitle( string $title ): self {
$this->title = $title;
return $this;
}
$this->title = $title;
return $this;
}
public function getCreationDate(): ?\DateTimeInterface {
return $this->creationDate;
}
return $this->creationDate;
}
public function setCreationDate( \DateTimeInterface $creationDate ): self {
$this->creationDate = $creationDate;
return $this;
}
$this->creationDate = $creationDate;
return $this;
}
public function getExpiracyDate(): ?\DateTimeInterface {
return $this->expiracyDate;
}
return $this->expiracyDate;
}
public function setExpiracyDate( \DateTimeInterface $expiracyDate ): self {
$this->expiracyDate = $expiracyDate;
return $this;
}
$this->expiracyDate = $expiracyDate;
return $this;
}
public function getOwner(): ?Owner {
return $this->owner;
}
return $this->owner;
}
public function setOwner( ?Owner $owner ): self {
$this->owner = $owner;
return $this;
}
$this->owner = $owner;
/**
* @return Collection|Vote[]
*/
public function getVotes(): Collection
{
return $this->votes;
}
return $this;
}
public function addVote(Vote $vote): self
{
if (!$this->votes->contains($vote)) {
$this->votes[] = $vote;
$vote->setPoll($this);
}
/**
* @return Collection|Vote[]
*/
public function getVotes(): Collection {
return $this->votes;
}
return $this;
}
public function addVote( Vote $vote ): self {
if ( ! $this->votes->contains( $vote ) ) {
$this->votes[] = $vote;
$vote->setPoll( $this );
}
public function removeVote(Vote $vote): self
{
if ($this->votes->contains($vote)) {
$this->votes->removeElement($vote);
// set the owning side to null (unless already changed)
if ($vote->getPoll() === $this) {
$vote->setPoll(null);
}
}
return $this;
}
return $this;
}
public function removeVote( Vote $vote ): self {
if ( $this->votes->contains( $vote ) ) {
$this->votes->removeElement( $vote );
// set the owning side to null (unless already changed)
if ( $vote->getPoll() === $this ) {
$vote->setPoll( null );
}
}
return $this;
}
public function getAdminKey(): ?string {
return $this->adminKey;
}
public function setAdminKey( string $adminKey ): self {
$this->adminKey = $adminKey;
return $this;
}
public function getDescription(): ?string {
return $this->description;
}
public function setDescription( string $description ): self {
$this->description = $description;
return $this;
}
public function getKind(): ?string {
return $this->kind;
}
public function setKind( string $kind ): self {
$this->kind = $kind;
return $this;
}
public function getCustomUrl(): ?string {
return $this->customUrl;
}
public function setCustomUrl( string $customUrl ): self {
$this->customUrl = $customUrl;
return $this;
}
public function getPassword(): ?string {
return $this->password;
}
public function setPassword( string $password ): self {
$this->password = $password;
return $this;
}
public function getModificationPolicy(): ?string {
return $this->modificationPolicy;
}
public function setModificationPolicy( string $modificationPolicy ): self {
$this->modificationPolicy = $modificationPolicy;
return $this;
}
public function getMailOnComment(): ?bool {
return $this->mailOnComment;
}
public function setMailOnComment( bool $mailOnComment ): self {
$this->mailOnComment = $mailOnComment;
return $this;
}
public function getMailOnVote(): ?bool {
return $this->mailOnVote;
}
public function setMailOnVote( bool $mailOnVote ): self {
$this->mailOnVote = $mailOnVote;
return $this;
}
public function getHideResults(): ?bool {
return $this->hideResults;
}
public function setHideResults( bool $hideResults ): self {
$this->hideResults = $hideResults;
return $this;
}
public function getShowResultEvenIfPasswords(): ?bool {
return $this->showResultEvenIfPasswords;
}
public function setShowResultEvenIfPasswords( bool $showResultEvenIfPasswords ): self {
$this->showResultEvenIfPasswords = $showResultEvenIfPasswords;
return $this;
}
}

View File

@ -41,46 +41,58 @@ class Vote {
private $poll;
public function getId(): ?int {
return $this->id;
}
return $this->id;
}
public function getAnswerTxt(): ?string {
return $this->answerTxt;
}
return $this->answerTxt;
}
public function setAnswerTxt( ?string $answerTxt ): self {
$this->answerTxt = $answerTxt;
return $this;
}
$this->answerTxt = $answerTxt;
return $this;
}
public function getAnswerDate(): ?\DateTimeInterface {
return $this->answerDate;
}
return $this->answerDate;
}
public function setAnswerDate( ?\DateTimeInterface $answerDate ): self {
$this->answerDate = $answerDate;
return $this;
}
$this->answerDate = $answerDate;
return $this;
}
public function getCreationDate(): ?\DateTimeInterface {
return $this->creationDate;
}
return $this->creationDate;
}
public function setCreationDate( \DateTimeInterface $creationDate ): self {
$this->creationDate = $creationDate;
return $this;
}
$this->creationDate = $creationDate;
return $this;
}
public function getPoll(): ?Poll {
return $this->poll;
}
return $this->poll;
}
public function setPoll( ?Poll $poll ): self {
$this->poll = $poll;
$this->poll = $poll;
return $this;
}
return $this;
}
public function getPseudo(): ?string
{
return $this->pseudo;
}
public function setPseudo(?string $pseudo): self
{
$this->pseudo = $pseudo;
return $this;
}
}