diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index c1b38fa39..4174f427e 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -119,8 +119,8 @@ class AccountController < ApplicationController @user = User.new @user.safe_attributes = user_params if params[:identity] == "2" # 2 企业 - #@user.firstname = params[:enterprise_name] - #@user.lastname = l(:field_enterprise) + @user.firstname = params[:enterprise_name] + @user.lastname = l(:field_enterprise) end @user.admin = false @user.register diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 3f6827159..1bc75d9d1 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -892,6 +892,18 @@ class ProjectsController < ApplicationController 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 def memberAccess @@ -1038,4 +1050,5 @@ class ProjectsController < ApplicationController end #gcmend + end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index ea72e8184..be5609d7c 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -246,4 +246,7 @@ module WatchersHelper link_to text, url, :remote => true, :method => method ,:class=>css end - end + def exit_project_link(project) + link_to("退出项目",exit_cur_project_path(project.id),:remote => true ) + end + end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 8ee7f42d8..48d590c4b 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -231,12 +231,12 @@ module WelcomeHelper # modif by nwb def find_all_new_hot_course limit = 9 ,school_id = 0 #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 - 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 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 end courses diff --git a/app/views/layouts/_join_exit_project.html.erb b/app/views/layouts/_join_exit_project.html.erb new file mode 100644 index 000000000..c43ad55a2 --- /dev/null +++ b/app/views/layouts/_join_exit_project.html.erb @@ -0,0 +1,20 @@ +
+ + <% if ( !(User.current.member_of? @project) && User.current.login?) %> + <%= watcher_link(@project, User.current) %> + <% end %> +
+ +
+ <% if ( !(User.current.member_of? @project) && User.current.login?) %> + + <%= applied_link(@project, User.current) %> + <% end %> +
+ + +
+ <% if ((User.current.member_of? @project) && User.current.login?) %> + <%= exit_project_link(@project) %> + <% end %> +
\ No newline at end of file diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 004aabc51..eea7a0f61 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -74,20 +74,9 @@ <% end %> -
- - <% if ( !(User.current.member_of? @project) && User.current.login?) %> - <%= watcher_link(@project, User.current) %> - <% end %> -
- -
- <% if ( !(User.current.member_of? @project) && User.current.login?) %> - - <%= applied_link(@project, User.current) %> - <% end %> +
+ <%= render 'layouts/join_exit_project' %>
- diff --git a/app/views/my/password.html.erb b/app/views/my/password.html.erb index 5e2b1989c..2808a8742 100644 --- a/app/views/my/password.html.erb +++ b/app/views/my/password.html.erb @@ -13,7 +13,7 @@

<%= password_field_tag 'new_password_confirmation', nil, :size => 25 %>

-<%= submit_tag l(:button_apply) %> +<%= submit_tag l(:label_button_ok) %>
<% end %> diff --git a/app/views/projects/exit_project.js.erb b/app/views/projects/exit_project.js.erb new file mode 100644 index 000000000..709f878be --- /dev/null +++ b/app/views/projects/exit_project.js.erb @@ -0,0 +1 @@ +$('#join_exit_project_div').html("<%= escape_javascript(render(:partial => 'layouts/join_exit_project')) %>"); diff --git a/app/views/welcome/_course_list.html.erb b/app/views/welcome/_course_list.html.erb new file mode 100644 index 000000000..f590cf868 --- /dev/null +++ b/app/views/welcome/_course_list.html.erb @@ -0,0 +1,28 @@ +<% course_list.map do |course| %> +
  • /,"") %>> +
    + <%= image_tag(get_course_avatar(course), :class => "avatar-4") %> +
    + +
    + + <% if (course.school == nil) %> +               + <% else %> + <%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %> + <% end %> + + + <%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %> + <%#=course.try(:teacher).try(:name)%> + +
    +
    + [<%= 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) %>资料) +
    +
  • +<% end %> diff --git a/app/views/welcome/_no_course_title.html.erb b/app/views/welcome/_no_course_title.html.erb new file mode 100644 index 000000000..f16b91dba --- /dev/null +++ b/app/views/welcome/_no_course_title.html.erb @@ -0,0 +1,5 @@ +

    +

    + <%= course_title%> +

    +

    \ No newline at end of file diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 7cab331b6..c979807b9 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -88,46 +88,15 @@ <%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %>
    -
    @@ -143,80 +112,12 @@ <% end %>
    -
    diff --git a/config/locales/en.yml b/config/locales/en.yml index 1d7b01d4f..367624f89 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1197,6 +1197,7 @@ en: label_tags_issue_description: issue description label_tags_all_objects: all objects label_apply_project: Apply Project + label_exit_project: Exit Project label_apply_project_waiting: "Application has been submitted, please wait for administrator review." label_unapply_project: Unsubscribe diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 572862174..62a5649a3 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1409,6 +1409,7 @@ zh: label_tags_issue_description: 问题描述 label_tags_all_objects: 所有 label_apply_project: 申请加入 + label_exit_project: 退出项目 label_apply_project_waiting: 已处理申请,请等待管理员审核 label_unapply_project: 取消申请 @@ -2100,4 +2101,7 @@ zh: # ajax异步验证 modal_valid_passing: 可以使用 label_bug: 漏洞 + + lable_school_no_course: 该学校未开设任何课程,您可以查看其他学校课程 + lable_school_less_course: 该学校开设课程较少,您可以查看其他学校课程 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 1e75ac23a..9d9b9d13b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -510,6 +510,7 @@ RedmineApp::Application.routes.draw do get 'projects/:id/repository/:repository_id', :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 get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'