This commit is contained in:
huang 2015-03-12 19:32:51 +08:00
commit fb907094f8
12 changed files with 78 additions and 34 deletions

10
Gemfile
View File

@ -25,8 +25,10 @@ gem 'rufus-scheduler'
#gem 'dalli', path: 'lib/dalli-2.7.2'
group :development do
gem 'grape-swagger'
gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git'
#gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git'
#gem 'puma'
gem 'pry-rails'
gem 'pry-byebug'
gem 'better_errors', path: 'lib/better_errors'
gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler'
end
@ -50,8 +52,8 @@ group :test do
#end
end
gem 'rspec-rails' , '2.13.1'
gem 'guard-rspec','2.5.0'
# gem 'rspec-rails' , '2.13.1'
# gem 'guard-rspec','2.5.0'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
@ -95,7 +97,7 @@ if File.exist?(database_file)
adapters.each do |adapter|
case adapter
when 'mysql2'
gem "mysql2", "= 0.3.11", :platforms => [:mri, :mingw]
gem "mysql2", "= 0.3.18", :platforms => [:mri, :mingw]
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
when 'mysql'
gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw]

View File

@ -97,12 +97,10 @@ class AttachmentsController < ApplicationController
end
if candown || User.current.admin? || User.current.id == @attachment.author_id
@attachment.increment_download
if stale?(:etag => @attachment.digest)
# images are sent inline
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment),
:disposition => (@attachment.image? ? 'inline' : 'attachment')
:disposition => 'attachment' #inline can open in browser
end
else

View File

@ -145,12 +145,17 @@ class FilesController < ApplicationController
end
end
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
@containers += @project.versions.includes(:attachments).reorder(sort).all
@containers = [ Project.includes(:attachments).find(@project.id)]
@containers += @project.versions.includes(:attachments).all
ids = []
@containers.each do |c|
ids += c.attachments.pluck(:id)
end
@containers = [Struct.new(:attachments).new(Attachment.where('id in (?)',ids).reorder(sort))]
show_attachments @containers
respond_to do |format|
format.html
format.js

View File

@ -338,12 +338,12 @@ class ProjectsController < ApplicationController
email = params[:mail]
Mailer.send_invite_in_project(email, @project, User.current).deliver
@is_zhuce =false
flash[:notice] = l(:notice_successful_update)
flash[:notice] = l(:notice_email_sent, :value => email)
else
@is_zhuce = true
end
respond_to do |format|
format.js
format.html{redirect_to invite_members_by_mail_project_url(@project)}
end
end
#发送邮件邀请新用户

View File

@ -41,7 +41,7 @@ class Project < ActiveRecord::Base
has_many :principals, :through => :member_principals, :source => :principal
has_many :enabled_modules, :dependent => :delete_all
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
has_many :issues, :dependent => :destroy, :include => [:status, :tracker],:order => "id ASC"
has_many :issues, :dependent => :destroy, :include => [:status, :tracker],:order => "issues.id ASC"
has_many :issue_changes, :through => :issues, :source => :journals
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
has_many :time_entries, :dependent => :delete_all

View File

@ -1,6 +1,6 @@
<span id="attachments_fields" xmlns="http://www.w3.org/1999/html">
<% if defined?(container) && container && container.saved_attachments %>
<% container.attachments.each_with_index do |attachment, i| %>
<% container.saved_attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="attachment">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>

View File

@ -34,7 +34,8 @@
<%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id},
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:class => 'delete',
:class => 'delete delete-homework-icon',
:remote => true,
:title => l(:button_delete) %>
<% else %>
<%= link_to image_tag('delete.png'), attachment_path(attachment),

View File

