diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 1e16d19be..82f92c2d1 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -365,14 +365,15 @@ class AccountController < ApplicationController def invalid_credentials logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}" - flash.now[:error] = l(:notice_account_invalid_creditentials) - render :layout => 'login' + flash[:error] = l(:notice_account_invalid_creditentials) + # render :layout => 'login' + redirect_to signin_path(:login=>true) end def invalid_credentials_new logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}" - flash.now[:error] = l(:notice_account_invalid_creditentials_new) - render :layout => 'login' + flash[:error] = l(:notice_account_invalid_creditentials_new) + render signin_path(:login=>true) end # Register a user for email activation. diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1c233ed6b..a6554075f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -563,7 +563,7 @@ class ApplicationController < ActionController::Base uri = URI.parse(back_url) # do not redirect user to another host or to the login or register page if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) - back_url = back_url.gsub(%r{\/users\/(\d+)},"/users/"+default.id.to_s) + back_url = back_url.gsub(%r{\/users\/(\d+)},"/users/"+default.id.to_s) if default.is_a?(:User) redirect_to(back_url) return end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 809f78ddc..784066378 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -96,11 +96,14 @@ class WelcomeController < ApplicationController @projects = Project.all_public.active render :layout => false, :content_type => 'text/plain' end - + def course - @course_page = FirstPage.find_by_page_type('course') - @school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117 - @logoLink ||= logolink() + redirect_to signin_path + return + # + # @course_page = FirstPage.find_by_page_type('course') + # @school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117 + # @logoLink ||= logolink() end def logolink() @@ -140,8 +143,11 @@ class WelcomeController < ApplicationController def contest - @contest_page = FirstPage.find_by_page_type('contest') - @contest_notifications = Contestnotification.order("created_at desc").limit(5) + redirect_to signin_path + return + + # @contest_page = FirstPage.find_by_page_type('contest') + # @contest_notifications = Contestnotification.order("created_at desc").limit(5) end def search @@ -181,28 +187,28 @@ class WelcomeController < ApplicationController private # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法 def entry_select - url = request.original_url.gsub('/','') - if url.include?(Setting.url_course.gsub('/','')) - if @first_page.show_course == 1 - course - render :course - else - render_404 - end - - return 0 - elsif url.include?(Setting.url_contest.gsub('/','')) - if @first_page.show_contest == 1 - contest - render :contest - else - render_404 - end - - return 0 - elsif url.include?(Setting.url_user.gsub('/','')) - #redirect_to(:controller => "users", :action => "index") - end + # url = request.original_url.gsub('/','') + # if url.include?(Setting.url_course.gsub('/','')) + # if @first_page.show_course == 1 + # course + # render :course + # else + # render_404 + # end + # + # return 0 + # elsif url.include?(Setting.url_contest.gsub('/','')) + # if @first_page.show_contest == 1 + # contest + # render :contest + # else + # render_404 + # end + # + # return 0 + # elsif url.include?(Setting.url_user.gsub('/','')) + # #redirect_to(:controller => "users", :action => "index") + # end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7f93345b4..7b83bb1c2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2254,6 +2254,21 @@ module ApplicationHelper technical_title end + def get_user_roll user + technical_title = "" + case user.user_extensions.identity.to_s + when "0" + technical_title = get_technical_title user + when "1" + technical_title = l(:label_account_identity_student) + when "2" + technical_title = l(:label_account_identity_enterprise) + when "3" + technical_title = l(:label_account_identity_developer) + end + technical_title + end + def ie8? request.env["HTTP_USER_AGENT"] =~ /MSIE 8.0/ diff --git a/app/models/course.rb b/app/models/course.rb index 26220f245..501d958e4 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -37,7 +37,8 @@ class Course < ActiveRecord::Base has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy has_many :course_activities - has_many :course_messages + # 课程消息 + has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy acts_as_taggable acts_as_nested_set :order => 'name', :dependent => :destroy diff --git a/app/models/course_message.rb b/app/models/course_message.rb index 95ce3a56b..4f62d24c2 100644 --- a/app/models/course_message.rb +++ b/app/models/course_message.rb @@ -11,6 +11,7 @@ class CourseMessage < ActiveRecord::Base validates :course_id,presence: true validates :course_message_id,presence: true validates :course_message_type, presence: true + validates_length_of :content, :maximum => 100 after_create :add_user_message def add_user_message diff --git a/app/models/project.rb b/app/models/project.rb index 77711edff..0618dd145 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -92,7 +92,7 @@ class Project < ActiveRecord::Base has_many :tags, :through => :project_tags, :class_name => 'Tag' has_many :project_tags, :class_name => 'ProjectTags' # 关联虚拟表 - has_many :forge_messages + has_many :forge_messages, :class_name =>'ForgeMessage', :as => :forge_message, :dependent => :destroy belongs_to :organization diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 8bdace544..56f2c5454 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -1,7 +1,7 @@ <%= stylesheet_link_tag 'new_user'%> <%= stylesheet_link_tag 'leftside'%> -
@@ -186,7 +206,7 @@ <%= back_url_hidden_field_tag %>
<%= text_field_tag 'username', params[:username], :tabindex => '1' , - :class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称'%> + :class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称', :onkeypress => "user_name_keypress(event);"%>
<% if Setting.openid? %> @@ -196,7 +216,7 @@ <% end %>
- <%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码'%> + <%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码', :onkeypress => "user_name_keypress(event);"%>
<% if Setting.autologin? %> diff --git a/app/views/courses/_history.html.erb b/app/views/courses/_history.html.erb index 70e943e99..864509546 100644 --- a/app/views/courses/_history.html.erb +++ b/app/views/courses/_history.html.erb @@ -5,7 +5,7 @@
<%= link_to image_tag(url_to_avatar(journal.user),:width => '46',:height => '46'), user_path(journal.user) %>
-
+
diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 8dd0bd2bb..18953d22d 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -33,12 +33,21 @@ $(function(){ $("#navHomepageSearchInput").keypress(function(e){ - if (e.keyCode == '13') { + var name = $.trim($('#navHomepageSearchInput').val()); + if (e.keyCode == '13' && name != "" && name.length != 0) { $('#type').val($('input[type=radio]:checked').val()); $(this).parent().submit(); } }) }); + + function search_in_header(obj){ + var name = $.trim($('#navHomepageSearchInput').val()); + if (name != "" && name.length != 0) { + $('#type').val($('input[type=radio]:checked').val()); + obj.parent().submit(); + } + }