Unverified Commit 3c0e101a authored by Maarten de Waard's avatar Maarten de Waard 🤘🏻
Browse files

add filter to show only courses in the currently selected language

parent b8291314
......@@ -47,7 +47,7 @@ require 'ruby-cheerio'
helpers do
def get_invitation_only_courses
courses = data.courses.clone
courses['results'] = data.courses['results'].select { |course| not course['hidden'] and course['invitation_only'] == true }
courses['results'] = data.courses['results'].select { |course| not course['hidden'] and course['invitation_only'] == true and filter_course_language(course['number'], locale) }
courses
end
......@@ -55,7 +55,7 @@ helpers do
# You can change this under Settings -> Advanced Settings in Studio.
def get_enrollable_courses
courses = data.courses.clone
courses['results'] = data.courses['results'].select { |course| course['invitation_only'] == false }
courses['results'] = data.courses['results'].select { |course| course['invitation_only'] == false and filter_course_language(course['number'], locale)}
courses
end
......@@ -127,6 +127,13 @@ helpers do
links
end
# Our convention is to end course numbers with their language code in upper
# case, an example course number: "TP_DR_FA" for Totem Project Desk Research
# Farsi
def filter_course_language(course_number, loc)
loc = loc.to_s.upcase
course_number.end_with? "_#{loc}"
end
end
# Site settings
......
......@@ -74,8 +74,13 @@ if courses["results"].any?
)
%>
</div>
<div class="container text-center">
<a class="btn btn-xl" href="https://learn.totem-project.org/courses">
<!-- <span><%= t :find_more_courses%></span> -->
<span>Find more courses</span>
</a>
</div>
</section>
<%
end # end `if courses["results"].any?` statement
fallback_image = '/img/books.svg'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment