This commit is contained in:
chenmin 2014-08-23 09:19:17 +08:00
commit c1da351ea0
10 changed files with 45 additions and 46 deletions

View File

@ -26,6 +26,18 @@ class FilesController < ApplicationController
include SortHelper include SortHelper
helper :project_score helper :project_score
def show_attachments obj
all_attachments = []
obj.each do |container|
all_attachments += container.attachments
end
@limit = 10
@feedback_count = all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@curse_attachments = all_attachments[@offset, @limit]
end
def index def index
#sort_init 'filename', 'asc' #sort_init 'filename', 'asc'
sort_init 'created_on', 'desc' sort_init 'created_on', 'desc'
@ -39,15 +51,7 @@ class FilesController < ApplicationController
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
all_attachments = [] show_attachments @containers
@containers.each do |container|
all_attachments += container.attachments
end
@limit = 10
@feedback_count = all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@curse_attachments = all_attachments[@offset, @limit]
render :layout => !request.xhr? render :layout => !request.xhr?
elsif params[:course_id] elsif params[:course_id]
@ -79,16 +83,7 @@ class FilesController < ApplicationController
@containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on desc").find(@course.id)] @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on desc").find(@course.id)]
end end
all_attachments = [] show_attachments @containers
@containers.each do |container|
all_attachments += container.attachments
end
@limit = 10
@feedback_count = all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@curse_attachments = all_attachments[@offset, @limit]
render :layout => 'base_courses' render :layout => 'base_courses'
end end
@ -133,6 +128,8 @@ class FilesController < ApplicationController
@containers = [Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun @containers = [Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
show_attachments @containers
@attachtype = 0 @attachtype = 0
@contenttype = 0 @contenttype = 0
@ -159,6 +156,8 @@ class FilesController < ApplicationController
@containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)] @containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
show_attachments @containers
@attachtype = 0 @attachtype = 0
@contenttype = 0 @contenttype = 0

View File

@ -441,7 +441,7 @@ module CoursesHelper
def homework_user_of_homework homework,is_teacher def homework_user_of_homework homework,is_teacher
homework_users = "" homework_users = ""
homework.users.each do |user| homework.users.each do |user|
homework_users = homework_users + (is_teacher ? (user.firstname + user.lastname) : user.login) homework_users = homework_users + (is_teacher ? (user.lastname + user.firstname) : user.login)
if user != homework.users.last if user != homework.users.last
homework_users = homework_users + "" homework_users = homework_users + ""
end end

View File

@ -864,7 +864,7 @@ FROM `users` where id = #{user.id}")
users = Attachment.find_by_sql("SELECT COUNT(*) as m_count FROM #{Attachment.table_name} WHERE author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}") users = Attachment.find_by_sql("SELECT COUNT(*) as m_count FROM #{Attachment.table_name} WHERE author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}")
result = 0 result = 0
if users.count > 0 if users.count > 0
result = users.first.m_coumt result = users.first.m_count
end end
result result
end end

View File

