Unverified Commit 5f46210a authored by Maarten de Waard's avatar Maarten de Waard 🤘🏻
Browse files

rename locale filter function and improve docs

parent a3392cac
......@@ -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 and filter_course_language(course['number'], locale) }
courses['results'] = data.courses['results'].select { |course| not course['hidden'] and course['invitation_only'] == true and course_number_matches_locale(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 and filter_course_language(course['number'], locale)}
courses['results'] = data.courses['results'].select { |course| course['invitation_only'] == false and course_number_matches_locale(course['number'], locale)}
courses
end
......@@ -129,8 +129,9 @@ helpers do
# 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)
# Farsi.
# Returns true if the course number matches the locale.
def course_number_matches_locale(course_number, loc)
loc = loc.to_s.upcase
course_number.end_with? "_#{loc}"
end
......
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