@ -1,11 +1,26 @@
<script>
function ismail(mail) {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(mail)) return true;
else {
alert('您的电子邮件格式不正确');
return false;}
}
function verifyAddress() {
var email = $('#mail').val();
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (email == "" || filter.test(email)) {
$("#valid_email").html("");
}
else
{
$("#valid_email").html("您所填写的电子邮件格式不正确");
}
}
// if (filter.test(email)&& !(email.value == null)) return true;
// else
// {
// document.getElementById('valid_email').innerHTML = "您所填写的电子邮件格式不正确";
// document.getElementById('valid_email').style.color = "#FF0000";
// return false;
// }
//
// }
</script>
<div class="project_r_h">
<h2 class="project_h2">邀请加入</h2>
@ -23,8 +38,9 @@
<div id="is_registed">
<%= render :partial => 'regested', locals: { :isregisted => false} %>
</div>
<%= form_tag('send_mail_to_member', :controller => 'projects',:action => 'send_mail_to_member', method: 'get',:remote=>true) do %>
<%= text_field_tag 'mail', '', :class => "fb_item fl", :placeholder => l(:label_input_email) %>
<%= form_tag('send_mail_to_member', :controller => 'projects',:action => 'send_mail_to_member', method: 'get') do %>
<span id="valid_email" style="color: #FF0000;"></span>
<%= text_field_tag 'mail', '', :class => "fb_item fl", :placeholder => l(:label_input_email), :onblur => "verifyAddress();" %>
<div class="cl"></div>
<div class="cl"></div>
<a href="#" class="btn_free" onclick="$(this).parent().submit();">

View File

@ -82,7 +82,16 @@ en:
#
# 邀请
#
notice_registed_success: 您输入的邮箱为空或者该邮箱已被注册!
label_invite_new_user: "发送邮件邀请新用户"
label_invite_join: 邀请加入
label_invite_email_tips: 输入好友邮箱地址Trustie会自动为该邮箱注册用户
label_email: 邮箱
notice_registed_success: 您所填写的电子邮件格式不正确或者该邮箱已被注册!
label_send_email_free: 免费发送
label_email_format_error: 您所填写的电子邮件格式不正确
label_invite_trustie_user: "邀请Trustie注册用户"
#

View File

@ -58,8 +58,7 @@ zh:
project_module_code_review: 代码审查
project_module_calendar: 日历
project_module_gantt: 甘特图
project_module_documents: 文档
project_module_files: 资源库
project_module_documents: 文档
label_project_tool_response: 用户反馈
label_module_share: DTS测试工具
@ -84,12 +83,14 @@ zh:
# 邀请
#
label_invite_new_user: "发送邮件邀请新用户"
label_invite_trustie_user: "邀请Trustie注册用户"
label_invite_join: 邀请加入
label_invite_email_tips: 输入好友邮箱地址Trustie会自动为该邮箱注册用户
notice_registed_success: 您输入的邮箱为空或者该邮箱已被注册!
label_send_email_free: 免费发送
label_email_format_error: 您所填写的电子邮件格式不正确
label_invite_trustie_user: "邀请Trustie注册用户"
#
# 项目托管平台

View File

@ -1,9 +1,11 @@
class AddDataToProjectIssuesIndexsInIssue < ActiveRecord::Migration
def change
for i in 1 ... 1000 do i
Issue.page(i).per(10).each do |e|
index = e.project.issues.index(e).to_i + 1
execute("update issues set project_issues_index = #{index} where id = #{e.id}")
transaction do
for i in 1 ... 1000 do i
Issue.page(i).per(10).each do |e|
index = e.project.issues.index(e).to_i + 1
execute("update issues set project_issues_index = #{index} where id = #{e.id}")
end
end
end
end

View File

@ -480,7 +480,7 @@ function observeAutocompleteField(fieldId, url, options) {
$('#'+fieldId).autocomplete($.extend({
source: url,
select: function(e,ui){self.location="/issues/"+ui.item.value;},
minLength: 2,
minLength: 1,
search: function(){$('#'+fieldId).addClass('ajax-loading');},
response: function(){$('#'+fieldId).removeClass('ajax-loading');
}
@ -850,3 +850,13 @@ function HS_setDate(inputObj){
function redo() {
window.location.reload()
}
//// 作业附件删除
$(function(){
$('.attachments a.delete-homework-icon').bind('ajax:complete', //this will work
function(event, data, status, xhr) { //note parametes
$(this).parent('p').remove();
console.log("delete complete.");
});
});