diff --git a/app/api/mobile/apis/auth.rb b/app/api/mobile/apis/auth.rb
index 320497e50..fbec9a3b0 100644
--- a/app/api/mobile/apis/auth.rb
+++ b/app/api/mobile/apis/auth.rb
@@ -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
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb
index ce899eff5..d0be72961 100644
--- a/app/controllers/members_controller.rb
+++ b/app/controllers/members_controller.rb
@@ -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
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb
index 290af0068..949ddd643 100644
--- a/app/controllers/welcome_controller.rb
+++ b/app/controllers/welcome_controller.rb
@@ -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
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a36f4b183..9629ed437 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -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 << "
#{ check_box_tag name, principal.id, false, :id => nil } #{h link_to principal.userInfo, user_path( principal.id)}\n"
+ end
+ s.html_safe
+ end
+
#扩展的checkbox生成
def principals_check_box_tags_ex(name, principals)
s = ''
diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb
index 6c11199fb..ed18b7ae4 100644
--- a/app/helpers/members_helper.rb
+++ b/app/helpers/members_helper.rb
@@ -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
diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb
index 09cc5d59d..c9ea1ca80 100644
--- a/app/services/courses_service.rb
+++ b/app/services/courses_service.rb
@@ -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 = []
diff --git a/app/services/users_service.rb b/app/services/users_service.rb
index 8cadf031c..f75a84c5b 100644
--- a/app/services/users_service.rb
+++ b/app/services/users_service.rb
@@ -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 1:female 0:male 其他:male
def edit_user params
diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb
index 3f483c18d..d68e6abe5 100644
--- a/app/views/layouts/base_users.html.erb
+++ b/app/views/layouts/base_users.html.erb
@@ -217,7 +217,7 @@
<% end %>
- <% unless @user.user_extensions.location.blank? %>
+ <% unless @user.user_extensions.nil?&&@user.user_extensions.location.empty?%>
diff --git a/app/views/members/autocomplete.js.erb b/app/views/members/autocomplete.js.erb
index 16809de48..f7f9de151 100644
--- a/app/views/members/autocomplete.js.erb
+++ b/app/views/members/autocomplete.js.erb
@@ -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");
diff --git a/app/views/projects/invite_members.html.erb b/app/views/projects/invite_members.html.erb
index d31a5bbe8..4b07b9b3e 100644
--- a/app/views/projects/invite_members.html.erb
+++ b/app/views/projects/invite_members.html.erb
@@ -1,7 +1,8 @@
+
邀请加入
-<%= error_messages_for 'member' %>
+<%#= render_flash_messages %>
<%
roles = Role.givable.all
if @project.project_type == Project::ProjectType_course
@@ -14,36 +15,46 @@
-
+
邀请Trustie注册用户
<% 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| %>
+
+
+
+ <%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_project_memberships_path(@project, :format => 'js',:flag => true) }')" %>
+
-
- <%= 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') }')" %>
+
+ <%= render_project_members(@project) %>
+
+
-
- <%= render_principals_for_new_members(@project) %>
-
-
- <%= l(:label_role_plural) %>:
- <% roles.each do |role| %>
-
+
+ -
+ <%= l(:label_role_plural) %>:
+
+ <% roles.each do |role| %>
+ -
+ <%= check_box_tag 'membership[role_ids][]', role.id %>
+ <%= h role %>
+
+ <% end %>
+
+
+
+ <%= l(:label_invite_members)%>
+
+
+
+
+
<% end %>
-
-
- <%= 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;' %>
-
- <% end %>
<% end %>
-
diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml
index 597ce4f57..64b0de952 100644
--- a/config/locales/projects/zh.yml
+++ b/config/locales/projects/zh.yml
@@ -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测试工具
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 076304404..82caa1a96 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -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: 退出当前分班
diff --git a/db/schema.rb b/db/schema.rb
index bad1cf2ae..4cce0b5c8 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index e10004db6..c24091605 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -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;}
|