Merge branch 'szzh' into guange_dev

memcached_alan^2
sw 10 years ago
commit ec1c9c2ac1

@ -111,11 +111,13 @@ module Mobile
requires :token, type: String requires :token, type: String
requires :user_id, type: Integer,desc: '被留言的用户id' requires :user_id, type: Integer,desc: '被留言的用户id'
requires :content,type:String,desc:'留言内容' requires :content,type:String,desc:'留言内容'
optional :refer_user_id,type:Integer,desc:'被回复的用户id' requires :ref_user_id,type:Integer,desc:'被回复的用户id'
requires :parent_id,type:Integer,desc:'留言父id'
requires :ref_message_id,type:Integer,desc:'引用消息id'
end end
post ':user_id/leave_message' do post ':user_id/leave_message' do
us = UsersService.new us = UsersService.new
jours = us.leave_messages params,current_user jours = us.reply_user_messages params,current_user
present :status,0 present :status,0
end end

@ -247,9 +247,9 @@ class ProjectsController < ApplicationController
# 1、自动注册 # 1、自动注册
# 2、加入项目、创建角色 # 2、加入项目、创建角色
# 3、用户得分 # 3、用户得分
if params[:email] if params[:mail]
user = User.find_by_mail(params[:email].to_s) Member.create(:role_ids => [4], :user_id => params[:user],:project_id => params[:id])
Member.create(:role_ids => [4], :user_id => user.id,:project_id => @project.id) UserGrade.create(:user_id =>params[:user], :project_id => params[:id])
end end
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
return return

@ -47,6 +47,18 @@ module AccountHelper
user user
end end
# 自动创建一个新用户,但是初始状态是锁定的
def automatically_register_lock(user, &block)
user.lock
user.last_login_on = Time.now
if user.save
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
else
yield if block_given?
end
user
end
def administrator_manually__register(user, &block) def administrator_manually__register(user, &block)
if user.save if user.save
UserStatus.create(:user_id => user.id ,:changsets_count => 0, :watchers_count => 0) UserStatus.create(:user_id => user.id ,:changsets_count => 0, :watchers_count => 0)

@ -255,7 +255,7 @@ module QueriesHelper
# Give it a name, required to be valid # Give it a name, required to be valid
@query = IssueQuery.new(:name => "_") @query = IssueQuery.new(:name => "_")
@query.project = @project @query.project = @project
params[:f] = %w(subject status_id priority_id author_id assigned_to_id) unless params[:status_id].nil? params[:f] = %w(subject status_id priority_id author_id assigned_to_id created_on) unless params[:status_id].nil?
params[:op] = {'subject' => "~" , params[:op] = {'subject' => "~" ,
'status_id' => ( params[:status_id] == '0' ? "!":"=" ), 'status_id' => ( params[:status_id] == '0' ? "!":"=" ),
'priority_id' => ( params[:priority_id] == '0' ? "!":"=" ), 'priority_id' => ( params[:priority_id] == '0' ? "!":"=" ),
@ -266,6 +266,19 @@ module QueriesHelper
'priority_id' => [params[:priority_id]], 'priority_id' => [params[:priority_id]],
'author_id' => [params[:author_id]], 'author_id' => [params[:author_id]],
'assigned_to_id' => [params[:assigned_to_id]]} unless params[:status_id].nil? 'assigned_to_id' => [params[:assigned_to_id]]} unless params[:status_id].nil?
if(params[:status_id] != nil)
if( params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='' &&
params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='' )
params[:op][:created_on]='><'
params[:v][:created_on]=[params[:issue_create_date_start],params[:issue_create_date_end]]
elsif(params[:issue_create_date_start]!=nil && params[:issue_create_date_start]!='')
params[:op][:created_on]='>='
params[:v][:created_on]=[params[:issue_create_date_start]]
elsif(params[:issue_create_date_end]!=nil && params[:issue_create_date_end]!='')
params[:op][:created_on]='<='
params[:v][:created_on]=[params[:issue_create_date_end]]
end
end
@query.build_from_params(params) @query.build_from_params(params)
#session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names} #session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names}
# else # else

@ -58,14 +58,10 @@ class Mailer < ActionMailer::Base
us = UsersService.new us = UsersService.new
# 自动激活用户 # 自动激活用户
user = us.register_auto(login, @email, @password) user = us.register_auto(login, @email, @password)
Member.create(:role_ids => [4], :user_id => user.id,:project_id => project.id)
UserGrade.create(:user_id => user.id, :project_id => project.id)
User.current = user unless User.current.nil? User.current = user unless User.current.nil?
@user = user @user = user
@token = Token.get_token_from_user(user, 'autologin') @token = Token.get_token_from_user(user, 'autologin')
@project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id,:user => user, :token => @token.value @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value)
)
mail :to => email, :subject => @subject mail :to => email, :subject => @subject
end end
@ -77,7 +73,7 @@ class Mailer < ActionMailer::Base
@project_name = "#{project.name}" @project_name = "#{project.name}"
@user = user @user = user
@token = Token.get_token_from_user(user, 'autologin') @token = Token.get_token_from_user(user, 'autologin')
@project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :email => email, :token => @token.value) @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value)
mail :to => email, :subject => @subject mail :to => email, :subject => @subject
end end

