Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Outreachy] Dashboard Redesign URL #8886

Merged
merged 4 commits into from
Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,29 @@ def dashboard
end
end

def dashboard_v2
# The new dashboard displays the blog and topics list
if current_user
@blog = Tag.find_nodes_by_type('blog', 'note', 1).first
# Topics a user has subscribed to
subscibed_tags = TagSelection.includes(:tag)
.where(following: true, user_id: current_user.id)

# Also Needed on the view:
# Number of people discussing the tag/topic: Not sure how to get this,
# is this the number of people commenting on posts?
# Total number of posts (post type: "notes" or wikis)
# Assuming that the node type to be displayed is type: "note"
# Tag.tagged_node_count(subscribed_tags[index].tag.name)
# Posts within the topic (Tag.find_research_notes(subscribed_tags[index].tag.name))
# Each topic card displayes at least 3 posts, would that be the most recent?

render template: 'dashboard/dashboard_v2'
else
redirect_to '/research'
end
end

def research
if current_user
redirect_to '/dashboard'
Expand Down
3 changes: 3 additions & 0 deletions app/views/dashboard/dashboard_v2.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@


<h1><%= raw translation('dashboard_v2.view') %></h2>
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ en:
first_time_post: "Moderate first-time post:"
_comment_moderate:
first_time_post: "Moderate first-time comment:"
dashboard_v2:
view: "This is the dashboard redesign page"
like:
index:
recent_likes: "Recent Likes"
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
get 'feed/liked' => 'notes#liked_rss'

get 'dashboard' => 'home#dashboard'
get 'v2/dashboard' => 'home#dashboard_v2'
get 'comments' => 'comment#index'
get 'profile/comments/:id' => 'users#comments'
get 'profile/comments/:id/tag/:tagname' => 'users#comments_by_tagname'
Expand Down
15 changes: 15 additions & 0 deletions test/functional/home_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,19 @@ def setup
assert_template 'home/home'
end
end

# dashboard_v2 tests
test 'should get research if not logged by v2/dashboard' do
get :dashboard_v2
assert_redirected_to :research
get :research
assert_response :success
end

test 'get v2/dashboard' do
UserSession.create(users(:bob))
get :dashboard_v2
assert_includes response.body, "This is the dashboard redesign page"
end

end