diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 8244c44cf..c383b2e0b 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -78,7 +78,12 @@ def description render json: { title: @attachment.title, description: @attachment.description, - author: @attachment.author.title, + author: + if @attachment.author + @attachment.author.title + else + '' + end, html: render_to_string(partial: 'attachments/description', formats: [:html], locals: {attachment: @attachment}) } end diff --git a/app/mailers/post_mailer.rb b/app/mailers/post_mailer.rb index 66f84ca16..2f014aeb4 100644 --- a/app/mailers/post_mailer.rb +++ b/app/mailers/post_mailer.rb @@ -35,7 +35,14 @@ def post_email(text, recipients, subject, sender, group, post) I18n.with_locale(recipients.first.try(:locale) || I18n.default_locale) do message = mail( - to: @to_field, from: sender.email, subject: subject, + to: @to_field, + from: + if sender.kind_of? User + sender.email + elsif sender.kind_of? String + sender + end, + subject: subject, reply_to: @reply_to ) message.smtp_envelope_to = @smtp_envelope_to_field diff --git a/app/models/event.rb b/app/models/event.rb index 7e1bee65f..e35446b90 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -16,7 +16,11 @@ def title end def to_param - "#{id} #{name} #{start_at.year}-#{start_at.month}-#{start_at.day}".parameterize + if start_at + "#{id} #{name} #{start_at.year}-#{start_at.month}-#{start_at.day}".parameterize + else + "#{id} #{name}".parameterize + end end diff --git a/app/views/search/_preview_officer_group.html.haml b/app/views/search/_preview_officer_group.html.haml index d7d75517b..f1f653e71 100644 --- a/app/views/search/_preview_officer_group.html.haml +++ b/app/views/search/_preview_officer_group.html.haml @@ -5,9 +5,9 @@ - obj.memberships.includes(:descendant).each do |membership| %p = link_to membership.user.title, membership.user - = "(#{t(:since)} #{localize membership.valid_from.to_date})" + = "(#{t(:since)} #{localize membership.valid_from.to_date if membership.valid_from})" - if obj.scope # which is the object the officer is officer for. %p = "#{t(:see_also)}:" - = link_to obj.scope.title, obj.scope \ No newline at end of file + = link_to obj.scope.title, obj.scope