course.trustie.net

This commit is contained in:
yanxd 2014-02-24 10:40:45 +08:00
parent 60e8f93594
commit 7deeab62bc
12 changed files with 105 additions and 93 deletions

View File

@ -220,6 +220,7 @@ class UsersController < ApplicationController
def index
@project_type = params[:project_type]
role = params[:role]
sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on)
@ -238,6 +239,14 @@ class UsersController < ApplicationController
# @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count
scope = UserStatus.visible
case role
when 'teacher'
scope = UserStatus.teacher
when 'student'
scope = UserStatus.student
else
end
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
# scope.each do |user|

View File

@ -19,6 +19,7 @@ class WelcomeController < ApplicationController
caches_action :robots
def index
(course() and render :course and return 0) if request.headers['REQUEST_URI'].match(/course\.trustie\.net/)
# @news = News.latest User.current
# @projects = Project.latest User.current
#by young
@ -74,7 +75,9 @@ class WelcomeController < ApplicationController
end
def course
@course = Project.course_entities
@teacher = User.teacher
@student = User.student
end
end

View File

@ -1501,6 +1501,8 @@ module ApplicationHelper
def render_dynamic_nav
home_link = link_to l(:field_homepage), home_path
course_all_course_link = link_to l(:label_course_all), {:controller => 'projects', :action => 'course', :project_type => 1}
course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher'}
courses_link = link_to l(:label_course_practice), {:controller => 'projects', :action => 'course', :project_type => 1}
projects_link = link_to l(:label_project_deposit), {:controller => 'projects', :action => 'index', :project_type => 0}
users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index'}
@ -1512,13 +1514,16 @@ module ApplicationHelper
#@nav_dispaly_project_label
nav_list = Array.new
nav_list.push(home_link)
nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label
nav_list.push(courses_link) if @nav_dispaly_course_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
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)
nav_list.push(stores_link) if !@nav_dispaly_course_all_label
content_li = ''
nav_list.collect do |nav_item|

View File

@ -229,4 +229,26 @@ module WelcomeHelper
end
end
def newbie_send_path
create_new_forum_path '新手讨论'
end
def suggestion_send_path
create_new_forum_path '网站建议'
end
private
def create_new_forum_path name
# 没有论坛则返回'#' 不能发帖
# 否则到指定论坛里发帖
# 没有找到置顶论坛就跑默认第一个论坛发帖
forum_relation = create_find_undefine_forum name
backUrl = '#'
backUrl = new_forum_memo_path(Forum.first) if Forum.count > 0
backUrl = new_forum_memo_path(forum_relation.first) if !forum_relation.empty?
return backUrl
end
def create_find_undefine_forum name
Forum.where("name LIKE \'%#{name}%\'")
end
end

View File

@ -122,6 +122,13 @@ class User < Principal
has_one :user_extensions,:dependent => :destroy
## end
scope :teacher, -> {
joins(:user_extensions).where('user_extensions.identity = ?', 0)
}
scope :student, -> {
joins(:user_extensions).where('user_extensions.identity = ?', 1)
}
attr_accessor :password, :password_confirmation
attr_accessor :last_before_login_on
# Prevents unauthorized assignments

View File

@ -7,6 +7,17 @@ class UserStatus < ActiveRecord::Base
validates_uniqueness_of :user_id
scope :visible, lambda {|*args| nil }
scope :teacher, -> {
joins('LEFT JOIN users ON user_statuses.user_id=users.id').
joins('LEFT JOIN user_extensions ON users.id=user_extensions.user_id').
where('user_extensions.identity = ?', 0)
}
scope :student, -> {
joins('LEFT JOIN users ON user_statuses.user_id=users.id').
joins('LEFT JOIN user_extensions ON users.id=user_extensions.user_id').
where('user_extensions.identity = ?', 1)
}
# 更新字段 watchers_count 加1 这里没有做用户是否存在的匹配
# 负责这个表的聂同学 是在新建用户时就新建了该表的记录
# 但是 如果超级用户删除其他用户的话会造成读取错误 这里是遗漏点

View File

@ -6,6 +6,8 @@
</div></div>
</div>
<%= debug(params) if Rails.env.development? %>
<%= 'request.headers[REQUEST_URI] ===> '+request.headers['REQUEST_URI'] if Rails.env.development? %>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

View File

@ -12,10 +12,14 @@
@nav_dispaly_bid_label = 1
elsif (request.headers['REQUEST_URI'].match(/forums/))
@nav_dispaly_forum_label = 1
elsif (request.headers['REQUEST_URI'].match(/[^projects]\/course$/))
elsif (request.headers['REQUEST_URI'].match(/[^projects]\/course[^\.]/))
@nav_dispaly_course_label = 1
@nav_dispaly_project_label = 1
@nav_dispaly_contest_label = 1
elsif (request.headers['REQUEST_URI'].match(/course\.trustie\.net/))
@nav_dispaly_course_all_label = 1
@nav_dispaly_teacher_all_label = 1
@nav_dispaly_forum_label = 1
else
@nav_dispaly_course_label = 1
@nav_dispaly_project_label = 1

View File