@ -4,4 +4,5 @@ $('#relation_file').html('<%=render_attachments_for_new_project(@project, nil)%>
<% elsif @course%> <% elsif @course%>
$('#relation_file').html('<%=render_attachments_for_new_course(@course, nil)%>'); $('#relation_file').html('<%=render_attachments_for_new_course(@course, nil)%>');
<% end%> <% end%>
$('#attachments').children().css("width","100%").css("word-break","break-all");

View File

@ -28,7 +28,7 @@
<tr> <tr>
<td style="vertical-align: top;width: 70px" > <td style="vertical-align: top;width: 70px" >
<table style="text-align: center;width: 100%;table-layout: fixed"> <table style="text-align: center;width: 100%;table-layout: fixed">
<% user_name = is_teacher ? (homework.user.firstname + homework.user.lastname) : homework.user.login %> <% user_name = is_teacher ? (homework.user.lastname + homework.user.firstname) : homework.user.login %>
<tr> <tr>
<td title="<%= user_name %>"><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td> <td title="<%= user_name %>"><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
</tr> </tr>

View File

@ -3,7 +3,7 @@
<% attachmenttypes = @course.attachmenttypes %> <% attachmenttypes = @course.attachmenttypes %>
<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %> <% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %> <% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
<table class="list files" id="ver-zebra"> <table class="list files" id="ver-zebra" style="table-layout: fixed">
<colgroup> <colgroup>
<col class="vzebra-odd"/> <col class="vzebra-odd"/>
<col class="vzebra-even"/> <col class="vzebra-even"/>
@ -40,17 +40,17 @@
<%next%> <%next%>
<%end%> <%end%>
<tr class="file <%= cycle("odd", "odd") %>"> <tr class="file <%= cycle("odd", "odd") %>">
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> --> <!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
<td class="filesize"><%= number_to_human_size(file.filesize) %></td> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="filesize"><%= number_to_human_size(file.filesize) %></td>
<td class="attach_type"> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="attach_type">
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName unless file.attachmentstype.nil? %></span> <span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName unless file.attachmentstype.nil? %></span>
<span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;"> <span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
<%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %> <%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %>
</span> </span>
</td> </td>
<td class="content_type"><%= file.show_suffix_type %></td> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="content_type"><%= file.show_suffix_type %></td>
<td class="field_file_dense"> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="field_file_dense">
<span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span> <span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
&nbsp; &nbsp;
<span id="field_file_dense_id_edit<%= file.id %>" style="white-space:nowrap;"> <span id="field_file_dense_id_edit<%= file.id %>" style="white-space:nowrap;">
@ -58,9 +58,9 @@
:attachment => file} %> :attachment => file} %>
</span> </span>
</td> </td>
<td class="downloads"><%= file.downloads %></td> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="downloads"><%= file.downloads %></td>
<!-- <td class="digest" width="300px"><%= file.description %></td> --> <!-- <td class="digest" width="300px"><%= file.description %></td> -->
<td align="center"> <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" align="center">
<%= link_to(image_tag('delete.png'), attachment_path(file), <%= link_to(image_tag('delete.png'), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
</td> </td>

View File

@ -4,7 +4,7 @@
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> <% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %> <% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
<div class="autoscroll"> <div class="autoscroll">
<table class="list files" id="ver-zebra" style="width: 100%;table-layout: fixed"> <table class="list files" id="ver-zebra" style=" table-layout: fixed">
<colgroup> <colgroup>
<col class="vzebra-odd"/> <col class="vzebra-odd"/>
<col class="vzebra-even"/> <col class="vzebra-even"/>

View File

@ -42,15 +42,14 @@
<ul class="sub_menu"> <ul class="sub_menu">
<% if @show_course == 1 %> <% if @show_course == 1 %>
<% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%> <% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
<% hasCourse=true%>
<% _bool=false %> <% hasCourse=false %>
<% User.current.courses.each do |course| %> <% User.current.courses.each do |course| %>
<% if !course_endTime_timeout?(course) %> <% if !course_endTime_timeout?(course) %>
<% _bool=true %> <% hasCourse=true %>
<% end %> <% end %>
<% end %> <% end %>
<% if _bool %> <% if hasCourse %>
<li id="course_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id} %> <li id="course_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id} %>
<ul class="course_sub_menu"> <ul class="course_sub_menu">
<% User.current.courses.each do |course| %> <% User.current.courses.each do |course| %>
@ -71,7 +70,7 @@
<% if hasCourse %> <% if hasCourse %>
<ul class="project_sub_menu" style="top: 35px"> <ul class="project_sub_menu" style="top: 35px">
<% else %> <% else %>
<ul class="project_sub_menu"> <ul class="project_sub_menu" style="top: 0px">
<% end %> <% end %>
<% User.current.projects.each do |project| %> <% User.current.projects.each do |project| %>
<li><%= link_to project.name.truncate(10, omission: '...'), {:controller => 'projects', :action => 'show',id: project.id, host: Setting.project_domain } %></li> <li><%= link_to project.name.truncate(10, omission: '...'), {:controller => 'projects', :action => 'show',id: project.id, host: Setting.project_domain } %></li>

View File

@ -128,7 +128,7 @@
<a class="modal_close" href="#"></a> <a class="modal_close" href="#"></a>
<h2>学校列表</h2> <h2>学校列表</h2>
&nbsp;&nbsp;
<div class="pcontent"> <div class="pcontent">
<ul id="provincelist" class="school_list"> <ul id="provincelist" class="school_list">
<% @ss = School.find_by_sql("select distinct province from schools") %> <% @ss = School.find_by_sql("select distinct province from schools") %>
@ -140,7 +140,7 @@
<% end %> <% end %>
</ul> </ul>
</div> </div>
<hr/>
<div class="content" style="font-size: 13px"> <div class="content" style="font-size: 13px">
<ul id="schoollist" class="school_list"> <ul id="schoollist" class="school_list">

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140812065417) do ActiveRecord::Schema.define(:version => 20140814062455) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -441,21 +441,21 @@ ActiveRecord::Schema.define(:version => 20140812065417) do
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "sort_type" t.integer "sort_type"
t.integer "image_width", :default => 107
t.integer "image_height", :default => 63
t.integer "show_course", :default => 1 t.integer "show_course", :default => 1
t.integer "show_contest", :default => 1 t.integer "show_contest", :default => 1
t.integer "image_width", :default => 107
t.integer "image_height", :default => 63
end end
create_table "forums", :force => true do |t| create_table "forums", :force => true do |t|
t.string "name", :null => false t.string "name", :null => false
t.string "description", :default => "" t.text "description"
t.integer "topic_count", :default => 0 t.integer "topic_count", :default => 0
t.integer "memo_count", :default => 0 t.integer "memo_count", :default => 0
t.integer "last_memo_id", :default => 0 t.integer "last_memo_id", :default => 0
t.integer "creator_id", :null => false t.integer "creator_id", :null => false
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
create_table "groups_users", :id => false, :force => true do |t| create_table "groups_users", :id => false, :force => true do |t|