18b61bed52
- Widen AdminCandidateEditorModal to size lg for better readability - Rename "Clip-Compilation" section to "Clip / Compilation", update copy to reflect single clips too, drop upload hint and Clip-Plattform field, rename label to "Link" - Fix NativeSelect dropdown clipping inside overflow-y-auto modals by teleporting the menu to body with fixed positioning, flip-up logic, and dynamic maxHeight capped to viewport - Add ClipAdminMenuVisible setting (backend domain, contracts, endpoint, migration) with matching frontend types, defaults, form wiring, and toggle in the Clip-Workflow modal — hides the Clips nav item from the admin sidebar when disabled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
91 lines
4.0 KiB
C#
91 lines
4.0 KiB
C#
using Backend.Contracts;
|
|
using Backend.Data;
|
|
using Backend.Common;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Backend.Endpoints;
|
|
|
|
public static partial class PublicEndpoints
|
|
{
|
|
private static async Task<IResult> GetSeasonCategories(int year, AwardsDbContext db)
|
|
{
|
|
var season = await db.Seasons
|
|
.AsNoTracking()
|
|
.Include(item => item.Categories.OrderBy(category => category.SortOrder))
|
|
.ThenInclude(category => category.Candidates.OrderBy(candidate => candidate.DisplayName))
|
|
.FirstOrDefaultAsync(item => item.Year == year);
|
|
|
|
if (season is null)
|
|
{
|
|
return Results.NotFound();
|
|
}
|
|
|
|
var phaseKey = SeasonMappings.NormalizePhaseKey(season.CurrentPhase);
|
|
var publicCategories = season.Categories
|
|
.Where(category => ShouldExposePublicCategory(phaseKey, category.Candidates.Count))
|
|
.ToArray();
|
|
var publicCategoryIds = publicCategories.Select(category => category.Id).ToArray();
|
|
var approvedClips = await db.ClipSubmissions
|
|
.AsNoTracking()
|
|
.Where(item =>
|
|
item.SeasonId == season.Id
|
|
&& item.Status == "approved"
|
|
&& item.CategoryId != null
|
|
&& publicCategoryIds.Contains(item.CategoryId.Value))
|
|
.Select(item => new PublicCandidateClip(
|
|
item.CategoryId,
|
|
item.CandidateId,
|
|
item.Creator,
|
|
item.ClipUrl,
|
|
item.Title,
|
|
item.Platform,
|
|
item.CreatedAt,
|
|
item.ReviewedAt))
|
|
.ToArrayAsync();
|
|
var clipsByCandidateId = BuildCandidateClipLookup(approvedClips);
|
|
var clipsByCreatorKey = BuildCreatorClipLookup(approvedClips);
|
|
|
|
return Results.Ok(new SeasonCategoriesResponse(
|
|
season.Id,
|
|
season.Year,
|
|
publicCategories.Select(category => new PublicCategoryDetailDto(
|
|
category.Id,
|
|
category.Name,
|
|
category.GroupName,
|
|
category.Description,
|
|
category.MaxNomineesPerUser,
|
|
category.Candidates
|
|
.Where(candidate => !string.Equals(candidate.AcceptanceStatus, "declined", StringComparison.OrdinalIgnoreCase))
|
|
.Select(candidate =>
|
|
{
|
|
var clip = ResolveCandidateClip(candidate, clipsByCandidateId, clipsByCreatorKey);
|
|
var candidateClipUrl = string.IsNullOrWhiteSpace(candidate.ClipCompilationUrl)
|
|
|| string.Equals(candidate.ClipEmbedStatus, "blocked", StringComparison.OrdinalIgnoreCase)
|
|
? null
|
|
: candidate.ClipCompilationUrl.Trim();
|
|
var clipUrl = candidateClipUrl ?? clip?.ClipUrl;
|
|
var clipTitle = candidateClipUrl is not null
|
|
? string.IsNullOrWhiteSpace(candidate.ClipCompilationTitle) ? "Highlight-Clip ansehen" : candidate.ClipCompilationTitle.Trim()
|
|
: clip?.Title;
|
|
var clipPlatform = candidateClipUrl is not null
|
|
? string.IsNullOrWhiteSpace(candidate.ClipCompilationPlatform) ? candidate.Platform : candidate.ClipCompilationPlatform.Trim()
|
|
: clip?.Platform;
|
|
var clipEmbedStatus = candidateClipUrl is not null
|
|
? candidate.ClipEmbedStatus
|
|
: null;
|
|
|
|
return new CandidateSummaryDto(
|
|
candidate.Id,
|
|
candidate.DisplayName,
|
|
candidate.ChannelSlug,
|
|
SeasonMappings.BuildProfileUrl(candidate.Platform, candidate.ChannelSlug),
|
|
candidate.Platform,
|
|
clipUrl,
|
|
clipTitle,
|
|
clipPlatform,
|
|
clipEmbedStatus);
|
|
}).ToArray()))
|
|
.ToArray()));
|
|
}
|
|
}
|