添加删除图片功能,修复用户修改资料界面form.quene undefine的js错误(导致加载中不消失的原因)
This commit is contained in:
parent
cf339edb6c
commit
6a45a0287d
|
@ -2,7 +2,7 @@ class AvatarController < ApplicationController
|
||||||
|
|
||||||
|
|
||||||
#before_filter :set_cache_buster
|
#before_filter :set_cache_buster
|
||||||
include AvatarHelper
|
include AvatarHelper
|
||||||
|
|
||||||
def upload
|
def upload
|
||||||
# Make sure that API users get used to set this content type
|
# Make sure that API users get used to set this content type
|
||||||
|
@ -77,6 +77,40 @@ class AvatarController < ApplicationController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#add by zjc
|
||||||
|
#删除图片
|
||||||
|
def delete_image
|
||||||
|
@source_type = params[:source_type]
|
||||||
|
@source_id = params[:source_id]
|
||||||
|
@source = nil #eval(@source_type).find(@source_id)
|
||||||
|
c = Object.const_get(@source_type)
|
||||||
|
if c.respond_to?(:find)
|
||||||
|
@source = c.find(@source_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
diskfile=disk_filename(@source_type,@source_id)
|
||||||
|
unless diskfile.nil? || diskfile == ""
|
||||||
|
path = File.dirname(diskfile)
|
||||||
|
if File.directory?(path) && File.exist?(diskfile)
|
||||||
|
File.delete(diskfile)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue e do
|
||||||
|
logger.info e.message
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
format.api {
|
||||||
|
if saved
|
||||||
|
render :action => 'upload', :status => :created
|
||||||
|
else
|
||||||
|
render_validation_errors(@avatar)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ module AvatarHelper
|
||||||
avatar_image(source)
|
avatar_image(source)
|
||||||
else
|
else
|
||||||
File.join(relative_path,avatar_directory(source.class),'0')
|
File.join(relative_path,avatar_directory(source.class),'0')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_avatar?(source)
|
def get_avatar?(source)
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<p style="margin-left:60px;padding-right: 20px;">
|
<p style="margin-left:60px;padding-right: 20px;">
|
||||||
<label for='attachments_fields'> <%= l(:label_site_image) %>:</label>
|
<label for='attachments_fields'> <%= l(:label_site_image) %>:</label>
|
||||||
</p>
|
</p>
|
||||||
<div style="margin-left: 82px;">
|
<div style="margin-left: 82px;" id="avatar">
|
||||||
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@contest_page} %>
|
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@contest_page} %>
|
||||||
</div>
|
</div>
|
||||||
<p style="margin-left:60px;padding-right: 20px;">
|
<p style="margin-left:60px;padding-right: 20px;">
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<p style="margin-left:60px;padding-right: 20px;">
|
<p style="margin-left:60px;padding-right: 20px;">
|
||||||
<label for='attachments_fields'> <%= l(:label_site_image) %>:</label>
|
<label for='attachments_fields'> <%= l(:label_site_image) %>:</label>
|
||||||
</p>
|
</p>
|
||||||
<div style="margin-left: 82px;">
|
<div style="margin-left: 82px;" id="avatar">
|
||||||
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@course_page} %>
|
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@course_page} %>
|
||||||
</div>
|
</div>
|
||||||
<p style="margin-left:60px;padding-right: 20px;">
|
<p style="margin-left:60px;padding-right: 20px;">
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<p style="margin-left:60px;padding-right: 20px;">
|
<p style="margin-left:60px;padding-right: 20px;">
|
||||||
<label for='attachments_fields'> <%= l(:label_site_image) %>:</label>
|
<label for='attachments_fields'> <%= l(:label_site_image) %>:</label>
|
||||||
</p>
|
</p>
|
||||||
<div style="margin-left: 82px;">
|
<div style="margin-left: 82px;" id="avatar">
|
||||||
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
|
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<div id="avatardiv">
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
a, a:hover {text-decoration:none;}
|
a, a:hover {text-decoration:none;}
|
||||||
.btn_addPic
|
.btn_addPic
|
||||||
|
@ -42,7 +43,8 @@
|
||||||
<div id="upload_progressbar" style="height:14px; margin-bottom: 10px;display: block"></div>
|
<div id="upload_progressbar" style="height:14px; margin-bottom: 10px;display: block"></div>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
<a href="javascript:void(0);" class="btn_addPic" style="text-decoration:none;">
|
<%= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "btn_addPic", :style => "text-decoration:none;" %>
|
||||||
|
<a href="javascript:void(0);" class="btn_addPic" style="text-decoration:none;">
|
||||||
<span><%= l(:button_upload_photo) %></span>
|
<span><%= l(:button_upload_photo) %></span>
|
||||||
</a>
|
</a>
|
||||||
<!-- :accept => 'image/png,image/gif,image/jpeg', -->
|
<!-- :accept => 'image/png,image/gif,image/jpeg', -->
|
||||||
|
@ -70,3 +72,4 @@
|
||||||
<% content_for :header_tags do %>
|
<% content_for :header_tags do %>
|
||||||
<%= javascript_include_tag 'avatars' %>
|
<%= javascript_include_tag 'avatars' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</div>
|
|
@ -0,0 +1,5 @@
|
||||||
|
var avatardiv = $('#avatardiv');
|
||||||
|
avatardiv.replaceWith("<%= escape_javascript(render :partial=>'avatar/avatar_form',:style => 'display:inline',:locals=> {source:@source}) %>");
|
||||||
|
//var imgSpan = $('#avatar_image');
|
||||||
|
|
||||||
|
//imgSpan.attr({"src":'<#%= @urlfile.to_s << "?" << Time.now.to_s%>'});
|
|
@ -36,20 +36,21 @@
|
||||||
<%= error_messages_for 'user' %>
|
<%= error_messages_for 'user' %>
|
||||||
|
|
||||||
<fieldset class="box" style="margin:10px;">
|
<fieldset class="box" style="margin:10px;">
|
||||||
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
|
|
||||||
<legend onclick="toggleFieldset(this);">
|
|
||||||
<%= l(:label_my_photo) %>
|
|
||||||
</legend>
|
|
||||||
<div>
|
|
||||||
<!--upload profiles-->
|
|
||||||
<%= render :partial => "avatar/avatar_form", :locals => {source: @user} %>
|
|
||||||
<!--upload-->
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
<%= labelled_form_for :user, @user,
|
<%= labelled_form_for :user, @user,
|
||||||
:url => {:action => "account"},
|
:url => {:action => "account"},
|
||||||
:html => {:id => 'my_account_form',
|
:html => {:id => 'my_account_form',
|
||||||
:method => :post} do |f| %>
|
:method => :post} do |f| %>
|
||||||
|
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
|
||||||
|
<legend onclick="toggleFieldset(this);">
|
||||||
|
<%= l(:label_my_photo) %>
|
||||||
|
</legend>
|
||||||
|
<div>
|
||||||
|
<!--upload profiles-->
|
||||||
|
<%= render :partial => "avatar/avatar_form",:style => "display:inline", :locals => {source: @user} %>
|
||||||
|
<!--upload-->
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
|
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
|
||||||
<legend onclick="toggleFieldset(this);">
|
<legend onclick="toggleFieldset(this);">
|
||||||
<%= l(:label_information_plural) %>
|
<%= l(:label_information_plural) %>
|
||||||
|
|
|
@ -1484,6 +1484,7 @@ zh:
|
||||||
label_contest_description: 内容:对你的竞赛进行描述
|
label_contest_description: 内容:对你的竞赛进行描述
|
||||||
label_requirement_bargain_money: 输入具体奖励方式(如金钱、奖项、学分)
|
label_requirement_bargain_money: 输入具体奖励方式(如金钱、奖项、学分)
|
||||||
button_upload_photo: 上传图片
|
button_upload_photo: 上传图片
|
||||||
|
button_delete_file: 删除
|
||||||
label_leave_me_message: 给我留言了
|
label_leave_me_message: 给我留言了
|
||||||
label_leave_others_message: 给他留言了
|
label_leave_others_message: 给他留言了
|
||||||
label_leave_a_message: 给他(她)留言
|
label_leave_a_message: 给他(她)留言
|
||||||
|
|
|
@ -629,6 +629,7 @@ RedmineApp::Application.routes.draw do
|
||||||
match 'uploads', :to => 'attachments#upload', :via => :post
|
match 'uploads', :to => 'attachments#upload', :via => :post
|
||||||
# Added by Tao
|
# Added by Tao
|
||||||
match 'upload_avatar', :to => 'avatar#upload', :via => :post
|
match 'upload_avatar', :to => 'avatar#upload', :via => :post
|
||||||
|
match 'delete_avatar', :to => 'avatar#delete_image',:via => :post
|
||||||
# Endof Tao's code
|
# Endof Tao's code
|
||||||
get 'robots.txt', :to => 'welcome#robots'
|
get 'robots.txt', :to => 'welcome#robots'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# -*coding:utf-8 -*-
|
||||||
class SetWebTitle < ActiveRecord::Migration
|
class SetWebTitle < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
FirstPage.all.each do |fp|
|
FirstPage.all.each do |fp|
|
||||||
|
|
76
db/schema.rb
76
db/schema.rb
|
@ -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 => 20140711012924) do
|
ActiveRecord::Schema.define(:version => 20140714081030) 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
|
||||||
|
@ -177,6 +177,58 @@ ActiveRecord::Schema.define(:version => 20140711012924) do
|
||||||
|
|
||||||
add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true
|
add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true
|
||||||
|
|
||||||
|
create_table "code_review_assignments", :force => true do |t|
|
||||||
|
t.integer "issue_id"
|
||||||
|
t.integer "change_id"
|
||||||
|
t.integer "attachment_id"
|
||||||
|
t.string "file_path"
|
||||||
|
t.string "rev"
|
||||||
|
t.string "rev_to"
|
||||||
|
t.string "action_type"
|
||||||
|
t.integer "changeset_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "code_review_project_settings", :force => true do |t|
|
||||||
|
t.integer "project_id"
|
||||||
|
t.integer "tracker_id"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
t.integer "updated_by"
|
||||||
|
t.boolean "hide_code_review_tab", :default => false
|
||||||
|
t.integer "auto_relation", :default => 1
|
||||||
|
t.integer "assignment_tracker_id"
|
||||||
|
t.text "auto_assign"
|
||||||
|
t.integer "lock_version", :default => 0, :null => false
|
||||||
|
t.boolean "tracker_in_review_dialog", :default => false
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "code_review_user_settings", :force => true do |t|
|
||||||
|
t.integer "user_id", :default => 0, :null => false
|
||||||
|
t.integer "mail_notification", :default => 0, :null => false
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "code_reviews", :force => true do |t|
|
||||||
|
t.integer "project_id"
|
||||||
|
t.integer "change_id"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
t.integer "line"
|
||||||
|
t.integer "updated_by_id"
|
||||||
|
t.integer "lock_version", :default => 0, :null => false
|
||||||
|
t.integer "status_changed_from"
|
||||||
|
t.integer "status_changed_to"
|
||||||
|
t.integer "issue_id"
|
||||||
|
t.string "action_type"
|
||||||
|
t.string "file_path"
|
||||||
|
t.string "rev"
|
||||||
|
t.string "rev_to"
|
||||||
|
t.integer "attachment_id"
|
||||||
|
t.integer "file_count", :default => 0, :null => false
|
||||||
|
t.boolean "diff_all"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "comments", :force => true do |t|
|
create_table "comments", :force => true do |t|
|
||||||
t.string "commented_type", :limit => 30, :default => "", :null => false
|
t.string "commented_type", :limit => 30, :default => "", :null => false
|
||||||
t.integer "commented_id", :default => 0, :null => false
|
t.integer "commented_id", :default => 0, :null => false
|
||||||
|
@ -359,9 +411,9 @@ ActiveRecord::Schema.define(:version => 20140711012924) do
|
||||||
t.string "web_title"
|
t.string "web_title"
|
||||||
t.string "title"
|
t.string "title"
|
||||||
t.string "description"
|
t.string "description"
|
||||||
t.string "page_type"
|
|
||||||
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.string "page_type"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "forums", :force => true do |t|
|
create_table "forums", :force => true do |t|
|
||||||
|
@ -754,18 +806,18 @@ ActiveRecord::Schema.define(:version => 20140711012924) do
|
||||||
create_table "relative_memos", :force => true do |t|
|
create_table "relative_memos", :force => true do |t|
|
||||||
t.integer "osp_id"
|
t.integer "osp_id"
|
||||||
t.integer "parent_id"
|
t.integer "parent_id"
|
||||||
t.string "subject", :null => false
|
t.string "subject", :null => false
|
||||||
t.text "content", :limit => 16777215, :null => false
|
t.text "content", :null => false
|
||||||
t.integer "author_id"
|
t.integer "author_id"
|
||||||
t.integer "replies_count", :default => 0
|
t.integer "replies_count", :default => 0
|
||||||
t.integer "last_reply_id"
|
t.integer "last_reply_id"
|
||||||
t.boolean "lock", :default => false
|
t.boolean "lock", :default => false
|
||||||
t.boolean "sticky", :default => false
|
t.boolean "sticky", :default => false
|
||||||
t.boolean "is_quote", :default => false
|
t.boolean "is_quote", :default => 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
|
||||||
t.integer "viewed_count_crawl", :default => 0
|
t.integer "viewed_count_crawl", :default => 0
|
||||||
t.integer "viewed_count_local", :default => 0
|
t.integer "viewed_count_local", :default => 0
|
||||||
t.string "url"
|
t.string "url"
|
||||||
t.string "username"
|
t.string "username"
|
||||||
t.string "userhomeurl"
|
t.string "userhomeurl"
|
||||||
|
|
|
@ -571,7 +571,7 @@ function warnLeavingUnsaved(message) {
|
||||||
function setupAjaxIndicator() {
|
function setupAjaxIndicator() {
|
||||||
|
|
||||||
$('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) {
|
$('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) {
|
||||||
|
|
||||||
if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
|
if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
|
||||||
$('#ajax-indicator').show();
|
$('#ajax-indicator').show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ function ajaxUpload(file, fileSpan, inputEl) {
|
||||||
ajaxUpload.uploading--;
|
ajaxUpload.uploading--;
|
||||||
fileSpan.removeClass('ajax-loading');
|
fileSpan.removeClass('ajax-loading');
|
||||||
var form = fileSpan.parents('form');
|
var form = fileSpan.parents('form');
|
||||||
|
|
||||||
if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) {
|
if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) {
|
||||||
$('input:submit', form).removeAttr('disabled');
|
$('input:submit', form).removeAttr('disabled');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue