This commit is contained in:
sw 2014-07-04 10:30:14 +08:00
commit 2506e8e50d
10 changed files with 104 additions and 89 deletions

View File

@ -51,7 +51,10 @@ class MemosController < ApplicationController
@memo_new = @memo.dup
@memo = @memo.root # 取出楼主防止输入帖子id让回复作为主贴显示
unless @memo.new_record?
@memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1))
end
page = params[:page]
if params[:r] && page.nil?
@ -68,11 +71,15 @@ class MemosController < ApplicationController
limit(@reply_pages.per_page).
offset(@reply_pages.offset).
all
if @memo.new_record?
format.html { redirect_to back_url, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
else
format.html { render action: :show }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
# format.html { redirect_to back_memo_or_forum_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
format.json { render json: @memo.errors, status: :unprocessable_entity }
end
end
end
end

View File

@ -32,7 +32,7 @@ class WelcomeController < ApplicationController
def course
if params[:school_id]
@school_id = params[:school_id]
else
elsif User.current.logged? && User.current.user_extensions.school
@school_id = User.current.user_extensions.school.id
end
@logoLink ||= logolink()

View File

@ -233,8 +233,13 @@ module WelcomeHelper
def find_all_new_hot_course limit = 9 ,school_id = 0
#sort_project_by_hot_rails 1, 'course_ac_para DESC', limit
time_now = Time.new.strftime("%Y");
if school_id
courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <>
?", school_id).order("course_ac_para DESC").limit(limit).all
else
courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL
").order("course_ac_para DESC").limit(limit).all
end
courses
end

View File

@ -3,9 +3,9 @@ class Memo < ActiveRecord::Base
belongs_to :forum
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
validates_presence_of :author_id, :forum_id, :subject
validates_presence_of :author_id, :forum_id, :subject,:content
# 若是主题帖,则内容可以是空
validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
#validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
validates_length_of :subject, maximum: 50
validates_length_of :content, maximum: 3072
validate :cannot_reply_to_locked_topic, :on => :create

View File

@ -164,7 +164,7 @@ class User < Principal
# Prevents unauthorized assignments
attr_protected :login, :admin, :password, :password_confirmation, :hashed_password
LOGIN_LENGTH_LIMIT = 60
LOGIN_LENGTH_LIMIT = 25
MAIL_LENGTH_LIMIT = 60
validates_presence_of :login, :firstname, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }

View File

@ -9,8 +9,7 @@
});
//设置div居中
function setCss()
{
function setCss() {
var mainBar = $('#main-content-bar')[0];
var topHeight = mainBar.offsetHeight;
var welcomeLeft = $('#welcome_left')[0];
@ -73,28 +72,34 @@
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h3><strong>新开课程</strong></h3>
<% if @school_id %>
<% school_course = find_miracle_course(10, 7, @school_id) %>
<% else %>
<%school_course=[]%>
<% end %>
<% if (school_course.count == 0) %>
<span><%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
</ul>
<ul class="d-p-projectlist">
<h1></h1>
<p id="errorExplanation">
该学校未开设任何课程,您可以查看其他学校课程
</p>
<h1></h1>
<% find_all_new_hot_course(9,@school_id).map do |project| %>
<li class='<%= cycle("odd", "even") %>' title=<%=project.description.to_s%>>
<% find_all_new_hot_course(9, @school_id).map do |course| %>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(project), :class => "avatar-4") %>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<% course = Course.find_by_extra(project.extra)%>
<% if (course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
@ -107,15 +112,12 @@
</span>
</div>
<div class='desc_item text_nowrap' style="width: 310px;">
[<%= get_course_term project %>]
<%= link_to( project.name, course_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
(<%= "#{studentCount(project)}人" %>)
<% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %>
(<%=link_to "#{files_count}份", course_files_path(project) %>资料)
[<%= get_course_term course %>]
<%= link_to(course.name, course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{studentCount(course)}人" %>)
<% files_count = course.attachments.count.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>
<!-- <div class='desc_item' style="">
<span class='font_lighter' title=<%#=project.description.to_s%>><%#=project.description.truncate(25, omission: '...')%></span>
</div> -->
</li>
<% end %>
</ul>
@ -135,15 +137,14 @@
</ul>
<ul class="d-p-projectlist">
<% school_course.map do |project| %>
<li class='<%= cycle("odd", "even") %>' title=<%=project.description.to_s%>>
<% school_course.map do |course| %>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(project), :class => "avatar-4") %>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<% course = project %>
<%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %>
</span>
<span class='font_bolder'>
@ -151,17 +152,17 @@
</span>
</div>
<div class='desc_item text_nowrap' style="width: 310px;">
[<%= get_course_term project %>]
<%= link_to( project.name, course_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
(<%= "#{studentCount(project)}人" %>)
<% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %>
(<%=link_to "#{files_count}份", course_files_path(project) %>资料)
[<%= get_course_term course %>]
<%= link_to(course.name, course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{studentCount(course)}人" %>)
<% files_count = course.attachments.count.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>
<div class='join_course_link'>
<% if !course_endTime_timeout?(project)%>
<% if !course_endTime_timeout?(course) %>
<div>
<%= join_in_course(project, User.current)%>
<%= join_in_course(course, User.current) %>
</div>
<% end %>
</div>
@ -170,19 +171,19 @@
<% if school_course.count < 9 %>
<li>
<h1></h1>
<p id="errorExplanation">
该学校开设课程较少,您可以查看其他学校课程
</p>
</li>
<% find_all_new_hot_course(9 - school_course.count,@school_id).map do |project| %>
<li class='<%= cycle("odd", "even") %>' title=<%=project.description.to_s%>>
<% find_all_new_hot_course(9 - school_course.count, @school_id).map do |course| %>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(project), :class => "avatar-4") %>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item'>
<span class=''>
<% course = project%>
<% if (course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %>
@ -195,11 +196,11 @@
</span>
</div>
<div class='desc_item text_nowrap' style="width: 310px;">
[<%= get_course_term project %>]
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
<%= "#{studentCount(project)}人" %> )
<% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %>
(<%=link_to "#{files_count}份", project_files_path(project) %>资料)
[<%= get_course_term course %>]
<%= link_to(course.name, course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
<%= "#{studentCount(course)}人" %> )
<% files_count = course.attachments.count.to_i.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>
</li>
<% end %>
@ -216,6 +217,7 @@
<%= 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_new_forum_topics(10).each do |topic| %>
@ -224,6 +226,7 @@
<span class="memo_activity text_nowrap" 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.forum.name + ']', forum_path(topic.forum), :class => 'memo_Bar_title' %><%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray", :style => "font-size: 10pt !important;" %>
</span>
<div class='memo_activity memo_attr'>
<span class='memo_timestamp'>
<%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -449,7 +449,7 @@ a.attachments_list_color {
font-size: 9pt;
}
.memo_activity span a{
color: gray;
/*color: gray;*/
}
/*帖子的最后回复人*/
.memo_activity .memo_last_person{