Skip to content

Commit

Permalink
Handling title-changing amendments when merging only one amendment
Browse files Browse the repository at this point in the history
  • Loading branch information
CatoTH committed Sep 18, 2023
1 parent 8300910 commit 65c2b0b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
6 changes: 2 additions & 4 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
- The motion list can now be filtered for To Do items (that is, motions/amendments that need to be screened) and also shows the To Do action for items on that list as part of the Status.
- The motion list now persists its filter and sort settings for each user session, until changed or reset.
- If an amendment is set to show the full text by default, this now also affects the PDF export.
- Merging a single amendment into a motion now also handles amendments only changing the title of the motion.
- The maintenance mode page is now specific to a consultation; that is, delegates bookmarking a link to a consultation that is still in maintenance mode can open that bookmark later and get to theat very consultation, not the generic home page.
- Bugfix: If a draft of a revised motion (by merging amendments) existed and the motion list was opened, the original motion was not shown anymore by default.
- Bugfix: Some edge cases around uploaded logos breaking the PDF export or not being shown on the page were resolved.
- Bugfix: Super-admins could lock themselves out of protected consultations.
- Bugfix: Putting a active speaker back into the speaking waiting list did not work - the speaker vanished from the list completely.
- Bugfix: Closing the full screen mode of a speaking list was leading to an error page.

### Version 4.12.1 [not released yet]

- The maintenance mode page is now specific to a consultation; that is, delegates bookmarking a link to a consultation that is still in maintenance mode can open that bookmark later and get to theat very consultation, not the generic home page.
- Bugfix: If not-logged-in users are allowed to support motions/amendments, they showed up as empty bullet points in the supporter list. Now they have to enter their name.
- Bugfix: The delete button in the admin motion list was shown even if no delete permissions were granted and it was therefore non-functional.
- Bugfix: If a motion collecting supporters was edited by an admin, then no publication mail was sent later when it was actually published.
Expand Down
2 changes: 1 addition & 1 deletion controllers/AmendmentMergingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function actionMerge(string $motionSlug, int $amendmentId): ResponseInter
$this->getPostValue('motionTitlePrefix'),
$this->getPostValue('motionVersion'),
$this->getPostValue('amendmentStatus'),
$this->getPostValue('newParas'),
$this->getPostValue('newParas', []),
$this->getPostValue('amendmentOverride', []),
$newAmendmentStatuses
);
Expand Down
44 changes: 22 additions & 22 deletions models/forms/MergeSingleAmendmentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,18 @@ class MergeSingleAmendmentForm
{
public Motion $oldMotion;
public ?Motion $newMotion = null;
public string $newTitlePrefix;
public string $newVersion;
public Amendment $mergeAmendment;
public int $mergeAmendStatus;
public array $otherAmendStatuses;
public array $otherAmendOverrides;
public array $paragraphs;

public function __construct(
Amendment $amendment,
string $newTitlePrefix,
string $newVersion,
int $newStatus,
array $paragraphs,
array $otherAmendOverrides,
array $otherAmendStatuses
public Amendment $mergeAmendment,
public string $newTitlePrefix,
public string $newVersion,
public int $mergeAmendStatus,
public array $paragraphs,
public array $otherAmendOverrides,
public array $otherAmendStatuses
)
{
$this->newTitlePrefix = $newTitlePrefix;
$this->newVersion = $newVersion;
$this->oldMotion = $amendment->getMyMotion();
$this->mergeAmendment = $amendment;
$this->mergeAmendStatus = $newStatus;
$this->paragraphs = $paragraphs;
$this->otherAmendStatuses = $otherAmendStatuses;
$this->otherAmendOverrides = $otherAmendOverrides;
$this->oldMotion = $mergeAmendment->getMyMotion();
}

private function getNewHtmlParas(): array
Expand Down Expand Up @@ -141,6 +127,9 @@ private function createNewMotionSections(): void
$newSection->dataRaw = '';
}
}
if ($section->getSettings()->type === ISectionType::TYPE_TITLE && $this->mergeAmendment->getSection($section->sectionId)) {
$newSection->setData($this->mergeAmendment->getSection($section->sectionId)->getData());
}
if (!$newSection->save()) {
throw new DB($newSection->getErrors());
}
Expand Down Expand Up @@ -175,6 +164,15 @@ private function rewriteOtherAmendments(): void
throw new DB($section->getErrors());
}
}
foreach ($amendment->getActiveSections(ISectionType::TYPE_TITLE) as $section) {
foreach ($this->oldMotion->sections as $motionSection) {
if ($motionSection->sectionId === $section->sectionId && $motionSection->getData() === $section->getData() && $this->mergeAmendment->getSection($section->sectionId)) {
// Change the title of amendments that didn't try to change the title of the motion
$section->setData($this->mergeAmendment->getSection($section->sectionId)->getData());
$section->save();
}
}
}
$amendment->motionId = $this->newMotion->id;
$amendment->cache = '';
$amendment->status = $this->otherAmendStatuses[$amendment->id];
Expand Down Expand Up @@ -232,6 +230,8 @@ public function performRewrite(): Motion
$consultation->save();
}

$this->newMotion->refreshTitle();
$this->newMotion->save();
$this->newMotion->trigger(Motion::EVENT_MERGED, new MotionEvent($this->newMotion));

return $this->newMotion;
Expand Down

0 comments on commit 65c2b0b

Please sign in to comment.