diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 2c4929019..b5975e452 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -234,7 +234,7 @@ class AccountController < ApplicationController end def password_authentication - user = User.try_to_login(params[:username], params[:password]) + user, last_login_on = User.try_to_login(params[:username], params[:password]) if user.nil? invalid_credentials @@ -244,7 +244,7 @@ class AccountController < ApplicationController onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id }) else # Valid user - successful_authentication(user) + successful_authentication(user, last_login_on) end end @@ -291,7 +291,7 @@ class AccountController < ApplicationController end end - def successful_authentication(user) + def successful_authentication(user, last_login_on) logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}" # Valid user self.logged_user = user @@ -304,13 +304,18 @@ class AccountController < ApplicationController code = /\d*/ #根据home_url生产正则表达式 eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") - if code=~params[:back_url] + if code=~params[:back_url] && last_login_on != '' redirect_to user_activities_path(user) else + if last_login_on == '' + redirect_to my_account_url + else #by young #redirect_back_or_default my_page_path - redirect_back_or_default User.current + #sredirect_back_or_default User.current + redirect_to my_account_url #redirect_to User.current + end end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 67948a8e1..32cfefa9d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -124,7 +124,7 @@ class ApplicationController < ActionController::Base else # HTTP Basic, either username/password or API key/random authenticate_with_http_basic do |username, password| - user = User.try_to_login(username, password) || User.find_by_api_key(username) + user = User.try_to_login(username, password)[0] || User.find_by_api_key(username) end end # Switch user if requested by an admin user @@ -267,6 +267,8 @@ class ApplicationController < ActionController::Base end when "contest" return true + when "Course" + allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false) else return true end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index a57b5f8a5..5c3503718 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -76,7 +76,7 @@ class AttachmentsController < ApplicationController candown = User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) elsif (@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course course = @attachment.container.course - candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) + candown = User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) elsif @attachment.container.is_a?(Course) course = @attachment.container candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) @@ -366,7 +366,7 @@ class AttachmentsController < ApplicationController end rescue NoMethodError @save_flag = false - @save_message = [] << l(:error_attachment_empty) + @save_message = [] << l(:label_course_empty_select) respond_to do |format| format.js end diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 833711e3e..627e1945b 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -37,6 +37,7 @@ class ContestsController < ApplicationController def index + render_404 # @contests = Contest.visible # @contests ||= [] @offset, @limit = api_offset_and_limit(:limit => 10) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index edfc893d8..bd389ff68 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -427,6 +427,7 @@ class CoursesController < ApplicationController end def index + render_404 @course_type = params[:course_type] @school_id = params[:school_id] per_page_option = 10 @@ -474,7 +475,7 @@ class CoursesController < ApplicationController respond_to do |format| format.html { - render :layout => 'base' + # render :layout => 'base' } format.atom { courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index ca7f8e040..251496e30 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -26,13 +26,15 @@ class FilesController < ApplicationController helper :sort include SortHelper + include FilesHelper helper :project_score def show_attachments obj - @all_attachments = [] + @attachments = [] obj.each do |container| - @all_attachments += container.attachments + @attachments += container.attachments end + @all_attachments = visable_attachemnts(@attachments) @limit = 10 @feedback_count = @all_attachments.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @@ -48,9 +50,11 @@ class FilesController < ApplicationController #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? if params[:insite] @result = find_public_attache q + @result = visable_attachemnts @result @searched_attach = paginateHelper @result,10 else @result = find_course_attache q,@course + @result = visable_attachemnts @result @searched_attach = paginateHelper @result,10 end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b3efdcf97..0b7cbbb5f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -105,6 +105,7 @@ class ProjectsController < ApplicationController end def index + render_404 #调用存储过程更新提交次数 #ActiveRecord::Base.connection.execute("CALL sp_project_status_cursor();") #Modified by nie @@ -156,8 +157,8 @@ class ProjectsController < ApplicationController respond_to do |format| - format.html { - render :layout => 'base' + format.html { + # render :layout => 'base' # scope = Project # unless params[:closed] # scope = scope.active diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b466e4721..0db7facbc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -295,6 +295,7 @@ class UsersController < ApplicationController #end def index + @status = params[:status] || 1 sort_init 'login', 'asc' sort_update %w(login firstname lastname mail admin created_on last_login_on) @@ -352,7 +353,8 @@ class UsersController < ApplicationController respond_to do |format| format.html { @groups = Group.all.sort - render :layout => @user_base_tag + # render :layout => @user_base_tag + render_404 } format.api end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1d528c183..9c5d8c9b5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1830,12 +1830,11 @@ module ApplicationHelper main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain} main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain} - course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'} + # course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'} course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain} - courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'} - projects_link = link_to l(:label_project_deposit), {:controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain} + # courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'} users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain} - contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'} + # contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'} bids_link = link_to l(:label_requirement_enterprise), {:controller => 'bids', :action => 'index'} forum_link = link_to l(:label_project_module_forums), {:controller => "forums", :action => "index"} stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'} @@ -1844,7 +1843,7 @@ module ApplicationHelper #@nav_dispaly_project_label nav_list = Array.new nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1 - nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1 + # nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1 nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1 nav_list.push(main_project_link) if @nav_dispaly_main_project_label @@ -1852,9 +1851,9 @@ module ApplicationHelper nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1 nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1 - nav_list.push(projects_link) if @nav_dispaly_project_label + # nav_list.push(projects_link) if @nav_dispaly_project_label nav_list.push(users_link) if @nav_dispaly_user_label - nav_list.push(contest_link) if @nav_dispaly_contest_label && @show_contest == 1 + # nav_list.push(contest_link) if @nav_dispaly_contest_label && @show_contest == 1 nav_list.push(bids_link) if @nav_dispaly_bid_label nav_list.push(forum_link) if @nav_dispaly_forum_label nav_list.push(stores_link) if @nav_dispaly_store_all_label diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 9a0a1127f..cd7603c65 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -44,10 +44,10 @@ module FilesHelper File.new(zipfile_name,'w+') end - def courses_check_box_tags(name,courses,current_course) + def courses_check_box_tags(name,courses,current_course,attachment) s = '' courses.each do |course| - if course.id != current_course.id && is_course_teacher(User.current,course) + if !(attachment.container_type && attachment.container_id == course.id) && is_course_teacher(User.current,course) s << "
" end end @@ -72,5 +72,20 @@ module FilesHelper result end + def visable_attachemnts attachments + result = [] + attachments.each do |attachment| + if attachment.is_public? || attachment.author_id == User.current.id + result << attachment + end + end + result + end + def get_qute_number attachment + if attachment.copy_from.nil? + return 0 + end + count = Attachment.find_by_sql("select count(*) from attachments where copy_from = #{attachment.copy_from}") + end end \ No newline at end of file diff --git a/app/models/role.rb b/app/models/role.rb index 57fccd53c..f363b52bf 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -161,7 +161,7 @@ class Role < ActiveRecord::Base if action.is_a? Hash allowed_actions.include? "#{action[:controller]}/#{action[:action]}" else - allowed_permissions.include? action + allowed_permissions.include? action end end diff --git a/app/models/user.rb b/app/models/user.rb index ff627763a..fe6222359 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -230,7 +230,12 @@ class User < Principal #选择项目成员时显示的用户信息文字 def userInfo - info=self.nickname + ' (' + self.realname + ')'; + if self.realname.gsub(' ','') == "" || self.realname.nil? + info = self.nickname; + else + info=self.nickname + ' (' + self.realname + ')'; + end + info end ###添加留言 fq @@ -359,8 +364,9 @@ class User < Principal end end end + last_login_on = user.last_login_on.nil? ? '' : user.last_login_on.to_s user.update_column(:last_login_on, Time.now) if user && !user.new_record? - user + [user, last_login_on] rescue => text raise text end diff --git a/app/views/account/email_valid.html.erb b/app/views/account/email_valid.html.erb index 6f4de1197..c77c0294e 100644 --- a/app/views/account/email_valid.html.erb +++ b/app/views/account/email_valid.html.erb @@ -11,7 +11,7 @@ <% email = @user.mail.split("@")[1] %> -
+

邮箱激活

@@ -19,9 +19,10 @@
-

请在24小时内点击邮件中的链接继续完成注册

-
- 邮件已发送到邮箱 +

请在24小时内点击邮件中的链接继续完成注册

+
+
+ 邮件已发送到邮箱 <%= @user.mail %>

@@ -33,12 +34,7 @@ padding: 10px 16px; line-height: 1.33;" target="_blank">立即查收邮件

- - 没收到邮件? - -
- - 请先检查是否在垃圾邮件中 +
diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb index 21bdd8fa7..0bebfdf5f 100644 --- a/app/views/account/register.html.erb +++ b/app/views/account/register.html.erb @@ -19,7 +19,7 @@

<%= f.text_field :login, :size => 25, :required => true %> <%= l(:label_max_number) %>

-

<%= f.password_field :password, :size => 25, :required => true %> +

<%= f.password_field :password, :size => 25, :required => true %> <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>

<%= f.password_field :password_confirmation, :size => 25, :required => true %>

@@ -56,10 +56,12 @@

<%= custom_field_tag_with_label :user, value %>

<% end %>
+<% password_min_length = Setting.password_min_length %>
@@ -25,8 +39,8 @@
<%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search f_l",:remote=>true) do %> <%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> - <%= submit_tag "课内搜索", :class => "re_schbtn b_dblue",:name => "incourse"%> - <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite" %> + <%= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onclick => "presscss('incourse')"%> + <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onclick => "presscss('insite')" %> <% end %> <% if is_course_teacher(User.current,@course) %> 上传资源 diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 554a3aea5..b8d0ad098 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -1,8 +1,8 @@ <% delete_allowed = User.current.allowed_to?(:manage_files, course) %>
-

共有 <%= User.current.member_of_course?(course) ? all_attachments.count : 0 %> 个资源

- + <#% end %>--> + 资源列表的多样化排序将在下周上线... +

<% curse_attachments.each do |file| %> - <%if file.is_public == 0 && !User.current.member_of_course?(@course)%> - <%next%> - <%end%>
- <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> - <% if is_course_teacher(User.current,@course) %> - <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> - - <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> - + <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> + <% if User.current.logged? %> + <% if is_course_teacher(User.current,@course) && file.author_id == User.current.id %> + <%= link_to "选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> + + <% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %> + + <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> + + <% else %> + + <% end %> + <% else %> + <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> + <% end %> <% else %> - <%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> <% end %>
-

文件大小:<%= number_to_human_size(file.filesize) %>

+

文件大小:<%= number_to_human_size(file.filesize) %>

<%= link_to( l(:button_delete), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed %> -

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用0

+ :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%> +

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  

diff --git a/app/views/files/_show_quote_resource.html.erb b/app/views/files/_show_quote_resource.html.erb index 8041802a5..58b0edda0 100644 --- a/app/views/files/_show_quote_resource.html.erb +++ b/app/views/files/_show_quote_resource.html.erb @@ -1,14 +1,14 @@
-

将此课件引入我的课程资源库

+
<%= form_tag course_attach_relations_path, method: :post, remote: true, id: "relation_file_form" do %> <%= hidden_field_tag(:file_id, file.id) %> - <%= content_tag('div', courses_check_box_tags('courses[course][]', User.current.courses,course), :id => 'courses')%> + <%= content_tag('div', courses_check_box_tags('courses[course][]', User.current.courses,course,file), :id => 'courses')%> 引  用取  消 <% end -%>
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 6cdc19471..6de46d2fe 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -56,7 +56,7 @@

<%= link_to "主页", home_path %> - > <%= link_to l(:label_course_all), :controller => 'courses', :action => 'index' %> + > <%=l(:label_courses_management_platform)%> > <%= link_to @course.name, nil %>

diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index a8c3174f5..ee490c653 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -44,7 +44,7 @@ <%= link_to request.host()+"/projects", :controller => 'projects', :action => 'index', :project_type => 0 %> -

<%=link_to l(:label_home),home_path %> > <%=link_to l(:label_project_deposit),:controller => 'projects', :action => 'index', :project_type => 0 %> > <%=link_to @project, project_path(@project) %>

+

<%=link_to l(:label_home),home_path %> > <%=link_to @project, project_path(@project) %>

diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 5aedec245..1e0811039 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -113,8 +113,7 @@ <%=link_to request.host()+"/users" ,:controller => 'users', :action => 'index' %> - <%=link_to "主页", home_path %> > - <%=link_to "软件创客", :controller => 'users', :action => 'index' %> > + <%=link_to "主页", home_path %> > <%=link_to @user.name, user_path %> diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 04793a02e..277a6eaca 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -106,7 +106,7 @@

- <%= f.text_field :login, :required => true, :size => 25, :name => "login", :readonly => true %> + <%= f.text_field :login, :required => true, :size => 25, :name => "login", :readonly => true, :style => 'border:1px solid #d3d3d3;'%> <%= l(:label_max_number) %>

diff --git a/app/views/tags/_tag_add.html.erb b/app/views/tags/_tag_add.html.erb index 14f2dc965..0b59015f2 100644 --- a/app/views/tags/_tag_add.html.erb +++ b/app/views/tags/_tag_add.html.erb @@ -1,13 +1,14 @@ <%= link_to '+ 添加标签', 'javascript:void(0);', :class => "yellowBtn f_l", :onclick=>"$('#add_tag_#{obj.id}').slideToggle();" if User.current.logged? %> - \ No newline at end of file diff --git a/app/views/tags/_tag_list.html.erb b/app/views/tags/_tag_list.html.erb index c815d71f8..549ed1751 100644 --- a/app/views/tags/_tag_list.html.erb +++ b/app/views/tags/_tag_list.html.erb @@ -14,7 +14,7 @@ <% end %> <% else %> - -    <%= l(:label_tags_no) %> - + + <% end %> \ No newline at end of file diff --git a/app/views/welcome/_more_course.html.erb b/app/views/welcome/_more_course.html.erb index 66f15fdf2..8d0f1564c 100644 --- a/app/views/welcome/_more_course.html.erb +++ b/app/views/welcome/_more_course.html.erb @@ -7,5 +7,3 @@ <%= link_to l(:label_course_join_student), join_private_courses_courses_path ,:remote => true, :class => 'icon icon-add' %>      <% end %> - -<%= link_to l(:label_more), {:controller => 'courses', :action => 'index', :school_id => school_id} %> \ No newline at end of file diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 4b7b0bf54..40be02464 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -160,8 +160,6 @@ <%= link_to(l(:label_newtype_contest), new_contest_contests_path, :class => 'icon icon-add') %> <% end %> <% end %> -    - <%= link_to l(:label_more), {:controller => 'contests', :action => 'index'}, :target => "_blank" %>
@@ -258,7 +256,6 @@

<%=l(:label_current_attendingcontest_work)%>

- <%= link_to l(:label_more_information), {:controller => 'softapplications', :action => 'index'}, :target => "_blank" %>
<% if Softapplication.count > 0%>
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 171b2b764..424d4eff0 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -1,5 +1,4 @@ -<% @nav_dispaly_project_label = 1 - @nav_dispaly_forum_label = 1 %> +<% @nav_dispaly_forum_label = 1 %> <%= stylesheet_link_tag 'welcome' %> <%= javascript_include_tag 'welcome' %>