Merge remote-tracking branch 'origin/szzh' into szzh

This commit is contained in:
lizanle 2015-05-04 17:37:05 +08:00
commit 96aef6dbe2
11 changed files with 157 additions and 43 deletions

View File

@ -247,10 +247,9 @@ class ProjectsController < ApplicationController
# 1、自动注册
# 2、加入项目、创建角色
# 3、用户得分
if params[:login]
# 自动激活用户
user.status = 1
user.save
if params[:email]
user = User.find_by_mail(params[:email].to_s)
Member.create(:role_ids => [4], :user_id => user.id,:project_id => @project.id)
end
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
return
@ -344,12 +343,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 +367,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

@ -329,12 +329,12 @@ module ApplicationHelper
imagesize = attachment.thumbnail(:size => "200*200")
imagepath = named_attachment_path(attachment, attachment.filename)
if imagesize
link_to image_tag(thumbnail_path(attachment), height: '73', width: '100', name: 'issue_attachment_picture'),
link_to image_tag(thumbnail_path(attachment), height: '73', width: '100', class: 'issue_attachment_picture'),
imagepath,
:title => attachment.filename
else
link_to image_tag(imagepath , height: '73', width: '100', name: 'issue_attachment_picture'),
link_to image_tag(imagepath , height: '73', width: '100', class: 'issue_attachment_picture'),
imagepath,
:title => attachment.filename
end

View File

@ -69,6 +69,18 @@ class Mailer < ActionMailer::Base
mail :to => email, :subject => @subject
end
# 邀请已注册的用户加入项目
def request_member_to_project(email, project, invitor)
@subject = "#{invitor.name} #{l(:label_invite_project)}: #{project.name} "
user = User.find_by_mail(email.to_s)
@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, :email => email, :token => @token.value)
mail :to => email, :subject => @subject
end
# author: alan
# 根据用户选择发送个人日报或周报
# 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言
@ -154,7 +166,7 @@ class Mailer < ActionMailer::Base
@course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o|
!o.empty?
}
binding.pry if Rails.env.development?
mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}"
#有内容才发,没有不发
mail :to => user.mail,:subject => subject if has_content
end
@ -829,11 +841,12 @@ class Mailer < ActionMailer::Base
end
set_language_if_valid @initial_language
super headers do |format|
m = super headers do |format|
format.text
format.html unless Setting.plain_text_mail?
end
mylogger.debug "Sent a mail from #{m.from} to [#{m.to},#{m.cc}, #{m.bcc if Setting.bcc_recipients?}] subject: #{m.subject}"
m
end
def initialize(*args)
@ -888,7 +901,11 @@ class Mailer < ActionMailer::Base
end
def mylogger
Rails.logger
if Setting.delayjob_enabled?
Delayed::Worker.logger
else
Rails.logger
end
end
def add_attachments(obj)

View File

@ -1,35 +1,30 @@
<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) { // 现代浏览器
var image = new Image();
image.src = img.src;
nWidth = image.width;
nHeight = image.height;
} else {
nWidth = img.naturalWidth;
nHeight = img.naturalHeight;
}
return [nWidth, nHeight]
}
for(i=0;i<img.length;i++)
jQuery(window).load(function () {
jQuery(".issue_attachment_picture").each(function () {
DrawImage(this, 100, 73);
});
});
function DrawImage(ImgD, FitWidth, FitHeight) {
var image = new Image();
image.src = ImgD.src;
if (image.width > 100 || image.height > 73)
{
imgNatural = getImgNaturalStyle(img[i]);
var width = imgNatural[0];
var height = imgNatural[1];
if (width<100)
{
img[i].width = width;
rateWidth = image.width / 100;
rateHeight = image.height / 73;
if (rateWidth > rateHeight) {
ImgD.width = 100;
ImgD.height = Math.round(image.height/rateWidth);
}
if (height<73) {
img[i].height = height;
else
{
ImgD.width = Math.round(image.width/rateHeight);
ImgD.height = 73;
}
}
});
}
</script>
<div class="attachments" style="font-weight:normal;">
<% is_float ||= false %>
<% for attachment in attachments %>

View File

