Conflicts:
	app/views/layouts/base_users.html.erb
This commit is contained in:
huang 2015-03-12 16:49:42 +08:00
commit 77bf3be20d
14 changed files with 151 additions and 55 deletions

View File

@ -40,6 +40,17 @@ module Mobile
{status: 0}
end
desc "忘记密码"
params do
requires :mail,type: String
end
post 'lost_password' do
us = UsersService.new
message = us.lost_password params
present :message, message
present :status, 0
end
end
end
end

View File

@ -107,17 +107,24 @@ class MembersController < ApplicationController
AppliedProject.deleteappiled(member.user_id, @project.id)
end
end
respond_to do |format|
format.html { redirect_to_settings_in_projects }
format.js { @members = members; @applied_members = applied_members; }
format.api {
@member = members.first
if @member.valid?
render :action => 'show', :status => :created, :location => membership_url(@member)
else
render_validation_errors(@member)
end
}
if params[:flag]
flash[:notice] = l(:label_invite_success)
respond_to do |format|
format.html { redirect_to invite_members_project_url(@project) }
end
else
respond_to do |format|
format.html { redirect_to_settings_in_projects }
format.js { @members = members; @applied_members = applied_members; }
format.api {
@member = members.first
if @member.valid?
render :action => 'show', :status => :created, :location => membership_url(@member)
else
render_validation_errors(@member)
end
}
end
end
elsif @course
course_info = []
@ -310,6 +317,7 @@ class MembersController < ApplicationController
end
def autocomplete
@flag = params[:flag] || false
respond_to do |format|
format.js
end

View File

@ -28,7 +28,8 @@ class WelcomeController < ApplicationController
# 企业版定制: params[:project]为传过来的参数
unless params[:organization].nil?
@organization = Organization.find params[:organization]
@organization_projects = Project.visible.joins(:project_status).joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").where("projects.organization_id = ?", @organization.id).order("score DESC").limit(10).all
# @organization_projects = Project.joins(:project_status).joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").where("projects.organization_id = ?", @organization.id).order("score DESC").limit(10).all
@organization_projects = @organization.projects.visible.joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").order("project_scores.score DESC").limit(10).all
@part_projects = @organization_projects.count < 9 ? find_miracle_project( 9 - @organization_projects.count, 3,"score desc") : []
# @cur_projects = Project.find(params[:organization])
# @organization = @cur_projects.enterprise_name

View File

@ -490,6 +490,15 @@ module ApplicationHelper
s.html_safe
end
#项目成员列表复选框生成
def project_member_check_box_tags_ex name, principals
s = ''
principals.each do |principal|
s << "<li>#{ check_box_tag name, principal.id, false, :id => nil } #{h link_to principal.userInfo, user_path( principal.id)}</li>\n"
end
s.html_safe
end
#扩展的checkbox生成
def principals_check_box_tags_ex(name, principals)
s = ''

View File

@ -23,15 +23,22 @@ module MembersHelper
principal_count = scope.count
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page'] #by young
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
s = content_tag('div', principals_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals')
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
}
s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
end
#获取项目可邀请的成员列表
def render_project_members project
scope = Principal.active.sorted.not_member_of(project).like(params[:q])
principals = paginateHelper scope,10
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :style => "margin-left: -40px;")
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options|
link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q],:flag => true, :format => 'js')), :remote => true
}
s + content_tag('ul', links,:class => 'wlist')
end
# add by nwb
@ -71,4 +78,18 @@ module MembersHelper
s + content_tag('div', content_tag('ul', links), :class => 'applied_new')
end
private
def paginateHelper obj, pre_size=20
@obj_count = obj.count
@obj_pages = Redmine::Pagination::Paginator.new @obj_count, pre_size, params['page']
if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation
obj.limit(@obj_pages.per_page).offset(@obj_pages.offset)
elsif obj.kind_of? Array
obj[@obj_pages.offset, @obj_pages.per_page]
else
logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}"
raise RuntimeError, 'unknow type, Please input you type into this helper.'
end
end
end

View File

