This commit is contained in:
cxt 2015-10-30 17:24:26 +08:00
commit 97de8b584c
19 changed files with 154 additions and 43 deletions

1
.gitignore vendored
View File

@ -29,3 +29,4 @@ vendor/cache
/public/images/avatars
/public/files
/tags
/config/initializers/gitlab_config.rb

View File

@ -57,9 +57,7 @@ class BlogCommentsController < ApplicationController
def destroy
@article = BlogComment.find(params[:id])
if @article.parent_id.nil? #如果是文章被删那么跳转到用户博客界面如果带了course_id过来那么就要跳转到课程首页
if params[:course_id]
@article.children.delete
@article.delete
if params[:course_id] #如果带了课程id过来说明这是课程大纲不要删除只需取消课程大纲就ok了
@course = Course.find(params[:course_id])
@course.outline = 0
@course.save
@ -73,7 +71,7 @@ class BlogCommentsController < ApplicationController
else#如果是回复被删,
if params[:course_id] #如果带了course_id过来了那么这是要跳到课程大纲去的
@article.delete
redirect_to show_course_outline_course_path(:id=>params[:course_id])
redirect_to syllabus_course_path(:id=>params[:course_id])
else
root = @article.root
@article.delete
@ -133,7 +131,7 @@ class BlogCommentsController < ApplicationController
respond_to do |format|
format.html {
if params[:course_id] #如果呆了course_id过来了那么这是要跳到课程大纲去的
redirect_to show_course_outline_course_path(:id=>params[:course_id])
redirect_to syllabus_course_path(:id=>params[:course_id])
else
redirect_to user_blog_blog_comment_path(:user_id=>@article.author_id,:blog_id=>@article.blog_id,:id=>@article)
end

View File

@ -740,7 +740,7 @@ class CoursesController < ApplicationController
end
#显示课程大纲
def show_course_outline
def syllabus
@article = BlogComment.find(@course.outline)
respond_to do |format|
format.html {render :layout => 'base_courses'}

View File

@ -263,7 +263,7 @@ update
@course_tag = params[:course]
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
ip = RepositoriesHelper::REPO_IP_ADDRESS
gitlab_address = RepositoriesHelper::REPO_GITLAB_ADDRESS
gitlab_address = Redmine::Configuration['gitlab_address']
if @repository.type.to_s=="Repository::Gitlab"
@repos_url = "http://"+gitlab_address.to_s+"/"+@project.owner.to_s+"/"+@repository.identifier+"."+"git"
else

View File

@ -243,7 +243,7 @@ class UsersController < ApplicationController
#status 1 同意 2 拒绝
def dealwith_apply_request
@msg = CourseMessage.find(params[:msg_id])
#CourseMessage content存的是role 7教辅 9 教师
case params[:agree]
when 'Y'
apply_user = User.find(@msg.course_message_id)

View File

@ -45,6 +45,11 @@ module RepositoriesHelper
end
end
def user_commit_rep(mail)
user = User.find_by_mail(mail)
user.nil? ? User.find(2) : User.find_by_mail(mail)
end
def render_properties(properties)
unless properties.nil? || properties.empty?
content = ''

View File

@ -301,26 +301,46 @@ class CoursesService
#@state == 5 您还未登录
#@state == 6 申请成功,请等待审核完毕
#@state == 7 您已经发送过申请了,请耐心等待
#@state == 8 您已经是该课程的教师了
#@state == 9 您已经是该课程的教辅了
#@state 其他 未知错误,请稍后再试
def join_course params,current_user
course = Course.find_by_id params[:object_id]
@state = 10
if course
if course_endTime_timeout? course
@state = 2
else
if current_user.member_of_course?(course) #如果已经是成员
member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0]
roleName = member.roles[0].name if member
if params[:course_password] == course.password
#如果加入角色为学生
if params[:role] == "10"
#如果加入角色为学生 并且当前是学生
if params[:role] == "10" && roleName == "Student"
@state = 3
elsif current_user.allowed_to?(:as_teacher,course)
@state = 3
else
Mailer.run.join_course_request(course, User.current, params[:role])
#如果加入角色为教师或者教辅
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
@state = 6
#如果加入的角色为老师,并且当前已经是老师
elsif params[:role] == "9" && roleName == "Teacher"
@state = 8
#如果加入的角色教辅并且当前为教辅
elsif params[:role] == "7" && roleName == "TeachingAsistant"
@state = 9
#如果加入角色为教师或者教辅,并且当前是学生,或者是要成为教辅,当前不是教辅,或者要成为教师,当前不是教师。那么要发送请求
elsif (params[:role] != "10" && roleName == "Student") || (params[:role] == "7" && roleName != "TeachingAsistant" ) || (params[:role] == "9" && roleName != "Teacher" )
#如果已经发送过消息了,那么就要给个提示
if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count != 0
@state = 7
else
Mailer.run.join_course_request(course, User.current, params[:role])
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
@state = 6
end
#如果加入角色是学生,但是是当前课程的教师或者教辅
elsif params[:role] == "10" && roleName != "Student"
member.role_ids = [params[:role]]
member.save
StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id])
@state = 0
end
else
@state = 1