@ -114,7 +114,7 @@ class Project < ActiveRecord::Base
validates_presence_of :name, :identifier validates_presence_of :name, :identifier
validates_uniqueness_of :identifier validates_uniqueness_of :identifier
validates_uniqueness_of :name # validates_uniqueness_of :name
validates_associated :wiki#, :repository validates_associated :wiki#, :repository
# validates_length_of :description, :maximum => 255 # validates_length_of :description, :maximum => 255
validates_length_of :name, :maximum => 255 validates_length_of :name, :maximum => 255

@ -166,13 +166,22 @@ class UsersService
jours jours
end end
# 给某个用户留言 # 回复用户
def leave_messages params,current_user def reply_user_messages params,current_user
user = User.find(params[:user_id]) user = User.find(params[:user_id])
user.add_jour(current_user, params[:content], params[:refer_user_id] ||= 0) parent_id = params[:parent_id]
unless params[:refer_user_id].nil? || params[:refer_user_id] == 0 || params[:refer_user_id] == User.current.id author_id = current_user.id
User.find(params[:refer_user_id]).add_jour(current_user, params[:content], params[:refer_user_id]) reply_user_id = params[:ref_user_id]
end reply_id = params[:ref_message_id]
content = params[:content]
options = {:user_id => author_id,
:status => true,
:m_parent_id => parent_id,
:m_reply_id => reply_id,
:reply_id => reply_user_id,
:notes => content,
:is_readed => false}
user.add_jour(nil, nil,nil,options)
end end

