lib/actv/asset.rb in actv-1.1.6 vs lib/actv/asset.rb in actv-1.1.17

- old
+ new

@@ -212,11 +212,132 @@ def thriva? self.sourceSystem[:legacyGuid].upcase == "2BA50ABA-080E-4E3D-A01C-1B4F56648A2E" rescue false end + def activenet? + self.sourceSystem[:legacyGuid].upcase == "FB27C928-54DB-4ECD-B42F-482FC3C8681F" rescue false + end + def registration_status @registration_status ||= nil end alias reg_status registration_status + + def attributes + @attributes ||= assetAttributes.sort_by do |attribute| + attribute[:attribute][:attributeType] + end.map do |attribute| + attribute[:attribute][:attributeValue] + end + end + + def attribute_paths + attributes.map do |attribute| + [sub_topic_path, urlize(attribute)].join "/" + end + end + + def meta_interests + @meta_interests ||= attrs[:assetMetaInterests].sort_by do |interest| + interest[:sequence] + end.map do |interest| + interest[:metaInterest][:metaInterestName] + end + end + + def meta_interest_paths + meta_interests.map do |meta_interest| + [sub_topic_path, urlize(meta_interest)].join "/" + end + end + + def location_path + @location ||= "#{place.cityName} #{place.stateProvinceCode}".downcase.gsub ' ','-' + end + + def first_topic + get_first_topic_taxonomy[0] + end + + def first_topic_path + urlize first_topic + end + + def sub_topic + get_first_topic_taxonomy[1] + end + + def sub_topic_path + urlize sub_topic + end + + def sub_2_topic + get_first_topic_taxonomy[2] + end + + def sub_2_topic_path + urlize "#{sub_topic_path}/#{sub_2_topic}" + end + + def image_with_placeholder + if image_path.empty? + "/images/logo-active-icon-gray.gif" + else + image_path + end + end + + def image_path + default_image = 'http://www.active.com/images/events/hotrace.gif' + image = image_without_placeholder.imageUrlAdr rescue "" + + if image.empty? and (logoUrlAdr && logoUrlAdr != default_image && !(logoUrlAdr =~ URI::regexp).nil?) + image = logoUrlAdr + end + + image + end + + def media_url + image_without_placeholder.imageUrlAdr rescue "" + end + + def image + image_without_placeholder + end + + private + + def image_without_placeholder + default_image = 'http://www.active.com/images/events/hotrace.gif' + current_image = nil + + asset_images.each do |i| + if i.imageUrlAdr.downcase != default_image + current_image = i + break + end + end + + current_image + end + + def get_first_topic_taxonomy + @first_topic_taxonomy ||= assetTopics.sort_by(&:sequence).first + if @first_topic_taxonomy + @first_topic_taxonomy.topic.topicTaxonomy.split '/' + else + [] + end + end + + def urlize str + if str + str.downcase.gsub ' ', '-' + else + "" + end + end + end end