mirror of
https://github.com/projekteuler/projekteuler.git
synced 2026-01-27 02:28:50 +01:00
Show author names in problem and translation views
This commit is contained in:
@@ -4,7 +4,8 @@ class Problem < ApplicationRecord
|
||||
delegate :title, :content, to: :translation
|
||||
|
||||
has_many :translations, inverse_of: :problem
|
||||
|
||||
has_many :authors, -> { where(translations: { status: [:in_use, :outdated] }).distinct }, through: :translations
|
||||
|
||||
self.per_page = 50
|
||||
|
||||
def is_translated?
|
||||
@@ -19,6 +20,10 @@ class Problem < ApplicationRecord
|
||||
self.translation.in_use!
|
||||
end
|
||||
|
||||
def has_anonymous_author?
|
||||
translations.where(status: [:in_use, :outdated], author: nil).any?
|
||||
end
|
||||
|
||||
def original_url
|
||||
"https://projecteuler.net/problem=#{self.id}"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user