超级管理员新增功能:留言列表、帖子、通知、最近登录用户列表、作业

This commit is contained in:
cxt 2015-08-15 17:06:50 +08:00
parent a872692984
commit da20f6bc89
12 changed files with 582 additions and 0 deletions

View File

@ -395,4 +395,74 @@ class AdminController < ApplicationController
end end
#留言列表
def leave_messages
@jour = JournalsForMessage.where("jour_type = 'Principal' or jour_type = 'Course'").reorder('created_on desc')
case params[:format]
when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 30})
else
@limit = 30#per_page_option
end
@jour_count = @jour.count
@jour_pages = Paginator.new @jour_count, @limit, params['page']
@offset ||= @jour_pages.offset
@jour = @jour.limit(@limit).offset(@offset).all
respond_to do |format|
format.html
end
end
#帖子
def messages_list
@memo = Memo.reorder("created_at desc")
=begin
case params[:format]
when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 30})
else
@limit = 30#per_page_option
end
@memo_count = @memo.count
@memo_pages = Paginator.new @memo_count, @limit, params['page']
@offset ||= @memo_pages.offset
@memo = @memo.limit(@limit).offset(@offset).all
=end
respond_to do |format|
format.html
end
end
#课程讨论区的帖子
def course_messages
#@boards=Board.where('course_id is NULL')
#@course_ms = Message.reorder('created_on desc')
@course_ms=Message.joins("join boards on messages.board_id=boards.id where boards.course_id is not NULL").reorder('created_on desc')
end
#项目讨论区的帖子
def project_messages
@project_ms=Message.joins("join boards on messages.board_id=boards.id where boards.project_id != -1").reorder('created_on desc')
end
#通知
def notices
@news = News.where('course_id is not NULL').order('created_on desc')
end
#最近登录用户列表
def latest_login_users
@user = User.order('last_login_on desc')
end
#作业
def homework
@homework = HomeworkCommon.order('end_time desc')
end
end end

View File

@ -0,0 +1,8 @@
<div class="tabs">
<ul>
<li><%= link_to l(:label_forum), {:action => 'messages_list'}, class: "#{current_page?(messages_list_path)? 'selected' : nil }" %></li>
<li><%= link_to l(:label_borad_course), {:action => 'course_messages'}, class: "#{current_page?(course_messages_path)? 'selected' : nil }" %></li>
<li><%= link_to l(:label_borad_project), {:action => 'project_messages'}, class: "#{current_page?(project_messages_path)? 'selected' : nil }" %></li>
</ul>
</div>

View File

@ -0,0 +1,66 @@
<h3>
<%=l(:label_message_plural)%>
</h3>
<%= render 'tab_messages' %>
<h4><%=l(:label_borad_course) %></h4>
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 30px;">
来源
</th>
<th style="width: 50px;">
作者
</th>
<th style="width: 70px;">
时间
</th>
<th style="width: 120px;">
标题
</th>
<th style="width: 30px;">
回复数
</th>
</tr>
</thead>
<tbody>
<% @count=0%>
<% for course in @course_ms -%>
<% @count=@count + 1 %>
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center;">
<%= @count %>
</td>
<td align="center">
<%= Board.where('id=?',course.board_id).first.course_id %>
</td>
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if course.try(:author).try(:realname) == ' '%><%= course.try(:author)%><% else %><%=course.try(:author).try(:realname) %><% end %>'>
<% if course.try(:author).try(:realname) == ' '%>
<%= link_to(course.try(:author), user_path(course.author)) %>
<% else %>
<%= link_to(course.try(:author).try(:realname), user_path(course.author)) %>
<% end %>
</td>
<td class="center">
<%= format_date(course.created_on) %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=course.subject %>'>
<%= course.subject %>
</td>
<td class="center">
<%=course.replies_count %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% html_title(l(:label_message_plural)) -%>

View File

@ -0,0 +1,62 @@
<h3>
<%=l(:label_user_homework)%>
</h3>
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 120px;">
作业名称
</th>
<th style="width: 120px;">
课程名称
</th>
<th style="width: 50px;">
作者
</th>
<th style="width: 50px;">
提交作品数
</th>
<th style="width: 70px;">
提交截止日期
</th>
</tr>
</thead>
<tbody>
<%@count=0 %>
<% for homework in @homework do %>
<% @count+=1 %>
<tr>
<td align="center">
<%=@count %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=homework.name%>'>
<%=link_to(homework.name, student_work_index_path(:homework => homework.id))%>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=homework.course.name%>'>
<%= link_to(homework.course.name, course_path(homework.course.id)) %>
</td>
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if homework.try(:user).try(:realname) == ' '%><%= homework.try(:user)%><% else %><%=homework.try(:user).try(:realname) %><% end %>'>
<% if homework.try(:user).try(:realname) == ' '%>
<%= link_to(homework.try(:user), user_path(homework.user_id)) %>
<% else %>
<%= link_to(homework.try(:user).try(:realname), user_path(homework.user_id)) %>
<% end %>
</td>
<td align="center">
<%=StudentWork.where('homework_common_id=?',homework.id).count %>
</td>
<td align="center">
<%=format_date(homework.end_time) %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% html_title(l(:label_user_homework)) -%>

View File

@ -0,0 +1,73 @@
<h3>
<%=l(:label_latest_login_user_list)%>
</h3>
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 70px;">
登录时间
</th>
<th style="width: 30px;">
用户id
</th>
<th style="width: 50px;">
用户姓名
</th>
<th style="width: 50px;">
用户昵称
</th>
<th style="width: 50px;">
用户身份
</th>
</tr>
</thead>
<tbody>
<% @count=0 %>
<% for user in @user do %>
<tr>
<% @count +=1 %>
<td align="center">
<%=@count %>
</td>
<td align="center">
<%=format_date(user.last_login_on) %>
</td>
<td align="center">
<%=user.id %>
</td>
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if user.try(:realname) == ' '%><%= user.login%><% else %><%=user.try(:realname) %><% end %>'>
<% if user.try(:realname) == ' '%>
<%= link_to(user.login, user_path(user)) %>
<% else %>
<%= link_to(user.try(:realname), user_path(user)) %>
<% end %>
</td>
<td align="center">
<%=link_to(user.login, user_path(user)) %>
</td>
<td align="center">
<% case user.user_extensions.identity %>
<% when 0 %>
<%='老师' %>
<% when 1 %>
<%='学生' %>
<% when 2 %>
<%='企业' %>
<% when 3 %>
<%='开发者' %>
<% else %>
<%='未知身份' %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% html_title(l(:label_latest_login_user_list)) -%>

View File

@ -0,0 +1,79 @@
<h3>
<%=l(:label_leave_message_list)%>
</h3>
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 50px;">
类型
</th>
<th style="width: 30px;">
来源
</th>
<th style="width: 50px;">
留言人
</th>
<th style="width: 70px;">
留言时间
</th>
<th style="width: 120px;">
留言内容
</th>
<th style="width: 30px;">
回复数
</th>
</tr>
</thead>
<tbody>
<% @count=0%>
<% for journal in @jour -%>
<% @count=@count + 1 %>
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center;">
<%= @count %>
</td>
<td align="center">
<%case journal.jour_type %>
<% when 'Principal' %>
<%='用户主页' %>
<% when 'Course' %>
<%='课程' %>
<% end %>
</td>
<td align="center">
<%= journal.jour_id %>
</td>
<td align="center" title='<%= journal.try(:user).try(:realname)%>'>
<%= link_to(journal.try(:user).try(:realname).truncate(6, omission: '...'), user_path(journal.user)) %>
</td>
<td class="center">
<%= format_date(journal.created_on) %>
</td>
<td title='<%=journal.notes %>'>
<%= journal.notes.truncate(15, omission: '...') %>
</td>
<td class="center">
<% if(journal.m_reply_count) %>
<%=journal.m_reply_count%>
<% else %>
<%=0 %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="pagination">
<ul>
<%= pagination_links_full @jour_pages, @jour_count %>
</ul>
</div>
<% html_title(l(:label_leave_message_list)) -%>

View File

@ -0,0 +1,69 @@
<h3>
<%=l(:label_message_plural)%>
</h3>
<%= render 'tab_messages' %>
<h4><%=l(:label_forum) %></h4>
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 30px;">
来源
</th>
<th style="width: 50px;">
作者
</th>
<th style="width: 70px;">
时间
</th>
<th style="width: 120px;">
标题
</th>
<th style="width: 30px;">
回复数
</th>
</tr>
</thead>
<tbody>
<% @count=0%>
<% for memo in @memo -%>
<% @count=@count + 1 %>
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center;">
<%= @count %>
</td>
<td align="center">
<%= memo.forum_id %>
</td>
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if memo.try(:author).try(:realname) == ' '%><%= memo.try(:author)%><% else %><%=memo.try(:author).try(:realname) %><% end %>'>
<% if memo.try(:author).try(:realname) == ' '%>
<%= link_to(memo.try(:author), user_path(memo.author)) %>
<% else %>
<%= link_to(memo.try(:author).try(:realname), user_path(memo.author)) %>
<% end %>
</td>
<td class="center">
<%= format_date(memo.created_at) %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=memo.subject %>'>
<%= memo.subject %>
</td>
<td class="center">
<%=memo.replies_count %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<!--<div class="pagination">
<ul>
<#%= pagination_links_full @memo_pages, @memo_count %>
</ul>
</div>-->
<% html_title(l(:label_message_plural)) -%>

View File

@ -0,0 +1,74 @@
<h3>
<%=l(:label_notification_list)%>
</h3>
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 30px;">
课程id
</th>
<th style="width: 120px;">
课程名称
</th>
<th style="width: 50px;">
主讲老师
</th>
<th style="width: 50px;">
作者
</th>
<th style="width: 70px;">
时间
</th>
<th style="width: 120px;">
标题
</th>
<th style="width: 30px;">
回复数
</th>
</tr>
</thead>
<tbody>
<% @count=0%>
<% for news in @news -%>
<% @count=@count + 1 %>
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center;">
<%= @count %>
</td>
<td align="center">
<%=news.course_id %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title="<%=news.course.name %>">
<%=link_to(news.course.name, course_path(news.course)) %>
</td>
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title="<%=news.course.try(:teacher).try(:realname) %>">
<%=link_to(news.course.try(:teacher).try(:realname), user_path(news.course.teacher)) %>
</td>
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if news.try(:author).try(:realname) == ' '%><%= news.try(:author)%><% else %><%=news.try(:author).try(:realname) %><% end %>'>
<% if news.try(:author).try(:realname) == ' '%>
<%= link_to(news.try(:author), user_path(news.author)) %>
<% else %>
<%= link_to(news.try(:author).try(:realname), user_path(news.author)) %>
<% end %>
</td>
<td class="center">
<%= format_date(news.created_on) %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=news.title %>'>
<%= link_to(news.title, news_path(news)) %>
</td>
<td class="center">
<%=news.comments_count %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% html_title(l(:label_notification_list)) -%>

View File

@ -0,0 +1,66 @@
<h3>
<%=l(:label_message_plural)%>
</h3>
<%= render 'tab_messages' %>
<h4><%=l(:label_borad_project) %></h4>
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 30px;">
来源
</th>
<th style="width: 50px;">
作者
</th>
<th style="width: 70px;">
时间
</th>
<th style="width: 120px;">
标题
</th>
<th style="width: 30px;">
回复数
</th>
</tr>
</thead>
<tbody>
<% @count=0%>
<% for project in @project_ms -%>
<% @count=@count + 1 %>
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center;">
<%= @count %>
</td>
<td align="center">
<%= Board.where('id=?',project.board_id).first.project_id %>
</td>
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if project.try(:author).try(:realname) == ' '%><%= project.try(:author)%><% else %><%=project.try(:author).try(:realname) %><% end %>'>
<% if project.try(:author).try(:realname) == ' '%>
<%= link_to(project.try(:author), user_path(project.author)) %>
<% else %>
<%= link_to(project.try(:author).try(:realname), user_path(project.author)) %>
<% end %>
</td>
<td class="center">
<%= format_date(project.created_on) %>
</td>
<td title='<%=project.subject %>' style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name">
<%= project.subject %>
</td>
<td class="center">
<%=project.replies_count %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% html_title(l(:label_message_plural)) -%>

View File

@ -552,6 +552,7 @@ zh:
label_registered_on: 注册于 label_registered_on: 注册于
label_overall_activity: 活动概览 label_overall_activity: 活动概览
label_new: 新建 label_new: 新建
label_latest_login_user_list: 最近登录用户列表
label_logged_as: 登录为 label_logged_as: 登录为
label_environment: 环境 label_environment: 环境
@ -1252,6 +1253,7 @@ zh:
label_leave_message_to: 给用户 %{name}留言 label_leave_message_to: 给用户 %{name}留言
label_leave_message: 留言内容 label_leave_message: 留言内容
label_message: 留言板 label_message: 留言板
label_leave_message_list: 留言列表
field_add: 添加于 %{time} 之前 field_add: 添加于 %{time} 之前
label_student_response: 作业答疑 # modified by bai label_student_response: 作业答疑 # modified by bai
@ -1748,6 +1750,7 @@ zh:
cancel_apply: 取消申请 cancel_apply: 取消申请
apply_master: 申请成为版主 apply_master: 申请成为版主
you_are_master: 您是该项目的版主 you_are_master: 您是该项目的版主
label_notification_list: 通知
#add by linchun (竞赛相关) #add by linchun (竞赛相关)
label_upload_softwarepackage: 上传软件包 label_upload_softwarepackage: 上传软件包

View File

@ -679,6 +679,13 @@ RedmineApp::Application.routes.draw do
match 'admin/default_configuration', :via => :post match 'admin/default_configuration', :via => :post
get 'admin/organization' get 'admin/organization'
get 'admin/schools' get 'admin/schools'
get 'admin/leave_messages'
match 'admin/messages_list', as: :messages_list
match 'admin/project_messages', as: :project_messages
match'admin/course_messages', as: :course_messages
get 'admin/notices'
get 'admin/latest_login_users'
get 'admin/homework'
resources :auth_sources do resources :auth_sources do
member do member do

View File

@ -386,6 +386,11 @@ Redmine::MenuManager.map :admin_menu do |menu|
:html => {:class => 'server_authentication'} :html => {:class => 'server_authentication'}
menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true
menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true
menu.push :leave_messages, {:controller => 'admin', :action => 'leave_messages'}, :caption => :label_leave_message_list
menu.push :messages_list, {:controller => 'admin', :action => 'messages_list'}, :caption => :label_message_plural
menu.push :notices, {:controller => 'admin', :action => 'notices'}, :caption => :label_notification_list
menu.push :latest_login_users, {:controller => 'admin', :action => 'latest_login_users'}, :caption => :label_latest_login_user_list
menu.push :homework, {:controller => 'admin', :action => 'homework'}, :caption => :label_user_homework
end end
#Modified by young #Modified by young