Added option to skip review for administrators, improved silent publish

This commit is contained in:
Mia Rose Winter 2024-02-26 13:59:29 +01:00
parent b71f6a4892
commit e72967aba1
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E

View file

@ -59,7 +59,8 @@
<AntiforgeryToken /> <AntiforgeryToken />
<button type="submit" class="btn btn-primary w-full sm:btn-wide">@Localizer["Review_Submit"]</button> <button type="submit" class="btn btn-primary w-full sm:btn-wide">@Localizer["Review_Submit"]</button>
</form> </form>
} else if (Article.Status is ArticleStatus.InReview) { }
@if (Article.Status is ArticleStatus.InReview || context.User.IsInRole("Admin")) {
<form @formname="submit-for-publish" method="post" @onsubmit="SubmitForPublish" class="max-sm:w-full"> <form @formname="submit-for-publish" method="post" @onsubmit="SubmitForPublish" class="max-sm:w-full">
<AntiforgeryToken /> <AntiforgeryToken />
<button type="submit" class="btn btn-primary w-full sm:btn-wide">@Localizer["Publish_Submit"]</button> <button type="submit" class="btn btn-primary w-full sm:btn-wide">@Localizer["Publish_Submit"]</button>
@ -232,11 +233,12 @@
context.Update(Article); context.Update(Article);
await context.SaveChangesAsync(); await context.SaveChangesAsync();
if (!PublishSilently && Features.Value.EmailSubscriptions) { if (Features.Value.EmailSubscriptions) {
try { try {
var newsletter = new EmailNewsletter { var newsletter = new EmailNewsletter {
Article = Article, Article = Article,
DistributionDateTime = Article.PublishDate DistributionDateTime = Article.PublishDate,
IsSend = PublishSilently
}; };
await context.Set<EmailNewsletter>().AddAsync(newsletter); await context.Set<EmailNewsletter>().AddAsync(newsletter);
await context.SaveChangesAsync(); await context.SaveChangesAsync();
@ -250,7 +252,7 @@
var author = Article.Author; var author = Article.Author;
string publishMessage = string publishMessage =
Article.PublishDate >= DateTimeOffset.Now ? (Article.PublishDate < DateTimeOffset.Now) ?
"Is is now publicly available." : "Is is now publicly available." :
$"It is currently scheduled for {Article.PublishDate.ToString("f", CultureInfo.GetCultureInfo("en-US"))}."; $"It is currently scheduled for {Article.PublishDate.ToString("f", CultureInfo.GetCultureInfo("en-US"))}.";
@ -260,7 +262,7 @@
"Article has been approved", "Article has been approved",
"Your Article is going to be published", "Your Article is going to be published",
$"<p>The Article '{Article.Title}' has been checked and approved by a reviewer.</p>" + $"<p>The Article '{Article.Title}' has been checked and approved by a reviewer.</p>" +
$"<p>It is currently scheduled for {Article.PublishDate.ToString("f", CultureInfo.GetCultureInfo("en-US"))}.</p>", $"<p>{publishMessage}</p>",
$"The Article '{Article.Title}' has been checked and approved by a reviewer. " + $"The Article '{Article.Title}' has been checked and approved by a reviewer. " +
publishMessage); publishMessage);
// TODO check if they enabled email notifications (property currently not implemented) // TODO check if they enabled email notifications (property currently not implemented)