Merge branch 'szzh' into develop

This commit is contained in:
sw 2015-04-30 11:24:09 +08:00
commit a38e0ab392
16 changed files with 194 additions and 36 deletions

View File

@ -228,6 +228,18 @@ module Mobile
present :status, 0
end
desc '课程课件'
params do
requires :token, type: String
requires :course_id,type: Integer,desc: '课程id'
end
get ":course_id/attachments" do
cs = CoursesService.new
count = cs.course_attachments params
present :data, count, with: Mobile::Entities::Attachment
present :status, 0
end
end
end
end

View File

@ -16,8 +16,11 @@ module Mobile
end
end
end
attachment_expose :id
attachment_expose :filename
attachment_expose :description
attachment_expose :downloads
attachment_expose :quotes
end
end
end

View File

@ -248,16 +248,9 @@ class ProjectsController < ApplicationController
# 2、加入项目、创建角色
# 3、用户得分
if params[:login]
login = params[:login]
login = login.sub(/%40/,'@')
mail = params[:login]
password = params[:password]
us = UsersService.new
user = us.register_auto(login,mail, 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.status = 1
user.save
end
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
return
@ -351,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
@ -365,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

@ -329,11 +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'),
link_to image_tag(thumbnail_path(attachment), height: '73', width: '100', name: 'issue_attachment_picture'),
imagepath,
:title => attachment.filename
else
link_to image_tag(imagepath , height: '73', width: '100'),
link_to image_tag(imagepath , height: '73', width: '100', name: 'issue_attachment_picture'),
imagepath,
:title => attachment.filename
end

View File

@ -33,7 +33,7 @@ class Mailer < ActionMailer::Base
@target = cls
end
def method_missing(name, *args, &block)
if Setting.delayjob_enabled && Object.const_defined?('Delayed')
if Setting.delayjob_enabled? && Object.const_defined?('Delayed')
@target.delay.send(name, *args, &block)
else
@target.send(name, *args, &block).deliver
@ -52,12 +52,35 @@ class Mailer < ActionMailer::Base
@email = email
@subject = "#{invitor.name} #{l(:label_invite_project)} #{project.name} "
@password = newpass(6)
@project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id,
:password => @password,
:login => email)
login = email
login = login.sub(/%40/,'@')
us = UsersService.new
# 自动激活用户
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 = 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, :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
# 根据用户选择发送个人日报或周报
# 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言
@ -143,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
@ -818,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)
@ -877,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

@ -19,6 +19,7 @@ class Principal < ActiveRecord::Base
self.table_name = "#{table_name_prefix}users#{table_name_suffix}"
# Account statuses
# 0 全部1 活动的; 2 已注册; 3 锁定
STATUS_ANONYMOUS = 0
STATUS_ACTIVE = 1
STATUS_REGISTERED = 2

View File

@ -428,6 +428,17 @@ class CoursesService
result
end
# 课程课件
def course_attachments params
result = []
@course = Course.find(params[:course_id])
@attachments = @course.attachments.order("created_on desc")
@attachments.each do |atta|
result << {:filename => atta.filename,:description => atta.description,:downloads => atta.downloads,:quotes => atta.quotes.nil? ? 0 :atta.quotes }
end
result
end
private
def show_homework_info course,bid,current_user,is_course_teacher
author_real_name = bid.author.lastname + bid.author.firstname

View File

@ -1,3 +1,64 @@
<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;
if (image.complete) {
callback(image);
} else {
image.onload = function () {
callback(image);
image.onload = null;
};
};
}
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],UpdateImageInformation);
var width = imgNatural[0];
var height = imgNatural[1];
if (width<100)
{
img[i].width = width;
}
if (height<73) {
img[i].height = height;
}
}
});
</script>
<div class="attachments" style="font-weight:normal;">
<% is_float ||= false %>
<% for attachment in attachments %>

View File

@ -5,8 +5,8 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show_project',:locals => {:project => project}) %>');
showModal('ajax-modal', '513px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'><a href='javascript:void(0)' onclick='closeModal()'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>")
$('#ajax-modal').parent().css("top","40%").css("left","30%");
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'><a href='javascript:void(0)' onclick='closeModal()'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","40%").css("left","36%");
$('#ajax-modal').parent().addClass("popbox_polls");
}

View File

@ -12,12 +12,12 @@
<%= link_to "<span class='pr_setting'></span>#{l(:button_configure)}".html_safe, settings_project_path(@project), :class => "pr_join_a" %>
<% end %>
<!--项目类型-->
<% if (User.current.login? && User.current.member_of?(@project) && Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.first.to_s.include?("Manager")) || User.current.admin? %>
<% if (User.current.login? && User.current.member_of?(@project) && Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.to_s.include?("Manager")) || User.current.admin? %>
<%= link_to "<span class='#{typeclass}'></span>#{text}".html_safe,"javascript:void(0)" ,:onClick => "show_window();", :class => "pr_join_a",:id => "setting_project_type"%>
<% end %>
<!--退出项目-->
<% if (User.current.member_of? @project) && User.current.login? && !User.current.admin &&
Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.first.to_s != "Manager" %>
!Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.to_s.include?("Manager") %>
<%= exit_project_link(@project) %>
<% end %>

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

@ -18,19 +18,19 @@
<li >
<%= link_to_user_header member.principal,false,:class => "w140_h c_setting_blue fl" %>
<span class="w180_h fl">
<%= h member.roles.sort.collect(&:to_s).join(', ') %>
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
:method => :put,
:html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}}
<%= h member.roles.sort.collect(&:to_s).join(', ') %>
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
:method => :put,
:html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}}
) do |f| %>
<% roles.each do |role| %>
<% roles.each do |role| %>
<ul style="text-align: left;" >
<%= check_box_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %>
<label ><%= h role %></label>
</ul>
<!--<br/>-->
<% end %>
<% end %>
<%= hidden_field_tag 'membership[role_ids][]', '' %>
<div>
<a href="javascript:void(0)" class="member_btn" onclick="$('#member-<%= member.id%>-roles-form').submit();" style="margin-right: 10px;">
@ -41,7 +41,7 @@
</a>
</div>
<% end %>
</span>
</span>
<% unless member.user_id == @project.user_id %>
<a href="javascript:void(0) " class="c_setting_blue ml30 fl" onclick="$('#member-<%= member.id%>-roles-form').show();$(this).parent().height(110);">编辑</a>
<%= delete_link membership_path(member),

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

@ -654,6 +654,16 @@ ActiveRecord::Schema.define(:version => 20150428021035) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_details_copy", :force => true do |t|
t.integer "journal_id", :default => 0, :null => false
t.string "property", :limit => 30, :default => "", :null => false
t.string "prop_key", :limit => 30, :default => "", :null => false
t.text "old_value"
t.text "value"
end
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"

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; border:2px solid #CCC; margin:10px 0;}
.pro_pic{ width:100px; height:73px;line-height:73px;border:2px solid #CCC; margin:10px 0;}
.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;}
@ -222,7 +222,7 @@ a:hover.ping_sub{ background:#14a8b9;}
/*.ping_distop span a{ float:right; width:20px; height:20px; background:url(images/star.png) -24px 0 no-repeat; margin-right:3px;}*/
/*上传资源弹出框样式*/
/*#popbox_polls{width:300px;height:100px;position:fixed !important;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}*/
.popbox_polls{position:fixed !important;}
.upload_con h2{ display:block; background:#eaeaea; font-size:14px; color:#343333; height:31px; width: auto; margin-top:25px; padding-left:20px; padding-top:5px;}
.upload_box{ width:430px; margin:15px auto;}
@ -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:14 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%;
@ -433,7 +433,7 @@ span.add_attachment a {padding-left:16px; background: url(../images/bullet_add.p
/*日历选择图*/
img.ui-datepicker-trigger {
display:block;
background:url(/images/public_icon.png) -31px 0 no-repeat;
background:url(../images/public_icon.png) -31px 0 no-repeat;
cursor: pointer;
vertical-align: middle;
margin-left: 5px;