@ -1,4 +1,3 @@
#coding=utf-8
class CoursesService
include ApplicationHelper
include CoursesHelper
@ -355,19 +354,19 @@ class CoursesService
latest_course_dynamics = []
latest_news = course.news.order("created_on desc").first
unless latest_news.nil?
latest_course_dynamics << {:type => 1,:time => latest_news.created_on,:message => '最近更新了通知' }#l(:label_recently_updated_notification,:locale => current_user.language.nil? ? 'zh':current_user.language)}
latest_course_dynamics << {:type => 1,:time => latest_news.created_on,:message => l(:label_recently_updated_notification,:locale => current_user.language.nil? ? 'zh':current_user.language)}
end
latest_message = course.journals_for_messages.order("created_on desc").first
unless latest_message.nil?
latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message => '最近更新了留言'}#l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)}
latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message => l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)}
end
latest_attachment = course.attachments.order("created_on desc").first
unless latest_attachment.nil?
latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message => '最近更新了课件'}#l(:label_recently_updated_courseware,:locale => current_user.language.nil? ? 'zh':current_user.language)}
latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message => l(:label_recently_updated_courseware,:locale => current_user.language.nil? ? 'zh':current_user.language)}
end
latest_bid = course.homeworks.order('updated_on DESC').first
unless latest_bid.nil?
latest_course_dynamics << {:type => 4,:time => latest_bid.updated_on,:message => '最近更新了作业'}#l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)}
latest_course_dynamics << {:type => 4,:time => latest_bid.updated_on,:message => l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)}
end
#每个作业中的最新留言
messages = []

View File

@ -80,6 +80,28 @@ class UsersService
{:id => @user.id, :img_url => img_url, :nickname => @user.login, :gender => gender, :work_unit => work_unit, :mail => @user.mail, :location => location, :brief_introduction => @user.user_extensions.brief_introduction}
end
#忘记密码
def lost_password params
user = ::User.find_by_mail(params[:mail].to_s)
# user not found or not active
unless user && user.active?
raise l(:notice_account_unknown_email,:locale => 'zh')
end
# user cannot change its password
unless user.change_password_allowed?
raise l(:notice_can_t_change_password,:locale => user.language)
return
end
# create a new token for password recovery
token = Token.new(:user => user, :action => "recovery")
if token.save
Thread.new do
Mailer.lost_password(token).deliver
end
return l(:notice_account_lost_email_sent,:locale => user.language)
end
end
#编辑用户
#gender 1female 0male 其他male
def edit_user params

View File

@ -217,7 +217,7 @@
</td>
</tr>
<% end %>
<% unless @user.user_extensions.location.blank? %>
<% unless @user.user_extensions.nil?&&@user.user_extensions.location.empty?%>
<tr>
<td style=" float: right" width="70px">

View File

@ -1,12 +1,16 @@
<% if @project%>
$('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_members(@project)) %>');
<% if @flag == "true"%>
$('#principals_for_new_member').html('<%= escape_javascript(render_project_members(@project)) %>');
<% else%>
$('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_members(@project)) %>');
<% end%>
<% elsif @course%>
var checked = $("#principals input:checked").size();
if(checked > 0)
{
alert('翻页或搜索后将丢失当前选择的用户数据!');
}
$('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_course_members(@course)) %>');
var checked = $("#principals input:checked").size();
if(checked > 0)
{
alert('翻页或搜索后将丢失当前选择的用户数据!');
}
$('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_course_members(@course)) %>');
<%end%>
var collection=$("#principals_for_new_member").children("#principals").children("label");
collection.css("text-overflow","ellipsis");

View File

