diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index e8463dc4..768aa26d 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -93,7 +93,7 @@ def export @project.stories.includes(:comments).approved.by_position.each do |story| comments = [] story.comments.each do |comment| - comments << "#{comment.user.name}: #{comment.body}" + comments << "#{display_name(comment.user)}: #{comment.body}" end csv << [story.id, story.title, story.description, story.position] + comments end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 24630ad2..6770a24e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -33,4 +33,8 @@ def markdown(text) markdown.render(text.to_s).html_safe end + + def display_name(user) + user.name || user.email + end end diff --git a/app/madmin/resources/user_resource.rb b/app/madmin/resources/user_resource.rb index 4139fd06..bc9a6048 100644 --- a/app/madmin/resources/user_resource.rb +++ b/app/madmin/resources/user_resource.rb @@ -9,7 +9,7 @@ class UserResource < Madmin::Resource attribute :estimates def self.display_name(record) - record.name.truncate(12) + record.name.truncate(12) || record.email.truncate(12) end # Uncomment this to customize the default sort column and direction. diff --git a/app/models/user.rb b/app/models/user.rb index 4289fb3e..d0c96124 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,4 +3,5 @@ class User < ApplicationRecord has_many :estimates has_many :comments + end diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 617fa2d0..c4488bd1 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,5 +1,5 @@
<%= comment.user.name %>: <%= markdown(comment.body) %> <%= comment.created_at %>
+
<%= display_name(comment.user) %>: <%= markdown(comment.body) %> <%= comment.created_at %>
<% if current_user == comment.user %> <%= link_to "Edit Comment", edit_project_story_comment_path(project, story, comment), class: "link-blue" %> | <%= link_to "Delete", project_story_comment_path(project, story, comment), method: :delete, data: { confirm: "Are you sure?" }, title: "Delete" %> diff --git a/app/views/reports/show.html.erb b/app/views/reports/show.html.erb index 1213f17b..3f40c37c 100644 --- a/app/views/reports/show.html.erb +++ b/app/views/reports/show.html.erb @@ -8,8 +8,8 @@