-
Notifications
You must be signed in to change notification settings - Fork 2
Feature:add new formatters for Tickets #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andrestejerina97
wants to merge
3
commits into
main
Choose a base branch
from
feature/add-ticket-formatters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+917
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
app/Audit/ConcreteFormatters/PrePaidSummitRegistrationDiscountCodeAuditLogFormatter.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| <?php | ||
|
|
||
| namespace App\Audit\ConcreteFormatters; | ||
|
|
||
| /** | ||
| * Copyright 2026 OpenStack Foundation | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| **/ | ||
|
|
||
| use App\Audit\AbstractAuditLogFormatter; | ||
| use App\Audit\Interfaces\IAuditStrategy; | ||
| use models\summit\PrePaidSummitRegistrationDiscountCode; | ||
| use Illuminate\Support\Facades\Log; | ||
|
|
||
| class PrePaidSummitRegistrationDiscountCodeAuditLogFormatter extends AbstractAuditLogFormatter | ||
| { | ||
| public function format($subject, array $change_set): ?string | ||
| { | ||
| if (!$subject instanceof PrePaidSummitRegistrationDiscountCode) { | ||
| return null; | ||
| } | ||
|
|
||
| try { | ||
| $code = $subject->getCode() ?? 'Unknown'; | ||
| $id = $subject->getId() ?? 'unknown'; | ||
| $summit = $subject->getSummit(); | ||
| $summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit'; | ||
|
|
||
| switch ($this->event_type) { | ||
| case IAuditStrategy::EVENT_ENTITY_CREATION: | ||
| return sprintf( | ||
| "Pre-Paid Discount Code '%s' (%d) created for Summit '%s' by user %s", | ||
| $code, | ||
| $id, | ||
| $summit_name, | ||
| $this->getUserInfo() | ||
| ); | ||
|
|
||
| case IAuditStrategy::EVENT_ENTITY_UPDATE: | ||
| $change_details = $this->buildChangeDetails($change_set); | ||
| return sprintf( | ||
| "Pre-Paid Discount Code '%s' (%d) for Summit '%s' updated: %s by user %s", | ||
| $code, | ||
| $id, | ||
| $summit_name, | ||
| $change_details, | ||
| $this->getUserInfo() | ||
| ); | ||
|
|
||
| case IAuditStrategy::EVENT_ENTITY_DELETION: | ||
| return sprintf( | ||
| "Pre-Paid Discount Code '%s' (%d) for Summit '%s' was deleted by user %s", | ||
| $code, | ||
| $id, | ||
| $summit_name, | ||
| $this->getUserInfo() | ||
| ); | ||
| } | ||
| } catch (\Exception $ex) { | ||
| Log::warning("PrePaidSummitRegistrationDiscountCodeAuditLogFormatter error: " . $ex->getMessage()); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
79 changes: 79 additions & 0 deletions
79
app/Audit/ConcreteFormatters/SummitRefundPolicyTypeAuditLogFormatter.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| <?php | ||
|
|
||
| namespace App\Audit\ConcreteFormatters; | ||
|
|
||
| /** | ||
| * Copyright 2026 OpenStack Foundation | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| **/ | ||
|
|
||
| use App\Audit\AbstractAuditLogFormatter; | ||
| use App\Audit\Interfaces\IAuditStrategy; | ||
| use models\summit\SummitRefundPolicyType; | ||
| use Illuminate\Support\Facades\Log; | ||
|
|
||
| class SummitRefundPolicyTypeAuditLogFormatter extends AbstractAuditLogFormatter | ||
| { | ||
| public function format($subject, array $change_set): ?string | ||
| { | ||
| if (!$subject instanceof SummitRefundPolicyType) { | ||
| return null; | ||
| } | ||
|
|
||
| try { | ||
| $name = $subject->getName() ?? 'Unknown'; | ||
| $id = $subject->getId() ?? 'unknown'; | ||
| $summit = $subject->getSummit(); | ||
| $summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit'; | ||
| $days_before = $subject->getUntilXDaysBeforeEventStarts(); | ||
| $refund_rate = $subject->getRefundRate(); | ||
|
|
||
| switch ($this->event_type) { | ||
| case IAuditStrategy::EVENT_ENTITY_CREATION: | ||
| return sprintf( | ||
| "Refund Policy '%s' (%d) created for Summit '%s': %s%% refund if cancelled %s days before event by user %s", | ||
| $name, | ||
| $id, | ||
| $summit_name, | ||
| ($refund_rate !== null ? sprintf("%.0f", $refund_rate) : 'N/A'), | ||
| ($days_before !== null ? $days_before : 'N/A'), | ||
| $this->getUserInfo() | ||
| ); | ||
|
|
||
| case IAuditStrategy::EVENT_ENTITY_UPDATE: | ||
| $change_details = $this->buildChangeDetails($change_set); | ||
| return sprintf( | ||
| "Refund Policy '%s' (%d) for Summit '%s' updated: %s by user %s", | ||
| $name, | ||
| $id, | ||
| $summit_name, | ||
| $change_details, | ||
| $this->getUserInfo() | ||
| ); | ||
|
|
||
| case IAuditStrategy::EVENT_ENTITY_DELETION: | ||
| return sprintf( | ||
| "Refund Policy '%s' (%d) for Summit '%s' (%s%% refund, %s days before) was deleted by user %s", | ||
| $name, | ||
| $id, | ||
| $summit_name, | ||
| ($refund_rate !== null ? sprintf("%.0f", $refund_rate) : 'N/A'), | ||
| ($days_before !== null ? $days_before : 'N/A'), | ||
| $this->getUserInfo() | ||
| ); | ||
| } | ||
| } catch (\Exception $ex) { | ||
| Log::warning("SummitRefundPolicyTypeAuditLogFormatter error: " . $ex->getMessage()); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } |
79 changes: 79 additions & 0 deletions
79
app/Audit/ConcreteFormatters/SummitTaxTypeAuditLogFormatter.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| <?php | ||
|
|
||
| namespace App\Audit\ConcreteFormatters; | ||
|
|
||
| /** | ||
| * Copyright 2026 OpenStack Foundation | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| **/ | ||
|
|
||
| use App\Audit\AbstractAuditLogFormatter; | ||
| use App\Audit\Interfaces\IAuditStrategy; | ||
| use models\summit\SummitTaxType; | ||
| use Illuminate\Support\Facades\Log; | ||
|
|
||
| class SummitTaxTypeAuditLogFormatter extends AbstractAuditLogFormatter | ||
| { | ||
| public function format($subject, array $change_set): ?string | ||
| { | ||
| if (!$subject instanceof SummitTaxType) { | ||
| return null; | ||
| } | ||
|
|
||
| try { | ||
| $name = $subject->getName() ?? 'Unknown'; | ||
| $id = $subject->getId() ?? 'unknown'; | ||
| $summit = $subject->getSummit(); | ||
| $summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit'; | ||
| $tax_id = $subject->getTaxId() ?? 'Not set'; | ||
| $rate = $subject->getRate(); | ||
|
|
||
| switch ($this->event_type) { | ||
| case IAuditStrategy::EVENT_ENTITY_CREATION: | ||
| return sprintf( | ||
| "Tax Type '%s' (%d) created for Summit '%s': Tax ID %s, rate %s by user %s", | ||
| $name, | ||
| $id, | ||
| $summit_name, | ||
| $tax_id, | ||
| ($rate !== null ? sprintf("%.2f%%", $rate) : 'N/A'), | ||
| $this->getUserInfo() | ||
| ); | ||
|
|
||
| case IAuditStrategy::EVENT_ENTITY_UPDATE: | ||
| $change_details = $this->buildChangeDetails($change_set); | ||
| return sprintf( | ||
| "Tax Type '%s' (%d) for Summit '%s' updated: %s by user %s", | ||
| $name, | ||
| $id, | ||
| $summit_name, | ||
| $change_details, | ||
| $this->getUserInfo() | ||
| ); | ||
|
|
||
| case IAuditStrategy::EVENT_ENTITY_DELETION: | ||
| return sprintf( | ||
| "Tax Type '%s' (%d) for Summit '%s' (Tax ID: %s, rate: %s) was deleted by user %s", | ||
| $name, | ||
| $id, | ||
| $summit_name, | ||
| $tax_id, | ||
| ($rate !== null ? sprintf("%.2f%%", $rate) : 'N/A'), | ||
| $this->getUserInfo() | ||
| ); | ||
| } | ||
| } catch (\Exception $ex) { | ||
| Log::warning("SummitTaxTypeAuditLogFormatter error: " . $ex->getMessage()); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } |
86 changes: 86 additions & 0 deletions
86
app/Audit/ConcreteFormatters/SummitTicketTypeAuditLogFormatter.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| <?php | ||
|
|
||
| namespace App\Audit\ConcreteFormatters; | ||
|
|
||
| /** | ||
| * Copyright 2026 OpenStack Foundation | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| **/ | ||
|
|
||
| use App\Audit\AbstractAuditLogFormatter; | ||
| use App\Audit\Interfaces\IAuditStrategy; | ||
| use models\summit\SummitTicketType; | ||
| use Illuminate\Support\Facades\Log; | ||
|
|
||
| class SummitTicketTypeAuditLogFormatter extends AbstractAuditLogFormatter | ||
| { | ||
| public function format($subject, array $change_set): ?string | ||
| { | ||
| if (!$subject instanceof SummitTicketType) { | ||
| return null; | ||
| } | ||
|
|
||
| try { | ||
| $name = $subject->getName() ?? 'Unknown'; | ||
| $id = $subject->getId() ?? 'unknown'; | ||
| $summit = $subject->getSummit(); | ||
| $summit_name = $summit ? ($summit->getName() ?? 'Unknown Summit') : 'Unknown Summit'; | ||
| $cost = $subject->getCost(); | ||
| $currency = $subject->getCurrency() ?? 'USD'; | ||
| $quantity_available = $subject->getQuantity2Sell(); | ||
| $audience = $subject->getAudience() ?? 'All'; | ||
|
|
||
| switch ($this->event_type) { | ||
| case IAuditStrategy::EVENT_ENTITY_CREATION: | ||
| return sprintf( | ||
| "Ticket Type '%s' (%d) created for Summit '%s': price %s %s, %s available, audience: %s by user %s", | ||
| $name, | ||
| $id, | ||
| $summit_name, | ||
| ($cost !== null ? $cost : 'N/A'), | ||
| $currency, | ||
| ($quantity_available !== null ? $quantity_available : 'N/A'), | ||
| $audience, | ||
| $this->getUserInfo() | ||
| ); | ||
|
|
||
| case IAuditStrategy::EVENT_ENTITY_UPDATE: | ||
| $change_details = $this->buildChangeDetails($change_set); | ||
| return sprintf( | ||
| "Ticket Type '%s' (%d) for Summit '%s' updated: %s by user %s", | ||
| $name, | ||
| $id, | ||
| $summit_name, | ||
| $change_details, | ||
| $this->getUserInfo() | ||
| ); | ||
|
|
||
| case IAuditStrategy::EVENT_ENTITY_DELETION: | ||
| $quantity_sold = $subject->getQuantitySold(); | ||
| return sprintf( | ||
| "Ticket Type '%s' (%d) for Summit '%s' with price %s %s (%s sold, %s available) was deleted by user %s", | ||
| $name, | ||
| $id, | ||
| $summit_name, | ||
| ($cost !== null ? $cost : 'N/A'), | ||
| $currency, | ||
| ($quantity_sold !== null ? $quantity_sold : 'N/A'), | ||
| ($quantity_available !== null ? $quantity_available : 'N/A'), | ||
| $this->getUserInfo() | ||
| ); | ||
| } | ||
| } catch (\Exception $ex) { | ||
| Log::warning("SummitTicketTypeAuditLogFormatter error: " . $ex->getMessage()); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrestejerina97 i do think that here we do need to include more info related to the discount code
including domain specific fields like rate / amount and so