View File

@ -24,6 +24,14 @@ hidden_join_course_form();
<% elsif @state == 7%>
alert("您已经发送过申请了,请耐心等待");
hidden_join_course_form();
<% elsif @state == 8%>
alert("您已经是该课程的教师了");
hidden_join_course_form();
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
<% elsif @state == 9%>
alert("您已经是该课程的教辅了");
hidden_join_course_form();
window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
<% else %>
alert("未知错误,请稍后再试");
<% end %>

View File

@ -1,8 +1,8 @@
hideModal();
<%if @course.tea_id == User.current.id && @course.outline == 0 %>
<% else %>
$("#course_outline_bar").html('<a href="<%=show_course_outline_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>')
$("#course_outline_bar").html('<a href="<%=syllabus_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>')
<%end %>
<%if @is_in_show_outline_page && @is_in_show_outline_page == 'Y'%>
window.location.href='<%=show_course_outline_course_path(@course) %>';
window.location.href='<%=syllabus_course_path(@course) %>';
<% end %>

View File

@ -39,14 +39,14 @@
showNormalImage('message_description_<%= @article.id %>');
});
</script>
<div class="postRightContainer ml10" onmouseover="$('#message_setting_<%= @article.id%>').show();" onmouseout="$('#message_setting_<%= @article.id%>').hide();">
<div class="postRightContainer ml10" >
<div class="postThemeContainer">
<div class="postDetailPortrait">
<%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
</div>
<div class="postThemeWrap">
<% if User.current && @article.author.id == User.current.id%>
<div class="homepagePostSetting" id="message_setting_<%= @article.id%>" style="display: none">
<div class="homepagePostSetting" id="message_setting_<%= @article.id%>" >
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
@ -55,7 +55,7 @@
</li>
<li>
<%= link_to(
'删除大纲',
'取消大纲',
{: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)},

View File

@ -22,8 +22,11 @@
<% end %>
</div>
<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://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>
</div>
</div>
<div class="side_bottom"></div>

View File

@ -89,11 +89,11 @@
<%if User.current && @course.tea_id == User.current.id && (@course.outline == 0 || BlogComment.where(:id=>@course.outline).count == 0) %>
<a href="javascript:void(0);" title="设置课程大纲" onclick="course_outline('<%= @course.id%>')" class="mr5 syllabusSetting fl"> </a>
<% elsif User.current && @course.tea_id == User.current.id && @course.outline != 0 && BlogComment.where(:id=>@course.outline).count != 0%>
<a href="<%=show_course_outline_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<% elsif User.current && @course.tea_id != User.current.id && !@course.is_public? && User.current.member_of_course?(@course)%>
<a href="<%=show_course_outline_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<% elsif User.current && @course.tea_id != User.current.id && @course.is_public?%>
<a href="<%=show_course_outline_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<a href="<%=syllabus_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<% elsif User.current && @course.tea_id != User.current.id && !@course.is_public? && User.current.member_of_course?(@course) && @course.outline != 0%>
<a href="<%=syllabus_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<% elsif User.current && @course.tea_id != User.current.id && @course.is_public? && @course.outline != 0%>
<a href="<%=syllabus_course_path(@course) %>" title="课程大纲" class="mr5 syllabusIcon fl"> </a>
<%else%>
<%end %>
</span>

View File

@ -16,15 +16,31 @@
<% show_diff = revisions.size > 1 %>
<% line_num = 1 %>
<% revisions.each do |changeset| %>
<tr class="changeset <%= cycle 'odd', 'even' %>">
<td class="id"><%= h truncate(changeset.id.to_s, :length => 20) %></td>
<!--<td class="checkbox"><%#= radio_button_tag('rev_to', changeset.id, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('#cb-#{line_num}').attr('checked')) {$('#cb-#{line_num-1}').attr('checked',true);}") if show_diff && (line_num > 1) %></td>-->
<td class="committed_on"><%= format_time(changeset.created_at) %></td>
<td class="author"><%= h truncate(changeset.author_name.to_s, :length => 30) %></td>
<td class="comments"><%= textilizable(truncate_at_line_break(changeset.message)) %></td>
</tr>
<% line_num += 1 %>
<div class="col-md-10 col-sm-12">
<ul class="bordered-list">
<li class="commit js-toggle-container">
<div class="commit-row-title">
<strong class="str-truncated">
<a class="commit-row-message"><%= textilizable(truncate_at_line_break(changeset.message)) %></a>
</strong>
<div class="pull-right" title="修订号">
<%= h truncate(changeset.short_id.to_s, :length => 20) %>
</div>
<div class="notes_count">
</div>
</div>
<div class="commit-row-info">
<a class="commit-author-link has_tooltip"> <span class="commit-author-name">
<%= image_tag(url_to_avatar(user_commit_rep(changeset.author_email)), :width => "20", :height => "20", :class => "fl portraitRadius mt2 ml4 mr5") %>
<%= link_to user_commit_rep(changeset.author_email), user_path(user_commit_rep(changeset.author_email)), :length => 30 %></span></a>
提交于
<div class="committed_ago">
<time class="time_ago js-timeago" title="<%= changeset.created_at %>"><%= time_tag(changeset.created_at) %> 前</time> &nbsp;
</div>
</div>
</li>
</ul>
</div>
<% end %>
</tbody>
</table>

