Skip to content

Commit

Permalink
Publish form - add alternative online watching url field (#1897)
Browse files Browse the repository at this point in the history
  • Loading branch information
adelikat authored Jun 29, 2024
1 parent bec6d46 commit 4858e6e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
11 changes: 8 additions & 3 deletions TASVideos/Pages/Submissions/Publish.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,20 @@
<label asp-for="Submission.OnlineWatchingUrl">Online-watching URL</label>
<input asp-for="Submission.OnlineWatchingUrl" />
<span asp-validation-for="Submission.OnlineWatchingUrl"></span>
<label asp-for="Submission.OnlineWatchUrlName">Online-watching URL Display Name (Optional)</label>
<input asp-for="Submission.OnlineWatchUrlName" />
<span asp-validation-for="Submission.OnlineWatchUrlName"></span>
</fieldset>
<fieldset>
<label asp-for="Submission.MirrorSiteUrl">Mirror site URL</label>
<input asp-for="Submission.MirrorSiteUrl" />
<span asp-validation-for="Submission.MirrorSiteUrl"></span>
</fieldset>
<fieldset>
<label asp-for="Submission.AlternateOnlineWatchingUrl">Alternative Online-watching URL (optional)</label>
<input asp-for="Submission.AlternateOnlineWatchingUrl" />
<span asp-validation-for="Submission.AlternateOnlineWatchingUrl"></span>
<label asp-for="Submission.AlternateOnlineWatchUrlName">Alternative Online-watching URL Display Name (optional)</label>
<input asp-for="Submission.AlternateOnlineWatchUrlName" />
<span asp-validation-for="Submission.AlternateOnlineWatchUrlName"></span>
</fieldset>
</column>
<column lg="6">
<fieldset>
Expand Down
32 changes: 28 additions & 4 deletions TASVideos/Pages/Submissions/Publish.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,20 @@ public async Task<IActionResult> OnPost()
GameGoalId = submission.GameGoalId
};

publication.PublicationUrls.AddStreaming(Submission.OnlineWatchingUrl, Submission.OnlineWatchUrlName);
publication.PublicationUrls.AddStreaming(Submission.OnlineWatchingUrl, "");
publication.PublicationUrls.AddMirror(Submission.MirrorSiteUrl);
if (!string.IsNullOrWhiteSpace(Submission.AlternateOnlineWatchingUrl))
{
publication.PublicationUrls.AddStreaming(Submission.AlternateOnlineWatchingUrl, Submission.AlternateOnlineWatchUrlName);
}

publication.Authors.CopyFromSubmission(submission.SubmissionAuthors);
publication.PublicationFlags.AddFlags(Submission.SelectedFlags);
publication.PublicationTags.AddTags(Submission.SelectedTags);

db.Publications.Add(publication);

await db.SaveChangesAsync(); // Need an Id for the Title
await db.SaveChangesAsync(); // Need an ID for the Title
publication.GenerateTitle();

await uploader.UploadScreenshot(publication.Id, Submission.Screenshot!, Submission.ScreenshotDescription);
Expand All @@ -156,7 +161,22 @@ public async Task<IActionResult> OnPost()
publication.Id,
publication.CreateTimestamp,
Submission.OnlineWatchingUrl,
Submission.OnlineWatchUrlName,
"",
publication.Title,
addedWikiPage!,
submission.System.Code,
publication.Authors.OrderBy(pa => pa.Ordinal).Select(pa => pa.Author!.UserName),
null);
await youtubeSync.SyncYouTubeVideo(video);
}

if (youtubeSync.IsYoutubeUrl(Submission.AlternateOnlineWatchingUrl))
{
var video = new YoutubeVideo(
publication.Id,
publication.CreateTimestamp,
Submission.AlternateOnlineWatchingUrl,
Submission.AlternateOnlineWatchUrlName,
publication.Title,
addedWikiPage!,
submission.System.Code,
Expand Down Expand Up @@ -221,8 +241,12 @@ public class SubmissionPublishModel
[StringLength(500)]
public string OnlineWatchingUrl { get; init; } = "";

[Url]
[StringLength(500)]
public string AlternateOnlineWatchingUrl { get; init; } = "";

[StringLength(100)]
public string? OnlineWatchUrlName { get; init; }
public string? AlternateOnlineWatchUrlName { get; init; }

[Url]
[StringLength(500)]
Expand Down

0 comments on commit 4858e6e

Please sign in to comment.