From 0d99e5ca2bab8bbf34124c57ea719b37d08205d0 Mon Sep 17 00:00:00 2001 From: Robbe Serry Date: Thu, 12 Oct 2023 12:34:17 +0000 Subject: [PATCH 1/6] calendar entity add eerstejaars/international --- migrations/Version20231012122945.php | 33 +++++++++++++ module/CalendarBundle/Entity/Node/Event.php | 54 +++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 migrations/Version20231012122945.php diff --git a/migrations/Version20231012122945.php b/migrations/Version20231012122945.php new file mode 100644 index 0000000000..29ce03f50c --- /dev/null +++ b/migrations/Version20231012122945.php @@ -0,0 +1,33 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE nodes_events ADD is_eerstejaars BOOLEAN DEFAULT \'false\''); + $this->addSql('ALTER TABLE nodes_events ADD is_international BOOLEAN DEFAULT \'false\''); + } + + /** + * @param \Doctrine\DBAL\Schema\Schema $schema + * @return void + */ + public function down(Schema $schema) : void + { + $this->throwIrreversibleMigrationException(); + } +} diff --git a/module/CalendarBundle/Entity/Node/Event.php b/module/CalendarBundle/Entity/Node/Event.php index 0aa3bc9328..e7a88d3772 100644 --- a/module/CalendarBundle/Entity/Node/Event.php +++ b/module/CalendarBundle/Entity/Node/Event.php @@ -76,6 +76,20 @@ class Event extends \CommonBundle\Entity\Node */ private $isCareer; + /** + * @var boolean The flag whether the article is a career event + * + * @ORM\Column(name="is_eerstejaars", type="boolean", nullable=true, options={"default" = false}) + */ + private $isEerstejaars; + + /** + * @var boolean The flag whether the article is a career event + * + * @ORM\Column(name="is_international", type="boolean", nullable=true, options={"default" = false}) + */ + private $isInternational; + /** * @param Person $person */ @@ -329,6 +343,46 @@ public function setIsCareer($isCareer) return $this; } + /** + * @return boolean + */ + public function isEerstejaars() + { + return $this->isEerstejaars; + } + + /** + * @param boolean $isEerstejaars + * + * @return self + */ + public function setIsEerstejaars($isEerstejaars) + { + $this->isEerstejaars = $isEerstejaars; + + return $this; + } + + /** + * @return boolean + */ + public function isInternational() + { + return $this->isInternational; + } + + /** + * @param boolean $isInternational + * + * @return self + */ + public function setIsInternational($isInternational) + { + $this->isInternational = $isInternational; + + return $this; + } + /** * @param EntityManager $em * @return \TicketBundle\Entity\Event From 4e45f47ade9491bd66e73ab35dd7b1fd5adeba69 Mon Sep 17 00:00:00 2001 From: Robbe Serry Date: Thu, 12 Oct 2023 12:34:42 +0000 Subject: [PATCH 2/6] calendar repository add eerstejaars/international --- .../CalendarBundle/Repository/Node/Event.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/module/CalendarBundle/Repository/Node/Event.php b/module/CalendarBundle/Repository/Node/Event.php index 40a4e6d1ae..0d6f4aa3dd 100644 --- a/module/CalendarBundle/Repository/Node/Event.php +++ b/module/CalendarBundle/Repository/Node/Event.php @@ -152,4 +152,62 @@ public function findAllCareerAndActiveAndNotHidden($nbResults = 15) return $query->getQuery()->getResult(); } + + public function findAllEerstejaarsAndActiveAndNotHidden($nbResults = 15) + { + $query = $this->getEntityManager()->createQueryBuilder(); + $query->select('e') + ->from('CalendarBundle\Entity\Node\Event', 'e') + ->where( + $query->expr()->andX( + $query->expr()->orX( + $query->expr()->gt('e.endDate', ':now'), + $query->expr()->gt('e.startDate', ':now'), + ), + $query->expr()->eq('e.isHistory', 'false'), + $query->expr()->eq('e.isEerstejaars', 'true'), + $query->expr()->orX( + $query->expr()->eq('e.isHidden', 'false'), + $query->expr()->isNull('e.isHidden') + ) + ) + ) + ->orderBy('e.startDate', 'ASC') + ->setParameter('now', new DateTime()); + + if ($nbResults > 0) { + $query->setMaxResults($nbResults); + } + + return $query->getQuery()->getResult(); + } + + public function findAllInternationalAndActiveAndNotHidden($nbResults = 15) + { + $query = $this->getEntityManager()->createQueryBuilder(); + $query->select('e') + ->from('CalendarBundle\Entity\Node\Event', 'e') + ->where( + $query->expr()->andX( + $query->expr()->orX( + $query->expr()->gt('e.endDate', ':now'), + $query->expr()->gt('e.startDate', ':now'), + ), + $query->expr()->eq('e.isHistory', 'false'), + $query->expr()->eq('e.isInternational', 'true'), + $query->expr()->orX( + $query->expr()->eq('e.isHidden', 'false'), + $query->expr()->isNull('e.isHidden') + ) + ) + ) + ->orderBy('e.startDate', 'ASC') + ->setParameter('now', new DateTime()); + + if ($nbResults > 0) { + $query->setMaxResults($nbResults); + } + + return $query->getQuery()->getResult(); + } } From a7bef05d92e8c77085e3e67e7726af14cae48ca3 Mon Sep 17 00:00:00 2001 From: Robbe Serry Date: Thu, 12 Oct 2023 12:35:22 +0000 Subject: [PATCH 3/6] calendar action add eerstejaars/international --- .../Controller/CalendarController.php | 36 +++++++++++++++++++ .../calendar/eerstejaars-calendar.twig | 0 .../calendar/international-calendar.twig | 0 3 files changed, 36 insertions(+) create mode 100644 module/CalendarBundle/Resources/views/calendar/calendar/eerstejaars-calendar.twig create mode 100644 module/CalendarBundle/Resources/views/calendar/calendar/international-calendar.twig diff --git a/module/CalendarBundle/Controller/CalendarController.php b/module/CalendarBundle/Controller/CalendarController.php index 82763a09a1..83159d39af 100644 --- a/module/CalendarBundle/Controller/CalendarController.php +++ b/module/CalendarBundle/Controller/CalendarController.php @@ -226,6 +226,42 @@ public function exportAction() ); } + public function eerstejaarsCalendarAction(){ + $events = $this->getEntityManager() + ->getRepository('CalendarBundle\Entity\Node\Event') + ->findAllEerstejaarsAndActiveAndNotHidden(); + + $calendarItems = array(); + foreach ($events as $event) { + $calendarItems[$event->getId()] = $event; + } + + return new ViewModel( + array( + 'entityManager' => $this->getEntityManager(), + 'calendarItems' => $calendarItems, + ) + ); + } + + public function internationalCalendarAction(){ + $events = $this->getEntityManager() + ->getRepository('CalendarBundle\Entity\Node\Event') + ->findAllEerstejaarsAndActiveAndNotHidden(); + + $calendarItems = array(); + foreach ($events as $event) { + $calendarItems[$event->getId()] = $event; + } + + return new ViewModel( + array( + 'entityManager' => $this->getEntityManager(), + 'calendarItems' => $calendarItems, + ) + ); + } + /** * @return Event|null */ diff --git a/module/CalendarBundle/Resources/views/calendar/calendar/eerstejaars-calendar.twig b/module/CalendarBundle/Resources/views/calendar/calendar/eerstejaars-calendar.twig new file mode 100644 index 0000000000..e69de29bb2 diff --git a/module/CalendarBundle/Resources/views/calendar/calendar/international-calendar.twig b/module/CalendarBundle/Resources/views/calendar/calendar/international-calendar.twig new file mode 100644 index 0000000000..e69de29bb2 From 0317d8c9f588220eb32a3e17fa81c94960094556 Mon Sep 17 00:00:00 2001 From: Robbe Serry Date: Thu, 12 Oct 2023 12:37:30 +0000 Subject: [PATCH 4/6] calendar form/hydr add eerstejaars/international --- module/CalendarBundle/Form/Admin/Event/Add.php | 16 ++++++++++++++++ module/CalendarBundle/Hydrator/Node/Event.php | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/module/CalendarBundle/Form/Admin/Event/Add.php b/module/CalendarBundle/Form/Admin/Event/Add.php index 4fbed7fffc..22a9001544 100644 --- a/module/CalendarBundle/Form/Admin/Event/Add.php +++ b/module/CalendarBundle/Form/Admin/Event/Add.php @@ -87,6 +87,22 @@ public function init() ) ); + $this->add( + array( + 'type' => 'checkbox', + 'name' => 'is_eerstejaars', + 'label' => 'Is Eerstejaars', + ) + ); + + $this->add( + array( + 'type' => 'checkbox', + 'name' => 'is_international', + 'label' => 'Is International', + ) + ); + $this->addSubmit('Add', 'calendar_add'); if ($this->getEvent() !== null) { diff --git a/module/CalendarBundle/Hydrator/Node/Event.php b/module/CalendarBundle/Hydrator/Node/Event.php index 2a8c8a1208..7bde790200 100644 --- a/module/CalendarBundle/Hydrator/Node/Event.php +++ b/module/CalendarBundle/Hydrator/Node/Event.php @@ -30,6 +30,8 @@ protected function doHydrate(array $data, $object = null) ->setEndDate(self::loadDateTime($data['end_date'])); $object->setIsHidden($data['is_hidden']); $object->setIsCareer($data['is_career']); + $object->setIsEerstejaars($data['is_eerstejaars']); + $object->setIsInternational($data['is_international']); foreach ($this->getLanguages() as $language) { $translation = $object->getTranslation($language, false); @@ -73,6 +75,8 @@ protected function doExtract($object = null) } $data['is_hidden'] = $object->isHidden(); $data['is_career'] = $object->isCareer(); + $data['is_eerstejaars'] = $object->isEerstejaars(); + $data['is_international'] = $object->isInternational(); foreach ($this->getLanguages() as $language) { $data['tab_content']['tab_' . $language->getAbbrev()]['title'] = $object->getTitle($language, false); From d99cd1cdefdef6047d9ee423dbb1bc715c8978ba Mon Sep 17 00:00:00 2001 From: Robbe Serry Date: Thu, 12 Oct 2023 12:47:34 +0000 Subject: [PATCH 5/6] calendar views add eerstejaars/international --- .../Controller/CalendarController.php | 2 +- .../calendar/eerstejaars-calendar.twig | 42 +++++++++++++++++++ .../calendar/international-calendar.twig | 42 +++++++++++++++++++ .../assets/site/less/vtk-homepage-layout.less | 2 + 4 files changed, 87 insertions(+), 1 deletion(-) diff --git a/module/CalendarBundle/Controller/CalendarController.php b/module/CalendarBundle/Controller/CalendarController.php index 83159d39af..7178b7a371 100644 --- a/module/CalendarBundle/Controller/CalendarController.php +++ b/module/CalendarBundle/Controller/CalendarController.php @@ -247,7 +247,7 @@ public function eerstejaarsCalendarAction(){ public function internationalCalendarAction(){ $events = $this->getEntityManager() ->getRepository('CalendarBundle\Entity\Node\Event') - ->findAllEerstejaarsAndActiveAndNotHidden(); + ->findAllInternationalAndActiveAndNotHidden(); $calendarItems = array(); foreach ($events as $event) { diff --git a/module/CalendarBundle/Resources/views/calendar/calendar/eerstejaars-calendar.twig b/module/CalendarBundle/Resources/views/calendar/calendar/eerstejaars-calendar.twig index e69de29bb2..337356e2ed 100644 --- a/module/CalendarBundle/Resources/views/calendar/calendar/eerstejaars-calendar.twig +++ b/module/CalendarBundle/Resources/views/calendar/calendar/eerstejaars-calendar.twig @@ -0,0 +1,42 @@ +{% extends 'site/base.twig' %} + +{% block content %} +
+
+

{{ translate('First years Calendar') }}

+
+
+ +
+ + {% if calendarItems|length != 0 %} +
+
+ {% for event in calendarItems %} +
+
+
+

{{ event.getTitle(language) }} + | {{ dateLocalized(event.getStartDate(), 'LLL')|capitalize }} {{ dateLocalized(event.getStartDate(), 'd') }}

+

{{ event.getSummary(150, language) }}

+
+ {{ translate('Read More') }} + {% if event.hasTicket(entityManager) == true and event.getTicket(entityManager).isVisible() %} + {{ translate('Buy Tickets') }} + {% endif %} +
+
+
+ {% endfor %} +
+
+ {% else %} +
+

{{ translate('There are no upcoming first year events.') }}

+
+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/module/CalendarBundle/Resources/views/calendar/calendar/international-calendar.twig b/module/CalendarBundle/Resources/views/calendar/calendar/international-calendar.twig index e69de29bb2..15367a9159 100644 --- a/module/CalendarBundle/Resources/views/calendar/calendar/international-calendar.twig +++ b/module/CalendarBundle/Resources/views/calendar/calendar/international-calendar.twig @@ -0,0 +1,42 @@ +{% extends 'site/base.twig' %} + +{% block content %} +
+
+

{{ translate('International Calendar') }}

+
+
+ +
+ + {% if calendarItems|length != 0 %} +
+
+ {% for event in calendarItems %} +
+
+
+

{{ event.getTitle(language) }} + | {{ dateLocalized(event.getStartDate(), 'LLL')|capitalize }} {{ dateLocalized(event.getStartDate(), 'd') }}

+

{{ event.getSummary(150, language) }}

+
+ {{ translate('Read More') }} + {% if event.hasTicket(entityManager) == true and event.getTicket(entityManager).isVisible() %} + {{ translate('Buy Tickets') }} + {% endif %} +
+
+
+ {% endfor %} +
+
+ {% else %} +
+

{{ translate('There are no upcoming International events.') }}

+
+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/module/CommonBundle/Resources/assets/site/less/vtk-homepage-layout.less b/module/CommonBundle/Resources/assets/site/less/vtk-homepage-layout.less index c00970b356..4367b35aab 100644 --- a/module/CommonBundle/Resources/assets/site/less/vtk-homepage-layout.less +++ b/module/CommonBundle/Resources/assets/site/less/vtk-homepage-layout.less @@ -162,6 +162,8 @@ margin-bottom: 50px } +.container.eerstejaarsCalendarHolder +.container.internationalCalendarHolder .container.careerCalendarHolder { position: relative; padding: 20px 15px; From c7bcf270259f40dd1e9055dfea41a8d300872770 Mon Sep 17 00:00:00 2001 From: Robbe Serry Date: Thu, 12 Oct 2023 12:51:17 +0000 Subject: [PATCH 6/6] calendar translations add eerstejaars/international --- module/CalendarBundle/Resources/translations/common.en.php | 4 ++++ module/CalendarBundle/Resources/translations/common.nl.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/module/CalendarBundle/Resources/translations/common.en.php b/module/CalendarBundle/Resources/translations/common.en.php index 9a3c5aa312..f2a448e762 100644 --- a/module/CalendarBundle/Resources/translations/common.en.php +++ b/module/CalendarBundle/Resources/translations/common.en.php @@ -7,4 +7,8 @@ 'Download' => 'Download', 'Shifts' => 'Shifts', 'Tickets' => 'Tickets', + 'First years Calendar' => 'First years Calendar', + 'International Calendar' => 'International Calendar', + 'There are no upcoming first year events.' => 'There are no upcoming first year events.', + 'There are no upcoming international events.' => 'There are no upcoming international events.', ); diff --git a/module/CalendarBundle/Resources/translations/common.nl.php b/module/CalendarBundle/Resources/translations/common.nl.php index 353993f889..72fa0d049d 100644 --- a/module/CalendarBundle/Resources/translations/common.nl.php +++ b/module/CalendarBundle/Resources/translations/common.nl.php @@ -7,4 +7,8 @@ 'Download' => 'Download', 'Shifts' => 'Shiften', 'Tickets' => 'Tickets', + 'First years Calendar' => 'Eerstejaarskalender', + 'International Calendar' => 'Internationaal Kalender', + 'There are no upcoming first year events.' => 'Er zijn geen komende eerstejaarsevenementen.', + 'There are no upcoming international events.' => 'Er zijn geen komende internationaal evenementen.', );