Created
January 25, 2011 14:20
-
-
Save acuizon/794970 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# activity_stream.rss.builder | |
xml.instruct! :xml, :version => "1.0" | |
xml.rss :version => "2.0" do | |
xml.channel do | |
xml.title "Activity Feed for #{@home.name}" | |
xml.description "Activity Feed for #{@home.name}" | |
xml.link property_activity_stream_url(@home.parcel_id, @home.slug) | |
target = @activity_stream.target | |
properties = @activity_stream.properties | |
users = @activity_stream.users | |
for item in @activity_stream.items | |
property = if item.respond_to?(:parcel_id) | |
properties.find { |p| p.parcel_id == item.parcel_id } | |
elsif item.respond_to?(:target_id) | |
properties.find { |p| p.id == item.target_id } | |
end | |
user = users.find { |u| u.id == item.user_id } unless item.is_a?(Story) | |
xml.item do | |
if item.is_a?(Story) | |
xml.title "News story \"#{item.headline}\" by #{item.author} at #{item.published.strftime("%b %e, %Y %I:%M %p")}" | |
xml.description item.teaser | |
xml.pubDate item.published.to_s(:rfc822) | |
xml.link show_story_url(item.to_param) | |
xml.guid show_story_url(item.to_param) | |
elsif item.is_a?(Note) | |
text = if item.historian? | |
"Historian left a Note on #{property.address}, #{property.city.name} at #{item.created_at.strftime("%b %e, %Y %I:%M %p")}" | |
elsif item.newsman? | |
"Newsman left a Note on #{property.address}, #{property.city.name} at #{item.created_at.strftime("%b %e, %Y %I:%M %p")}" | |
elsif user | |
if item.business? | |
"#{user.name} left a Note on #{property.address}, #{property.city.name} at #{item.created_at.strftime("%b %e, %Y %I:%M %p")}" | |
elsif item.on_the_block? | |
"#{user.name} left an On the Block Note#{" on #{property.neighborhood.name}" if property.neighborhood.present?} at #{item.created_at.strftime("%b %e, %Y %I:%M %p")}" | |
else | |
"#{user.name} left a Note on #{property.address}, #{property.city.name} at #{item.created_at.strftime("%b %e, %Y %I:%M %p")}" | |
end | |
end | |
xml.title text | |
xml.description item.headline | |
xml.pubDate item.created_at.to_s(:rfc822) | |
xml.link note_url(item.slug) | |
xml.guid note_url(item.slug) | |
elsif item.is_a?(UserTypeClaim) && user | |
if item.updated_at == item.sale_at | |
text = "#{user.name} worked on #{property.address}, #{property.city.name} at #{item.sale_at.strftime("%b %e, %Y")}" | |
item_date = item.sale_at.to_s(:rfc822) | |
else | |
text = "#{user.name} added Work History from #{item.sale_at.strftime("%b %e, %Y")} on #{property.address}, #{property.city.name} at #{item.created_at.strftime("%b %e, %Y %I:%M %p")}" | |
item_date = item.created_at.to_s(:rfc822) | |
end | |
xml.title text | |
xml.description text | |
xml.pubDate item_date | |
xml.link user_url(user) | |
xml.guid user_url(user) | |
elsif item.is_a?(SaleClaim) | |
text = if item.updated_at == item.sale_at | |
"Repped #{item.bs == 'B' ? 'Buyer' : 'Seller'}: #{item.agent.full_name} sold #{property.address}, #{property.city.name} on #{item.sale_at.strftime("%b %e, %Y")}" | |
else | |
"Repped #{item.bs == 'B' ? 'Buyer' : 'Seller'}: #{item.agent.full_name} added Sales History#{" from #{item.sale_at.strftime("%b %e, %Y")}" if item.sale_at.present?} on #{property.address if property}, #{property.city.name if property and property.city} at #{item.created_at.strftime("%b %e, %Y %I:%M %p")}" | |
end | |
xml.title text | |
xml.description text | |
xml.pubDate item.created_at.to_s(:rfc822) | |
xml.link show_agent_url(item.agent_id) | |
xml.guid show_agent_url(item.agent_id) | |
elsif item.is_a?(Gallery) && user | |
text = "#{user.name} uploaded a Photo Gallery#{" on #{property.address}, #{property.city.name}" if property.present?} at #{item.created_at.strftime("%b %e, %Y %I:%M %p")}" | |
xml.title text | |
xml.description text | |
xml.pubDate item.created_at.to_s(:rfc822) | |
xml.link url_for("http://#{DOMAIN.downcase}#{bs_galleries_path(item, :show)}") | |
xml.guid url_for("http://#{DOMAIN.downcase}#{bs_galleries_path(item, :show)}") | |
elsif item.is_a?(Offer) && user | |
xml.title "New Offer: #{user.name} is offering #{item.title}#{" for HomeClub Members only" if item.homeclub} at #{item.created_at.strftime("%b %e, %Y %I:%M %p")}" | |
xml.description "New Offer: #{user.name} is offering #{item.title}#{" for HomeClub Members only" if item.homeclub} at #{item.created_at.strftime("%b %e, %Y %I:%M %p")}" | |
xml.pubDate item.created_at.to_s(:rfc822) | |
xml.link offer_url(item) | |
xml.guid offer_url(item) | |
end | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.sortable_table | |
%table#textable.sortable | |
%thead | |
%tr | |
%th # | |
%th Agent name | |
%th | |
%tbody | |
- unless @results.empty? | |
- @results.each_with_index do |agent,index| | |
%tr | |
%td= index+1 | |
%td | |
=link_to(agent.full_name, show_agent_path(agent.slug)) | |
%br | |
%div{:id => "agent_teaser_#{agent.id}" } | |
%strong Active in: | |
- cities = agent.cities_working | |
= cities[0..3].compact.map{|city| (link_to city.name, city_path(city.slug))}.join(', ') | |
- if cities.size > 4 | |
\.. | |
= link_to_function 'More', "jQuery('#agent_teaser_#{agent.id}').hide();jQuery('#agent_all_#{agent.id}').show();" | |
- if cities.size > 4 | |
%div{:id => "agent_all_#{agent.id}", :style => "display:none" } | |
%strong Active in: | |
= cities.map{|city| (link_to city.name, city_path(city.slug))}.join(', ') | |
\.. | |
= link_to_function 'Less', "jQuery('#agent_teaser_#{agent.id}').show();jQuery('#agent_all_#{agent.id}').hide();" | |
%td= link_to_ask_agent('Ask the agent a question', agent, {},{:class => 'ask_agent'}) | |
- else | |
%tr | |
%td Nothing was found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected | |
#Explicit implementation is defined in order for after_find to run: http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html | |
def after_find | |
sig = self.read_attribute(:note_signature) | |
if sig.present? | |
sig.gsub!(/\n/, '<br />') | |
new_sig = Sanitize.clean(sig, :elements => ['a', 'br'], :attributes => {'a' => ['href', 'target']}, :output_encoding => "US-ASCII").gsub(/&\S+;/, '') | |
write_attribute(:note_signature, new_sig) unless new_sig == sig | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_neighbors | |
limit = 30 | |
if self.complex | |
self.complex.properties.all( | |
:conditions => ["id != ?", self.id], | |
:limit => limit, | |
:include => :street) | |
else | |
return [] unless self.street | |
neighbors = [] | |
range = [50, 250, 500] | |
index = 0 | |
while (neighbors.size != limit && index != 3) do | |
val = range[index].to_i | |
index += 1 | |
ids = neighbors.collect(&:id) << self.id | |
neighbors << self.street.properties.all( | |
:conditions => ['id NOT IN (?) AND num BETWEEN ? AND ? AND city_id = ?', | |
ids, self.num.to_i-val, self.num.to_i+val, self.city_id], | |
:limit => limit-neighbors.size, | |
:order => 'properties.num DESC', | |
:include => :street) | |
neighbors.flatten! | |
end | |
neighbors | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context "for_political" do | |
should "return listings related political_id" do | |
political = Factory(:political, :grouping => 1, :region_id => 1) | |
property = Factory(:property, :parcel_id => "1-test", :political_id => political.id, :region_id => 1 ) | |
listing = Factory(:listing, :property_id => property.id, :parcel_id => property.parcel_id) | |
assert Listing.for_political(political).include?(listing) | |
end | |
should "return listings related political2_id" do | |
political = Factory(:political, :grouping => 2, :region_id => 1) | |
property = Factory(:property, :parcel_id => "2-test", :political2_id => political.id, :region_id => 1 ) | |
listing = Factory(:listing, :property_id => property.id, :parcel_id => property.parcel_id) | |
assert Listing.for_political(political).include?(listing) | |
end | |
should "return listings related political3_id" do | |
political = Factory(:political, :grouping => 3, :region_id => 1) | |
property = Factory(:property, :parcel_id => "3-test", :political3_id => political.id, :region_id => 1 ) | |
listing = Factory(:listing, :property_id => property.id, :parcel_id => property.parcel_id) | |
assert Listing.for_political(political).include?(listing) | |
end | |
should "return listings related political4_id" do | |
political = Factory(:political, :grouping => 4, :region_id => 1) | |
property = Factory(:property, :parcel_id => "4-test", :political4_id => political.id, :region_id => 1 ) | |
listing = Factory(:listing, :property_id => property.id, :parcel_id => property.parcel_id) | |
assert Listing.for_political(political).include?(listing) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment