From 27ff5471ec0aaeba36739572b4468766b4dbfc76 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 18 Aug 2015 14:40:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD=E9=A1=B5=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E3=80=81=E6=B7=BB=E5=8A=A0=E8=B6=85=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=9F=A5=E8=AF=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 66 +++++++++++---------- app/views/admin/course_messages.html.erb | 9 ++- app/views/admin/homework.html.erb | 8 ++- app/views/admin/latest_login_users.html.erb | 25 +++++++- app/views/admin/leave_messages.html.erb | 37 ++++++++---- app/views/admin/messages_list.html.erb | 14 ++--- app/views/admin/notices.html.erb | 8 ++- app/views/admin/project_messages.html.erb | 10 +++- db/schema.rb | 8 +-- 9 files changed, 118 insertions(+), 67 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 25536615a..1624008f2 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -397,19 +397,10 @@ class AdminController < ApplicationController #留言列表 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 - + @jour = JournalsForMessage.find_by_sql("SELECT * FROM journals_for_messages AS j1 + WHERE j1.jour_type IN ('Course','Principal') AND (j1.m_parent_id IS NULL OR (j1.m_parent_id IN (SELECT id FROM journals_for_messages WHERE jour_type IN ('Course','Principal')))) order by created_on desc") + @jour = paginateHelper @jour,30 + @page = (params['page'] || 1).to_i - 1 respond_to do |format| format.html end @@ -418,21 +409,8 @@ class AdminController < ApplicationController #帖子 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 - + @memo = paginateHelper @memo,30 + @page = (params['page'] || 1).to_i - 1 respond_to do |format| format.html end @@ -440,29 +418,55 @@ class AdminController < ApplicationController #课程讨论区的帖子 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') + @course_ms = paginateHelper @course_ms,30 + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| + format.html + end 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') + @project_ms = paginateHelper @project_ms,30 + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| + format.html + end end #通知 def notices @news = News.where('course_id is not NULL').order('created_on desc') + @news = paginateHelper @news,30 + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| + format.html + end end #最近登录用户列表 def latest_login_users - @user = User.order('last_login_on desc') + scope = User.order('last_login_on desc') + scope = scope.where("last_login_on>= '#{params[:startdate]} 00:00:00'") if params[:startdate].present? + scope =scope.where("last_login_on <= '#{params[:enddate]} 23:59:59'") if params[:enddate].present? + @user = scope + @user = paginateHelper @user,30 + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| + format.html + end end #作业 def homework @homework = HomeworkCommon.order('end_time desc') + @homework = paginateHelper @homework,30 + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| + format.html + end end end diff --git a/app/views/admin/course_messages.html.erb b/app/views/admin/course_messages.html.erb index 8564d13dc..3db0a3e11 100644 --- a/app/views/admin/course_messages.html.erb +++ b/app/views/admin/course_messages.html.erb @@ -29,7 +29,7 @@ - <% @count=0%> + <% @count=@page*30%> <% for course in @course_ms -%> <% @count=@count + 1 %> @@ -51,10 +51,10 @@ <%= format_date(course.created_on) %> - <%= course.subject %> + <%= link_to(course.subject, course_boards_path(Board.where('id=?',course.board_id).first.course_id)) %> - <%=course.replies_count %> + <%= link_to(course.replies_count, course_boards_path(Board.where('id=?',course.board_id).first.course_id)) %> @@ -62,5 +62,8 @@ + <% html_title(l(:label_message_plural)) -%> diff --git a/app/views/admin/homework.html.erb b/app/views/admin/homework.html.erb index 360ca4e39..7260d68ff 100644 --- a/app/views/admin/homework.html.erb +++ b/app/views/admin/homework.html.erb @@ -27,7 +27,7 @@ - <%@count=0 %> + <%@count=@page*30 %> <% for homework in @homework do %> <% @count+=1 %> @@ -48,7 +48,7 @@ <% end %> - <%=StudentWork.where('homework_common_id=?',homework.id).count %> + <%=link_to(StudentWork.where('homework_common_id=?',homework.id).count, student_work_index_path(:homework => homework.id))%> <%=format_date(homework.end_time) %> @@ -59,4 +59,8 @@ + + <% 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 index dc35daec8..838cc0dcb 100644 --- a/app/views/admin/latest_login_users.html.erb +++ b/app/views/admin/latest_login_users.html.erb @@ -1,7 +1,26 @@ +<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>

<%=l(:label_latest_login_user_list)%>