@ -15,10 +15,10 @@
<label class="fl" >&nbsp;&nbsp;<%= l(:field_quote)%>&nbsp;&nbsp;</label> <label class="fl" >&nbsp;&nbsp;<%= l(:field_quote)%>&nbsp;&nbsp;</label>
<!--<textarea name="bid[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="hwork_text fl"></textarea>--> <!--<textarea name="bid[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="hwork_text fl"></textarea>-->
<% if edit_mode %> <% if edit_mode %>
<%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:owner_id => bid.id,:owner_type =>OwnerTypeHelper::BID %> <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:owner_id => bid.id,:owner_type =>OwnerTypeHelper::BID,:resizeType => 0 %>
<% else %> <% else %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor' %> <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:resizeType => 0 %>
<% end %> <% end %>
</li> </li>
<div class="cl"></div> <div class="cl"></div>

@ -46,9 +46,7 @@
<%= text_field_tag 'name', params[:name], :size => 30, :onkeyup => 'regexName1();', :width => "125px" %> <%= text_field_tag 'name', params[:name], :size => 30, :onkeyup => 'regexName1();', :width => "125px" %>
<%= hidden_field_tag 'project_type', params[:project_type] %> <%= hidden_field_tag 'project_type', params[:project_type] %>
<%#= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %> <%#= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %>
<a href="#" onclick="submitSerch();" class="ButtonColor m3p10" style="padding-top: 7px !important;"> <%= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %>
<%= l(:label_search)%>
</a>
<br /> <br />
<span id="contest_name_span_head"></span> <span id="contest_name_span_head"></span>
</div> </div>

@ -39,8 +39,8 @@
</p> </p>
<p> <p>
<%= content_tag "span", "#{l(:label_course_brief_introduction)}:", :class => "course-font" %> <%= content_tag "span", "#{l(:label_course_brief_introduction)}:", :class => "course-font" %>
<%= content_tag "div", course.short_description, :class => "brief_introduction", :title => course.short_description %>
</p> </p>
<%= content_tag "div", course.short_description, :class => "brief_introduction",:style=>'float:left;', :title => course.short_description %>
</div> </div>

@ -1,19 +1,38 @@
<script> <script>
$(function(){
$("input[nhtype='dateinput']").each(function(){
$(this).attr('readonly',true);
$(this).datepicker({
dateFormat: 'yy-mm-dd',
showButtonPanel: true,showClearButton: true,showTodayButton: true,
changeMonth: true,
changeYear: true
});
$(this).change(function(){
$("#issue_query_form").submit();
})
});
});
function remote_function() { function remote_function() {
$.ajax({ $("#issue_query_form").submit();
url:'<%= project_issues_path(@project)%>', // $.ajax({
data:{ // url:'<%#= project_issues_path(@project)%>',
subject:$("#v_subject").attr("value").replace(/(^\s*)|(\s*$)/g, ""), // data:{
status_id: $("#status_id").attr("value").replace(/(^\s*)|(\s*$)/g, ""), // subject:$("#v_subject").attr("value").replace(/(^\s*)|(\s*$)/g, ""),
assigned_to_id: $("#assigned_to_id option:selected").attr("value").replace(/(^\s*)|(\s*$)/g, ""), // status_id: $("#status_id").attr("value").replace(/(^\s*)|(\s*$)/g, ""),
priority_id: $("#priority_id option:selected").attr("value").replace(/(^\s*)|(\s*$)/g, ""), // assigned_to_id: $("#assigned_to_id option:selected").attr("value").replace(/(^\s*)|(\s*$)/g, ""),
author_id: $("#author_id option:selected").attr("value").replace(/(^\s*)|(\s*$)/g, "") // priority_id: $("#priority_id option:selected").attr("value").replace(/(^\s*)|(\s*$)/g, ""),
}, // author_id: $("#author_id option:selected").attr("value").replace(/(^\s*)|(\s*$)/g, "")
success: function(data){ // },
}, // success: function(data){
error: function(data){ // },
// error: function(data){
// }
// });
} }
}); function nh_reset_form() {
$("#issue_query_form")[0].reset();
remote_function();
} }
function EnterPress(e){ function EnterPress(e){
@ -31,41 +50,56 @@
</div> </div>
<div class="problem_top"> <div class="problem_top">
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %> <% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
<%#= form_tag({:controller => 'issues', :action => 'index', :project_id => @project}, :method => :get,:id=>"issue_query_form", :class => 'query_form') do %> <%= form_tag({:controller => 'issues', :action => 'index', :project_id => @project},:remote=>'true', :method => :get,:id=>"issue_query_form", :class => 'query_form') do %>
<%= hidden_field_tag 'set_filter', '1' %> <%= hidden_field_tag 'set_filter', '1' %>
<div class="problem_search" > <div class="problem_search" >
<input class="problem_search_input fl" id="v_subject" type="text" name="v[subject]" value="<%= @subject ? @subject : ""%>" onkeypress="EnterPress(event)" onkeydown="EnterPress()"> <input class="problem_search_input fl" id="v_subject" type="text" name="subject" value="<%= @subject ? @subject : ""%>" onkeypress="EnterPress(event)" onkeydown="EnterPress()">
<a href="javascript:void(0)" class="problem_search_btn fl" onclick="remote_function();" >搜索</a> <a href="javascript:void(0)" class="problem_search_btn fl" onclick="remote_function();" >搜索</a>
<!--<a href="javascript:void(0)" class="problem_search_btn fl" onclick="nh_reset_form();" >清空</a>-->
</div><!--problem_search end--> </div><!--problem_search end-->
<div id="filter_form" class="fr" > <div id="filter_form" class="fr" >
<%= select( :issue, :user_id, principals_options_for_isuue_list(@project), <%= select( :issue, :user_id, principals_options_for_isuue_list(@project),
{ :include_blank => false,:selected=>@assign_to_id ? @assign_to_id : 0 { :include_blank => false,:selected=>@assign_to_id ? @assign_to_id : 0
}, },
{:onchange=>"remote_function();",:id=>"assigned_to_id",:name=>"v[assigned_to_id]",:class=>"w90"} {:onchange=>"remote_function();",:id=>"assigned_to_id",:name=>"assigned_to_id",:class=>"w90"}
) )
%> %>
<%= select( :issue,:prior, [["低",1],["正常",2],["高",3],["紧急",4],["立刻",5]].unshift(["优先级",0]), <%= select( :issue,:prior, [["低",1],["正常",2],["高",3],["紧急",4],["立刻",5]].unshift(["优先级",0]),
{ :include_blank => false,:selected=>@priority_id ? @priority_id : 0 { :include_blank => false,:selected=>@priority_id ? @priority_id : 0
}, },
{:onchange=>"remote_function();",:id=>"priority_id",:name=>"v[priority_id]",:class=>"w90"} {:onchange=>"remote_function();",:id=>"priority_id",:name=>"priority_id",:class=>"w90"}
) )
%> %>
<%= select( :issue,:status, [["新增",1],["正在解决",2],["已解决",3],["反馈",4],["关闭",5],["拒绝",6]].unshift(["状态",0]), <%= select( :issue,:status, [["新增",1],["正在解决",2],["已解决",3],["反馈",4],["关闭",5],["拒绝",6]].unshift(["状态",0]),
{ :include_blank => false,:selected=>@status_id ? @status_id : 0 { :include_blank => false,:selected=>@status_id ? @status_id : 0
}, },
{:onchange=>"remote_function();",:id=>"status_id",:name=>"v[status_id]",:class=>"w90"} {:onchange=>"remote_function();",:id=>"status_id",:name=>"status_id",:class=>"w90"}
) )
%> %>
<%= select( :issue,:user_id, @project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["作者",0]), <%= select( :issue,:user_id, @project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["作者",0]),
{ :include_blank => false,:selected=>@author_id ? @author_id : 0 { :include_blank => false,:selected=>@author_id ? @author_id : 0
}, },
{:onchange=>"remote_function();",:id=>"author_id",:name=>"v[author_id]",:class=>"w90"} {:onchange=>"remote_function();",:id=>"author_id",:name=>"author_id",:class=>"w90"}
) )
%> %>
</div><!--filter_form end--> </div><!--filter_form end-->
<div class="cl"></div> <div class="cl"></div>
<%# end %> <!--<div>-->
<!--<div style="float:left;">创建时间&nbsp;:&nbsp;</div>-->
<!--<div>-->
<!--<%#= text_field_tag 'issue_create_date_start', '',:readonly=>true, :size=>15, :onchange => "remote_function()",:style=>'float:left;'%>-->
<!--<%#= calendar_for('issue_create_date_start') %>-->
<!--</div>-->
<!--<div style="float:left;">&nbsp;-&nbsp;</div>-->
<!--<div>-->
<!--<%#= text_field_tag 'issue_create_date_end', '',:readonly=>true, :size=>15, :onchange => "remote_function()",:style=>'float:left;'%>-->
<!--<%#= calendar_for('issue_create_date_end') %>-->
<!--</div>-->
<!--</div>-->
<!--<div class="cl"></div>-->
<% end %>
<p class="problem_p fl" ><%= l(:label_issues_sum) %><a href="javascript:void(0)" class="c_red"><%= @project.issues.visible.all.count %></a> <p class="problem_p fl" ><%= l(:label_issues_sum) %><a href="javascript:void(0)" class="c_red"><%= @project.issues.visible.all.count %></a>
<%= l(:lable_issues_undo) %><a href="javascript:void(0)" class="c_red"><%= @project.issues.where('status_id in (1,2,4,6)').visible.all.count %> </a> <%= l(:lable_issues_undo) %><a href="javascript:void(0)" class="c_red"><%= @project.issues.where('status_id in (1,2,4,6)').visible.all.count %> </a>
</p> </p>

@ -19,11 +19,11 @@
<div class="cl"></div> <div class="cl"></div>
<p>由<a href="javascript:void(0)" class="problem_name"><%= @issue.author %></a> <p>由<a href="javascript:void(0)" class="problem_name"><%= @issue.author %></a>
<% if @issue.created_on != @issue.updated_on %> <%# if @issue.created_on != @issue.updated_on %>
更新于 <%= format_time(@issue.created_on).html_safe %> 添加于 <%= format_time(@issue.created_on).html_safe %>
<% else %> <%# else %>
添加于 <%= format_time(@issue.updated_on).html_safe %> <%#= format_time(@issue.updated_on).html_safe %>
<% end %> <%# end %>
</div> </div>
<!--talk_txt end--> <!--talk_txt end-->
<a href="javascript:void(0)" class="talk_edit fr"<%= render :partial => 'action_menu' %></a> <a href="javascript:void(0)" class="talk_edit fr"<%= render :partial => 'action_menu' %></a>

@ -1,4 +1,3 @@
<div class="project_r_h"> <div class="project_r_h">
<h2 class="project_h2"><%= l(:label_invite_join) %></h2> <h2 class="project_h2"><%= l(:label_invite_join) %></h2>
</div> </div>
@ -68,5 +67,32 @@
var text=$(label).text(); var text=$(label).text();
$(label).attr("title",text); $(label).attr("title",text);
} }
function nh_show_err_message(msg){
$("#RSide>.flash").remove();
$("#RSide").prepend('<div class="flash error" id="flash_error">'+msg+'</div>');
}
$('#new_membership').submit(function(){
var user_ischeck=false;
$("input[name='membership[user_ids][]']").each(function(){
if($(this).prop('checked')){
user_ischeck=true;
}
});
if(user_ischeck==false){
nh_show_err_message('请选择用户!');
return false;
}
var role_ischeck=false;
$("input[name='membership[role_ids][]']").each(function(){
if($(this).prop('checked')){
role_ischeck=true;
}
});
if(role_ischeck==false){
nh_show_err_message('请选择角色!');
return false;
}
});
}); });
</script> </script>
Loading…
Cancel
Save