Merge branch 'szzh' into guange_dev

This commit is contained in:
sw 2015-04-30 11:22:42 +08:00
commit 74a85e1601
7 changed files with 91 additions and 12 deletions

View File

@ -344,12 +344,22 @@ class ProjectsController < ApplicationController
end
# 两种情况1、系统外用户2、系统内用户 (通过邮件判定)
def send_mail_to_member
if !params[:mail].blank? && User.find_by_mail(params[:mail].to_s).nil?
email = params[:mail]
Mailer.run.send_invite_in_project(email, @project, User.current)
@is_zhuce =false
flash[:notice] = l(:notice_email_sent, :value => email)
elsif !User.find_by_mail(params[:mail].to_s).nil?
user = User.find_by_mail(params[:mail].to_s)
if !user.member_of?(@project)
email = params[:mail]
Mailer.run.request_member_to_project(email, @project, User.current)
flash[:notice] = l(:notice_email_sent, :value => email)
else
flash[:error] = l(:label_member_of_project, :value => email)
end
else
flash[:error] = l(:notice_registed_error, :value => email)
@is_zhuce = true
@ -358,6 +368,7 @@ class ProjectsController < ApplicationController
format.html{redirect_to invite_members_by_mail_project_url(@project)}
end
end
#发送邮件邀请新用户
def invite_members_by_mail
if User.current.member_of?(@project) || User.current.admin?

View File

@ -69,6 +69,18 @@ class Mailer < ActionMailer::Base
mail :to => email, :subject => @subject
end
# 邀请已注册的用户加入项目
def request_member_to_project(email, project, invitor)
user = User.find_by_mail(email.to_s)
Member.create(:role_ids => [4], :user_id => user.id,:project_id => project.id)
@invitor_name = "#{invitor.name}"
@project_name = "#{project.name}"
@user = user
@token = Token.get_token_from_user(user, 'autologin')
@project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id,:user => user, :token => @token.value)
mail :to => email, :invitor_name => "#{@invitor_name}", :project_name => "#{@project_name}"
end
# author: alan
# 根据用户选择发送个人日报或周报
# 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言

View File

@ -1,23 +1,49 @@
<script type="text/javascript">
document.addEventListener('DOMContentLoaded',function(){
var img = document.getElementsByName('issue_attachment_picture');
function getImgNaturalStyle(img,callback) {
var nWidth, nHeight
if (typeof img.naturalWidth == "undefined"|| img.naturalWidth == 0) { // 现代浏览器
function getImgNaturalStyle(img, callback) {
var nWidth, nHeight;
if (typeof img.naturalWidth == "undefined"|| img.naturalWidth == 0) {
var image = new Image();
image.src = img.src;
nWidth = image.width;
nHeight = image.height;
} else {
nWidth = img.naturalWidth;
nHeight = img.naturalHeight;
if (image.complete) {
callback(image);
} else {
image.onload = function () {
callback(image);
image.onload = null;
};
};
}
return [nWidth, nHeight]
else
{
if (img.complete) {
nWidth = img.naturalWidth;
nHeight = img.naturalHeight;
} else {
img.onload = function () {
nWidth = img.naturalWidth;
nHeight = img.naturalHeight;
image.onload = null;
};
};
}
return [nWidth, nHeight];
}
function UpdateImageInformation(image) {
return [image.width,image.height];
}
for(i=0;i<img.length;i++)
{
imgNatural = getImgNaturalStyle(img[i]);
imgNatural = getImgNaturalStyle(img[i],UpdateImageInformation);
var width = imgNatural[0];
var height = imgNatural[1];
if (width<100)
@ -29,7 +55,10 @@
}
}
});
</script>
<div class="attachments" style="font-weight:normal;">
<% is_float ||= false %>
<% for attachment in attachments %>

View File

@ -0,0 +1,22 @@
<div class="mail_box" style="border:1px solid #c8c8c8; width:570px; height: auto; padding:15px; margin-top:10px; margin-bottom:10px;">
<ul style="list-style-type:none; margin:0; padding:0;">
<li style="list-style-type:none; margin:0; padding:0;"><span style="float: left;"><strong><%= l(:mail_issue_content)%></strong></span>
<span style="float: left; width: 526px">
<p><span style="color:#1b55a7; font-weight:bold;"><%= @invitor_name %></span> 邀请您加入项目:<span style="color:#1b55a7; font-weight:bold;"><%= @project_name %></span> </p>
<div class="cl" style="margin-top: 30px; clear:both; overflow:hidden;"></div>
<p>点击“同意加入”按钮,即可快速加入项目!</p> <br/>
<label class="mail_reply">
<%= link_to( l(:label_agree_join_project), @project_url, :class => "mail_reply", :style =>'display:block; float:right; width:80px; text-align:center; height:30px; background:#15bccf; color:#fff; font-weight:normal; font-size:14px; line-height: 30px;') %>
</label>
<div class="cl" style="margin-top: 30px; clear:both; overflow:hidden;"></div>
</span>
</li>
</ul>
<div class="cl" style="margin-top: 30px; clear:both; overflow:hidden;"></div>
</div>

View File

@ -0,0 +1,3 @@
<%= @invitor_name %>
<%= @project_name %>
<%= link_to( l(:label_apply_project), @project_url) %>

View File

@ -48,11 +48,13 @@ zh:
# 左边栏
#
label_project_id: "项目ID:"
label_agree_join_project: 同意加入
label_apply_project: "+申请加入"
label_button_following: "+添加关注"
label_exit_project: 退出项目
label_apply_project_waiting: 已处理申请,请等待管理员审核
label_member_of_project: 该用户已经是项目成员了!
label_unapply_project: 取消申请
lable_sure_exit_project: 是否确认退出该项目
label_friend_organization: 圈子模式

View File

@ -338,7 +338,7 @@ a:hover.st_add{ color:#ff8e15;}
.newpro_box input{ height:26px; float:left; margin-bottom:10px;}
.newpro_box textarea{ height:150px; float:left; margin-bottom:10px;}
.newpro_box select{ height:29px; float:left; margin-bottom:10px;}
.label{ width:80px; text-align:right; font-size:14px; background-image: url(../images/true.png); }
/*.label{ width:80px; text-align:right; font-size:14 background-image: url(../images/true.png); }*/
.icon-reload { background-image: url(../images/reload.png); }
.icon {
background-position: 0% 50%;