Merge branch 'szzh' into develop

This commit is contained in:
huang 2015-11-02 13:56:34 +08:00
commit 6e21e50aaf
18 changed files with 81 additions and 32 deletions

View File

@ -125,20 +125,8 @@ update
@repository.type = 'Repository::Gitlab'
@repository.url = @repository.identifier
if request.post? && @repository.save
g = ::Gitlab.client
gid = @project.owner.gid
gproject = g.create_project(@repository.identifier,
path: @repository.identifier,
description: @project.description,
wiki_enabled: false,
wall_enabled: false,
issues_enabled: false,
snippets_enabled: false,
public: false,
user_id: gid
)
@project.gpid = gproject.id
@project.save!
s = Trustie::Gitlab::Sync.new
s.create_project(@project, @repository)
redirect_to settings_project_url(@project, :tab => 'repositories')
else
redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages)

View File

@ -36,7 +36,7 @@ module CoursesHelper
#生成课程老师成员链接
def course_teacher_link teacher_num
if User.current.member_of_course?(@course) || User.current.admin?
link_to "#{teacher_num}", course_member_path(@course, :role => 1), :class => 'info_foot_num c_blue'
link_to "#{teacher_num}", course_member_path(@course, :role => 1), :class => 'info_foot_num c_blue', :id => 'teacher_number'
else
content_tag 'span',teacher_num, :class => 'info_foot_num c_blue'
end
@ -45,7 +45,7 @@ module CoursesHelper
#生成课程学生列表连接
def course_student_link student_num
if (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course)) || User.current.admin?
link_to "#{student_num}", course_member_path(@course, :role => 2), :class => 'info_foot_num c_blue'
link_to "#{student_num}", course_member_path(@course, :role => 2), :class => 'info_foot_num c_blue', :id => "student_number"
else
content_tag 'span',student_num, :class => 'info_foot_num c_blue'
end

View File

@ -209,7 +209,7 @@ class User < Principal
validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
validate :validate_password_length
# validates_email_realness_of :mail
before_create :set_mail_notification, :sync_gitlab_user
before_create :set_mail_notification
before_save :update_hashed_password
before_destroy :remove_references_before_destroy
# added by fq
@ -218,6 +218,8 @@ class User < Principal
# 更新邮箱用户或用户名的同事,同步更新邀请信息
after_update :update_invite_list
include Trustie::Gitlab::ManageUser
scope :in_group, lambda {|group|
group_id = group.is_a?(Group) ? group.id : group.to_i
where("#{User.table_name}.id IN (SELECT gu.user_id FROM #{table_name_prefix}groups_users#{table_name_suffix} gu WHERE gu.group_id = ?)", group_id)

View File

@ -58,7 +58,7 @@
'取消大纲',
{:controller => 'blog_comments',:action => 'destroy',:user_id=>BlogComment.find(@course.outline).author_id,:blog_id=>BlogComment.find(@course.outline).blog_id, :id => @course.outline,:course_id=>@course.id},
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:data => {:confirm => '确定取消么'},
:class => 'postOptionLink'
) if User.current && User.current.id == @article.author.id %>
</li>

View File

@ -24,9 +24,9 @@
<div class="mt5">
<!--<a target="hiddentab" href="http://wpa.qq.com/msgrd?v=1&uin=1554253403&site=qq&menu=yes" style="color: #269ac9;">-->
<%#= l(:label_technical_support) %>
<!--白&nbsp;&nbsp;&nbsp;羽</a>-->
<a target="hiddentab" href="http://shang.qq.com/wpa/qunwpa?idkey=4fe2d63a4527cddce038f04f0b1d728a62082074fb4a74870a5444ee1a6910ad" style="color: #269ac9;">
请加入师姐答疑群</a>
<!--白&nbsp;&nbsp;&nbsp;羽</a> http://shang.qq.com/wpa/qunwpa?idkey=4fe2d63a4527cddce038f04f0b1d728a62082074fb4a74870a5444ee1a6910ad-->
<a href="javascript:void(0);" style="color: #269ac9;">
<p style="text-align: center"> 请加入师姐答疑群</p> <p style="text-align: center">173184401</p> </a>
</div>
</div>
<div class="side_bottom"></div>

View File

@ -76,7 +76,7 @@
<!--参数-->
<div class="pr_info_foot">
<%= l(:label_member) %><%= link_to "#{@project.members.count}", project_member_path(@project), :class => 'info_foot_num c_blue' %>
<%= l(:label_member) %><%= link_to "#{@project.members.count}", project_member_path(@project), :class => 'info_foot_num c_blue', :id => 'project_members_number' %>
<span>|&nbsp;</span>
<%= l(:label_user_watcher) %><%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id}, :class => 'info_foot_num c_blue' %>
<% attaments_num = @project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count %>

View File

@ -46,7 +46,7 @@
</div>
<div class="fl ml10">
<p class="homepageImageName hidden db mb5">
<%= @user.realname %>
<%= @user.realname.blank? ? @user.login : @user.realname %>
</p>
<% if (@user.user_extensions && (@user.user_extensions.identity != 2) ) %>
<span class="<%= @user.user_extensions.gender == 1 ? 'homepageImageSexWomen' : 'homepageImageSexMan' %> "></span>

View File

@ -4,6 +4,7 @@
<% else%>
$('#pro_st_tbc_03').html('<%= escape_javascript(render :partial => 'projects/settings/new_members') %>');
hideOnLoad();
$("#project_members_number").html("<%= @project.members.count %>");
alert("<%= @succes_message%>");
<% end%>
<%elsif @course%>
@ -11,6 +12,8 @@
alert("<%= @create_member_error_messages%>");
<% else%>
$('#course_members_setting').html('<%= escape_javascript(render :partial => 'courses/course_members') %>');
$("#teacher_number").html("<%= searchTeacherAndAssistant(@course).count %>");
$("#student_number").html("<%= studentCount(@course) %>");
alert("添加成功");
<% end%>
hideOnLoad();

View File

@ -1,7 +1,10 @@
<%if @project%>
$('#pro_st_tbc_03').html('<%= escape_javascript(render :partial => 'projects/settings/new_members') %>');
$("#project_members_number").html("<%= @project.members.count %>");
// $('#tab-content-members').html('<%#= escape_javascript(render :partial => 'projects/settings/members') %>');
<%elsif @course%>
$('#course_members_setting').html('<%= escape_javascript(render :partial => 'courses/course_members') %>');
$("#teacher_number").html("<%= searchTeacherAndAssistant(@course).count %>")
$("#student_number").html("<%= studentCount(@course) %>");
<%end%>
hideOnLoad();

View File

@ -170,7 +170,7 @@
<li><input id="new_password_confirmation" name="new_password_confirmation" class="w210" type="password" required="true" nh_required="1"></li>
<li class="ml2">
<a href="javascript:;" id="my_password_form_link" class="blue_btn fl">确认</a>
<!--<input type="submit" id="my_password_form_btn" style="display:none;"/>-->
<input type="submit" id="my_password_form_btn" style="display:none;"/>
<!--<a href="javascript:void(0);" class="grey_btn ml10 fl">取消</a>-->
</li>
</ul>

View File

@ -17,7 +17,6 @@
版本库地址:<%= h @repository.url %>
<% end %>
<!-- added by bai -->
<div class="fb"><a href="http://<%=Setting.host_name %>/forums/1/memos/1232" class=" c_blue ">点击查看如何提交代码</a></div>
<div class="cl"></div>
</div>
<% else %>

View File

@ -41,6 +41,11 @@
<%= homework_common.language_name%>
</div>
<% end %>
<% if homework_common.homework_detail_manual.comment_status == 0 %>
<div class="homepagePostDeadline mr15">
<%= l(:label_publish_time)%><%= homework_common.publish_time%>
</div>
<% end %>
<div class="homepagePostDeadline">
<%= l(:label_end_time)%><%= homework_common.end_time%>
</div>

View File

@ -2024,6 +2024,7 @@ zh:
label_creat: 创建
#api end
label_publish_time: 发布时间
label_end_time: 截止时间
label_send_email: 确定发送
label_input_email: 请输入邮箱地址(必填)

View File

@ -60,6 +60,11 @@ class Gitlab::Client
put("/users/#{user_id}", :body => options)
end
def delete_user(user_id)
delete("/users/#{user_id}")
end
# Creates a new user session.
#
# @example

View File

@ -4,15 +4,26 @@ module Trustie
module Gitlab
module Helper
def change_password(uid, en_pwd, salt)
return unless uid
options = {:encrypted_password=>en_pwd, :password_salt=>salt}
self.g.put("/users/ext/#{uid}", :body => options)
# g.edit_user(uid, :encrypted_password=>en_pwd, :password_salt=>salt)
end
def find_user(user)
us = self.g.get("/users?search=#{user.mail}")
if Array === us
us.each do |u|
return u if u.email == user.mail
end
end
return nil
end
def add_user(user)
u = nil
begin
u = self.g.get("/users?search=#{user.mail}").first
u = find_user(user)
unless u
u = self.g.create_user(user.mail,
user.hashed_password,
@ -29,7 +40,8 @@ module Trustie
end
def del_user(user)
## gitlab unimplement
return unless user.gid
self.g.delete_user(user.gid)
end
end

View File

@ -9,8 +9,8 @@ module Trustie
def self.included(base)
base.class_eval {
before_create :add_gitlab_user
before_destroy :delete_gitlab_user
#before_create :add_gitlab_user
#before_destroy :delete_gitlab_user
before_save :change_gitlab_user
}
end
@ -27,7 +27,6 @@ module Trustie
change_password(self.gid, self.hashed_password, self.salt)
end
private
def g
@g ||= ::Gitlab.client
end

View File

@ -26,10 +26,37 @@ module Trustie
user.mail_notification = "day"
end
user.save!
u
end
def create_project(project, repository)
gid = project.owner.gid
unless gid
gid = sync_user(project.owner).id
end
raise "unknow gid" unless gid
gproject = g.create_project(repository.identifier,
path: repository.identifier,
description: project.description,
wiki_enabled: false,
wall_enabled: false,
issues_enabled: false,
snippets_enabled: false,
public: false,
user_id: gid
)
project.gpid = gproject.id
project.save!
end
def sync_project(project, opt={})
gid = project.owner.gid
unless gid
gid = sync_user(project.owner).id
end
raise "unknow gid" unless gid
path = opt[:path]
raise "unknow path" unless path
@ -61,7 +88,11 @@ module Trustie
project.members.each do |m|
begin
self.g.add_team_member(gproject.id, m.user.gid, UserLevel::DEVELOPER)
gid = m.user.gid
unless gid
gid = sync_user(m.user).id
end
self.g.add_team_member(gproject.id, gid, UserLevel::DEVELOPER)
rescue => e
puts e
end

View File

@ -666,6 +666,7 @@ function regex_homework_end_publish_time()
$("#homework_publish_time").val(myDate.toLocaleDateString());
}
var publish_time = Date.parse($("#homework_publish_time").val());
var end_time = Date.parse($("#homework_end_time").val());
if(end_time < publish_time)
{
$("#homework_end_time_span").text("截止日期不能小于发布日期");
@ -1258,4 +1259,4 @@ function course_outline(id){
// $('#course_outline_search').on('input',function(){
// alert('<%= @course.id%>')
// })
//})
//})