This commit is contained in:
zhanghaitao 2014-08-11 16:39:35 +08:00
commit d7bfdc8de4
14 changed files with 93 additions and 127 deletions

View File

@ -119,8 +119,8 @@ class AccountController < ApplicationController
@user = User.new @user = User.new
@user.safe_attributes = user_params @user.safe_attributes = user_params
if params[:identity] == "2" # 2 企业 if params[:identity] == "2" # 2 企业
#@user.firstname = params[:enterprise_name] @user.firstname = params[:enterprise_name]
#@user.lastname = l(:field_enterprise) @user.lastname = l(:field_enterprise)
end end
@user.admin = false @user.admin = false
@user.register @user.register

View File

@ -892,6 +892,18 @@ class ProjectsController < ApplicationController
end end
end end
def exit_project
@project = Project.find params[:id]
if User.current.login?
members = Member.where(:user_id => User.current.id, :project_id=>params[:id]).first
if members != nil
members.destroy
end
respond_to do |format|
format.js
end
end
end
private private
def memberAccess def memberAccess
@ -1038,4 +1050,5 @@ class ProjectsController < ApplicationController
end end
#gcmend #gcmend
end end

View File

@ -246,4 +246,7 @@ module WatchersHelper
link_to text, url, :remote => true, :method => method ,:class=>css link_to text, url, :remote => true, :method => method ,:class=>css
end end
end def exit_project_link(project)
link_to("退出项目",exit_cur_project_path(project.id),:remote => true )
end
end

View File

@ -231,12 +231,12 @@ module WelcomeHelper
# modif by nwb # modif by nwb
def find_all_new_hot_course limit = 9 ,school_id = 0 def find_all_new_hot_course limit = 9 ,school_id = 0
#sort_project_by_hot_rails 1, 'course_ac_para DESC', limit #sort_project_by_hot_rails 1, 'course_ac_para DESC', limit
time_now = Time.new.strftime("%Y"); time_now = Time.new.strftime("%Y")
if school_id if school_id
courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <> courses = Course.includes(:school, :members).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <>
?", school_id).order("course_ac_para DESC").limit(limit).all ?", school_id).order("course_ac_para DESC").limit(limit).all
else else
courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL courses = Course.includes(:school, :members).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL
").order("course_ac_para DESC").limit(limit).all ").order("course_ac_para DESC").limit(limit).all
end end
courses courses

View File

@ -0,0 +1,20 @@
<div style="margin-left: 20px;">
<% if ( !(User.current.member_of? @project) && User.current.login?) %> <!--added by linchun-->
<span class="icon-fav icon"></span><%= watcher_link(@project, User.current) %>
<% end %>
</div>
<!--添加项目申请-->
<div style="margin-left: 20px;">
<% if ( !(User.current.member_of? @project) && User.current.login?) %>
<span class="icon-fav icon"></span>
<%= applied_link(@project, User.current) %>
<% end %>
</div>
<!--添加退出项目-->
<div style="margin-left: 20px;">
<% if ((User.current.member_of? @project) && User.current.login?) %>
<%= exit_project_link(@project) %>
<% end %>
</div>

View File

@ -74,20 +74,9 @@
<% end %> <% end %>
<!-- end --> <!-- end -->
</div> </div>
<div style="margin-left: 20px;"> <div id="join_exit_project_div">
<%= render 'layouts/join_exit_project' %>
<% if ( !(User.current.member_of? @project) && User.current.login?) %> <!--added by linchun-->
<span class="icon-fav icon"></span><%= watcher_link(@project, User.current) %>
<% end %>
</div>
<!--添加项目申请-->
<div style="margin-left: 20px;">
<% if ( !(User.current.member_of? @project) && User.current.login?) %>
<span class="icon-fav icon"></span>
<%= applied_link(@project, User.current) %>
<% end %>
</div> </div>
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -13,7 +13,7 @@
<p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label> <p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label>
<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p> <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p>
<%= submit_tag l(:button_apply) %> <%= submit_tag l(:label_button_ok) %>
</div> </div>
<% end %> <% end %>

View File

@ -0,0 +1 @@
$('#join_exit_project_div').html("<%= escape_javascript(render(:partial => 'layouts/join_exit_project')) %>");

View File

@ -0,0 +1,28 @@
<% course_list.map do |course| %>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s.gsub(/<\/?.*?>/,"") %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<% if (course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
<% end %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
<%#=course.try(:teacher).try(:name)%>
</span>
</div>
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= course.members.count %>人)
<%# files_count = course.attachments.count.to_s %>
(<%= link_to "#{course.attachments.count.to_s}份", course_files_path(course) %>资料)
</div>
</li>
<% end %>

View File

@ -0,0 +1,5 @@
<h1></h1>
<p id="errorExplanation">
<%= course_title%>
</p>
<h1></h1>