@ -1,7 +1,8 @@
<div class="project_r_h">
<h2 class="project_h2">邀请加入</h2>
</div>
<%= error_messages_for 'member' %>
<%#= render_flash_messages %>
<%
roles = Role.givable.all
if @project.project_type == Project::ProjectType_course
@ -14,36 +15,46 @@
<div style="margin-left: 30px" >
<div class="floatbox" style="margin:100px;">
<div ><a href="#" class="box_close"></a></div>
<div >
<a href="#" class="box_close"></a>
</div>
<div class="cl"></div>
<div class="box_main">
<h3 class="box_h3">邀请Trustie注册用户</h3>
<% if roles.any? %>
<%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
<%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :method => :post}) do |f| %>
<div class="invi_search">
<input hidden="hidden" value="true" name="flag">
<input id="principal_search" class="invi_search_input fl" type="text" placeholder="输入用户名称搜索好友">
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_project_memberships_path(@project, :format => 'js',:flag => true) }')" %>
<div class="cl"></div>
<div class="invi_search">
<%= label_tag "principal_search", l(:label_principal_search) %>
<%= text_field_tag 'principal_search', nil %>
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_project_memberships_path(@project, :format => 'js') }')" %>
<div id="principals_for_new_member">
<%= render_project_members(@project) %>
</div>
<div class="cl"></div>
<div id="principals_for_new_member">
<%= render_principals_for_new_members(@project) %>
</div>
<p style="padding-top: 5px">
<%= l(:label_role_plural) %>:
<% roles.each do |role| %>
<label>
<%= check_box_tag 'membership[role_ids][]', role.id %>
<%= h role %>
</label>
<ul class="rolebox">
<li class="fl mr5">
<%= l(:label_role_plural) %>:
</li>
<% roles.each do |role| %>
<li class="fl mr5">
<%= check_box_tag 'membership[role_ids][]', role.id %>
<%= h role %>
</li>
<% end %>
</ul>
<div class="cl mb10"></div>
<a href="#" class="btn_free" onclick="$('#new_membership').submit();">
<%= l(:label_invite_members)%>
</a>
</div>
<!--<p>-->
<!--<%#= submit_tag l(:label_invite_members), :id => 'member-add-submit', :style => 'display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;' %>-->
<!--</p>-->
<% end %>
</p>
<p>
<%= submit_tag l(:label_invite_members), :id => 'member-add-submit', :style => 'display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;' %>
</p>
<% end %>
<% end %>
</div>
</div>
</div>
</div>

View File

@ -60,7 +60,8 @@ zh:
project_module_code_review: 代码审查
project_module_calendar: 日历
project_module_gantt: 甘特图
project_module_documents: 文档
project_module_documents: 文档
project_module_files: 资源库
label_project_tool_response: 用户反馈
label_module_share: DTS测试工具

View File

@ -1719,6 +1719,7 @@ zh:
label_bids_task_list: 作业列表
label_join_course: 加入
label_invite_project: 邀请您加入项目
label_invite_success: 邀请成功
label_invite_members: 邀请用户
label_exit_course: 退出
label_exit_group: 退出当前分班

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150305081132) do
ActiveRecord::Schema.define(:version => 20150311013036) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false

View File

@ -8,6 +8,13 @@ h3, .wiki h2 {font-size: 15px; padding-left: 5px}
h4, .wiki h3 {font-size: 13px;}
h4 {border-bottom: 1px dotted #bbb;}
/****翻页***/
ul.wlist{ margin-left: -40px; border-bottom:none; }
ul.wlist li{float: left;}
ul.wlist li a{ border:1px solid #15bccf; padding:4px; margin-left:3px;}
ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;}
.wlist_select { background-color:#64bdd9; color:#fff; padding: 4px 3px 3px 3px; margin-left:3px;margin-top: -5px; border:1px solid #64bdd9;}
/*20150203项目界面优化样式 By: huangjignquan*/
.project_new{font-size: 15px; padding: 5px;}
.project_new .description{font-size: 12px; color: #ff7450; margin-bottom: 2px;}
@ -101,13 +108,14 @@ a:hover.more{ color:#64bdd9;}
.icon_addm:hover{background:url(../images/img_floatbox.png) 0 -61px no-repeat; }
.icon_removem{ background:url(../images/img_floatbox.png) -22px -33px no-repeat;width:16px; height:16px; display:block; margin:5px 0 0 5px}
.icon_removem:hover{background:url(../images/img_floatbox.png) -22px -61px no-repeat;}
.btn_free{ background:#ff5722; display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;}
.btn_free{ background:#ff5722; display:block; width:80px; text-align:center; color:#fff !important; height:26px; padding-top:8px; margin-bottom:10px;}
.btn_free:hover{ background:#d63502;}
/*成员邀请*/
.invi_search{ width:295px; margin:0 auto;}
.invi_search{ width:345px; margin:0 auto;}
.invi_search_input{ border:1px solid #15bccf; width:180px; height:24px; color:#9b9b9b; padding-left:5px; margin-bottom:10px;}
.invi_search_btn{ background:#15bccf; color:#fff; text-align: center; width:40px; height:22px;border:1px solid #15bccf; padding-top:2px; cursor:pointer;}
.invi_search_btn:hover{ background:#0da1b2; border:1px solid #0da1b2;}
.rolebox{ margin-left: -40px;}
/*问题跟踪*/
.problem_top{ margin:10px 0 ;}
.problem_search_input{ border:1px solid #64bdd9; width:180px; height:24px; color:#9b9b9b; padding-left:5px; margin-bottom:10px;}