-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c0ba35d
feat: add new formatters for Tickets
andrestejerina97 33d9255
fix: change in ticket formatters
andrestejerina97 1fe4d74
fix: remove operation for description
andrestejerina97 133388c
feat: add new fields on PrePaidSummitRegistrationDiscountCodeAuditLog…
andrestejerina97 ca6d776
chore: Add requested changes
matiasperrone-exo 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
101 changes: 101 additions & 0 deletions
101
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,101 @@ | ||
| <?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 | ||
| { | ||
|
|
||
| private function buildDiscountDetails(PrePaidSummitRegistrationDiscountCode $subject): string | ||
| { | ||
| $details = []; | ||
|
|
||
| $rate = $subject->getRate(); | ||
| $amount = $subject->getAmount(); | ||
| $quantity_available = $subject->getQuantityAvailable(); | ||
|
|
||
| if ($rate > 0) { | ||
| $details[] = sprintf("rate: %.2f%%", $rate); | ||
| } | ||
|
|
||
| if ($amount > 0) { | ||
| $details[] = sprintf("amount: $%.2f", $amount); | ||
| } | ||
|
|
||
| if ($quantity_available > 0) { | ||
| $details[] = sprintf("quantity: %d", $quantity_available); | ||
| } | ||
|
|
||
| return implode(", ", $details); | ||
| } | ||
|
|
||
| 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'; | ||
| $discount_details = $this->buildDiscountDetails($subject); | ||
|
|
||
| switch ($this->event_type) { | ||
| case IAuditStrategy::EVENT_ENTITY_CREATION: | ||
| return sprintf( | ||
| "Pre-Paid Discount Code '%s' (%d) created for Summit '%s' with %s by user %s", | ||
| $code, | ||
| $id, | ||
| $summit_name, | ||
| $discount_details, | ||
| $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 (current: %s) by user %s", | ||
| $code, | ||
| $id, | ||
| $summit_name, | ||
| $change_details, | ||
| $discount_details, | ||
| $this->getUserInfo() | ||
| ); | ||
|
|
||
| case IAuditStrategy::EVENT_ENTITY_DELETION: | ||
| return sprintf( | ||
| "Pre-Paid Discount Code '%s' (%d) for Summit '%s' with %s was deleted by user %s", | ||
| $code, | ||
| $id, | ||
| $summit_name, | ||
| $discount_details, | ||
| $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, | ||
| $currency, | ||
| $quantity_available, | ||
| $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, | ||
| $currency, | ||
| $quantity_sold, | ||
| $quantity_available, | ||
| $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.
Uh oh!
There was an error while loading. Please reload this page.