@ -135,120 +135,59 @@
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>我的课程</strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= (link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :project_sort_type => 1}) if User.current.login? %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist" style="height:200px;">
<%if !User.current.login?%>
<li style="background-image:none;">
请<%=link_to "登录", signin_path %>后查看
</li>
<%else%>
<% find_all_hot_course(2).map do |project| %>
<li style="background-image:none;">
<div style="float: left;">
<% if get_avatar?(project)%>
<%= image_tag(url_to_avatar(project), :class => "avatar-4") %>
<% else %>
<%= image_tag('../images/avatars/Project/course.jpg', :class => "avatar-4") %>
<% end %>
</div>
<div style="float: left; margin-left: 10px; width: 360px;">
<p class="layout">
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}", :target => "_blank" )%>
<span style="cursor: pointer; display: inline-block; float: right; color: #ec6300; white-space: nowrap;">学生人数:<%= link_to "#{studentCount(project)}", project_member_path(project, :role => 2) ,:course =>'1', :target => "_blank" %></span>
</p>
<p class="layout-1" >
<%= content_tag "span", project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description %>
</p>
</div>
</li>
<% end %>
<% end -%>
</ul>
</div>
<div class="web_status">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>当前网站状态</strong></h3>
<table>
<tbody>
<tr>
<td>课程总量: 15</td>
<td>教师数量: 6</td>
<td>课程总量: <%=@course.count%></td>
<td>教师数量: <%=@teacher.count%></td>
</tr>
<tr>
<td>用户总量: 810</td>
<td>学生数量: 233</td>
<td>用户总量: <%=User.count%></td>
<td>学生数量: <%=@student.count%></td>
</tr>
<tr>
<td>资源总量: 0810</td>
<td>资源总量: <%=Attachment.count%></td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<div style="text-align: right; padding-right: 20px">
<%= link_to "意见反馈" , '#', {:class => 'orangeButton', :style => "color: #EEEEEE" }%>
<%= link_to "意见反馈" , suggestion_send_path, {:class => 'orangeButton', :style => "color: #EEEEEE" }%>
</div>
</div>
</div>
<div class="clearfix"></div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>热门项目</strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0}, :target => "_blank" %></span>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="margin-top: 20px; float: right;">
<h3 style="margin-left: 5px; color: #e8770d;">
<strong>问题和反馈动态</strong>
<%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
<%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
</h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", forums_path %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_project(6).map do |project| %>
<li style="background-image:none;">
<div style="float: left;">
<%= image_tag url_to_avatar(project), :class => "avatar-4" %>
</div>
<div style="float: left; margin-left: 10px; width: 360px;">
<p class="layout">
<span style="display: inline-block; width: 250px;"><%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name", :title => "#{project.name}", :target => "_blank" )%></span>
<%= content_tag "span", show_grade(project),
:style => "cursor: pointer; display: inline-block; float: right; color: #ec6300; ",
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
:class => "tooltip",
:id => "tooltip-#{project.id}" %>
</p>
<p class="layout-1" >
<%= content_tag "span", project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description %>
</p>
</div>
</li>
<% end %>
</ul>
</div>
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<h3 style="margin-left: 5px; color: color: (51, 119, 51);"><strong>热门竞赛</strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1}, :target => "_blank" %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
<li style="background-image:none;">
<p class="layout">
<span style = "background: url('/images/007.gif') no-repeat scroll ;background-position: left center;"><%= link_to( contest.name, respond_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}",
:style => "margin-left: 28px;", :target => "_blank") %></span>
</p>
<p class="layout-1" >
<%= content_tag "span", contest.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => contest.description %>
</p>
<% find_new_forum_topics(4).each do |topic|%>
<li class="message-brief-intro" style="min-height: 20px;padding-bottom:3px; line-height:1.23em; ">
<div style="display: inline-block; width: 100%;">
<span style="color:gray; display: inline-block; margin-bottom:6px; background: url('/images/list-icon.png') no-repeat scroll ;background-position: left center;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %>
</span>
<br>
<span style="margin-left: 24px; color: rgb(172, 174, 177); white-space: nowrap; font-size 9pt !important;;"><%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前</span>
<span style="margin-left: 8px; margin-bottom: 0px; color: rgb(172, 174, 177) !important; white-space: nowrap;">
由&nbsp;<%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);" %>&nbsp;发表
</span>
<span style="float: right; color: rgb(172, 174, 177); white-space: nowrap; font-size 9pt !important;;">回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url %>)</span>
</div>
</li>
<% end %>
</ul>
</div>
</div>
<div class="clearfix"></div>
<div class="clr">
</div>
<br/><br/><br/><br/><br/><br/><br/>
<div style="padding-top: 40px"></div>

View File

@ -111,7 +111,7 @@
<ul class="welcome-message-list">
<div class="forum-topic" style="height: 25px; width: 98%; margin-left: 6px;">
<h3 style="color: rgb(21, 188, 207);"><strong>贴吧动态</strong></h3>
<span style="margin-top: -30px;float: right; display: block;"><%= link_to "更多>>", forums_path, :target => "_blank" %></span>
<span style="margin-top: -30px;float: right; display: block;"><%= link_to "更多>>", forums_path %></span>
</div>
<div class="welcome-box-list-new">
<% find_new_forum_topics(8).each do |topic|%>

View File

@ -511,6 +511,8 @@ zh:
label_requirement: 需求
label_new_course: 课程列表
label_course_practice: 课程实践
label_course_all: 所有课程
label_teacher_all: 所有教师
label_project_deposit: 项目托管
label_software_user: 软件创客
label_contest_innovate: 创新竞赛

View File

@ -390,4 +390,12 @@ a.attachments_list_color {
height: 1.5em;
padding-left: 50px;
color:#6B6D72;
}
.idea_btn {
width: auto;
font-size: 13px;
margin: 0 5px;
padding: 0 6px;
line-height: 1.3em;
margin-bottom: 3px;
}