View File

@ -88,46 +88,15 @@
<span><%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %></span> <span><%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %></span>
<div class="d-p-projectlist-box"> <div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
</ul>
<ul class="d-p-projectlist"> <ul class="d-p-projectlist">
<% if User.current.logged? %> <% if User.current.logged? %>
<h1></h1> <li>
<p id="errorExplanation"> <%= render :partial => 'no_course_title', :locals => {:course_title => l(:lable_school_no_course)} %>
该学校未开设任何课程,您可以查看其他学校课程
</p>
<h1></h1>
<% end %>
<% find_all_new_hot_course(9, @school_id).map do |course| %>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s.gsub(/<\/?.*?>/,"") %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<% if (course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
<% end %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
<%#=course.try(:teacher).try(:name)%>
</span>
</div>
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{memberCount(course)}人" %>)
<% files_count = course.attachments.count.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>
</li> </li>
<%= render :partial => 'course_list', :locals => {:course_list => find_all_new_hot_course(9, @school_id)} %>
<% else %>
<%= render :partial => 'course_list', :locals => {:course_list => find_all_new_hot_course(10, @school_id)} %>
<% end %> <% end %>
</ul> </ul>
</div> </div>
@ -143,80 +112,12 @@
<% end %> <% end %>
<div class="d-p-projectlist-box"> <div class="d-p-projectlist-box">
<ul class="d-p-projectlist"> <ul class="d-p-projectlist">
<%= render :partial => 'course_list', :locals => {:course_list => school_course} %>
</ul>
<ul class="d-p-projectlist">
<% school_course.map do |course| %>
<% if course.school%>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s.gsub(/<\/?.*?>/,"") %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %>
</span>
</div>
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{memberCount(course)}人" %>)
<% files_count = course.attachments.count.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>
<!--
<div class='join_course_link'>
<%# if !course_endTime_timeout?(course) %>
<div>
<%#= join_in_course(course, User.current) %>
</div>
<%# end %>
</div>
-->
</li>
<%end%>
<% end; reset_cycle %>
<% if school_course.count < 10 %> <% if school_course.count < 10 %>
<li> <li>
<h1></h1> <%= render :partial => 'no_course_title', :locals => {:course_title => l(:lable_school_less_course)} %>
<p id="errorExplanation">
该学校开设课程较少,您可以查看其他学校课程
</p>
</li> </li>
<% find_all_new_hot_course(10 - school_course.count, @school_id).map do |course| %> <%= render :partial => 'course_list', :locals => {:course_list => find_all_new_hot_course(9 - school_course.count, @school_id)} %>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s.gsub(/<\/?.*?>/,"") %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<% if (course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
<!-- modified by zjc 添加超链接 -->
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
<% end %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %>
</span>
</div>
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{memberCount(course)}人" %> )
<% files_count = course.attachments.count.to_i.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>
</li>
<% end %>
<% end %> <% end %>
</ul> </ul>
</div> </div>

View File

@ -1197,6 +1197,7 @@ en:
label_tags_issue_description: issue description label_tags_issue_description: issue description
label_tags_all_objects: all objects label_tags_all_objects: all objects
label_apply_project: Apply Project label_apply_project: Apply Project
label_exit_project: Exit Project
label_apply_project_waiting: "Application has been submitted, please wait for administrator review." label_apply_project_waiting: "Application has been submitted, please wait for administrator review."
label_unapply_project: Unsubscribe label_unapply_project: Unsubscribe

View File

@ -1409,6 +1409,7 @@ zh:
label_tags_issue_description: 问题描述 label_tags_issue_description: 问题描述
label_tags_all_objects: 所有 label_tags_all_objects: 所有
label_apply_project: 申请加入 label_apply_project: 申请加入
label_exit_project: 退出项目
label_apply_project_waiting: 已处理申请,请等待管理员审核 label_apply_project_waiting: 已处理申请,请等待管理员审核
label_unapply_project: 取消申请 label_unapply_project: 取消申请
@ -2101,3 +2102,6 @@ zh:
modal_valid_passing: 可以使用 modal_valid_passing: 可以使用
label_bug: 漏洞 label_bug: 漏洞
lable_school_no_course: 该学校未开设任何课程,您可以查看其他学校课程
lable_school_less_course: 该学校开设课程较少,您可以查看其他学校课程

View File

@ -510,6 +510,7 @@ RedmineApp::Application.routes.draw do
get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
get 'projects/:id/repository', :to => 'repositories#show', :path => nil get 'projects/:id/repository', :to => 'repositories#show', :path => nil
get 'projects/:id/exit', :to => 'projects#exit_project', :as => 'exit_cur_project'
# additional routes for having the file name at the end of url # additional routes for having the file name at the end of url
get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment' get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'