Browse Source

Merge pull request #16747 from abpframework/issue-16746

The detail page should not give an error if a post is without an author
pull/16749/head
Engincan VESKE 3 years ago
committed by GitHub
parent
commit
db2d9da16c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 68
      modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml
  2. 6
      modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml.cs

68
modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml

@ -147,27 +147,32 @@
}
</div>
<div class="col ps-1">
<h5 class="mt-2 mb-1">
<a href="/Members/@Model.Post.Writer.UserName">
@if (Model.Post.Writer.Name != null && Model.Post.Writer.Surname != null)
{
<p class="fw-bold pt-2 fs-5">@Model.Post.Writer.Name @Model.Post.Writer.Surname</p>
}
else
@if (Model.Post.Writer != null)
{
<h5 class="mt-2 mb-1">
<a href="/Members/@Model.Post.Writer.UserName">
@if (Model.Post.Writer.Name != null && Model.Post.Writer.Surname != null)
{
<p class="fw-bold pt-2 fs-5">@Model.Post.Writer.Name @Model.Post.Writer.Surname</p>
}
else
{
<p class="fw-bold pt-2 fs-5">@Model.Post.Writer.UserName</p>
}
</a>
</h5>
<div class="position-relative">
@if (Model.Post.Writer.JobTitle != null)
{
<p class="fw-bold pt-2 fs-5">@Model.Post.Writer.UserName</p>
<p class="fw-lighter">@Model.Post.Writer.JobTitle</p>
}
</a>
</h5>
<div class="position-relative">
@if (Model.Post.Writer.JobTitle != null)
{
<p class="fw-lighter">@Model.Post.Writer.JobTitle</p>
}
</div>
@if (CurrentUser.UserName == Model.Post.Writer.UserName)
</div>
}
@if (CurrentUser.Id.HasValue && CurrentUser.Id.Value == Model.Post.Writer?.Id)
{
<a class="fw-lighter" href="/Members/@Model.Post.Writer.UserName#edit-profile">@L["EditProfile"] <i class="fas fa-edit"></i></a>
<a class="fw-lighter" href="/Members/@Model.Post.Writer?.UserName#edit-profile">@L["EditProfile"] <i class="fas fa-edit"></i></a>
}
</div>
@if (Model.LatestPosts.Count > 1)
@ -185,23 +190,24 @@
<div class="article-owner">
<div class="article-infos">
<div class="user-card pt-3">
<div class="row">
<div class="col-auto pe-1">
@if (post.Writer != null)
{
@if (post.Writer != null)
{
<div class="row">
<div class="col-auto pe-1">
<a href="/Members/@post.Writer.UserName" aria-label="Go to user profile">
<img gravatar-email="@post.Writer.Email" default-image="Identicon" class="last-post-image" alt="User Avatar"/>
</a>
}
</div>
<div class="col">
<h5 class="last-post-name">
<a href="/Members/@post.Writer.UserName">
@(post.Writer.UserName)
</a>
</h5>
</div>
<div class="col">
<h5 class="last-post-name">
<a href="/Members/@post.Writer!.UserName">
@(post.Writer!.UserName)
</a>
</h5>
</div>
</div>
</div>
}
</div>
</div>
<div class="col mt-2">

6
modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml.cs

@ -86,7 +86,11 @@ namespace Volo.Blogging.Pages.Blog.Posts
{
Blog = await _blogAppService.GetByShortNameAsync(BlogShortName);
Post = await _postAppService.GetForReadingAsync(new GetPostInput { BlogId = Blog.Id, Url = PostUrl });
PostsList = await _postAppService.GetListByUserIdAsync(Post.Writer.Id);
PostsList = Post.Writer != null
? await _postAppService.GetListByUserIdAsync(Post.Writer.Id)
: new List<PostWithDetailsDto>();
LatestPosts = await _postAppService.GetLatestBlogPostsAsync(Blog.Id, 5);
CommentsWithReplies = await _commentAppService.GetHierarchicalListOfPostAsync(Post.Id);
CountComments();

Loading…
Cancel
Save