lib/services/reg_center.rb in Active-0.0.27 vs lib/services/reg_center.rb in Active-0.0.28

- old
+ new

@@ -40,14 +40,18 @@ if @data.has_key?("event") && @data["event"].has_key?("eventDetailsPageUrl") @data["event"]["eventDetailsPageUrl"] elsif @data.has_key?("event") && @data["event"].has_key?("registrationUrl") @data["event"]["registrationUrl"] elsif @data.has_key?("event") && @data["event"].has_key?("eventContactUrl") - @data["event"]["eventContactUrl"] + @data["event"]["eventContactUrl"] end end + def event_url + @data[:event][:eventUrl] + end + def categories if @data.has_key?("event") && @data["event"].has_key?("channels") && @data["event"]["channels"]!=nil && @data["event"]["channels"].has_key?("channel") && @data["event"]["channels"]["channel"]!=nil channels = @data["event"]["channels"]["channel"] if channels.class==Array @data["event"]["channels"]["channel"].collect {|e| e["channelName"]} @@ -106,10 +110,14 @@ end def end_date nil end + # The date and time that registration closes + def registration_close_date + DateTime.parse(@data["event"]["eventCloseDate"]) + end def category primary_category end @@ -120,16 +128,16 @@ # u.first_name = @data["meta"]["contactName"] || nil # u.phone = @data["meta"]["contactPhone"] || nil u end - def desc + def desc_old if @data.has_key?("event") && @data["event"].has_key?("briefDescription") - ret=@data["event"]["briefDescription"] - if @data["event"].has_key?("eventDetails") && @data["event"]["eventDetails"]!=nil && @data["event"]["eventDetails"].has_key?("eventDetail") + ret = @data["event"]["briefDescription"] + if @data["event"].has_key?("eventDetails") && @data["event"]["eventDetails"] != nil && @data["event"]["eventDetails"].has_key?("eventDetail") eventDetail = @data["event"]["eventDetails"]["eventDetail"] - if eventDetail.class==Array + if eventDetail.class == Array @data["event"]["eventDetails"]["eventDetail"].each do |detail| ret +="<div><b>" + detail["eventDetailsName"] + ":</b> " + cleanup_reg_string(detail["eventDetailsValue"]) + "</div>" end else #hash @@ -137,9 +145,39 @@ end end return ret elsif @data.has_key?("event") && @data["event"].has_key?("eventDescription") return @data["event"]["eventDescription"] + end + end + + def desc(length = :full) + if length == :full + @data["event"]["eventDescription"] + else + @data["event"]["briefDescription"] + end + end + + # Content should be a array of hashes. + # [ {:title => "briefDescription", :type => "html", :content => "..." }] + # + # It should contain everything in briefDescription description and eventDetails. + # It should just be one big happy + # + # TODO: Need to order this by detail[:eventDetailsOrder] + # TODO: Add the other description blocks to this + def content + if @data["event"] and @data["event"]["eventDetails"] + + if @data["event"]["eventDetails"]["eventDetail"].class == Array + return @data["event"]["eventDetails"]["eventDetail"].collect { |obj| {:title => obj[:eventDetailsName], :content => obj[:eventDetailsValue]} } + else + return [{:title => @data["event"]["eventDetails"]["eventDetail"]["eventDetailsName"],:content => @data["event"]["eventDetails"]["eventDetail"]["eventDetailsValue"]}] + end + + else + return [] end end def cleanup_reg_string(input) input.gsub("\r","").gsub("\n","").gsub("\"","""").gsub("\342\200\234","""").gsub("\342\200\235","""")