From f5b69be967d3f40649a7c8eee204a0de160253bb Mon Sep 17 00:00:00 2001 From: z9hang Date: Sat, 5 Jul 2014 14:43:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E8=B4=B4=E5=90=A7=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E4=B8=BA=E7=A9=BA=E4=B8=8D=E8=83=BD=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E3=80=81=E6=90=9C=E7=B4=A2=E7=A9=BA=E5=86=85=E5=AE=B9=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 2 +- app/controllers/courses_controller.rb | 3 ++- app/controllers/forums_controller.rb | 2 ++ app/controllers/users_controller.rb | 2 +- app/controllers/welcome_controller.rb | 3 ++- app/models/forum.rb | 2 +- app/views/forums/show.html.erb | 12 ++++++------ 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index adadfbf4..1b172e0c 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -26,7 +26,7 @@ class ContestsController < ApplicationController # @contests = Contest.visible # @contests ||= [] @offset, @limit = api_offset_and_limit({:limit => 10}) - @contests = Contest.visible + @contests = Contest.visible @contests = @contests.like(params[:name]) if params[:name].present? @contest_count = @contests.count @contest_pages = Paginator.new @contest_count, @limit, params['page'] diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index b46ab52b..157de5ce 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -99,7 +99,8 @@ class CoursesController < ApplicationController # add by nwb def search courses_all = Course.all_course - + name = params[:name] + (redirect_to courses_path, :notice => l(:label_sumbit_empty);return) if name.blank? @courses = courses_all.visible if params[:name].present? @courses_all = @courses.like(params[:name]) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index b54d98b8..f3ebfad8 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -166,6 +166,8 @@ class ForumsController < ApplicationController def search_forum # @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'") + name = params[:name] + (redirect_to forums_path, :notice => l(:label_sumbit_empty);return) if name.blank? @offset, @limit = api_offset_and_limit({:limit => 10}) @forums_all = Forum.where("name LIKE '%#{params[:name]}%'") @forums_count = @forums_all.count diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 144e86f4..1c2db7f7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -373,7 +373,7 @@ class UsersController < ApplicationController def search sort_init 'login', 'asc' sort_update %w(login firstname lastname mail admin created_on last_login_on) - + (redirect_to users_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank? case params[:format] when 'xml', 'json' @offset, @limit = api_offset_and_limit({:limit => 15}) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 9c72d301..3e708b94 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -88,7 +88,8 @@ class WelcomeController < ApplicationController when :users_student redirect_to users_search_path(:name => search_condition, :role => :student) else - redirect_to home_path, :alert => l(:label_sumbit_empty) + #redirect_to home_path, :alert => l(:label_sumbit_empty) + (redirect_to home_path, :notice => l(:label_sumbit_empty);return) #if params[:name].blank? end } end diff --git a/app/models/forum.rb b/app/models/forum.rb index e6b16df3..cd9c210d 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -9,7 +9,7 @@ class Forum < ActiveRecord::Base 'memo_count', 'last_memo_id', 'creator_id' - validates_presence_of :name, :creator_id + validates_presence_of :name, :creator_id, :description validates_length_of :name, maximum: 50 validates_length_of :description, maximum: 255 validates :name, :uniqueness => true diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 72e7ce22..34fc953d 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -3,17 +3,17 @@

<%=l(:label_memo_new)%>

<% if User.current.logged? %> <%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %> - <% if @memo.errors.any? %> +

<%= f.text_field :subject, :required => true%>

<%= f.text_area :content, :required => true, :id => 'editor02' %>