Verified Commit 72a61bfa authored by Roberto Bochet's avatar Roberto Bochet
Browse files

Fix generator courses page bug

parent 22676334
......@@ -98,12 +98,12 @@ module Jekyll
def preprocessing_editions(site)
site.data["courses"].each do |n, v|
# checks begins and ends values
if !v["begin"] or !v["ends"]
if !v["begins"] or !v["ends"]
# if schedule dates are set they are used for update begins and ends
if v["schedule"].kind_of?(Array)
# retrieves dates from schedule
dates = v["schedule"].map { |s| s["date"] }.select { |d| d != nil }.map { |d| DateTime.parse(d) }.reverse
# if schedule dates are set they are used for update begins and ends
if dates.size != 0
v["begins"] ||= dates.first
v["ends"] ||= dates.last
......@@ -111,13 +111,14 @@ module Jekyll
elsif v["begins"] != nil
v["ends"] = v["begins"]
else
@logger.warn("In session #{n} is not define any time reference")
@logger.error("In session #{n} is not define any time reference")
end
end
# check if edition has already been
v["is_past"] = v["ends"] < DateTime.now
v["is_past"] = v["ends"].nil? ? false : v["ends"] < DateTime.now
if !v["schedule"].nil?
# fix levels composition of room value
v["schedule"].each do |s|
if s["room"] != nil && !s["room"].is_a?(Hash)
......@@ -131,6 +132,7 @@ module Jekyll
end
end
end
end
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