Документация Discourse стала главной причиной, по которой я выбрал Discourse вместо другого программного обеспечения для форумов. Однако для меня есть один существенный недостаток: по умолчанию сортировка осуществляется по активности. Я хотел бы полностью убрать возможность сортировки по активности, но не могу понять, как это сделать.
Я нашел этот участок кода, удалил оператор elsif для сортировки по активности, но это не помогло.
if @filters[:order] == "title"
if @filters[:ascending].present?
results = results.reorder('topics.title')
else
results = results.reorder('topics.title DESC')
end
elsif @filters[:order] == "activity"
if @filters[:ascending].present?
results = results.reorder('topics.last_posted_at')
else
results = results.reorder('topics.last_posted_at DESC')
end
end
Я также сделал то же самое в этом файле, но сортировка по-прежнему работает так же.
context 'when ordering results' do
context 'by title' do
it 'should return the list ordered descending' do
get "/docs.json?order=title"
expect(response.status).to eq(200)
json = response.parsed_body
topics = json['topics']['topic_list']['topics']
expect(topics[0]['id']).to eq(topic2.id)
expect(topics[1]['id']).to eq(topic.id)
end
it 'should return the list ordered ascending with an additional parameter' do
get "/docs.json?order=title&ascending=true"
expect(response.status).to eq(200)
json = response.parsed_body
topics = json['topics']['topic_list']['topics']
expect(topics[0]['id']).to eq(topic.id)
expect(topics[1]['id']).to eq(topic2.id)
end
end
context 'by date' do
before do
topic2.update(last_posted_at: Time.zone.now + 100)
end
it 'should return the list ordered descending' do
get "/docs.json?order=activity"
expect(response.status).to eq(200)
json = response.parsed_body
topics = json['topics']['topic_list']['topics']
expect(topics[0]['id']).to eq(topic.id)
expect(topics[1]['id']).to eq(topic2.id)
end
it 'should return the list ordered ascending with an additional parameter' do
get "/docs.json?order=activity&ascending=true"
expect(response.status).to eq(200)
json = response.parsed_body
topics = json['topics']['topic_list']['topics']
expect(topics[0]['id']).to eq(topic2.id)
expect(topics[1]['id']).to eq(topic.id)
end
end
end
Я вносил изменения как напрямую в файл на сервере, так и в форк документации Discourse, который затем установил.
Есть ли у кого-нибудь советы? Я действительно думал, что это займет три минуты, но уже потратил на это много часов…
Спасибо!