Permalink
Browse files

Merge branch 'develop' of https://github.com/Th0ar/zjforum into develop

  • Loading branch information...
liudangyi committed Oct 28, 2012
2 parents 86737e3 + 00341b5 commit d272f61441e14d409f922e0903d4e77d5c2673fe
@@ -1,3 +1,4 @@
+# coding: utf-8
class ApplicationController < ActionController::Base
protect_from_forgery
@@ -6,4 +7,10 @@ class ApplicationController < ActionController::Base
@posts_rec = Post.popular.limit(4)
@events_rec = Event.unfinished.limit(4)
end
+
+ def ensure_admin!
+ if current_user == nil || !current_user.admin?
+ return false
+ end
+ end
end
@@ -1,4 +1,5 @@
class BigpicsController < ApplicationController
+ before_filter :ensure_admin!
# GET /bigpics
# GET /bigpics.json
def index
@@ -1,4 +1,5 @@
class DonatesController < ApplicationController
+ before_filter :ensure_admin!, except: [:show, :index]
# GET /donates
# GET /donates.json
def index
@@ -1,4 +1,5 @@
class EventsController < ApplicationController
+ before_filter :ensure_admin!, except: [:show, :index]
# GET /events
# GET /events.json
def index
@@ -1,5 +1,6 @@
# coding: utf-8
class MatesController < ApplicationController
+ before_filter :ensure_admin!, except: [:show, :index]
# GET /mates
# GET /mates.json
def index
@@ -1,4 +1,5 @@
class MessagesController < ApplicationController
+ before_filter :ensure_admin!, except: [:show, :index, :new]
# GET /messages
# GET /messages.json
def index
@@ -1,4 +1,5 @@
class NewsController < ApplicationController
+ before_filter :ensure_admin!, except: [:show, :index]
# GET /news
# GET /news.json
def index
@@ -1,4 +1,5 @@
class PostsController < ApplicationController
+ before_filter :ensure_admin!, only: [:destroy, :delete_comment]
# GET /posts
# GET /posts.json
def index
@@ -1,4 +1,5 @@
class UserManageController < ApplicationController
+ before_filter :ensure_admin!
layout 'home'
def index
View
@@ -7,4 +7,24 @@ class News
default_scope desc(:created_at)
has_many :comments
+
+ def self.reports
+ reports = []
+ cnt = 0
+ self.all.each do |news|
+ if not news.images.empty?
+ cnt += 1
+ reports << news
+ end
+ break if cnt >= 2
+ end
+
+ reports
+ end
+
+ def images
+ imgs = []
+ imgs << self.content.scan(/src="(.*?)"/)
+ return imgs.compact.flatten
+ end
end
@@ -148,17 +148,14 @@
.yellow-block
.yellow-ribbon
- / h4: a href="#" 通讯
+ h4: a href="#" 通讯
ul.unstyled.broadcast
- li
- a href="#"
- | “CMRC中国经济观察”第30次季度报告会特别专场快报通稿
- img src="http://www.nsd.edu.cn/cn/userfiles/Image/2012-07/20120722150205541253291.JPG"
- li
- a href="#"
- | “CMRC中国经济观察”第30次季度报告会特别专场快报通稿
- img src="http://www.nsd.edu.cn/cn/userfiles/Image/2012-07/20120722150205541253291.JPG"
- .yellow-block
+ - News.reports.each do |press|
+ li
+ a href="#"
+ = press.title
+ = image_tag(press.images.first)
+
.yellow-ribbon
h4 相关链接
.relative-link

0 comments on commit d272f61

Please sign in to comment.