This commit is contained in:
nwb 2014-07-05 15:11:57 +08:00
commit 5f18b1a38c
7 changed files with 15 additions and 11 deletions

View File

@ -26,7 +26,7 @@ class ContestsController < ApplicationController
# @contests = Contest.visible # @contests = Contest.visible
# @contests ||= [] # @contests ||= []
@offset, @limit = api_offset_and_limit({:limit => 10}) @offset, @limit = api_offset_and_limit({:limit => 10})
@contests = Contest.visible @contests = Contest.visible
@contests = @contests.like(params[:name]) if params[:name].present? @contests = @contests.like(params[:name]) if params[:name].present?
@contest_count = @contests.count @contest_count = @contests.count
@contest_pages = Paginator.new @contest_count, @limit, params['page'] @contest_pages = Paginator.new @contest_count, @limit, params['page']

View File

@ -99,7 +99,8 @@ class CoursesController < ApplicationController
# add by nwb # add by nwb
def search def search
courses_all = Course.all_course 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 @courses = courses_all.visible
if params[:name].present? if params[:name].present?
@courses_all = @courses.like(params[:name]) @courses_all = @courses.like(params[:name])

View File

@ -166,6 +166,8 @@ class ForumsController < ApplicationController
def search_forum def search_forum
# @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'") # @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}) @offset, @limit = api_offset_and_limit({:limit => 10})
@forums_all = Forum.where("name LIKE '%#{params[:name]}%'") @forums_all = Forum.where("name LIKE '%#{params[:name]}%'")
@forums_count = @forums_all.count @forums_count = @forums_all.count

View File

@ -373,7 +373,7 @@ class UsersController < ApplicationController
def search def search
sort_init 'login', 'asc' sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on) 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] case params[:format]
when 'xml', 'json' when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15}) @offset, @limit = api_offset_and_limit({:limit => 15})

View File

@ -88,7 +88,8 @@ class WelcomeController < ApplicationController
when :users_student when :users_student
redirect_to users_search_path(:name => search_condition, :role => :student) redirect_to users_search_path(:name => search_condition, :role => :student)
else 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
} }
end end

View File

@ -9,7 +9,7 @@ class Forum < ActiveRecord::Base
'memo_count', 'memo_count',
'last_memo_id', 'last_memo_id',
'creator_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 :name, maximum: 50
validates_length_of :description, maximum: 255 validates_length_of :description, maximum: 255
validates :name, :uniqueness => true validates :name, :uniqueness => true

View File

@ -3,17 +3,17 @@
<h3><%=l(:label_memo_new)%></h3> <h3><%=l(:label_memo_new)%></h3>
<% if User.current.logged? %> <% if User.current.logged? %>
<%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %> <%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
<% if @memo.errors.any? %> <!--<#% if @memo.errors.any? %>
<div id="error_explanation"> <div id="error_explanation">
<h2><%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2> <h2><#%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>
<ul> <ul>
<% @memo.errors.full_messages.each do |msg| %> <#% @memo.errors.full_messages.each do |msg| %>
<li><%= msg %></li> <li><#%= msg %></li>
<% end %> <#% end %>
</ul> </ul>
</div> </div>
<% end %> <#% end %> -->
<div class="actions" style="max-width:680px"> <div class="actions" style="max-width:680px">
<p><%= f.text_field :subject, :required => true%></p> <p><%= f.text_field :subject, :required => true%></p>
<p style="max-width:680px"><%= f.text_area :content, :required => true, :id => 'editor02' %></p> <p style="max-width:680px"><%= f.text_area :content, :required => true, :id => 'editor02' %></p>