@ -0,0 +1,66 @@
<style type="text/css">
#preview{width:360px;height:360px;border:1px solid #000;overflow:hidden;}
#imghead {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);}
</style>
<script type="text/javascript">
function previewImage(file)
{
var MAXWIDTH = 360;
var MAXHEIGHT = 360;
var div = document.getElementById('preview');
if (file.files && file.files[0])
{
div.innerHTML = '<img id=imghead>';
var img = document.getElementById('imghead');
img.onload = function(){
var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
img.width = rect.width;
img.height = rect.height;
img.style.marginLeft = rect.left+'px';
img.style.marginTop = rect.top+'px';
}
var reader = new FileReader();
reader.onload = function(evt){img.src = evt.target.result;}
reader.readAsDataURL(file.files[0]);
}
else
{
var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
file.select();
var src = document.selection.createRange().text;
div.innerHTML = '<img id=imghead>';
var img = document.getElementById('imghead');
img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;margin-left:"+rect.left+"px;"+sFilter+src+"\"'></div>";
}
}
function clacImgZoomParam( maxWidth, maxHeight, width, height ){
var param = {top:0, left:0, width:width, height:height};
if( width>maxWidth || height>maxHeight )
{
rateWidth = width / maxWidth;
rateHeight = height / maxHeight;
if( rateWidth > rateHeight )
{
param.width = maxWidth;
param.height = Math.round(height / rateWidth);
}else
{
param.width = Math.round(width / rateHeight);
param.height = maxHeight;
}
}
param.left = Math.round((maxWidth - param.width) / 2);
param.top = Math.round((maxHeight - param.height) / 2);
return param;
}
</script>
<div id="preview">
<img id="imghead" width=100 height=100 border=0 src="file:///C:/Users/whimlex/Downloads/1.jpg">
</div>
<br/>
<input type="file" onchange="previewImage(this)" />

View File

@ -4,7 +4,7 @@
<% html_title "#{@issue.tracker.name} #{@issue.source_from}'#'#{@issue.project_index}: #{@issue.subject}" %>
<div class="pro_page_box">
<div class="pro_page_top break_word">
<a href="javascript:void(0)"><%= @issue.project.name %></a> >
<%= link_to "#{@issue.project.name}"+">", project_issues_path(@issue.project) %>
<a href="javascript:void(0)"><%= "#" + @issue.project_index %></a>
</div>
<div class="problem_main">

View File

@ -89,7 +89,7 @@
<%=l(:label_project_hosting_platform) %>
</a>
>
<%= link_to @project.name, nil %>
<%= link_to @project.name, project_path(@project.id) %>
</p>
</div>
<div class="search fl">
@ -122,13 +122,12 @@
<!-- 项目得分 -->
<div class="cl"></div>
<div>
<a class="pr_info_name fl c_dark fb break_word" href="javascript:void(0)" target="_blank" >
<%= l(:label_project_name) %><%= @project.name %>
<%= link_to l(:label_project_name)+"#{@project.name}", project_path(@project.id), :class=>"pr_info_name fl c_dark fb break_word" %>
<% if @project.is_public? %>
<span class="img_private"><%= l(:label_public)%></span>
<% else %>
<span class="img_private"><%= l(:label_private)%></span>
<% end %></a>
<% end %>
</div>
<div class="cl"></div>
<div>

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

@ -87,7 +87,7 @@ a.pro_mes_w{ height:20px; float:left;display:block; color:#999999;}
.pro_page_top{ font-size:14px; border-bottom:2px solid #64bdd9; margin-bottom:10px; padding-bottom:5px;}
.pro_page_tit{color:#3e4040; font-weight:bold;width:480px; float:left; font-size:14px; margin-bottom:5px;}
.pro_pic_box{ margin-left:60px; }
.pro_pic{ width:100px; height:73px;line-height:73px;border:2px solid #CCC; margin:10px 0;}
.pro_pic{ width:100px; height:75px;line-height:73px;border:2px solid #CCC; margin:10px 0; text-align: center;}
.pro_info_box{ margin-left:60px; background:#f0fbff; height:80px; padding:10px 0;}
.pro_info_box ul{}
.pro_info_box ul li{ margin-bottom:10px;}
@ -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%;