Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
acfd8837bb
|
@ -45,11 +45,45 @@ class FilesController < ApplicationController
|
|||
'filename' => "#{Attachment.table_name}.filename",
|
||||
'size' => "#{Attachment.table_name}.filesize",
|
||||
'downloads' => "#{Attachment.table_name}.downloads"
|
||||
sort = ""
|
||||
|
||||
if params[:project_id]
|
||||
@isproject = true
|
||||
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
|
||||
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
||||
|
||||
if params[:sort]
|
||||
params[:sort].split(",").each do |sort_type|
|
||||
order_by = sort_type.split(":")
|
||||
|
||||
case order_by[0]
|
||||
when "filename"
|
||||
attribute = "filename"
|
||||
when "size"
|
||||
attribute = "filesize"
|
||||
when "attach_type"
|
||||
attribute = "attachtype"
|
||||
when "content_type"
|
||||
attribute = "created_on"
|
||||
when "field_file_dense"
|
||||
attribute = "is_public"
|
||||
when "downloads"
|
||||
attribute = "downloads"
|
||||
when "created_on"
|
||||
attribute = "created_on"
|
||||
end
|
||||
|
||||
if order_by.count == 1
|
||||
sort += "#{Attachment.table_name}.#{attribute} desc "
|
||||
elsif order_by.count == 2
|
||||
sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} "
|
||||
end
|
||||
if sort_type != params[:sort].split(",").last
|
||||
sort += ","
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
|
||||
@containers += @project.versions.includes(:attachments).reorder(sort).all.sort
|
||||
|
||||
show_attachments @containers
|
||||
|
||||
|
@ -57,7 +91,6 @@ class FilesController < ApplicationController
|
|||
elsif params[:course_id]
|
||||
@isproject = false
|
||||
|
||||
sort = ""
|
||||
if params[:sort]
|
||||
params[:sort].split(",").each do |sort_type|
|
||||
order_by = sort_type.split(":")
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
<%= @project ? l(:label_news_new) : l(:bale_news_notice) %>
|
||||
</div>
|
||||
<div class="box tabular">
|
||||
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %></p>
|
||||
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;", :onblur => "regexTitle();" %></p>
|
||||
<P><span id="title_notice_span">(60个字符以内)</span></P>
|
||||
<!-- <p style="margin-left:-10px;"><%#= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> -->
|
||||
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %></p>
|
||||
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;", :onblur => "regexDescription();" %></p>
|
||||
<P><span id="description_notice_span"></span></P>
|
||||
<p id="attachments_form" style="margin-left:-10px;"><label style="padding-right: 15px;"><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @news} %></p>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,3 +1,56 @@
|
|||
<script type="text/javascript">
|
||||
function regexTitle()
|
||||
{
|
||||
var name = $("#news_title").val();
|
||||
if(name.length ==0)
|
||||
{
|
||||
$("#title_notice_span").text("标题不能为空");
|
||||
$("#title_notice_span").css('color','#ff0000');
|
||||
$("#title_notice_span").focus();
|
||||
return false;
|
||||
}
|
||||
else if(name.length <= 60)
|
||||
{
|
||||
$("#title_notice_span").text("填写正确");
|
||||
$("#title_notice_span").css('color','#008000');
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#title_notice_span").text("标题超过60个字符");
|
||||
$("#title_notice_span").css('color','#ff0000');
|
||||
$("#title_notice_span").focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function regexDescription()
|
||||
{
|
||||
var name = $("#news_description").val();
|
||||
if(name.length ==0)
|
||||
{
|
||||
$("#description_notice_span").text("描述不能为空");
|
||||
$("#description_notice_span").css('color','#ff0000');
|
||||
$("#description_notice_span").focus();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#description_notice_span").text("填写正确");
|
||||
$("#description_notice_span").css('color','#008000');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function submitNews()
|
||||
{
|
||||
if(regexTitle() && regexDescription())
|
||||
{
|
||||
$("#news-form").submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<%
|
||||
if @project.project_type == Project::ProjectType_course
|
||||
btn_tips = l(:label_news_notice)
|
||||
|
@ -22,7 +75,9 @@
|
|||
<%= labelled_form_for @news, :url => project_news_index_path(@project),
|
||||
:html => {:id => 'news-form', :multipart => true} do |f| %>
|
||||
<%= render :partial => 'news/form', :locals => {:f => f} %>
|
||||
<%= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %><!-- button-submit --> |
|
||||
<%#= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %><!-- button-submit -->
|
||||
<%= link_to l(:button_create), "#", :onclick => 'submitNews();', :class => 'whiteButton m3p10' %>
|
||||
|
|
||||
<%= preview_link preview_news_path(:project_id => @project), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %>
|
||||
|
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-news").hide()', :class => 'whiteButton m3p10' %>
|
||||
|
|
|
@ -1,3 +1,55 @@
|
|||
<script type="text/javascript">
|
||||
function regexTitle()
|
||||
{
|
||||
var name = $("#news_title").val();
|
||||
if(name.length ==0)
|
||||
{
|
||||
$("#title_notice_span").text("标题不能为空");
|
||||
$("#title_notice_span").css('color','#ff0000');
|
||||
$("#title_notice_span").focus();
|
||||
return false;
|
||||
}
|
||||
else if(name.length <= 60)
|
||||
{
|
||||
$("#title_notice_span").text("填写正确");
|
||||
$("#title_notice_span").css('color','#008000');
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#title_notice_span").text("标题超过60个字符");
|
||||
$("#title_notice_span").css('color','#ff0000');
|
||||
$("#title_notice_span").focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function regexDescription()
|
||||
{
|
||||
var name = $("#news_description").val();
|
||||
if(name.length ==0)
|
||||
{
|
||||
$("#description_notice_span").text("描述不能为空");
|
||||
$("#description_notice_span").css('color','#ff0000');
|
||||
$("#description_notice_span").focus();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#description_notice_span").text("填写正确");
|
||||
$("#description_notice_span").css('color','#008000');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function submitNews()
|
||||
{
|
||||
if(regexTitle() && regexDescription())
|
||||
{
|
||||
$("#news-form").submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div class="contextual">
|
||||
<%= watcher_link(@news, User.current) %>
|
||||
<%= link_to(l(:button_edit),
|
||||
|
@ -15,9 +67,10 @@
|
|||
<%= labelled_form_for :news, @news, :url => news_path(@news),
|
||||
:html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<%= preview_link preview_news_path(:project_id => @project, :id => @news), 'news-form',target='preview',{:class => ''} %> |
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;' %>
|
||||
<%#= submit_tag l(:button_save) %>
|
||||
<%= link_to l(:button_save), "#", :onclick => 'submitNews();',:class => 'whiteButton m3p10' %>
|
||||
<%= preview_link preview_news_path(:project_id => @project, :id => @news), 'news-form',target='preview',{:class => 'whiteButton m3p10'} %> |
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;',:class => 'whiteButton m3p10' %>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
</div>
|
||||
|
|
|
@ -20,27 +20,18 @@
|
|||
<tr>
|
||||
<!-- added by bai 区分了个人列表里的项目与课程 -->
|
||||
<td colspan="2" width="580px"><p class="font_description">
|
||||
<% unless user.memberships.empty? %>
|
||||
<% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %>
|
||||
<% memberships = user.memberships.all(:conditions => cond) %>
|
||||
<%= l(:label_x_contribute_to, :count => memberships.count) %>
|
||||
<% for member in memberships %>
|
||||
<%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= l(:label_x_contribute_to, :count => 0) %>
|
||||
<% end %>
|
||||
|
||||
<p class="font_description">
|
||||
<% unless user.memberships.empty? %>
|
||||
<% cond = Project.visible_condition(User.current) + " AND projects.project_type = 1" %>
|
||||
<% memberships = user.memberships.all(:conditions => cond) %>
|
||||
<%= l(:label_x_course_contribute_to, :count => memberships.count) %>
|
||||
<% for member in memberships %>
|
||||
<%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= l(:label_x_course_contribute_to, :count => 0) %>
|
||||
<% user_courses = user_courses_list(user) %>
|
||||
<%= l(:label_x_course_contribute_to, :count => user_courses.count) %>
|
||||
<% for course in user_courses %>
|
||||
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : ',' %>
|
||||
<% end %>
|
||||
</p>
|
||||
</td>
|
||||
|
|
|
@ -7,29 +7,30 @@
|
|||
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :title => "#{user.name}" %></td>
|
||||
<td><table width="580px" border="0">
|
||||
<tr> <!-- modified by bai 增加了关注人的名字全称-->
|
||||
<td colspan="2" valign="top"><strong><%= content_tag "div", link_to(user.name,user_path(user)), :class => "project_avatar_name" %>
|
||||
<td colspan="2" valign="top"><strong><%= content_tag "div", link_to(user.name,user_path(user)), :class => "project_avatar_name" %></strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr> <!-- modified by bai 区别了“关注”里个人参与的项目与课程-->
|
||||
<td colspan="2" width="580px" ><p class="font_description">
|
||||
<% unless user.memberships.empty? %>
|
||||
<%# unless user.memberships.empty? %>
|
||||
<% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %>
|
||||
<% memberships = user.memberships.all(:conditions => cond) %>
|
||||
<%= l(:label_x_contribute_to, :count => memberships.count) %>
|
||||
<% for member in memberships %>
|
||||
<%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%# end %>
|
||||
</p>
|
||||
<p class="font_description">
|
||||
<% unless user.memberships.empty? %>
|
||||
<% cond = Project.visible_condition(User.current) + " AND projects.project_type = 1" %>
|
||||
<% memberships = user.memberships.all(:conditions => cond) %>
|
||||
<%= l(:label_x_course_contribute_to, :count => memberships.count) %>
|
||||
<% for member in memberships %>
|
||||
<%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %>
|
||||
<% end %>
|
||||
<%# unless user.memberships.empty? %>
|
||||
<% user_courses = user_courses_list(user) %>
|
||||
<%= l(:label_x_course_contribute_to, :count => user_courses.count) %>
|
||||
<% for course in user_courses %>
|
||||
<%# if course.name != nil %>
|
||||
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : ',' %>
|
||||
<%# end %>
|
||||
<% end %>
|
||||
<%# end %>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue