Commit 279fbd1925b6fb71f0d2bbacf9cb834de33f5a8c

Authored by Gabriel Silva
1 parent 25603bbb

finishes followed profiles list

Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Signed-off-by: Artur Bersan de Faria <artur_bersan@hotmail.com>
app/controllers/my_profile/followers_controller.rb
1 1 class FollowersController < MyProfileController
2 2  
3 3 def index
4   - @followed_people = Person.all.limit(10).paginate(:per_page => 5, :page => params[:npage])
  4 + @followed_people = current_person.following_profiles.paginate(:per_page => 5, :page => params[:npage])
5 5 end
6 6  
7 7 def set_category
... ...
app/controllers/public/profile_controller.rb
... ... @@ -166,7 +166,8 @@ class ProfileController &lt; PublicController
166 166 if current_person.follows?(profile)
167 167 current_person.unfollow(profile)
168 168 end
169   - redirect_to profile.url
  169 + redirect_url = params["redirect_to"] ? params["redirect_to"] : profile.url
  170 + redirect_to redirect_url
170 171 end
171 172  
172 173 def check_friendship
... ...
app/models/person.rb
... ... @@ -601,7 +601,7 @@ class Person &lt; Profile
601 601 protected
602 602  
603 603 def followed_by?(profile)
604   - self == profile || self.is_a_friend?(profile) || self.followers.include?(profile)
  604 + self == profile || self.followers.include?(profile)
605 605 end
606 606  
607 607 end
... ...
app/models/profile.rb
... ... @@ -204,7 +204,7 @@ class Profile &lt; ApplicationRecord
204 204 scope :more_recent, -> { order "created_at DESC" }
205 205  
206 206 scope :following_profiles, -> person {
207   - distinct.select('profiles.*').
  207 + distinct.select('profiles.*, profile_followers.group').
208 208 joins('join profile_followers ON profile_followers.profile_id = profiles.id').
209 209 where('profile_followers.follower_id = ?', person.id)
210 210 }
... ...
app/views/followers/_profile_list.html.erb
... ... @@ -3,12 +3,12 @@
3 3 <li>
4 4 <%= link_to_profile profile_image(profile) + tag('br') + profile.short_name,
5 5 profile.identifier, :class => 'profile-link' %>
6   - <div id="category-name">
7   - <%= _(Category) %>
8   - </div>
  6 + <p class="category-name">
  7 + <%= profile.group %>
  8 + </p>
9 9 <div class="controll">
10 10 <%= button_without_text :remove, content_tag('span',_('unfollow')),
11   - { :controller => "profile", :profile => profile.identifier , :action => 'unfollow', :redirect_to => "gabriel" },
  11 + { :controller => "profile", :profile => profile.identifier , :action => 'unfollow', :redirect_to => url_for({:controller => "followers", :profile => user.identifier}) },
12 12 :title => _('remove') %>
13 13 <%= modal_icon_button :change_categoy, content_tag('span',_('change category')),
14 14 profile.url.merge(:controller => 'followers', :action => 'set_category', :profile => profile.identifier)%>
... ...
app/views/followers/_set_category_modal.html.erb
1   -<div class='set-category-content'>
2   - <h2><%= _("Select a category") %></h2>
  1 +<div class='set-category-modal'>
  2 + <h2><%= _("Choose a new category") %></h2>
3 3 <form>
4   - <%= labelled_text_field _("Category: "), "person_category" %>
5   - <div>
  4 + <div id="category-name">
  5 + <%= labelled_text_field _("Category: "), "person_category" %>
  6 + </div>
  7 + <div id="actions-container">
6 8 <%= submit_button('save', _('Save')) %>
7 9 <%= modal_close_button _("Cancel") %>
8 10 </div>
... ...
public/stylesheets/blocks/profile-info.scss
... ... @@ -99,9 +99,6 @@
99 99 margin: 0px 0px 5px 0px;
100 100 padding: 2px;
101 101 }
102   -#follower-container {
103   - padding-top: 5px;
104   -}
105 102 #follower-container:hover {
106 103 background-color: #eee;
107 104 -o-transition:.5s;
... ... @@ -109,6 +106,8 @@
109 106 -moz-transition:.5s;
110 107 -webkit-transition:.5s;
111 108 transition:.5s;
  109 + padding-top: 5px;
  110 + padding-bottom: 5px;
112 111 }
113 112 #follower-container #category-form {
114 113 margin-bottom: 5px;
... ...
public/stylesheets/profile-list.scss
... ... @@ -216,22 +216,35 @@
216 216 font-size: 12px;
217 217 }
218 218 .action-profile-members .profile_link{
219   - position: relative;
  219 + position: relative;
220 220 }
221 221 .action-profile-members .profile_link span.new-profile:last-child{
222   - position: absolute;
223   - top: 3px;
224   - right: 2px;
225   - text-transform: uppercase;
226   - color: #FFF;
227   - font-size: 9px;
228   - background: #66CC33;
229   - padding: 2px;
230   - display: block;
231   - width: 35px;
232   - font-weight: 700;
  222 + position: absolute;
  223 + top: 3px;
  224 + right: 2px;
  225 + text-transform: uppercase;
  226 + color: #FFF;
  227 + font-size: 9px;
  228 + background: #66CC33;
  229 + padding: 2px;
  230 + display: block;
  231 + width: 35px;
  232 + font-weight: 700;
233 233 }
234 234 .action-profile-members .profile_link .fn{
235   - font-style: normal;
236   - color: #000;
  235 + font-style: normal;
  236 + color: #000;
  237 +}
  238 +.category-name {
  239 + margin-top: 0px;
  240 + margin-bottom: 0px;
  241 + font-style: italic;
  242 + color: #888a85;
  243 + text-align: center;
  244 +}
  245 +.set-category-modal {
  246 + width: 250px;
  247 +}
  248 +.set-category-modal #actions-container {
  249 + margin-top: 20px
237 250 }
... ...