Skip to content

Feature/website url#497

Merged
NielsPilgaard merged 6 commits into
mainfrom
feature/website-url
Feb 6, 2026
Merged

Feature/website url#497
NielsPilgaard merged 6 commits into
mainfrom
feature/website-url

Conversation

@NielsPilgaard

Copy link
Copy Markdown
Owner

No description provided.

@coderabbitai

coderabbitai Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a nullable WebsiteUrl to Group and GroupSlim (with URL and max-length validation), creates an EF Core migration, surfaces WebsiteUrl through service and UI, consolidates location/radius validation across Group/Post/User search filters, updates multiple URL validation messages on Partner, fixes an encoding in DataForsyningenOptions, and adds unit tests for search-filter validation.

Changes

Cohort / File(s) Summary
Group model & slim
src/shared/Jordnaer.Shared/Database/Group.cs, src/shared/Jordnaer.Shared/Groups/GroupSlim.cs
Added public string? WebsiteUrl { get; set; } with [Url(ErrorMessage = "...")] and [MaxLength(500, ...)] on Group; added WebsiteUrl to GroupSlim.
EF Core migration & snapshot
src/web/Jordnaer/Migrations/20260204154220_AddWebsiteUrlToGroups.cs, src/web/Jordnaer/Migrations/20260204154220_AddWebsiteUrlToGroups.Designer.cs, src/web/Jordnaer/Migrations/JordnaerDbContextModelSnapshot.cs
New migration adds nullable WebsiteUrl column (nvarchar(500)) to Groups; model snapshot updated.
Service mappings
src/web/Jordnaer/Features/Groups/GroupService.cs
Map WebsiteUrl into GroupSlim responses and set currentGroup.WebsiteUrl on updates.
UI pages
src/web/Jordnaer/Pages/Groups/CreateGroup.razor, src/web/Jordnaer/Pages/Groups/EditGroup.razor, src/web/Jordnaer/Pages/Groups/GroupDetails.razor
Added Website input bound to _group.WebsiteUrl on create/edit forms; details view shows conditional “Besøg hjemmeside” link when present.
Search filter validation
src/shared/Jordnaer.Shared/Groups/GroupSearchFilter.cs, src/shared/Jordnaer.Shared/Posts/PostSearchFilter.cs, src/shared/Jordnaer.Shared/UserSearch/UserSearchFilter.cs
Removed LocationRequiredAttribute; consolidated logic into RadiusRequiredAttribute.IsValid using a hasLocation check (radius required only when location string present or both lat+long present).
Search filter tests
tests/web/Jordnaer.Tests/Groups/GroupSearchFilterTests.cs, tests/web/Jordnaer.Tests/PostSearchFilterTests.cs, tests/web/Jordnaer.Tests/UserSearch/UserSearchFilterTests.cs
Added test suites (7 tests each) exercising permutations of location coordinates/string and radius presence, asserting success/failure and Danish error message.
Partner URL validation messages
src/shared/Jordnaer.Shared/Database/Partner.cs
Replaced plain [Url] with localized [Url(ErrorMessage = "...")] on multiple URL properties (LogoUrl, PartnerPageLink, AdLink, AdImageUrl, pending variants).
Other minor fix
src/shared/Jordnaer.Shared/UserSearch/DataForsyningenOptions.cs
Fixed encoding in [Required] error message to "Påkrævet.".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ❌ 3
❌ Failed checks (1 warning, 2 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.68% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Feature/website url' is vague and uses non-descriptive branch-naming conventions rather than conveying the actual changeset content. Use a descriptive title that summarizes the main change, such as 'Add WebsiteUrl property to Group and GroupSlim entities' or 'Add website URL support to groups'.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess relatedness to the changeset. Add a description explaining the purpose of the changes, such as adding website URL support to groups with validation and database migration details.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/website-url

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/web/Jordnaer/Features/Groups/GroupService.cs (1)

526-534: ⚠️ Potential issue | 🟠 Major

Persist WebsiteUrl when updating groups.
Edits made in the UI won’t save unless UpdateExistingGroupAsync copies the new field.

✅ Suggested fix
-        currentGroup.ShortDescription = updatedGroup.ShortDescription;
-        currentGroup.Description = updatedGroup.Description;
+        currentGroup.ShortDescription = updatedGroup.ShortDescription;
+        currentGroup.Description = updatedGroup.Description;
+        currentGroup.WebsiteUrl = updatedGroup.WebsiteUrl;
🤖 Fix all issues with AI agents
In `@src/web/Jordnaer/Pages/Groups/GroupDetails.razor`:
- Around line 234-241: The external link opened in a new tab in
GroupDetails.razor (MudLink rendering _group.WebsiteUrl) is missing
rel="noopener" which risks reverse tabnabbing; update the MudLink component to
pass UserAttributes including { "rel", "noopener" } (follow the same pattern
used in AdCard.razor) so the rendered anchor includes rel="noopener" when
Target="_blank".
🧹 Nitpick comments (6)
src/shared/Jordnaer.Shared/Posts/PostSearchFilter.cs (1)

62-73: LocationRequiredAttribute contains redundant code.

The if (!hasLocation) check on lines 68-71 is unnecessary since both branches return ValidationResult.Success. The method always succeeds regardless of the condition.

This same pattern appears in UserSearchFilter.cs and GroupSearchFilter.cs.

♻️ Proposed simplification
 file class LocationRequiredAttribute : ValidationAttribute
 {
 	protected override ValidationResult IsValid(object? value, ValidationContext validationContext)
 	{
-		var postSearchFilter = (PostSearchFilter)validationContext.ObjectInstance;
-
-		// Check if location data exists
-		var hasLocation = !string.IsNullOrEmpty(postSearchFilter.Location) ||
-						  (postSearchFilter.Latitude.HasValue && postSearchFilter.Longitude.HasValue);
-
-		// If no location is provided, search is valid (radius will be ignored)
-		// This allows searching without location even if radius slider has a value
-		if (!hasLocation)
-		{
-			return ValidationResult.Success!;
-		}
-
+		// Location is never required - validation always succeeds.
+		// The RadiusRequiredAttribute handles the cross-field validation.
 		return ValidationResult.Success!;
 	}
 }
src/shared/Jordnaer.Shared/Groups/GroupSearchFilter.cs (1)

92-103: Same redundant code as noted in PostSearchFilter.cs.

The LocationRequiredAttribute always returns Success regardless of the hasLocation condition. Consider simplifying as suggested in the PostSearchFilter.cs review.

tests/web/Jordnaer.Tests/Groups/GroupSearchFilterTests.cs (1)

8-151: Well-structured tests with comprehensive coverage.

The tests thoroughly cover all validation scenarios for the location/radius cross-field validation logic, including edge cases like incomplete coordinates.

Consider adding [Trait("Category", "Unit")] attributes to the test class or individual methods for CI filtering purposes. As per coding guidelines: "Write unit tests in tests/web/Jordnaer.Tests folder with appropriate Category attributes for CI filtering."

src/shared/Jordnaer.Shared/UserSearch/UserSearchFilter.cs (1)

104-115: Same redundant code pattern.

The LocationRequiredAttribute has the same dead code issue as in the other filter files.

tests/web/Jordnaer.Tests/PostSearchFilterTests.cs (1)

8-151: Good test coverage for PostSearchFilter validation.

The tests correctly mirror the validation scenarios and use the appropriate filter-specific field (Contents instead of Name).

Same note about adding [Trait("Category", "Unit")] for CI filtering applies here. Based on learnings: "Write unit tests in tests/web/Jordnaer.Tests folder with appropriate Category attributes for CI filtering."

tests/web/Jordnaer.Tests/UserSearch/UserSearchFilterTests.cs (1)

8-151: Consistent test coverage for UserSearchFilter validation.

The tests follow the established pattern and provide good coverage. Same recommendation for adding [Trait("Category", "Unit")] attributes for CI filtering purposes.

Comment thread src/web/Jordnaer/Pages/Groups/GroupDetails.razor
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Jordnaer Community Website Feb 4, 2026
@NielsPilgaard NielsPilgaard merged commit 6906522 into main Feb 6, 2026
5 checks passed
@NielsPilgaard NielsPilgaard deleted the feature/website-url branch February 6, 2026 07:42
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Jordnaer Community Website Feb 6, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant