Notifcation index page

This commit is contained in:
Rei
2014-01-22 13:43:00 +08:00
parent 457cbcdca0
commit 1deb97c3e6
11 changed files with 77 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ $nav-link-hover-bg: transparent;
@import "topics";
@import "posts";
@import "post_votes";
@import "notifications";
body {
background: #eee;

View File

@@ -7,11 +7,14 @@
background-color: #ccc;
}
a {
color: #555;
li {
a {
color: #555;
&:hover {
color: #333;
&:hover {
color: #333;
background-color: #f9f9f9;
}
}
}
}

View File

@@ -0,0 +1,25 @@
.notifications {
position: relative;
.badge {
background: $brand-primary;
position: absolute;
top: 5px;
right: 5px;
}
}
.list-group-notification {
margin: 0 -16px;
padding: 0;
list-style: none;
}
.list-group-item-notification {
padding: 16px;
border-bottom: 1px solid #eee;
&:first-child {
border-top: 1px solid #eee;
}
}

View File

@@ -0,0 +1,7 @@
class NotificationsController < ApplicationController
before_filter :require_logined
def index
@notifications = current_user.notifications.page(params[:page])
end
end

View File

@@ -0,0 +1,2 @@
module NotificationsHelper
end

View File

@@ -27,6 +27,10 @@ html
#navbar.collapse.navbar-collapse
ul.nav.navbar-nav.navbar-right
- if logined?
li
a.notifications href=notifications_path
i.fa.fa-bell-o
.badge 1
li.dropdown
a.dropdown-toggle data-toggle="dropdown" href='#'
= current_user.name

View File

@@ -0,0 +1,15 @@
.row
.col-md-9
.panel.panel-campo
.panel-heading.clearfix
.pull-right
= paginate @notifications, theme: 'campo', left: 1, right: 1, window: 2
h3.panel-title Notifications
.panel-body
ul.list-group-notification
- @notifications.each do |notification|
- begin
= render "notification/#{notification.name}"
- rescue
.list-group-item-notification
= "##{notification.id} Missing template for #{notification.name} notification."

View File

@@ -26,6 +26,8 @@ Rails.application.routes.draw do
end
end
resources :notifications, only: [:index]
if Rails.env.development?
get 'qunit', to: 'qunit#index'
end

View File

@@ -0,0 +1,10 @@
require 'test_helper'
class NotificationsControllerTest < ActionController::TestCase
test "should get index" do
assert_require_logined do
get :index
end
assert_response :success, @response.body
end
end

View File

@@ -3,7 +3,6 @@
FactoryGirl.define do
factory :notification do
user
subject
name "name_type"
end
end

View File

@@ -0,0 +1,4 @@
require 'test_helper'
class NotificationsHelperTest < ActionView::TestCase
end