超级管理员新增功能页面的分页、添加超链接,添加查询条件。

This commit is contained in:
cxt 2015-08-18 14:40:12 +08:00
parent bc993e3b5c
commit 27ff5471ec
9 changed files with 118 additions and 67 deletions

View File

@ -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

View File

@ -29,7 +29,7 @@
</tr>
</thead>
<tbody>
<% @count=0%>
<% @count=@page*30%>
<% for course in @course_ms -%>
<% @count=@count + 1 %>
@ -51,10 +51,10 @@
<%= format_date(course.created_on) %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=course.subject %>'>
<%= course.subject %>
<%= link_to(course.subject, course_boards_path(Board.where('id=?',course.board_id).first.course_id)) %>
</td>
<td class="center">
<%=course.replies_count %>
<%= link_to(course.replies_count, course_boards_path(Board.where('id=?',course.board_id).first.course_id)) %>
</td>
</tr>
@ -62,5 +62,8 @@
</tbody>
</table>
</div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_message_plural)) -%>

View File

@ -27,7 +27,7 @@
</tr>
</thead>
<tbody>
<%@count=0 %>
<%@count=@page*30 %>
<% for homework in @homework do %>
<% @count+=1 %>
<tr>
@ -48,7 +48,7 @@
<% end %>
</td>
<td align="center">
<%=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))%>
</td>
<td align="center">
<%=format_date(homework.end_time) %>
@ -59,4 +59,8 @@
</table>
</div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_user_homework)) -%>

View File

@ -1,7 +1,26 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>
<h3>
<%=l(:label_latest_login_user_list)%>
</h3>
<%= form_tag({}, :method => :get) do %>
<fieldset>
<legend>
<%= l(:label_filter_plural) %>
</legend>
<label style="float:left">开始日期:</label>
<%= text_field_tag 'startdate', params[:startdate], :size => 15, :onchange =>"regexDeadLine();", :style=>"float:left"%>
<%= calendar_for('startdate')%>
<label style="float:left">结束日期:</label>
<%= text_field_tag 'enddate', params[:enddate], :size => 15, :onchange =>"regexDeadLine();", :style=>"float:left"%>
<%= calendar_for('enddate')%> &nbsp;
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'latest_login_users'}, :class => 'icon icon-reload' %>
</fieldset>
<% end %>
&nbsp;
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
@ -27,7 +46,7 @@
</tr>
</thead>
<tbody>
<% @count=0 %>
<% @count=@page * 30 %>
<% for user in @user do %>
<tr>
<% @count +=1 %>
@ -70,4 +89,8 @@
</table>
</div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_latest_login_user_list)) -%>

View File

@ -31,7 +31,7 @@
</tr>
</thead>
<tbody>
<% @count=0%>
<% @count = @page * 30 %>
<% for journal in @jour -%>
<% @count=@count + 1 %>
<tr class="<%= cycle("odd", "even") %>">
@ -49,20 +49,39 @@
<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 align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<% if journal.try(:user).try(:realname) == ' '%><%= 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 %>
</td>
<td class="center">
<%= format_date(journal.created_on) %>
</td>
<td title='<%=journal.notes %>'>
<%= journal.notes.truncate(15, omission: '...') %>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=journal.notes %>'>
<%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 %>
</td>
<td class="center">
<% 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 %>
</td>
</tr>
@ -71,9 +90,7 @@
</table>
</div>
<div class="pagination">
<ul>
<%= pagination_links_full @jour_pages, @jour_count %>
</ul>
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_leave_message_list)) -%>

View File

@ -29,7 +29,7 @@
</tr>
</thead>
<tbody>
<% @count=0%>
<% @count=@page * 30%>
<% for memo in @memo -%>
<% @count=@count + 1 %>
<tr class="<%= cycle("odd", "even") %>">
@ -50,20 +50,18 @@
<%= format_date(memo.created_at) %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" title='<%=memo.subject %>'>
<%= memo.subject %>
<%= link_to(memo.subject, forum_memo_path(memo.forum, memo)) %>
</td>
<td class="center">
<%=memo.replies_count %>
<%= link_to(memo.replies_count, forum_memo_path(memo.forum, memo)) %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<!--<div class="pagination">
<ul>
<#%= pagination_links_full @memo_pages, @memo_count %>
</ul>
</div>-->
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_message_plural)) -%>

View File

@ -33,7 +33,7 @@
</tr>
</thead>
<tbody>
<% @count=0%>
<% @count=@page * 30%>
<% for news in @news -%>
<% @count=@count + 1 %>
<tr class="<%= cycle("odd", "even") %>">
@ -63,7 +63,7 @@
<%= link_to(news.title, news_path(news)) %>
</td>
<td class="center">
<%=news.comments_count %>
<%= link_to(news.comments_count, news_path(news)) %>
</td>
</tr>
<% end %>
@ -71,4 +71,8 @@
</table>
</div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_notification_list)) -%>

View File

@ -29,7 +29,7 @@
</tr>
</thead>
<tbody>
<% @count=0%>
<% @count=@page * 30 %>
<% for project in @project_ms -%>
<% @count=@count + 1 %>
@ -51,10 +51,10 @@
<%= format_date(project.created_on) %>
</td>
<td title='<%=project.subject %>' style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name">
<%= project.subject %>
<%= link_to(project.subject, project_boards_path(Board.where('id=?',project.board_id).first.project_id)) %>
</td>
<td class="center">
<%=project.replies_count %>
<%= link_to(project.replies_count, project_boards_path(Board.where('id=?',project.board_id).first.project_id)) %>
</td>
</tr>
@ -63,4 +63,8 @@
</table>
</div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_message_plural)) -%>

View File

@ -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"