Skip to content

Commit

Permalink
Merge branch 'dev-eerstejaars-international-calendar'
Browse files Browse the repository at this point in the history
  • Loading branch information
rserry committed Oct 12, 2023
2 parents 171cb79 + c7bcf27 commit d3cb770
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 0 deletions.
33 changes: 33 additions & 0 deletions migrations/Version20231012122945.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);

namespace Migrations;

use Doctrine\DBAL\Schema\Schema;

/**
* Version 20231012122945
*/
class Version20231012122945 extends \Doctrine\Migrations\AbstractMigration
{
/**
* @param \Doctrine\DBAL\Schema\Schema $schema
* @return void
*/
public function up(Schema $schema) : void
{
$this->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();
}
}
36 changes: 36 additions & 0 deletions module/CalendarBundle/Controller/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
54 changes: 54 additions & 0 deletions module/CalendarBundle/Entity/Node/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions module/CalendarBundle/Form/Admin/Event/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions module/CalendarBundle/Hydrator/Node/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
58 changes: 58 additions & 0 deletions module/CalendarBundle/Repository/Node/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
4 changes: 4 additions & 0 deletions module/CalendarBundle/Resources/translations/common.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
4 changes: 4 additions & 0 deletions module/CalendarBundle/Resources/translations/common.nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% extends 'site/base.twig' %}

{% block content %}
<div class="container">
<div class="standardPageTitleHolder">
<h1>{{ translate('First years Calendar') }}</h1>
<div class="pageTitleDeco"></div>
</div>

<div style="height: 20px"></div>

{% if calendarItems|length != 0 %}
<div class="eerstejaarsCalendarHolder">
<div class="calendar-grid" style="margin-bottom: 40px">
{% for event in calendarItems %}
<div style="position: relative" class="calendar-item">
<div class="DELETE-BGIMAGE"
style="background-image:url({{ url('calendar',{'action':'poster', 'name': event.getPoster()}) }})"></div>
<div class="calendar-item-tekst">
<h4>{{ event.getTitle(language) }}
| {{ dateLocalized(event.getStartDate(), 'LLL')|capitalize }} {{ dateLocalized(event.getStartDate(), 'd') }} </h4>
<p class="calendar-emptyfill">{{ event.getSummary(150, language) }}</p>
<div class="vtk-flex-horizontal" style="position: absolute; bottom: -10px">
<a class="myVtkButton"
href="{{ url('calendar', {'action': 'view', 'name': event.getName()}) }}">{{ translate('Read More') }}</a>
{% if event.hasTicket(entityManager) == true and event.getTicket(entityManager).isVisible() %}
<a class="myVtkButton"
href="{{ url('ticket', {'id': event.getTicket(entityManager).getRandId()}) }}">{{ translate('Buy Tickets') }}</a>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% else %}
<div>
<h4>{{ translate('There are no upcoming first year events.') }}</h4>
</div>
{% endif %}
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% extends 'site/base.twig' %}

{% block content %}
<div class="container">
<div class="standardPageTitleHolder">
<h1>{{ translate('International Calendar') }}</h1>
<div class="pageTitleDeco"></div>
</div>

<div style="height: 20px"></div>

{% if calendarItems|length != 0 %}
<div class="internationalCalendarHolder">
<div class="calendar-grid" style="margin-bottom: 40px">
{% for event in calendarItems %}
<div style="position: relative" class="calendar-item">
<div class="DELETE-BGIMAGE"
style="background-image:url({{ url('calendar',{'action':'poster', 'name': event.getPoster()}) }})"></div>
<div class="calendar-item-tekst">
<h4>{{ event.getTitle(language) }}
| {{ dateLocalized(event.getStartDate(), 'LLL')|capitalize }} {{ dateLocalized(event.getStartDate(), 'd') }} </h4>
<p class="calendar-emptyfill">{{ event.getSummary(150, language) }}</p>
<div class="vtk-flex-horizontal" style="position: absolute; bottom: -10px">
<a class="myVtkButton"
href="{{ url('calendar', {'action': 'view', 'name': event.getName()}) }}">{{ translate('Read More') }}</a>
{% if event.hasTicket(entityManager) == true and event.getTicket(entityManager).isVisible() %}
<a class="myVtkButton"
href="{{ url('ticket', {'id': event.getTicket(entityManager).getRandId()}) }}">{{ translate('Buy Tickets') }}</a>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% else %}
<div>
<h4>{{ translate('There are no upcoming International events.') }}</h4>
</div>
{% endif %}
</div>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
margin-bottom: 50px
}

.container.eerstejaarsCalendarHolder
.container.internationalCalendarHolder
.container.careerCalendarHolder {
position: relative;
padding: 20px 15px;
Expand Down

0 comments on commit d3cb770

Please sign in to comment.