mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-07 18:13:36 +01:00
added group_timelines
This commit is contained in:
parent
eaa4096af5
commit
a8ed21942e
9 changed files with 83 additions and 81 deletions
7
app/controllers/group_controller.rb
Normal file
7
app/controllers/group_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class GroupController < ApplicationController
|
||||||
|
before_filter :index
|
||||||
|
|
||||||
|
def index
|
||||||
|
@timeline = Group.find_by_name(params[:group_name]).timeline.paginate(page: params[:page])
|
||||||
|
end
|
||||||
|
end
|
|
@ -15,4 +15,9 @@ class Group < ActiveRecord::Base
|
||||||
def remove_member(user)
|
def remove_member(user)
|
||||||
GroupMember.where(group: self, user: user).first!.destroy
|
GroupMember.where(group: self, user: user).first!.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [Array] the groups' timeline
|
||||||
|
def timeline
|
||||||
|
Answer.where("user_id in (?)", members.pluck(:user_id)).order(:created_at).reverse_order
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
class ScreenNameValidator < ActiveModel::EachValidator
|
class ScreenNameValidator < ActiveModel::EachValidator
|
||||||
FORBIDDEN_SCREEN_NAMES = %w(justask_admin retrospring_admin admin justask retrospring support about public
|
FORBIDDEN_SCREEN_NAMES = %w(justask_admin retrospring_admin admin justask retrospring support about public
|
||||||
notifications inbox sign_in sign_up sidekiq moderation moderator mod administrator
|
notifications inbox sign_in sign_up sidekiq moderation moderator mod administrator
|
||||||
siteadmin site_admin help retro_spring retroospring retrosprlng niisding nllsding)
|
siteadmin site_admin help retro_spring retroospring retrosprlng niisding nllsding
|
||||||
|
group settings)
|
||||||
|
|
||||||
def validate_each(record, attribute, value)
|
def validate_each(record, attribute, value)
|
||||||
if FORBIDDEN_SCREEN_NAMES.include? value.downcase
|
if FORBIDDEN_SCREEN_NAMES.include? value.downcase
|
||||||
|
|
16
app/views/group/index.html.haml
Normal file
16
app/views/group/index.html.haml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
.container.j2-page
|
||||||
|
.col-md-3.col-sm-3
|
||||||
|
= render 'shared/sidebar'
|
||||||
|
.col-md-9.col-xs-12.col-sm-9
|
||||||
|
= render 'layouts/messages'
|
||||||
|
|
||||||
|
#timeline
|
||||||
|
- @timeline.each do |answer|
|
||||||
|
= render 'shared/answerbox', a: answer
|
||||||
|
|
||||||
|
#pagination= will_paginate @timeline, renderer: BootstrapPagination::Rails, page_links: false
|
||||||
|
|
||||||
|
- if @timeline.next_page
|
||||||
|
%button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @timeline.current_page }}
|
||||||
|
Load more
|
||||||
|
.visible-xs= render 'shared/links'
|
8
app/views/group/index.js.erb
Normal file
8
app/views/group/index.js.erb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
$('#timeline').append('<% @timeline.each do |answer|
|
||||||
|
%><%= j render 'shared/answerbox', a: answer
|
||||||
|
%><% end %>');
|
||||||
|
<% if @timeline.next_page %>
|
||||||
|
$('#pagination').html('<%= j will_paginate @timeline, renderer: BootstrapPagination::Rails, page_links: false %>');
|
||||||
|
<% else %>
|
||||||
|
$('#pagination, #load-more-btn').remove();
|
||||||
|
<% end %>
|
|
@ -1,45 +1,6 @@
|
||||||
.container.j2-page
|
.container.j2-page
|
||||||
.col-md-3.col-sm-3
|
.col-md-3.col-sm-3
|
||||||
.panel.panel-default.hidden-xs
|
= render 'shared/sidebar'
|
||||||
.panel-body
|
|
||||||
%p
|
|
||||||
Welcome,
|
|
||||||
= current_user.screen_name
|
|
||||||
- unless inbox_count.nil?
|
|
||||||
%p
|
|
||||||
%strong
|
|
||||||
You have
|
|
||||||
= pluralize(inbox_count, 'new question')
|
|
||||||
in your inbox!
|
|
||||||
.row
|
|
||||||
%a{href: show_user_followers_path(current_user.screen_name)}
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#follower-count= current_user.follower_count
|
|
||||||
%h6.entry-subtext Followers
|
|
||||||
%a{href: show_user_friends_path(current_user.screen_name)}
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#friend-count= current_user.friend_count
|
|
||||||
%h6.entry-subtext Following
|
|
||||||
.row
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#asked-count= current_user.asked_count
|
|
||||||
%h6.entry-subtext Questions
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#answered-count= current_user.answered_count
|
|
||||||
%h6.entry-subtext Answers
|
|
||||||
.row
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#asked-count= current_user.commented_count
|
|
||||||
%h6.entry-subtext Comments
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#answered-count= current_user.smiled_count
|
|
||||||
%h6.entry-subtext Smiles
|
|
||||||
.panel.panel-default
|
|
||||||
.panel-body
|
|
||||||
%ul.nav.nav-pills.nav-stacked
|
|
||||||
= nav_entry "Timeline", root_path
|
|
||||||
= nav_entry "Public", public_timeline_path
|
|
||||||
.hidden-xs= render 'shared/links'
|
|
||||||
.col-md-9.col-xs-12.col-sm-9
|
.col-md-9.col-xs-12.col-sm-9
|
||||||
= render 'layouts/messages'
|
= render 'layouts/messages'
|
||||||
|
|
||||||
|
|
42
app/views/shared/_sidebar.html.haml
Normal file
42
app/views/shared/_sidebar.html.haml
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
.panel.panel-default.hidden-xs
|
||||||
|
.panel-body
|
||||||
|
%p
|
||||||
|
Welcome,
|
||||||
|
= current_user.screen_name
|
||||||
|
- unless inbox_count.nil?
|
||||||
|
%p
|
||||||
|
%strong
|
||||||
|
You have
|
||||||
|
= pluralize(inbox_count, 'new question')
|
||||||
|
in your inbox!
|
||||||
|
.row
|
||||||
|
%a{href: show_user_followers_path(current_user.screen_name)}
|
||||||
|
.col-md-6.col-sm-6.col-xs-6
|
||||||
|
%h4.entry-text#follower-count= current_user.follower_count
|
||||||
|
%h6.entry-subtext Followers
|
||||||
|
%a{href: show_user_friends_path(current_user.screen_name)}
|
||||||
|
.col-md-6.col-sm-6.col-xs-6
|
||||||
|
%h4.entry-text#friend-count= current_user.friend_count
|
||||||
|
%h6.entry-subtext Following
|
||||||
|
.row
|
||||||
|
.col-md-6.col-sm-6.col-xs-6
|
||||||
|
%h4.entry-text#asked-count= current_user.asked_count
|
||||||
|
%h6.entry-subtext Questions
|
||||||
|
.col-md-6.col-sm-6.col-xs-6
|
||||||
|
%h4.entry-text#answered-count= current_user.answered_count
|
||||||
|
%h6.entry-subtext Answers
|
||||||
|
.row
|
||||||
|
.col-md-6.col-sm-6.col-xs-6
|
||||||
|
%h4.entry-text#asked-count= current_user.commented_count
|
||||||
|
%h6.entry-subtext Comments
|
||||||
|
.col-md-6.col-sm-6.col-xs-6
|
||||||
|
%h4.entry-text#answered-count= current_user.smiled_count
|
||||||
|
%h6.entry-subtext Smiles
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-body
|
||||||
|
%ul.nav.nav-pills.nav-stacked
|
||||||
|
= nav_entry "Timeline", root_path
|
||||||
|
= nav_entry "Public", public_timeline_path
|
||||||
|
- current_user.groups.each do |group|
|
||||||
|
= nav_entry group.display_name, group_timeline_path(group.name)
|
||||||
|
.hidden-xs= render 'shared/links'
|
|
@ -1,46 +1,7 @@
|
||||||
- if user_signed_in?
|
- if user_signed_in?
|
||||||
.container.j2-page
|
.container.j2-page
|
||||||
.col-md-3.col-sm-3
|
.col-md-3.col-sm-3
|
||||||
.panel.panel-default.hidden-xs
|
= render 'shared/sidebar'
|
||||||
.panel-body
|
|
||||||
%p
|
|
||||||
Welcome,
|
|
||||||
= current_user.screen_name
|
|
||||||
- unless inbox_count.nil?
|
|
||||||
%p
|
|
||||||
%strong
|
|
||||||
You have
|
|
||||||
= pluralize(inbox_count, 'new question')
|
|
||||||
in your inbox!
|
|
||||||
.row
|
|
||||||
%a{href: show_user_followers_path(current_user.screen_name)}
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#follower-count= current_user.follower_count
|
|
||||||
%h6.entry-subtext Followers
|
|
||||||
%a{href: show_user_friends_path(current_user.screen_name)}
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#friend-count= current_user.friend_count
|
|
||||||
%h6.entry-subtext Following
|
|
||||||
.row
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#asked-count= current_user.asked_count
|
|
||||||
%h6.entry-subtext Questions
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#answered-count= current_user.answered_count
|
|
||||||
%h6.entry-subtext Answers
|
|
||||||
.row
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#asked-count= current_user.commented_count
|
|
||||||
%h6.entry-subtext Comments
|
|
||||||
.col-md-6.col-sm-6.col-xs-6
|
|
||||||
%h4.entry-text#answered-count= current_user.smiled_count
|
|
||||||
%h6.entry-subtext Smiles
|
|
||||||
.panel.panel-default
|
|
||||||
.panel-body
|
|
||||||
%ul.nav.nav-pills.nav-stacked
|
|
||||||
= nav_entry "Timeline", root_path
|
|
||||||
= nav_entry "Public", public_timeline_path
|
|
||||||
.hidden-xs= render 'shared/links'
|
|
||||||
.col-md-9.col-xs-12.col-sm-9
|
.col-md-9.col-xs-12.col-sm-9
|
||||||
= render 'layouts/messages'
|
= render 'layouts/messages'
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
match '/public', to: 'public#index', via: :get, as: :public_timeline
|
match '/public', to: 'public#index', via: :get, as: :public_timeline
|
||||||
|
match '/group/:group_name', to: 'group#index', via: :get, as: :group_timeline
|
||||||
|
|
||||||
match '/notifications(/:type)', to: 'notifications#index', via: :get, as: :notifications, defaults: {type: 'all'}
|
match '/notifications(/:type)', to: 'notifications#index', via: :get, as: :notifications, defaults: {type: 'all'}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue