diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index a44b58789..25536615a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -395,4 +395,74 @@ class AdminController < ApplicationController 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 diff --git a/app/views/admin/_tab_messages.erb b/app/views/admin/_tab_messages.erb new file mode 100644 index 000000000..ec04246ba --- /dev/null +++ b/app/views/admin/_tab_messages.erb @@ -0,0 +1,8 @@ +
+ +
\ No newline at end of file diff --git a/app/views/admin/course_messages.html.erb b/app/views/admin/course_messages.html.erb new file mode 100644 index 000000000..8564d13dc --- /dev/null +++ b/app/views/admin/course_messages.html.erb @@ -0,0 +1,66 @@ +

+ <%=l(:label_message_plural)%> +

+ +<%= render 'tab_messages' %> +

<%=l(:label_borad_course) %>

+
+ + + + + + + + + + + + + <% @count=0%> + <% for course in @course_ms -%> + + <% @count=@count + 1 %> + "> + + + + + + + + + <% end %> + +
+ 序号 + + 来源 + + 作者 + + 时间 + + 标题 + + 回复数 +
+ <%= @count %> + + <%= Board.where('id=?',course.board_id).first.course_id %> + <%= 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 %> + + <%= format_date(course.created_on) %> + + <%= course.subject %> + + <%=course.replies_count %> +
+
+ +<% html_title(l(:label_message_plural)) -%> diff --git a/app/views/admin/homework.html.erb b/app/views/admin/homework.html.erb new file mode 100644 index 000000000..360ca4e39 --- /dev/null +++ b/app/views/admin/homework.html.erb @@ -0,0 +1,62 @@ +

+ <%=l(:label_user_homework)%> +

+ +
+ + + + + + + + + + + + + <%@count=0 %> + <% for homework in @homework do %> + <% @count+=1 %> + + + + + + + + + <% end %> + +
+ 序号 + + 作业名称 + + 课程名称 + + 作者 + + 提交作品数 + + 提交截止日期 +
+ <%=@count %> + + <%=link_to(homework.name, student_work_index_path(:homework => homework.id))%> + + <%= link_to(homework.course.name, course_path(homework.course.id)) %> + <%= 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 %> + + <%=StudentWork.where('homework_common_id=?',homework.id).count %> + + <%=format_date(homework.end_time) %> +
+
+ +<% html_title(l(:label_user_homework)) -%> diff --git a/app/views/admin/latest_login_users.html.erb b/app/views/admin/latest_login_users.html.erb new file mode 100644 index 000000000..dc35daec8 --- /dev/null +++ b/app/views/admin/latest_login_users.html.erb @@ -0,0 +1,73 @@ +

+ <%=l(:label_latest_login_user_list)%> +

+ +
+ + + + + + + + + + + + + <% @count=0 %> + <% for user in @user do %> + + <% @count +=1 %> + + + + + + + + <% end %> + +
+ 序号 + + 登录时间 + + 用户id + + 用户姓名 + + 用户昵称 + + 用户身份 +
+ <%=@count %> + + <%=format_date(user.last_login_on) %> + + <%=user.id %> + <%= 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 %> + + <%=link_to(user.login, user_path(user)) %> + + <% case user.user_extensions.identity %> + <% when 0 %> + <%='老师' %> + <% when 1 %> + <%='学生' %> + <% when 2 %> + <%='企业' %> + <% when 3 %> + <%='开发者' %> + <% else %> + <%='未知身份' %> + <% end %> +
+
+ +<% html_title(l(:label_latest_login_user_list)) -%> diff --git a/app/views/admin/leave_messages.html.erb b/app/views/admin/leave_messages.html.erb new file mode 100644 index 000000000..975c60b15 --- /dev/null +++ b/app/views/admin/leave_messages.html.erb @@ -0,0 +1,79 @@ +

+ <%=l(:label_leave_message_list)%> +

+ + +
+ + + + + + + + + + + + + + <% @count=0%> + <% for journal in @jour -%> + <% @count=@count + 1 %> + "> + + + + + + + + + <% end %> + +
+ 序号 + + 类型 + + 来源 + + 留言人 + + 留言时间 + + 留言内容 + + 回复数 +
+ <%= @count %> + + <%case journal.jour_type %> + <% when 'Principal' %> + <%='用户主页' %> + <% when 'Course' %> + <%='课程' %> + <% end %> + + <%= journal.jour_id %> + + <%= link_to(journal.try(:user).try(:realname).truncate(6, omission: '...'), user_path(journal.user)) %> + + <%= format_date(journal.created_on) %> + + <%= journal.notes.truncate(15, omission: '...') %> + + <% if(journal.m_reply_count) %> + <%=journal.m_reply_count%> + <% else %> + <%=0 %> + <% end %> +
+
+ + +<% html_title(l(:label_leave_message_list)) -%> diff --git a/app/views/admin/messages_list.html.erb b/app/views/admin/messages_list.html.erb new file mode 100644 index 000000000..77cdbbc69 --- /dev/null +++ b/app/views/admin/messages_list.html.erb @@ -0,0 +1,69 @@ +

+ <%=l(:label_message_plural)%> +

+ +<%= render 'tab_messages' %> +

<%=l(:label_forum) %>

+
+ + + + + + + + + + + + + <% @count=0%> + <% for memo in @memo -%> + <% @count=@count + 1 %> + "> + + + + + + + + <% end %> + +
+ 序号 + + 来源 + + 作者 + + 时间 + + 标题 + + 回复数 +
+ <%= @count %> + + <%= memo.forum_id %> + <%= 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 %> + + <%= format_date(memo.created_at) %> + + <%= memo.subject %> + + <%=memo.replies_count %> +
+
+ + +<% html_title(l(:label_message_plural)) -%> diff --git a/app/views/admin/notices.html.erb b/app/views/admin/notices.html.erb new file mode 100644 index 000000000..56f212720 --- /dev/null +++ b/app/views/admin/notices.html.erb @@ -0,0 +1,74 @@ +

+ <%=l(:label_notification_list)%> +

+ +
+ + + + + + + + + + + + + + + <% @count=0%> + <% for news in @news -%> + <% @count=@count + 1 %> + "> + + + + + + + + + + <% end %> + +
+ 序号 + + 课程id + + 课程名称 + + 主讲老师 + + 作者 + + 时间 + + 标题 + + 回复数 +
+ <%= @count %> + + <%=news.course_id %> + + <%=link_to(news.course.name, course_path(news.course)) %> + + <%=link_to(news.course.try(:teacher).try(:realname), user_path(news.course.teacher)) %> + <%= 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 %> + + <%= format_date(news.created_on) %> + + <%= link_to(news.title, news_path(news)) %> + + <%=news.comments_count %> +
+
+ +<% html_title(l(:label_notification_list)) -%> diff --git a/app/views/admin/project_messages.html.erb b/app/views/admin/project_messages.html.erb new file mode 100644 index 000000000..af2978422 --- /dev/null +++ b/app/views/admin/project_messages.html.erb @@ -0,0 +1,66 @@ +

+ <%=l(:label_message_plural)%> +

+ +<%= render 'tab_messages' %> +

<%=l(:label_borad_project) %>

+
+ + + + + + + + + + + + + <% @count=0%> + <% for project in @project_ms -%> + + <% @count=@count + 1 %> + "> + + + + + + + + + <% end %> + +
+ 序号 + + 来源 + + 作者 + + 时间 + + 标题 + + 回复数 +
+ <%= @count %> + + <%= Board.where('id=?',project.board_id).first.project_id %> + <%= 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 %> + + <%= format_date(project.created_on) %> + + <%= project.subject %> + + <%=project.replies_count %> +
+
+ +<% html_title(l(:label_message_plural)) -%> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index c47976275..d679d18cc 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -552,6 +552,7 @@ zh: label_registered_on: 注册于 label_overall_activity: 活动概览 label_new: 新建 + label_latest_login_user_list: 最近登录用户列表 label_logged_as: 登录为 label_environment: 环境 @@ -1252,6 +1253,7 @@ zh: label_leave_message_to: 给用户 %{name}留言 label_leave_message: 留言内容 label_message: 留言板 + label_leave_message_list: 留言列表 field_add: 添加于 %{time} 之前 label_student_response: 作业答疑 # modified by bai @@ -1748,6 +1750,7 @@ zh: cancel_apply: 取消申请 apply_master: 申请成为版主 you_are_master: 您是该项目的版主 + label_notification_list: 通知 #add by linchun (竞赛相关) label_upload_softwarepackage: 上传软件包 diff --git a/config/routes.rb b/config/routes.rb index cdcb1126c..86435d7c1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -679,6 +679,13 @@ RedmineApp::Application.routes.draw do match 'admin/default_configuration', :via => :post get 'admin/organization' 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 member do diff --git a/lib/redmine.rb b/lib/redmine.rb index 0f6c14b8a..99b7ea22f 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -386,6 +386,11 @@ Redmine::MenuManager.map :admin_menu do |menu| :html => {:class => 'server_authentication'} menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :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 #Modified by young