+<%= form_tag({}, :method => :get) do %> +
+ + <%= l(:label_filter_plural) %> + + + <%= text_field_tag 'startdate', params[:startdate], :size => 15, :onchange =>"regexDeadLine();", :style=>"float:left"%> + <%= calendar_for('startdate')%> + + <%= text_field_tag 'enddate', params[:enddate], :size => 15, :onchange =>"regexDeadLine();", :style=>"float:left"%> + <%= calendar_for('enddate')%>   + <%= submit_tag l(:button_apply), :class => "small", :name => nil %> + <%= link_to l(:button_clear), {:controller => 'admin', :action => 'latest_login_users'}, :class => 'icon icon-reload' %> +
+<% end %> +  + +
@@ -27,7 +46,7 @@ - <% @count=0 %> + <% @count=@page * 30 %> <% for user in @user do %> <% @count +=1 %> @@ -70,4 +89,8 @@
+ + <% 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 index 975c60b15..360e9b864 100644 --- a/app/views/admin/leave_messages.html.erb +++ b/app/views/admin/leave_messages.html.erb @@ -31,7 +31,7 @@ - <% @count=0%> + <% @count = @page * 30 %> <% for journal in @jour -%> <% @count=@count + 1 %> "> @@ -49,20 +49,39 @@ <%= journal.jour_id %> - - <%= link_to(journal.try(:user).try(:realname).truncate(6, omission: '...'), user_path(journal.user)) %> + <%= journal.try(:user)%><% else %><%=journal.try(:user).try(:realname) %><% end %>'> + <% if journal.try(:user).try(:realname) == ' '%> + <%= link_to(journal.try(:user), user_path(journal.user)) %> + <% else %> + <%= link_to(journal.try(:user).try(:realname), user_path(journal.user)) %> + <% end %> <%= format_date(journal.created_on) %> - - <%= journal.notes.truncate(15, omission: '...') %> + + <%case journal.jour_type %> + <% when 'Principal' %> + <%= link_to(journal.notes.html_safe, feedback_path(journal.jour_id)) %> + <% when 'Course' %> + <%= link_to(journal.notes.html_safe, course_feedback_path(journal.jour_id)) %> + <% end %> <% if(journal.m_reply_count) %> - <%=journal.m_reply_count%> + <%case journal.jour_type %> + <% when 'Principal' %> + <%= link_to(journal.m_reply_count, feedback_path(journal.jour_id)) %> + <% when 'Course' %> + <%= link_to(journal.m_reply_count, course_feedback_path(journal.jour_id)) %> + <% end %> <% else %> - <%=0 %> + <%case journal.jour_type %> + <% when 'Principal' %> + <%= link_to(0, feedback_path(journal.jour_id)) %> + <% when 'Course' %> + <%= link_to(0, course_feedback_path(journal.jour_id)) %> + <% end %> <% end %> @@ -71,9 +90,7 @@ <% 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 index 77cdbbc69..e0c84279d 100644 --- a/app/views/admin/messages_list.html.erb +++ b/app/views/admin/messages_list.html.erb @@ -29,7 +29,7 @@ - <% @count=0%> + <% @count=@page * 30%> <% for memo in @memo -%> <% @count=@count + 1 %> "> @@ -50,20 +50,18 @@ <%= format_date(memo.created_at) %> - <%= memo.subject %> + <%= link_to(memo.subject, forum_memo_path(memo.forum, memo)) %> - <%=memo.replies_count %> + <%= link_to(memo.replies_count, forum_memo_path(memo.forum, memo)) %> <% end %> - + <% html_title(l(:label_message_plural)) -%> diff --git a/app/views/admin/notices.html.erb b/app/views/admin/notices.html.erb index 56f212720..f03a7b97a 100644 --- a/app/views/admin/notices.html.erb +++ b/app/views/admin/notices.html.erb @@ -33,7 +33,7 @@ - <% @count=0%> + <% @count=@page * 30%> <% for news in @news -%> <% @count=@count + 1 %> "> @@ -63,7 +63,7 @@ <%= link_to(news.title, news_path(news)) %> - <%=news.comments_count %> + <%= link_to(news.comments_count, news_path(news)) %> <% end %> @@ -71,4 +71,8 @@ + + <% html_title(l(:label_notification_list)) -%> diff --git a/app/views/admin/project_messages.html.erb b/app/views/admin/project_messages.html.erb index af2978422..dc44a7cba 100644 --- a/app/views/admin/project_messages.html.erb +++ b/app/views/admin/project_messages.html.erb @@ -29,7 +29,7 @@ - <% @count=0%> + <% @count=@page * 30 %> <% for project in @project_ms -%> <% @count=@count + 1 %> @@ -51,10 +51,10 @@ <%= format_date(project.created_on) %> - <%= project.subject %> + <%= link_to(project.subject, project_boards_path(Board.where('id=?',project.board_id).first.project_id)) %> - <%=project.replies_count %> + <%= link_to(project.replies_count, project_boards_path(Board.where('id=?',project.board_id).first.project_id)) %> @@ -63,4 +63,8 @@ + + <% html_title(l(:label_message_plural)) -%> diff --git a/db/schema.rb b/db/schema.rb index 8d78a9ca0..841bcc7e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -474,13 +474,6 @@ ActiveRecord::Schema.define(:version => 20150815030833) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "documents", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.integer "category_id", :default => 0, :null => false @@ -893,6 +886,7 @@ ActiveRecord::Schema.define(:version => 20150815030833) do t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false t.integer "course_id" + t.datetime "updated_on" end add_index "news", ["author_id"], :name => "index_news_on_author_id"