diff --git a/app/controllers/avatar_controller.rb b/app/controllers/avatar_controller.rb index 84b8a92e4..ef7cdf2f7 100644 --- a/app/controllers/avatar_controller.rb +++ b/app/controllers/avatar_controller.rb @@ -8,23 +8,26 @@ class AvatarController < ApplicationController # Make sure that API users get used to set this content type # as it won't trigger Rails' automatic parsing of the request body for parameters unless request.content_type == 'application/octet-stream' - render :nothing => true, :status => 406 - return - end - - unless request.raw_post.nil? - @source_type = params[:source_type] + @source_type = params[:source_type] @source_id = params[:source_id] - @temp_file = request.raw_post - if @temp_file.size > 0 - if @temp_file.respond_to?(:original_filename) - @image_file = @temp_file.original_filename - #image_file.force_encoding("UTF-8") if filename.respond_to?(:force_encoding) - else - @image_file=params[:filename] - end + @temp_file = params[:avatar][:image] + @image_file = @temp_file.original_filename + else + unless request.raw_post.nil? + @source_type = params[:source_type] + @source_id = params[:source_id] + @temp_file = request.raw_post + if @temp_file.size > 0 + if @temp_file.respond_to?(:original_filename) + @image_file = @temp_file.original_filename + #image_file.force_encoding("UTF-8") if filename.respond_to?(:force_encoding) + else + @image_file=params[:filename] + end + end end end + if @temp_file && (@temp_file.size > 0) diskfile=disk_filename(@source_type,@source_id) @urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file)) @@ -61,6 +64,10 @@ class AvatarController < ApplicationController image.compress(300) respond_to do |format| + format.json{ + render :inline => "#{@urlfile.to_s}?#{Time.now.to_i}",:content_type => 'text/html' + return + } format.js format.api { if saved diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index a1e547a84..1d1212bf1 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -5,6 +5,7 @@ class CoursesController < ApplicationController helper :activities helper :members helper :words + helper :attachments before_filter :auth_login1, :only => [:show, :feedback] menu_item :overview diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 12ee4bc3b..b6035ca51 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -58,7 +58,7 @@ class IssuesController < ApplicationController def index retrieve_query - sort_init(@query.sort_criteria.empty? ? [['updated_on', 'desc']] : @query.sort_criteria) + sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) sort_update(@query.sortable_columns) @query.sort_criteria = sort_criteria.to_a @@ -387,7 +387,7 @@ class IssuesController < ApplicationController def retrieve_previous_and_next_issue_ids retrieve_query_from_session if @query - sort_init(@query.sort_criteria.empty? ? [['updated_on', 'desc']] : @query.sort_criteria) + sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) sort_update(@query.sortable_columns, 'issues_index_sort') limit = 500 issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version]) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 405dc72ed..9c261df85 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1770,8 +1770,7 @@ module ApplicationHelper def get_memo @new_memo = Memo.new - #@new_memo.subject = "有什么想说的,尽管来咆哮吧~~" - @public_forum = Forum.find(1) + @public_forum = Forum.find(1) rescue ActiveRecord::RecordNotFound end #获取用户未过期的课程 diff --git a/app/models/token.rb b/app/models/token.rb index d9fc75d76..e0accb59c 100644 --- a/app/models/token.rb +++ b/app/models/token.rb @@ -32,6 +32,8 @@ class Token < ActiveRecord::Base token = Token.get_token_from_user(user, 'autologin') unless token token = Token.create(:user => user, :action => 'autologin') + else + token.update_attribute(:created_on, Time.now) end token end diff --git a/app/views/avatar/_new_avatar_form.html.erb b/app/views/avatar/_new_avatar_form.html.erb index e341bc83a..793252d3a 100644 --- a/app/views/avatar/_new_avatar_form.html.erb +++ b/app/views/avatar/_new_avatar_form.html.erb @@ -7,8 +7,7 @@ :id => nil, :class => 'upload_file', :size => "1", - :multiple => false, - :onchange => 'addInputAvatar(this);', + :multiple => true, :data => { :max_file_size => Setting.attachment_max_size.to_i.kilobytes, :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), @@ -22,6 +21,6 @@ } %> <% content_for :header_tags do %> - <%= javascript_include_tag 'avatars' %> + <%= javascript_include_tag 'jq-upload/jquery.ui.widget', 'jq-upload/jquery.iframe-transport', 'jq-upload/jquery.fileupload', 'jq-upload/upload' %> <% end %> -
\ No newline at end of file + diff --git a/app/views/avatar/upload.js.erb b/app/views/avatar/upload.js.erb index b39e308ec..1fa90c5a3 100644 --- a/app/views/avatar/upload.js.erb +++ b/app/views/avatar/upload.js.erb @@ -1,4 +1,4 @@ -var imgSpan = $('#avatar_image'); +var imgSpan = jQuery('#avatar_image'); imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'}); diff --git a/app/views/courses/_course.html.erb b/app/views/courses/_course.html.erb index 755dd63b0..222d90458 100644 --- a/app/views/courses/_course.html.erb +++ b/app/views/courses/_course.html.erb @@ -56,7 +56,7 @@<%= content_tag('span', "#{garble @course.members.count}", :class => "info") %> - <%= content_tag('span', l(:label_x_member, :count => memberCount(@course))) %> + <%= content_tag('span', l(:label_x_member, :count => @course.members.count)) %>
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 1d2c42457..2a818b892 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -21,6 +21,7 @@