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/Controller/CalendarController.php b/module/CalendarBundle/Controller/CalendarController.php index 82763a09a1..7178b7a371 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') + ->findAllInternationalAndActiveAndNotHidden(); + + $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/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 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); 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(); + } } 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.', ); 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..337356e2ed --- /dev/null +++ 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 new file mode 100644 index 0000000000..15367a9159 --- /dev/null +++ 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;