Skip to content
Snippets Groups Projects
Commit af9ddb96 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Jan-Hendrik Willms
Browse files

fix creation and deletion of consultation events, fixes #982

Closes #982

Merge request studip/studip!971
parent 2ee736d8
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* @property bool has_bookings computed column * @property bool has_bookings computed column
* @property Range range computed column * @property Range range computed column
* @property SimpleORMapCollection slots has_many ConsultationSlot * @property SimpleORMapCollection slots has_many ConsultationSlot
* @property ConsultationResponsibility[] responsibilities has_many ConsultationResponsibility * @property ConsultationResponsibility[]|SimpleCollection responsibilities has_many ConsultationResponsibility
* @property User[] responsible_persons * @property User[] responsible_persons
*/ */
class ConsultationBlock extends SimpleORMap implements PrivacyObject class ConsultationBlock extends SimpleORMap implements PrivacyObject
......
...@@ -22,7 +22,7 @@ class ConsultationEvent extends SimpleORMap ...@@ -22,7 +22,7 @@ class ConsultationEvent extends SimpleORMap
'class_name' => ConsultationSlot::class, 'class_name' => ConsultationSlot::class,
'foreign_key' => 'slot_id', 'foreign_key' => 'slot_id',
]; ];
$config['belongs_to']['event'] = [ $config['has_one']['event'] = [
'class_name' => EventData::class, 'class_name' => EventData::class,
'foreign_key' => 'event_id', 'foreign_key' => 'event_id',
'assoc_foreign_key' => 'event_id', 'assoc_foreign_key' => 'event_id',
......
...@@ -193,6 +193,10 @@ class ConsultationSlot extends SimpleORMap ...@@ -193,6 +193,10 @@ class ConsultationSlot extends SimpleORMap
*/ */
public function updateEvents() public function updateEvents()
{ {
if ($this->isNew()) {
return;
}
// If no range is associated, remove the event // If no range is associated, remove the event
if (!$this->block->range) { if (!$this->block->range) {
$this->events->delete(); $this->events->delete();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment