diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f47ba446e..178a82d17 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -725,6 +725,12 @@ class ApplicationController < ActionController::Base #查找首页相关信息 def find_first_page @first_page = FirstPage.where("page_type = 'project'").first + if @first_page.nil? + @first_page = FirstPage.new + @first_page.page_type = 'project' + @first_page.description = "" + @first_page.save() + end @show_course = @first_page.show_course @show_contest = @first_page.show_contest end diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb index 94131a2e0..de686493b 100644 --- a/app/controllers/trackers_controller.rb +++ b/app/controllers/trackers_controller.rb @@ -17,7 +17,7 @@ class TrackersController < ApplicationController layout 'admin' - + helper "project_score" before_filter :require_admin, :except => :index before_filter :require_admin_or_api_request, :only => :index accept_api_auth :index @@ -38,6 +38,7 @@ class TrackersController < ApplicationController @tracker ||= Tracker.new(params[:tracker]) @trackers = Tracker.sorted.all @projects = Project.all + @courses = Course.all end def create diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index eaa96e82a..98b24bc12 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -295,8 +295,8 @@ class UsersController < ApplicationController # 活跃度排序, 就是所谓的得分情况 @s_type = 1 @users = scope. - joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). - reorder('user_scores.active DESC') + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') when '2' # 粉丝数排序 @s_type = 2 @@ -308,8 +308,8 @@ class UsersController < ApplicationController # 默认活跃度排序 @s_type = 1 @users = scope. - joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). - reorder('user_scores.active DESC') + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') end # limit and offset diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 80b4e3576..4e7cf0ce9 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -20,11 +20,12 @@ class WelcomeController < ApplicationController include WelcomeHelper helper :project_score caches_action :robots + before_filter :find_first_page, :only => [:index] # before_filter :fake, :only => [:index, :course] before_filter :entry_select, :only => [:index] def index - @first_page = FirstPage.where("page_type = 'project'").first + #@first_page = FirstPage.where("page_type = 'project'").first #@show_course = @first_page.show_course if @first_page.nil? || @first_page.sort_type.nil? @projects = find_miracle_project(10, 3,"score desc") @@ -76,7 +77,7 @@ class WelcomeController < ApplicationController logo = get_avatar?(@course_page) id = params[:school_id] logo_link = "" - if id.nil? && User.current.user_extensions.school.nil? + if id.nil? && (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) if logo logo_link = url_to_avatar(@course_page) else @@ -148,8 +149,8 @@ class WelcomeController < ApplicationController private # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法 def entry_select - @first_page = FirstPage.where("page_type = 'project'").first - url = request.original_url + #@first_page = FirstPage.where("page_type = 'project'").first + url = request.original_url.gsub('/','') if url.include?(Setting.host_course) if @first_page.show_course == 1 course diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index a5506be93..10aa39df2 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -54,7 +54,7 @@ class ZipdownController < ApplicationController end rescue => e - render file: 'public/file_not_found.html' + render file: 'public/file_not_found.html' , :layout => 'course_base' end private diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb index ecfb097e9..6c11199fb 100644 --- a/app/helpers/members_helper.rb +++ b/app/helpers/members_helper.rb @@ -31,6 +31,7 @@ module MembersHelper } s + content_tag('div', content_tag('ul', links), :class => 'pagination_new') + end # add by nwb diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index 8e9e6bbb9..17b68c3f6 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -12,6 +12,8 @@ module TagsHelper @obj = Issue.find_by_id(obj_id) when '4' @obj = Bid.find_by_id(obj_id) + when '5' + @obj = Forum.find_by_id(obj_id) when '6' @obj = Attachment.find_by_id(obj_id) when '7' @@ -44,6 +46,8 @@ module TagsHelper if user.id == obj_id @result = true end + when '5' + @result = is_forum_manager?(user.id,obj_id) when '7' if user.id == obj_id @result = true @@ -56,6 +60,17 @@ module TagsHelper end +# 判断用户是否是贴吧的管理员 +# add by chenmin +def is_forum_manager?(user_id,forum_id) + @result = false + @user_id = Forum.find(forum_id).creator_id; + if @user_id == user.id + @result = true + end + return @result +end + def tagname_val ("#tag_name_name").value end \ No newline at end of file diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index 06bf45012..0677d324b 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -13,16 +13,17 @@ <% end %>
<% end %> -<%= l(:label_bids_reward_method) %><%= @contest.budget%>
-<%= l(:label_class_period) %> * - <%= text_field_tag :class_period, @course.class_period, :placeholder => "在此输入课时" %> <%= l(:label_class_hour)%> + <%= text_field_tag :class_period, @course.class_period, :placeholder => "在此输入课时",:maxlength=>5 %> <%= l(:label_class_hour)%> |
<%= l(:label_class_period) %> * - <%= text_field_tag :class_period, nil, :placeholder => "在此输入课时" %><%= l(:label_class_hour)%> + <%= text_field_tag :class_period, nil, :placeholder => "在此输入课时",:maxlength=>5 %><%= l(:label_class_hour)%> |