View File

@ -30,8 +30,8 @@
<div class="cl"></div>
<div class="recordBanner mt10">
<% if @changesets && !@changesets.empty? %>
<%= image_tag(url_to_avatar(@changesets_latest_coimmit.author_name), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
<span class="fl"><div class="fb fontGrey3 mr5 fl"><%=link_to @changesets_latest_coimmit.author_name, user_path(@changesets_latest_coimmit.author_name) %></div>
<%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
<span class="fl"><div class="fb fontGrey3 mr5 fl"><%=link_to user_commit_rep(@changesets_latest_coimmit.author_email), user_path(@changesets_latest_coimmit.author_name) %></div>
<div class="fl">提交于<%= time_tag(@changesets_latest_coimmit.created_at) %></div>
<div class="commit_content_dec fl" title="<%= @changesets_latest_coimmit.comments %>"><%= @changesets_latest_coimmit.message %></div>
</span>

View File

@ -200,6 +200,9 @@ default:
repository_root_path: '/tmp/htdocs'
judge_server: 'http://judge.trustie.net/'
# Git's url
gitlab_address: 'http://gitfast.trustie.net'
# specific configuration options for production environment
# that overrides the default ones
production:

View File

@ -1,7 +1,7 @@
Gitlab.configure do |config|
# config.endpoint = 'http://192.168.41.130:3000/trustie/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
# config.private_token = 'cK15gUDwvt8EEkzwQ_63' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
config.endpoint = 'http://git.trustie.net/trustie/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
config.endpoint = 'http://gitfast.trustie.net/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
config.private_token = 'fPc_gBmEiSANve8TCfxW' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
# Optional
# config.user_agent = 'Custom User Agent' # user agent, default: 'Gitlab Ruby Gem [version]'

View File

@ -792,7 +792,7 @@ RedmineApp::Application.routes.draw do
get 'course_outline'
post 'search_course_outline'
post 'set_course_outline'
get 'show_course_outline'
get 'syllabus'
end
collection do
match 'join_private_courses', :via => [:get, :post]

View File

@ -148,7 +148,7 @@ a.postReplyCancel:hover {color:#ffffff;}
.homepagePostSetting ul li:hover ul {display:block;}
.homepagePostSettingIcon {background:url(../images/homepage_icon.png) -93px -5px no-repeat; width:20px; height:20px;}
.homepagePostSettiongText {width:85px; line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:-68px; top:20px; padding:5px 0px; display:none;}
.homepagePostSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;}
.homepagePostSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;cursor: pointer}
a.postOptionLink {color:#616060; display:block; width:55px; padding:0px 15px;}
a.postOptionLink:hover {color:#ffffff; background-color:#269ac9;}
.homepagePostReplyPortrait {float:left; width:33px;}

View File

@ -219,3 +219,60 @@
.mt1 {margin-top:1px;}
.mt2 {margin-top:2px;}
.commit_content_dec{width: 300px;overflow: hidden; white-space: nowrap;text-overflow: ellipsis;}
/*提交信息列表*/
.col-md-10 {
width: 100%;
}
ul.bordered-list {
margin: 5px 0px;
padding: 0px;
}
ul.bordered-list li {
padding: 5px 0px;
border-bottom: 1px solid #EEE;
overflow: hidden;
display: block;
margin: 0px;
}
.commits-row ul li.commit {
padding: 8px 0px;
}
li.commit .commit-row-title {
font-size: 15px;
line-height: 20px;
margin-bottom: 2px;
}
li.commit .commit-row-title .str-truncated {
max-width: 70%;
}
.str-truncated {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: top;
white-space: nowrap;
max-width: 82%;
}
li.commit .commit-row-title .commit-row-message {
color: #444;
}
.pull-right {
float: right;
color: #777;
}
li.commit .commit-row-title .commit_short_id {
min-width: 65px;
font-family: "Menlo","Liberation Mono","Consolas","DejaVu Sans Mono","Ubuntu Mono","Courier New","andale mono","lucida console",monospace;
}
li.commit .commit-row-info {
color: #777;
line-height: 24px;
font-size: 13px;
}
li.commit .commit-row-info a {
color: #777;
}
li.commit .commit-row-info .committed_ago {
display: inline-block;
}