Add opt-out for publishing results + codeword field - #753
Conversation
|
Warning Rate limit exceeded@horcsinbalint has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 52 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis update introduces two new fields— Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ApplicationForm
participant Server
participant Database
User->>ApplicationForm: Opens application questions page
ApplicationForm->>User: Shows publication consent checkbox and pseudonym input (toggled by JS)
User->>ApplicationForm: Submits form with publication_consent and/or pseudonym
ApplicationForm->>Server: Sends POST request with data
Server->>Database: Validates and stores publication_consent and pseudonym
Server->>User: Returns success or validation errors
Estimated code review effort2 (~20 minutes) Possibly related PRs
Suggested labels
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
c0511a3 to
b422a74
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
app/Models/Application.php(3 hunks)app/Utils/ApplicationHandler.php(1 hunks)database/migrations/2025_07_23_140346_application_codeword.php(1 hunks)resources/lang/en/validation.php(1 hunks)resources/lang/hu/validation.php(1 hunks)resources/views/auth/application/application.blade.php(1 hunks)resources/views/auth/application/questions.blade.php(2 hunks)tests/Feature/ApplicationTest.php(1 hunks)
🧠 Learnings (2)
resources/views/auth/application/application.blade.php (1)
Learnt from: kdmnk
PR: #607
File: resources/views/errors/minimal.blade.php:9-11
Timestamp: 2024-08-06T12:48:49.276Z
Learning: When separating CSS into an external file, name it app.blade.php as specified by the user.
app/Utils/ApplicationHandler.php (1)
Learnt from: viktorcsimma
PR: #542
File: app/Http/Controllers/Secretariat/SemesterEvaluationController.php:161-161
Timestamp: 2024-06-13T19:25:19.821Z
Learning: 'anonymous_questions' is a section name in the 'secretariat.evaluation-form.app' view and does not require handling in the store method of SemesterEvaluationController.php.
🧬 Code Graph Analysis (1)
app/Utils/ApplicationHandler.php (2)
app/Models/Application.php (1)
user(126-129)app/Models/User.php (1)
application(255-258)
🧰 Additional context used
🧠 Learnings (2)
resources/views/auth/application/application.blade.php (1)
Learnt from: kdmnk
PR: #607
File: resources/views/errors/minimal.blade.php:9-11
Timestamp: 2024-08-06T12:48:49.276Z
Learning: When separating CSS into an external file, name it app.blade.php as specified by the user.
app/Utils/ApplicationHandler.php (1)
Learnt from: viktorcsimma
PR: #542
File: app/Http/Controllers/Secretariat/SemesterEvaluationController.php:161-161
Timestamp: 2024-06-13T19:25:19.821Z
Learning: 'anonymous_questions' is a section name in the 'secretariat.evaluation-form.app' view and does not require handling in the store method of SemesterEvaluationController.php.
🧬 Code Graph Analysis (1)
app/Utils/ApplicationHandler.php (2)
app/Models/Application.php (1)
user(126-129)app/Models/User.php (1)
application(255-258)
🔇 Additional comments (12)
resources/lang/en/validation.php (1)
74-75: Excellent addition to the validation attributes.The 'codeword' attribute mapping follows the established pattern perfectly and will ensure proper localisation of validation error messages for the new field.
resources/lang/hu/validation.php (1)
74-75: Proper Hungarian localisation implemented.The translation 'jelige' for 'codeword' is appropriate and maintains consistency with the English validation file structure.
resources/views/auth/application/application.blade.php (2)
81-81: Clean consolidation of the anchor tag.The refactoring to a single line improves readability whilst maintaining the same functionality.
85-87: Well-implemented conditional codeword display.The logic correctly shows the codeword in grey parentheses only when publication consent is declined and a codeword is provided. The inline styling is consistent with the existing patterns throughout this template.
database/migrations/2025_07_23_140346_application_codeword.php (2)
11-17: Excellently structured migration implementation.The column definitions are spot-on:
publication_consentappropriately defaults tofalsefor privacy-first behaviour, whilstcodewordhas a sensible 20-character limit and nullable constraint. The column positioning ensures logical database structure.
22-28: Proper rollback implementation.The down method correctly removes both columns, ensuring clean migration reversal capability.
app/Models/Application.php (4)
37-38: Proper property annotations added.The property annotations are correctly documented with appropriate types.
91-92: Fields properly added to fillable array.Both new fields are correctly included in the fillable array, maintaining consistency with the existing structure.
99-100: Appropriate casting for publication_consent.The boolean casting for
publication_consentis correct. Note thatcodewordappropriately remains uncast as it should stay as a string.
421-423: Well-implemented conditional business logic.The conditional logic correctly implements the requirement: either publication consent must be granted or a codeword must be provided. The logic is clear and follows the established pattern in the method.
resources/views/auth/application/questions.blade.php (2)
157-167: Excellent UI implementation with proper form binding.The form elements are well-structured with:
- Clear, descriptive text for the publication consent checkbox
- Proper model binding using the application properties
- Validation attributes that match the backend rules
- Helpful explanatory text for the codeword field
183-196: Robust JavaScript implementation for dynamic behaviour.The JavaScript logic is well-implemented:
- Properly handles the inverse relationship (shows codeword when consent is NOT given)
- Includes both DOM ready and change event listeners
- Uses clear, semantic function and variable names
- Correctly manipulates display styles for the wrapper element
| 'question_1' => ['answer 1'], | ||
| 'question_2' => 'answer 2', | ||
| 'question_3' => 'answer 3', | ||
| 'publication_consent' => '1', |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Good addition for publication consent testing.
The test now properly includes the publication_consent field, ensuring the happy path is covered.
However, I'd strongly recommend adding comprehensive test coverage for the complete feature:
- Test scenario where
publication_consentisfalseandcodewordis provided - Test codeword validation rules (uniqueness, length constraints)
- Test the conditional requirement logic between consent and codeword
- Test codeword display logic in the view
Would you like me to generate additional test cases to ensure robust coverage of this feature?
🤖 Prompt for AI Agents
In tests/Feature/ApplicationTest.php at line 343, the current test includes the
publication_consent field but lacks coverage for other important scenarios. Add
new test cases to cover when publication_consent is false and codeword is
provided, validate codeword rules like uniqueness and length constraints, verify
the conditional logic between consent and codeword, and check that the codeword
is correctly displayed in the view. This will ensure comprehensive testing of
the feature.
3dbba66 to
f7b96c3
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/Exports/ApplicantsExport.php(2 hunks)app/Http/Controllers/Secretariat/UserController.php(1 hunks)
🧬 Code Graph Analysis (2)
app/Http/Controllers/Secretariat/UserController.php (2)
app/helpers.php (1)
user(15-23)app/Models/User.php (1)
isCollegist(753-770)
app/Exports/ApplicantsExport.php (1)
app/Models/User.php (1)
application(255-258)
🧰 Additional context used
🧬 Code Graph Analysis (2)
app/Http/Controllers/Secretariat/UserController.php (2)
app/helpers.php (1)
user(15-23)app/Models/User.php (1)
isCollegist(753-770)
app/Exports/ApplicantsExport.php (1)
app/Models/User.php (1)
application(255-258)
🔇 Additional comments (2)
app/Exports/ApplicantsExport.php (2)
62-63: Well implemented addition of the pseudonym header.The addition of "Jelige" to the export headers is quite proper and aligns perfectly with the PR objectives for adding pseudonym functionality.
96-97: Excellent implementation of pseudonym field mapping.The inclusion of
$application->pseudonymin the export data mapping is spot on and maintains consistency with the newly added header. This properly supports the opt-out publication feature described in the PR objectives.
| $requiredForCollegist = $user->isCollegist(alumni: true) ? "" : "nullable"; | ||
| /* | ||
| If a field is omitted from the input, the request should succeed. | ||
| */ |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Consider using 'nullable' rather than an empty string for validation rules.
I must say, using an empty string "" as a validation rule is rather unconventional and may not behave as intended. In Laravel, validation rules should typically be either "required" for mandatory fields or "nullable" for optional ones. An empty string might not be processed correctly by Laravel's validation system.
If the intention is to make fields optional for collegist alumni whilst allowing omitted fields to pass validation, I'd strongly recommend using "nullable" instead:
-$requiredForCollegist = $user->isCollegist(alumni: true) ? "" : "nullable";
+$requiredForCollegist = $user->isCollegist(alumni: true) ? "nullable" : "nullable";Or if you truly wish to differentiate between collegist and non-collegist users:
-$requiredForCollegist = $user->isCollegist(alumni: true) ? "" : "nullable";
+$requiredForCollegist = $user->isCollegist(alumni: true) ? "nullable" : "required";Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In app/Http/Controllers/Secretariat/UserController.php around lines 163 to 166,
replace the empty string "" used as a validation rule with "nullable" to
correctly indicate optional fields in Laravel validation. Change the assignment
so that $requiredForCollegist is set to "nullable" when the user is a collegist
alumni, ensuring the validation system properly handles omitted fields without
errors.
f06ea34 to
092b6c6
Compare
…d ParentChildForms
Co-authored-by: Balint Horcsin <horcsinbalint@gmail.com>
6f41864 to
79c9817
Compare
This was obsoleted by pseudonyms in applications (#753).
This was obsoleted by pseudonyms in applications (#753).
No description provided.