GitLab's annual major release is around the corner. Along with a lot of new and exciting features, there will be a few breaking changes. Learn more here.

Commit b439f1f7 authored by Bráulio Bhavamitra's avatar Bráulio Bhavamitra
Browse files

Merge branch 'favorite-enterprises-actions' into 'master'

favorite_enterprise: track actions to wall

See merge request !498
parents ab8d14e6 db1e4abf
......@@ -85,4 +85,10 @@ module ActionTrackerHelper
}
end
def favorite_enterprise_description ta
_('favorited enterprise %{title}') % {
title: link_to(truncate(ta.get_enterprise_name), ta.get_enterprise_url),
}
end
end
......@@ -23,7 +23,7 @@ class Enterprise < Organization
has_many :production_costs, :as => :owner
has_many :favorite_enterprise_people
has_many :fans, through: :favorite_enterprise_people, source: :person
has_many :fans, source: :person, through: :favorite_enterprise_people
def product_categories
ProductCategory.by_enterprise(self)
......
class FavoriteEnterprisePerson < ActiveRecord::Base
self.table_name = :favorite_enteprises_people
attr_accessible :person, :enterprise
track_actions :favorite_enterprise, :after_create, keep_params: [:enterprise_name, :enterprise_url], if: proc{ |f| f.is_trackable? }
belongs_to :enterprise
belongs_to :person
protected
def is_trackable?
self.enterprise.public?
end
def enterprise_name
self.enterprise.short_name(nil)
end
def enterprise_url
self.enterprise.url
end
end
......@@ -81,6 +81,9 @@ roles] }
has_many :scraps_sent, :class_name => 'Scrap', :foreign_key => :sender_id, :dependent => :destroy
has_many :favorite_enterprise_people
has_many :favorite_enterprises, source: :enterprise, through: :favorite_enterprise_people
has_and_belongs_to_many :acepted_forums, :class_name => 'Forum', :join_table => 'terms_forum_people'
has_and_belongs_to_many :articles_with_access, :class_name => 'Article', :join_table => 'article_privacy_exceptions'
......@@ -315,8 +318,6 @@ roles] }
]
end
has_and_belongs_to_many :favorite_enterprises, :class_name => 'Enterprise', :join_table => 'favorite_enteprises_people'
def email_domain
user && user.email_domain || environment.default_hostname(true)
end
......
......@@ -744,7 +744,11 @@ private :generate_url, :url_options
include ActionView::Helpers::TextHelper
def short_name(chars = 40)
if self[:nickname].blank?
truncate self.name, :length => chars, :omission => '...'
if chars
truncate self.name, length: chars, omission: '...'
else
self.name
end
else
self[:nickname]
end
......
<div class='profile-activity-image'>
<%= link_to(profile_image(activity.user, :minor), activity.user.url) %>
</div>
<div class='profile-activity-description'>
<p class='profile-activity-text'>
<%= link_to activity.user.short_name(nil), activity.user.url %> <%= describe activity %>
</p>
<p class='profile-activity-time'><%= time_ago_as_sentence activity.created_at %></p>
<div class='profile-wall-actions'>
<%= link_to_function(_('Remove'), 'remove_item_wall(this, \'%s\', \'%s\', \'%s\'); return false ;' % [".profile-activity-item", url_for(:profile => params[:profile], :action => :remove_activity, :activity_id => activity.id, :view => params[:view]), _('Are you sure you want to remove this activity and all its replies?')]) if logged_in? && current_person == @profile %>
</div>
</div>
<div style="clear: both"></div>
......@@ -40,6 +40,9 @@ ActionTrackerConfig.verbs = {
remove_product: {
},
favorite_enterprise: {
},
}
ActionTrackerConfig.current_user = proc do
......
class AddIdToFavoriteEnterprisesPeople < ActiveRecord::Migration
def up
rename_table :favorite_enteprises_people, :favorite_enterprise_people
change_table :favorite_enterprise_people do |t|
t.timestamps
end
add_column :favorite_enterprise_people, :id, :primary_key
add_index :favorite_enterprise_people, [:person_id, :enterprise_id]
add_index :favorite_enterprise_people, :person_id
add_index :favorite_enterprise_people, :enterprise_id
end
def down
rename_table :favorite_enterprise_people, :favorite_enteprises_people
remove_column :favorite_enteprises_people, :id
remove_column :favorite_enteprises_people, :created_at
remove_column :favorite_enteprises_people, :updated_at
remove_index :favorite_enteprises_people, [:person_id, :enterprise_id]
remove_index :favorite_enteprises_people, :person_id
remove_index :favorite_enteprises_people, :enterprise_id
end
end
......@@ -351,11 +351,17 @@ ActiveRecord::Schema.define(:version => 20150712130827) do
add_index "external_feeds", ["enabled"], :name => "index_external_feeds_on_enabled"
add_index "external_feeds", ["fetched_at"], :name => "index_external_feeds_on_fetched_at"
create_table "favorite_enteprises_people", :id => false, :force => true do |t|
t.integer "person_id"
t.integer "enterprise_id"
create_table "favorite_enterprise_people", :force => true do |t|
t.integer "person_id"
t.integer "enterprise_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "favorite_enterprise_people", ["enterprise_id"], :name => "index_favorite_enterprise_people_on_enterprise_id"
add_index "favorite_enterprise_people", ["person_id", "enterprise_id"], :name => "index_favorite_enterprise_people_on_person_id_and_enterprise_id"
add_index "favorite_enterprise_people", ["person_id"], :name => "index_favorite_enterprise_people_on_person_id"
create_table "friendships", :force => true do |t|
t.integer "person_id"
t.integer "friend_id"
......
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