From 6b526ee438cf5e2ad1e117e627165253ec5ed5f8 Mon Sep 17 00:00:00 2001 From: t430 Date: Tue, 29 Apr 2014 07:47:26 +0800 Subject: [PATCH 01/39] fix --- app/views/layouts/_base_footer.html.erb.orig | 73 ++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 app/views/layouts/_base_footer.html.erb.orig diff --git a/app/views/layouts/_base_footer.html.erb.orig b/app/views/layouts/_base_footer.html.erb.orig new file mode 100644 index 00000000..c2e9c1f3 --- /dev/null +++ b/app/views/layouts/_base_footer.html.erb.orig @@ -0,0 +1,73 @@ + +
+<<<<<<< HEAD + +
+ <%= debug(params) if Rails.env.development? %> + + +
From 268dc1acce6ec75b340ff834b0b4ccfca6bc9d20 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 8 May 2014 17:37:38 +0800 Subject: [PATCH 02/39] =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=90=A7=E5=8A=A8=E6=80=81=E5=89=8D=E6=98=BE=E7=A4=BA=E5=90=A7?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/forums/show.html.erb | 2 +- app/views/welcome/index.html.erb | 2 +- db/schema.rb | 11 ----------- public/stylesheets/welcome.css | 10 ++++++++++ 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 677416a6..72e7ce22 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -19,7 +19,7 @@

<%= f.text_area :content, :required => true, :id => 'editor02' %>


-

+

<%= l(:label_attachment_plural) %>
<%= render :partial => 'attachments/form', :locals => {:container => @memo} %>

diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 3fdee2a9..0a69b1f7 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -100,7 +100,7 @@ <% find_new_forum_topics(7).each do |topic|%>
  • - <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url,title: topic.subject %> + <%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %><%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url,title: topic.subject %>
    diff --git a/db/schema.rb b/db/schema.rb index fe23a1ca..2477e5a3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -755,11 +755,6 @@ ActiveRecord::Schema.define(:version => 20140428013546) do add_index "time_entries", ["project_id"], :name => "time_entries_project_id" add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - create_table "tmp", :force => true do |t| - t.string "name" - t.string "part_number" - end - create_table "tokens", :force => true do |t| t.integer "user_id", :default => 0, :null => false t.string "action", :limit => 30, :default => "", :null => false @@ -966,10 +961,4 @@ ActiveRecord::Schema.define(:version => 20140428013546) do add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" - create_table "yans", :force => true do |t| - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - end diff --git a/public/stylesheets/welcome.css b/public/stylesheets/welcome.css index cdfacf9e..2533305f 100644 --- a/public/stylesheets/welcome.css +++ b/public/stylesheets/welcome.css @@ -405,6 +405,16 @@ a.attachments_list_color { background: url('../images/list-icon.png') no-repeat scroll left center; font-size: 10pt; } + /*帖子标题前吧名*/ + .memo_activity .memo_Bar_title{ + display: inline-block; + /*color: #59ceff;*/ + color: #e8770d; + font-weight: bold; + margin-bottom: 3px; + padding-left: 0px; + font-size: 10pt; + } /*帖子的各种属性*/ .memo_activity .memo_attr{ margin-left: 20px; From 42e6fc6a68c2072b26354ab2768336c5658725c1 Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 8 May 2014 18:03:48 +0800 Subject: [PATCH 03/39] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E7=B1=BB=E5=9E=8Bcontrol=E3=80=81model=E5=8F=8A=E8=A1=A8?= =?UTF-8?q?=E7=BB=93=E6=9E=84=202.=E8=B5=84=E6=BA=90(attachments)=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=B5=84=E6=BA=90=E5=88=86=E7=B1=BB=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 1 + app/models/attachmentstype.rb | 3 +++ .../20140508030039_create_attachmentstypes.rb | 12 ++++++++++++ ...20140508030358_add_attachtype_to_attachments.rb | 5 +++++ db/schema.rb | 14 ++------------ test/fixtures/attachmentstypes.yml | 9 +++++++++ test/unit/attachmentstype_test.rb | 7 +++++++ 7 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 app/models/attachmentstype.rb create mode 100644 db/migrate/20140508030039_create_attachmentstypes.rb create mode 100644 db/migrate/20140508030358_add_attachtype_to_attachments.rb create mode 100644 test/fixtures/attachmentstypes.yml create mode 100644 test/unit/attachmentstype_test.rb diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 73ae44b4..792a1776 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -23,6 +23,7 @@ class Attachment < ActiveRecord::Base belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'" belongs_to :author, :class_name => "User", :foreign_key => "author_id" + belongs_to :attachmentstype, :foreign_key => "attachtype" validates_presence_of :filename, :author validates_length_of :filename, :maximum => 255 diff --git a/app/models/attachmentstype.rb b/app/models/attachmentstype.rb new file mode 100644 index 00000000..1d3c2cfc --- /dev/null +++ b/app/models/attachmentstype.rb @@ -0,0 +1,3 @@ +class Attachmentstype < ActiveRecord::Base + attr_accessible :typeId, :typeName +end diff --git a/db/migrate/20140508030039_create_attachmentstypes.rb b/db/migrate/20140508030039_create_attachmentstypes.rb new file mode 100644 index 00000000..62568634 --- /dev/null +++ b/db/migrate/20140508030039_create_attachmentstypes.rb @@ -0,0 +1,12 @@ +class CreateAttachmentstypes < ActiveRecord::Migration + def self.up + create_table :attachmentstypes do |t| + t.column :typeId, :integer, :null => false + t.column :typeName, :string, :limit =>50 + end + end + + def self.down + drop_table :attachmentstypes + end +end \ No newline at end of file diff --git a/db/migrate/20140508030358_add_attachtype_to_attachments.rb b/db/migrate/20140508030358_add_attachtype_to_attachments.rb new file mode 100644 index 00000000..24a98839 --- /dev/null +++ b/db/migrate/20140508030358_add_attachtype_to_attachments.rb @@ -0,0 +1,5 @@ +class AddAttachtypeToAttachments < ActiveRecord::Migration + def change + add_column :attachments, :attachtype, :int + end +end diff --git a/db/schema.rb b/db/schema.rb index fe23a1ca..2ff8ca00 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140428013546) do +ActiveRecord::Schema.define(:version => 20140508030358) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -36,6 +36,7 @@ ActiveRecord::Schema.define(:version => 20140428013546) do t.datetime "created_on" t.string "description" t.string "disk_directory" + t.integer "attachtype" end add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" @@ -755,11 +756,6 @@ ActiveRecord::Schema.define(:version => 20140428013546) do add_index "time_entries", ["project_id"], :name => "time_entries_project_id" add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - create_table "tmp", :force => true do |t| - t.string "name" - t.string "part_number" - end - create_table "tokens", :force => true do |t| t.integer "user_id", :default => 0, :null => false t.string "action", :limit => 30, :default => "", :null => false @@ -966,10 +962,4 @@ ActiveRecord::Schema.define(:version => 20140428013546) do add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" - create_table "yans", :force => true do |t| - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - end diff --git a/test/fixtures/attachmentstypes.yml b/test/fixtures/attachmentstypes.yml new file mode 100644 index 00000000..429b31b4 --- /dev/null +++ b/test/fixtures/attachmentstypes.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + typeId: + typeName: + +two: + typeId: + typeName: diff --git a/test/unit/attachmentstype_test.rb b/test/unit/attachmentstype_test.rb new file mode 100644 index 00000000..0dcee447 --- /dev/null +++ b/test/unit/attachmentstype_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class AttachmentstypeTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 14dcb18b9635ea06c53ae7925a846f50ffb09fd5 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 9 May 2014 10:20:34 +0800 Subject: [PATCH 04/39] =?UTF-8?q?=E5=B0=86=E4=BD=9C=E4=B8=9A=E6=97=81?= =?UTF-8?q?=E8=BE=B9=E7=9A=84=20=E2=80=9C=E5=A5=BD=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E2=80=9D=EF=BC=8C=E2=80=9C=E7=83=82=E9=97=AE=E9=A2=98=E2=80=9D?= =?UTF-8?q?=20=E9=80=89=E9=A1=B9=E5=8E=BB=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/show.html.erb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/bids/show.html.erb b/app/views/bids/show.html.erb index aaa45c37..8b7e0d8e 100644 --- a/app/views/bids/show.html.erb +++ b/app/views/bids/show.html.erb @@ -20,10 +20,6 @@ <%= render :partial => 'attachments/links', :locals => {:attachments => @bid.attachments, :options => options} %> <% end %>
    - - <%= render :partial => "/praise_tread/praise_tread", - :locals => {:obj => @bid,:show_flag => true,:user_id =>User.current.id}%> -
    @@ -35,6 +31,6 @@ + + From 7a341972e7bd43de0d45ca813e7eccd75959d956 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 9 May 2014 11:47:41 +0800 Subject: [PATCH 05/39] =?UTF-8?q?course=E7=BD=91=E7=AB=99=E4=B8=AD?= =?UTF-8?q?=E5=A4=A7=E5=AD=A6=E5=90=8D=E5=8A=A0=E4=B8=8A=E8=AF=A5=E5=A4=A7?= =?UTF-8?q?=E5=AD=A6=E5=9C=A8=E6=9C=AC=E7=AB=99=E7=9A=84=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/course.html.erb | 4 ++-- public/stylesheets/welcome.css | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index b8b755b5..f2ae619d 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -23,7 +23,7 @@ <%= image_tag(@logoLink, size:'75x75') %> -
    +

    <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> <% else%> @@ -33,7 +33,7 @@ <%= School.find(User.current.user_extensions.school.id).name %>
    <% else %> - <%= School.find(params[:school_id]).name %> + <%= link_to School.find(params[:school_id]).name,options={:action => 'course',:school_id => params[:school_id]}, html_options={:class => 'font_welcome_school',:method => 'get'}%>
    <% end %> <% end %> diff --git a/public/stylesheets/welcome.css b/public/stylesheets/welcome.css index 2533305f..f7756e5b 100644 --- a/public/stylesheets/welcome.css +++ b/public/stylesheets/welcome.css @@ -452,4 +452,15 @@ a.attachments_list_color { font-size: 10pt; } - /************************** 贴吧动态 结束 **************************** \ No newline at end of file + /************************** 贴吧动态 结束 ****************************/ + /************************** 学校课程 开始 ****************************/ + .course{ + + } + .course .font_welcome_school{ + font-family: Tahoma,"Microsoft YaHei"; + font-weight: bold; + font-size: 20px; + color:#e8770d; +} +/************************** 学校课程 结束 ****************************/ \ No newline at end of file From 425e2bb11ea76d27cd056b8cb65565cd816a2ed6 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 9 May 2014 14:18:38 +0800 Subject: [PATCH 06/39] =?UTF-8?q?course=E7=BD=91=E7=AB=99=E4=B8=AD?= =?UTF-8?q?=E6=9C=AA=E9=80=89=E5=AD=A6=E6=A0=A1=EF=BC=8C=E6=9C=89=E7=99=BB?= =?UTF-8?q?=E9=99=86=E7=94=A8=E6=88=B7=EF=BC=8C=E4=B8=94=E7=99=BB=E9=99=86?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=B7=B2=E5=A1=AB=E5=AD=A6=E6=A0=A1=E6=97=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/course.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index f2ae619d..40df3d07 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -30,10 +30,10 @@ <% if params[:school_id] == "0" %> <% else %> <% if params[:school_id].nil? %> - <%= School.find(User.current.user_extensions.school.id).name %> + <%= link_to School.find(User.current.user_extensions.school.id).name, options={:action => 'course',:school_id => User.current.user_extensions.school.id}, html_options={:class => 'font_welcome_school',:method => 'get'}%>
    <% else %> - <%= link_to School.find(params[:school_id]).name,options={:action => 'course',:school_id => params[:school_id]}, html_options={:class => 'font_welcome_school',:method => 'get'}%> + <%= link_to School.find(params[:school_id]).name ,options={:action => 'course',:school_id => params[:school_id]}, html_options={:class => 'font_welcome_school',:method => 'get'}%>
    <% end %> <% end %> From 2077b1e8b8f14ec61f75b1ba23f5df1bde4ab6ba Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 9 May 2014 14:49:03 +0800 Subject: [PATCH 07/39] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=EF=BC=8C=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B=E9=A1=B5=E9=9D=A2=E9=97=AE=E9=A2=98=E5=8F=8D=E9=A6=88?= =?UTF-8?q?=E5=89=8D=E6=B7=BB=E5=8A=A0=E5=90=A7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/contest.html.erb | 4 ++-- app/views/welcome/course.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index daeca6de..a5104695 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -183,8 +183,8 @@ <% find_new_forum_topics(11).each do |topic|%>
  • -       - <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %> +       + <%= 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;" %>
    <%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前 diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 40df3d07..14277afe 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -113,8 +113,8 @@ <% find_new_forum_topics(10).each do |topic|%>
  • -       - <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %> +       + <%= 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;" %>
    <%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前 From 753746f833b28d2c624227ddb16a8b5b6b6aba4c Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 9 May 2014 15:45:21 +0800 Subject: [PATCH 08/39] =?UTF-8?q?1.=E9=A1=B9=E7=9B=AE=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=88=86=E7=B1=BB=202.=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=8F=82=E6=95=B0=203.=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 2 +- app/models/attachment.rb | 6 ++++++ app/models/project.rb | 14 +++++++++----- app/views/files/_new.html.erb | 9 +++++++++ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 86a20d3e..dc60b24a 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -53,7 +53,7 @@ class FilesController < ApplicationController def create container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) - attachments = Attachment.attach_files(container, params[:attachments]) + attachments = Attachment.attach_filesex(container, params[:attachments],params[:attachment_type]) render_attachment_warning_if_needed(container) if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 792a1776..f0533e05 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -261,6 +261,12 @@ class Attachment < ActiveRecord::Base result end + def self.attach_filesex(obj, attachments,attachment_type) + result = obj.save_attachmentsex(attachments, User.current,attachment_type) + obj.attach_saved_attachments + result + end + def self.latest_attach(attachments, filename) attachments.sort_by(&:created_on).reverse.detect { |att| att.filename.downcase == filename.downcase diff --git a/app/models/project.rb b/app/models/project.rb index e0cc27b3..827ed099 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -38,8 +38,7 @@ class Project < ActiveRecord::Base :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})" has_many :users, :through => :members has_many :principals, :through => :member_principals, :source => :principal - - has_many :enabled_modules, :dependent => :delete_all + has_many :enabled_modules, :dependent => :delete_all has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position" has_many :issues, :dependent => :destroy, :include => [:status, :tracker] has_many :issue_changes, :through => :issues, :source => :journals @@ -159,8 +158,12 @@ class Project < ActiveRecord::Base def new_course self.where('project_type = ?', 1) end - - + + # 获取项目的资源类型列表 + def attachmenttypes + @attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ]) + end + # 项目留言 added by fq def self.add_jour(user, notes) project = Project.find('trustie') @@ -726,7 +729,8 @@ class Project < ActiveRecord::Base 'custom_fields', 'tracker_ids', 'issue_custom_field_ids', - 'project_type' + 'project_type', + 'attachmenttype' diff --git a/app/views/files/_new.html.erb b/app/views/files/_new.html.erb index ac5dce46..fcb916e3 100644 --- a/app/views/files/_new.html.erb +++ b/app/views/files/_new.html.erb @@ -1,5 +1,6 @@

    <%=l(:label_attachment_new)%>

    <% versions = project.versions.sort %> +<% attachmenttypes = project.attachmenttypes %> <%= error_messages_for 'attachment' %> <%= form_tag(project_files_path(project), :multipart => true, :class => "tabular") do %>
    @@ -10,6 +11,14 @@ options_from_collection_for_select(versions, "id", "name") %>

    <% end %> + <% if attachmenttypes.any? %> +

    + <%= select_tag "attachment_type", content_tag('option', '') + + options_from_collection_for_select(attachmenttypes, "id", + "typeName") %> +

    + <% end %> +

    <%= render :partial => 'attachments/form' %>

    <%= submit_tag l(:button_add) %> From 7ccbc5e88a2918851716b6cf7f516538c16e82d5 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 9 May 2014 17:13:23 +0800 Subject: [PATCH 09/39] =?UTF-8?q?=E8=AF=BE=E6=97=B6=E9=99=90=E5=88=B6?= =?UTF-8?q?=E4=B8=BA=E5=8F=AA=E8=83=BD=E8=BE=93=E5=85=A5=E6=AD=A3=E6=95=B4?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 4 +++ app/models/course.rb | 10 ++++++- app/models/project.rb | 7 +++++ app/views/files/index.html.erb | 6 +++-- app/views/files/show_by_attachtype.html.erb | 26 +++++++++++++++++++ config/locales/en.yml | 1 + config/locales/zh.yml | 1 + ...508030358_add_attachtype_to_attachments.rb | 2 +- db/schema.rb | 11 +++++++- .../lib/acts_as_attachable.rb | 6 +++++ 10 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 app/views/files/show_by_attachtype.html.erb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index dc60b24a..8f2b79bd 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -61,4 +61,8 @@ class FilesController < ApplicationController end redirect_to project_files_path(@project) end + + def show_by_attachtype + + end end diff --git a/app/models/course.rb b/app/models/course.rb index d2f1abfe..9f0c42c6 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -7,6 +7,7 @@ class Course < ActiveRecord::Base belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 has_many :bid validates_presence_of :password, :term + validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/ safe_attributes 'extra', 'time', 'name', @@ -17,7 +18,14 @@ class Course < ActiveRecord::Base 'password', 'term', 'password' - + + #自定义验证 + def validate + if !class_period.match([0-9]) + errors.add_to_base("class period can only digital") + end + end + def get_endup_time begin end_time = Time.parse(self.endup_time) diff --git a/app/models/project.rb b/app/models/project.rb index 827ed099..007f7e30 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -164,6 +164,13 @@ class Project < ActiveRecord::Base @attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ]) end + #自定义验证 + def validation + if !class_period.match([0-9]) + errors.add_to_base("class period can only digital") + end + end + # 项目留言 added by fq def self.add_jour(user, notes) project = Project.find('trustie') diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 7552b994..b9da42d9 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -174,6 +174,8 @@ div.pagination{ <% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> + + @@ -190,7 +192,7 @@ div.pagination{ <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> - + <% @containers.each do |container| %> <% next if container.attachments.empty? -%> <% if container.is_a?(Version) -%> @@ -233,7 +235,7 @@ div.pagination{ <% html_title(l(:label_attachment_plural)) -%> - + +<%inited=false%> + \ No newline at end of file diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index b9da42d9..0a367e7e 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,133 +1,179 @@ +<%isCategoryBrowser=false%> +<% selAttachType =1%> +<% attachmenttypes = @project.attachmenttypes %> - + <%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区
    @@ -137,144 +183,231 @@ div.pagination{ <%#= link_to('上传文件', new_project_file_path(@project), :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %> <%= link_to( l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %> <%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %> + + <% if attachmenttypes.any? %> + + <%= select_tag "attachment_browse", content_tag('option', '') +options_from_collection_for_select(attachmenttypes, "id", "typeName"), + :onchange=>"attachmenttypes_search(this.value)"%> + <% end %> + +
    + - + <%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:project_id => @project.id, :format => 'js') }')" %> <% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> - -
    - - - - +<%if !isCategoryBrowser%> +
    +
      +
    + + - - - <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> - <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> - <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> - <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> - <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> - - + + + + + <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> + <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> + <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> + <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> + <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> + <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> + + <% @containers.each do |container| %> - <% next if container.attachments.empty? -%> - <% if container.is_a?(Version) -%> - - - - <% end -%> - <% container.attachments.each do |file| %> - "> - - - - - - - - - - - <% end -%> - <% reset_cycle %> + <% next if container.attachments.empty? -%> + <% if container.is_a?(Version) -%> + + + + <% end -%> + <% container.attachments.each do |file| %> + "> + + + + + + + + + + + + <% end -%> + <% reset_cycle %> <% end -%> - -
    - <%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %> -
    <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.downloads %> - <%= link_to(image_tag('delete.png'), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> -
    -
    - <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> -
    -
    - -
    + <%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %> +
    <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> + <%= link_to(image_tag('delete.png'), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> +
    +
    + <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> +
    +
    + +
    + + + +
    +<%else%> +
    +
      + + + + + + + + + + <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> + <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> + <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> + <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> + <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> + <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> + + + + <% @containers.each do |container| %> + <% next if container.attachments.empty? -%> + <% container.attachments.each do |file| %> + <% if file.attachtype==selAttachType%> + "> + + + + + + + + + + + + <% end -%> + <% end -%> + <% reset_cycle %> + <% end -%> + + + +
      <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> + <%= link_to(image_tag('delete.png'), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> +
      +
      + <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> +
      +
      + +
      +
    +
    + <%end%> <% html_title(l(:label_attachment_plural)) -%> + +<%inited=false%> + \ No newline at end of file diff --git a/app/views/files/show_by_attachtype.html.erb b/app/views/files/show_by_attachtype.html.erb index 7610a1ae..bd9db346 100644 --- a/app/views/files/show_by_attachtype.html.erb +++ b/app/views/files/show_by_attachtype.html.erb @@ -1,26 +1,421 @@ -

    <%=l(:label_attachment_new)%>

    -<% versions = project.versions.sort %> -<% attachmenttypes = project.attachmenttypes %> -<%= error_messages_for 'attachment' %> -<%= form_tag(project_files_path(project), :multipart => true, :class => "tabular") do %> -
    + +<%isCategoryBrowser=false%> +<% selAttachType =1%> +<% attachmenttypes = @project.attachmenttypes %> + - <% if versions.any? %> -

    - <%= select_tag "version_id", content_tag('option', '') + - options_from_collection_for_select(versions, "id", "name") %>

    - <% end %> - <% if attachmenttypes.any? %> -

    - <%= select_tag "attachment_type", content_tag('option', '') + - options_from_collection_for_select(attachmenttypes, "id", - "typeName") %> -

    - <% end %> +<%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区 -

    <%= render :partial => 'attachments/form' %>

    +
    + <%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %> +
    +
    + <%#= link_to('上传文件', new_project_file_path(@project), :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %> + <%= link_to( l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %> + <%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %> + + <% if attachmenttypes.any? %> + + <%= select_tag "attachment_browse", content_tag('option', '') +options_from_collection_for_select(attachmenttypes, "id", "typeName"), + :onchange=>"attachmenttypes_search(this.value)"%> + <% end %> + + - <%= submit_tag l(:button_add) %> -<% end %> -
    \ No newline at end of file + +
    + +
    +<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:project_id => @project.id, :format => 'js') }')" %> + + +<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> + +<%if !isCategoryBrowser%> +
    +
      + + + + + + + + + + <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> + <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> + <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> + <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> + <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> + <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> + + + + <% @containers.each do |container| %> + <% next if container.attachments.empty? -%> + <% if container.is_a?(Version) -%> + + + + <% end -%> + <% container.attachments.each do |file| %> + "> + + + + + + + + + + + + <% end -%> + <% reset_cycle %> + <% end -%> + + + + +
      + <%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %> +
      <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> + <%= link_to(image_tag('delete.png'), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> +
      +
      + <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> +
      +
      + +
      +
    +
    +<%else%> +
    +
      + + + + + + + + + + <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> + <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> + <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> + <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> + <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> + <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> + + + + <% @containers.each do |container| %> + <% next if container.attachments.empty? -%> + <% container.attachments.each do |file| %> + <% if file.attachtype==selAttachType%> + "> + + + + + + + + + + + + <% end -%> + <% end -%> + <% reset_cycle %> + <% end -%> + + + + +
      <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> + <%= link_to(image_tag('delete.png'), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> +
      +
      + <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> +
      +
      + +
      +
    +
    +<%end%> +<% html_title(l(:label_attachment_plural)) -%> + + + +<%inited=false%> + \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index b5c59808..b092c3d1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -132,6 +132,7 @@ en: actionview_instancetag_blank_option: Please select + attachment_browse: 'Attachment Browse' attachment_type: 'Attachment Type' general_text_No: 'No' general_text_Yes: 'Yes' diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 902a1829..e8fafa47 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -140,6 +140,7 @@ zh: actionview_instancetag_blank_option: 请选择 + attachment_browse: '分类浏览' attachment_type: '资源分类' general_text_No: '否' general_text_Yes: '是' diff --git a/config/routes.rb b/config/routes.rb index be0d11ce..d804e5b0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,73 +16,73 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do - resources :no_uses - delete 'no_uses', :to => 'no_uses#delete' - - resources :apply_project_masters - delete 'apply_project_masters', :to => 'apply_project_masters#delete' - - - resources :open_source_projects do - collection do - match 'search', via: [:get, :post] - match 'remove_condition', via: [:get, :post] - end - resources :relative_memos - member do - match 'master_apply', via: [:get, :post] - match 'accept_master_apply', via: [:get, :post] - match 'refuse_master_apply', via: [:get, :post] - end - end - mount SeemsRateable::Engine => '/rateable', :as => :rateable - - namespace :zipdown do - match 'assort' - end - namespace :test do - match 'courselist' - match 'zip' - end - ##new added by linchun #以发布应用的形式参与竞赛 - resources :softapplications do - - collection do - match 'new_message', via: :get - end - member do - match 'create_message' , via: :post - end - end - - ## new added by linchun #新竞赛相关 - resources :contests, only: [:index] do - collection do - match 'new_contest' , via: :get - match 'join_in_contest' , via: :post - match 'unjoin_in_contest' , via: :delete - match 'create_contest' , via: :post - match 'new_join' , via: :post - match 'new' , via: :post - end - member do - match 'add_softapplication' - match 'update_contest' , via: [:put] - match 'show_contest' , via: :get - match 'show_project' , via: :get - match 'show_softapplication', via: :get - match 'show_participator' , via: :get - match 'add' , via: [:get, :post] - match 'add_softapplication' , via: [:get, :post] - match 'create' , via: :post - match 'settings' , via: [:get, :post] - end - end - + resources :no_uses + delete 'no_uses', :to => 'no_uses#delete' + + resources :apply_project_masters + delete 'apply_project_masters', :to => 'apply_project_masters#delete' + + + resources :open_source_projects do + collection do + match 'search', via: [:get, :post] + match 'remove_condition', via: [:get, :post] + end + resources :relative_memos + member do + match 'master_apply', via: [:get, :post] + match 'accept_master_apply', via: [:get, :post] + match 'refuse_master_apply', via: [:get, :post] + end + end + mount SeemsRateable::Engine => '/rateable', :as => :rateable + + namespace :zipdown do + match 'assort' + end + namespace :test do + match 'courselist' + match 'zip' + end + ##new added by linchun #以发布应用的形式参与竞赛 + resources :softapplications do + + collection do + match 'new_message', via: :get + end + member do + match 'create_message' , via: :post + end + end + + ## new added by linchun #新竞赛相关 + resources :contests, only: [:index] do + collection do + match 'new_contest' , via: :get + match 'join_in_contest' , via: :post + match 'unjoin_in_contest' , via: :delete + match 'create_contest' , via: :post + match 'new_join' , via: :post + match 'new' , via: :post + end + member do + match 'add_softapplication' + match 'update_contest' , via: [:put] + match 'show_contest' , via: :get + match 'show_project' , via: :get + match 'show_softapplication', via: :get + match 'show_participator' , via: :get + match 'add' , via: [:get, :post] + match 'add_softapplication' , via: [:get, :post] + match 'create' , via: :post + match 'settings' , via: [:get, :post] + end + end + resources :stores do collection do match 'search', via: [:get, :post] - end + end end resources :forums do @@ -100,20 +100,20 @@ RedmineApp::Application.routes.draw do end end - resources :shares + resources :shares #added by william get "tags/index" - + get "tags/show" - + get "praise_tread/praise_plus" get "praise_tread/tread_plus" #end root :to => 'welcome#index', :as => 'home' - + #added by baiyu match 'git_usage/ch_usage', :controller => 'git_usage', :action => 'ch_usage', :via => :get, :as => 'ch_usage' match 'git_usage/en_usage', :controller => 'git_usage', :action => 'en_usage', :via => :get, :as => 'en_usage' @@ -167,21 +167,21 @@ RedmineApp::Application.routes.draw do get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report' get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details' post '/users/:id/user_activities', :to => 'users#show', :as => "user_activities" - + #added by young - resources :users do + resources :users do member do match 'user_projects', :to => 'users#user_projects', :via => :get match 'user_activities', :to => 'users#show', :via => :get, :as => "user_activities" - match 'user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "user_newfeedback" - match 'watch_calls', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] + match 'user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "user_newfeedback" + match 'watch_calls', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] match 'info', :to => 'users#info', :via => [:get , :post], :as => 'user_info' match 'user_watchlist', :to => 'users#user_watchlist', :via => :get, :as => "user_watchlist" #add by huang match 'user_fanslist', :to => 'users#user_fanslist', :via => :get, :as => "user_fanslist" #add by huang match 'user_courses', :to => 'users#user_courses', :via => :get match 'user_homeworks', :to => 'users#user_homeworks', :via => :get - match 'watch_projects', :to => 'users#watch_projects', :via => :get - # added by bai + match 'watch_projects', :to => 'users#watch_projects', :via => :get + # added by bai match 'show_score', :to => 'users#show_score', :via => :get match 'topic_score_index', :controller => 'users', :action => 'topic_score_index', :via => [:get, :post] match 'project_score_index', :to => 'users#project_score_index', :via => :get @@ -195,13 +195,13 @@ RedmineApp::Application.routes.draw do match 'file_score_index', :to => 'projects#file_score_index', :via => [:get, :post] match 'code_submit_score_index', :to => 'projects#code_submit_score_index', :via => [:get, :post] match 'projects_topic_score_index', :to => 'projects#projects_topic_score_index', :via => [:get, :post] - # end + # end end end match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" match 'users/:id/user_projects', :controller => 'users', :action => 'user_projects', :via => :get - #match 'user/:id/watch_calls', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] - + #match 'user/:id/watch_calls', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] + #end match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post] match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post] @@ -276,7 +276,7 @@ RedmineApp::Application.routes.draw do # get 'projects/:project_id/repository', :to => 'repositories#show', :as => 'project_repository' # match '/show', :controller => 'projects', :action => 'show', :as => 'project_show', :via => :get - match '/watcherlist', :controller=>'projects', :action=> 'watcherlist', :as => 'watcherlist', :via => :get #add by huang + match '/watcherlist', :controller=>'projects', :action=> 'watcherlist', :as => 'watcherlist', :via => :get #add by huang # matche '/news', :controller => 'news', :action => 'index', :as => 'news', :via => :get #end @@ -299,7 +299,7 @@ RedmineApp::Application.routes.draw do # issue form update match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form' - resources :files, :only => [:index, :new, :create] + resources :files, :only => [:index, :new, :create,:showbyattachtype] resources :versions, :except => [:index, :show, :edit, :update, :destroy] do collection do @@ -326,7 +326,7 @@ RedmineApp::Application.routes.draw do resources :repositories, :except => [:index, :show] do member do get 'newrepo', :via => [:get, :post] - # get 'create', :via=>[:get, :post] + # get 'create', :via=>[:get, :post] end end match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get @@ -518,10 +518,10 @@ RedmineApp::Application.routes.draw do match 'uploads', :to => 'attachments#upload', :via => :post # Added by Tao - match 'upload_avatar', :to => 'avatar#upload', :via => :post + match 'upload_avatar', :to => 'avatar#upload', :via => :post # Endof Tao's code get 'robots.txt', :to => 'welcome#robots' - + ##############测试留言功能 fq post 'words/new', :to => 'words#new' post 'words/create', :to => 'words#create' @@ -545,7 +545,7 @@ RedmineApp::Application.routes.draw do match 'calls/:id/new_submit_homework', to: 'bids#new_submit_homework', via: :get, as: 'new_submit_homework' match 'words/add_project_respond', :controller => 'words', :action => 'add_project_respond' match 'words/:id/leave_project_message', :controller => 'words', :action => 'leave_project_message' - + match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback' match 'calls/create_bid', :to => 'bids#create_bid' match 'contest/create_contest', :to => 'bids#create_contest' #huang @@ -559,24 +559,24 @@ RedmineApp::Application.routes.draw do match 'calls/:id/show_course', :to => 'bids#show_course', :as => 'show_course' match 'calls/:id/show_bid_project', :to => 'bids#show_bid_project', :as => 'show_bid_project' match 'calls/:id/show_bid_user', :to => 'bids#show_bid_user', :as => 'show_bid_user' - + match 'project/:id/share', :to => 'projects#share', :as => 'share_show' #share - - post 'join_in/join', :to => 'courses#join', :as => 'join' + + post 'join_in/join', :to => 'courses#join', :as => 'join' delete 'join_in/join', :to => 'courses#unjoin' post 'calls/:id/join_in_contest', :to => 'bids#join_in_contest', :as => 'join_in_contest' delete 'calls/:id/join_in_contest', :to => 'bids#unjoin_in_contest' match 'calls/:id/show_participator', :to => 'bids#show_participator' #bai match 'calls/:id/update_contest', :to => 'bids#update_contest' #bai match 'calls/:id/settings', :to => 'bids#settings' #bai - + delete 'attachment/:id', :to => 'attachments#delete_homework' match 'new_join', :to => 'projects#new_join', :as => 'try_join' match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest' match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post match 'calls/:id/manage',:to => 'bids#manage',:via => [:get,:post] match 'project/course', :to => 'projects#course', :as => 'course' - + #added by william # match 'calls/:id/set_results',:controller => 'bids', :action => 'set_results',:via => [:get,:post],:as => 'set_results' # match 'calls/:id/set_prizes',:controller => 'bids',:action => 'set_prizes',:as => 'set_prizes' @@ -584,10 +584,10 @@ RedmineApp::Application.routes.draw do # added by young match 'calls', :controller => 'bids', :action => 'index' - + match 'calls/:id', :controller => 'bids', :action => 'show', :as => 'respond' match 'contest', :controller => 'bids', :action => 'contests', :as => 'contest' #modified @20140403 - + ######################## ##added by wen########## @@ -616,7 +616,7 @@ RedmineApp::Application.routes.draw do match 'parise_tread/tread_plus',:to => 'parise_tread#tread_plus',:as=>"tread" match 'tags/delete',:to=>'tags#delete' match 'tags/remove_tag',:to=>'tags#remove_tag',:as=>"remove_tag" - + match 'words/add_brief_introdution', :controller => 'words', :action => 'add_brief_introdution' Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir| From 5d2bb4ccbdafedbab3ac6d206c375284bfe5a39e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 13 May 2014 10:30:15 +0800 Subject: [PATCH 14/39] =?UTF-8?q?1.=E9=80=89=E6=8B=A9=E5=AD=A6=E6=A0=A1?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E5=AD=A6=E6=A0=A1=E8=AF=BE=E7=A8=8B=E5=88=97?= =?UTF-8?q?=E8=A1=A8=EF=BC=8C=E7=82=B9=E5=87=BB=E6=9B=B4=E5=A4=9A=E7=94=B1?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=89=80=E6=9C=89=E8=AF=BE=E7=A8=8B=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E6=94=B9=E4=B8=BA=E6=98=BE=E7=A4=BA=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E6=8E=92=E5=BA=8F=E4=B9=9F=E4=B8=80=E6=A0=B7?= =?UTF-8?q?=202.=E5=BD=93=E6=9F=A5=E8=AF=A2=E5=AD=A6=E6=A0=A1=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=88=97=E8=A1=A8=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E6=94=B9=E4=B8=BA=E6=9C=AC=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E4=B8=AD=E6=9C=AC=E5=B9=B4=E5=BA=A6=E5=BC=80=E8=AE=BE=E7=9A=84?= =?UTF-8?q?=E6=9C=80=E5=A5=BD=E7=9A=84=E8=AF=BE=E7=A8=8B=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E8=AF=BE=E7=A8=8B=E3=80=82=E6=AD=A4=E6=97=B6?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=9B=B4=E5=A4=9A=E6=9F=A5=E7=9C=8B=E7=9A=84?= =?UTF-8?q?=E4=B8=BA=E6=89=80=E6=9C=89=E8=AF=BE=E7=A8=8B=203.=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=87=BA=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8=E5=B0=86?= =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E5=92=8C=E6=95=99=E5=B8=88=E6=94=BE=E5=9C=A8?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=B8=8A=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 2 +- app/helpers/projects_helper.rb | 26 +- app/helpers/welcome_helper.rb | 6 + app/views/projects/course.html.erb | 2 +- app/views/welcome/course.html.erb | 321 +++++++++++++------------ 5 files changed, 185 insertions(+), 172 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d26cf698..a120394e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -198,7 +198,7 @@ class ProjectsController < ApplicationController @project_type = params[:project_type] @school_id = params[:school_id] per_page_option = 10 - if @school_id == "0" or @school.nil? + if @school_id == "0" or @school_id.nil? @projects_all = Project.active.visible. joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id"). where("#{Project.table_name}.project_type = ? ", Project::ProjectType_course) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 5bd677bd..bddf9d0d 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -62,33 +62,33 @@ module ProjectsHelper content_tag('div', content, :class => "tabs_enterprise") end - def sort_course(state, project_type) + def sort_course(state, project_type, school_id) content = ''.html_safe case state when 0 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :school_id => school_id, :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) when 1 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id), :class=>"selected"), :class=>"selected") # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) when 2 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id))) #gcm when 3 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type, :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type, :school_id => school_id))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type, :school_id => school_id), :class=>"selected"), :class=>"selected") end #gcmend diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index ed435fe6..e05f789a 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -154,6 +154,12 @@ module WelcomeHelper sort_course_by_hot limit end + def find_all_new_hot_course limit = 9 + #sort_project_by_hot_rails 1, 'course_ac_para DESC', limit + time_now = Time.new.strftime("%Y"); + Project.visible.joins(:project_status).where("#{Project.table_name}.project_type = ? and #{Project.table_name}.created_on like '%#{time_now}%'", 1).order("course_ac_para DESC").limit(limit).all + end + def find_all_hot_bid sort_bid_by_hot end diff --git a/app/views/projects/course.html.erb b/app/views/projects/course.html.erb index 1359b8be..98228c16 100644 --- a/app/views/projects/course.html.erb +++ b/app/views/projects/course.html.erb @@ -30,7 +30,7 @@ <% end %>
    -<%= sort_course(@s_type, @project_type)%> +<%= sort_course(@s_type, @project_type, @school_id)%>
    <%= render_project_hierarchy(@projects)%> diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 286ff60d..005f5371 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -1,197 +1,204 @@ <%= stylesheet_link_tag 'welcome' %> <%= javascript_include_tag 'welcome' %>
    - -
    -
    - <%= image_tag(@logoLink, size:'75x75') %> + +
    +
    + <%= image_tag(@logoLink, size:'75x75') %> -
    -
    -
    +
    +
    +
    <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> - <% else%> + <% else%> <% if params[:school_id] == "0" %> - <% else %> + <% else %> <% if params[:school_id].nil? %> <%= link_to School.find(User.current.user_extensions.school.id).name, options={:action => 'course',:school_id => User.current.user_extensions.school.id}, html_options={:class => 'font_welcome_school',:method => 'get'}%> -
    +
    <% else %> <%= link_to School.find(params[:school_id]).name ,options={:action => 'course',:school_id => params[:school_id]}, html_options={:class => 'font_welcome_school',:method => 'get'}%> -
    +
    <% end %> <% end %> <% end %>
    - <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> - <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> - , <%= l(:label_welcome_trustie_course_description) %> - <% else %> - <% if params[:school_id] == "0" %> - , <%= l(:label_welcome_trustie_course_description) %> - <% end %> - <% end %> -
    - -
    -
    + <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> + <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> + , <%= l(:label_welcome_trustie_course_description) %> + <% else %> + <% if params[:school_id] == "0" %> + , <%= l(:label_welcome_trustie_course_description) %> + <% end %> + <% end %> +
    + +
    +
    -
    +
    -

    新开课程

    - <%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => params[:school_id]} %> -
    -
      +

      新开课程

      + <% if(find_miracle_course(10, 7,params[:school_id]).map.count == 0) %> + <%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => nil} %> +
      +
        -
      - -
        - <% if(find_miracle_course(10, 7,params[:school_id]).map.count == 0) %> -

        -

        - 该学校未开设任何课程,您可以查看其他学校课程 -

        -

        - <% find_all_hot_course(9).map do |project| %> -
      • > -
        - <%= image_tag(get_course_avatar(project), :class => "avatar-4") %> -
        - -
        - [<%= get_course_term project %>] - <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%> - (<%= link_to "#{studentCount(project)}人", project_member_path(project, :role => 2) ,:course =>'1' %>) - <% 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) %>资料) -
        -
        - - <% course = Course.find_by_extra(project.identifier)%> - <% if(course.school == nil) %> -               - <% else %> - <%= course.school.name.try(:gsub, /(.+)$/, '\1:') %> - <% end %> - - - <%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %> - <%#=course.try(:teacher).try(:name)%> - -
        - - -
      • - <% end %> - <% else %> - <% find_miracle_course(10, 7,params[:school_id]).map do |project| %> -
      • > -
        - <%= image_tag(get_course_avatar(project), :class => "avatar-4") %> -
        - -
        - [<%= get_course_term project %>] - <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%> - (<%= link_to "#{studentCount(project)}人", project_member_path(project, :role => 2) ,:course =>'1' %>) - <% 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) %>资料) -
        -
        - - <% course = Course.find_by_extra(project.identifier) %> - <%= course.school.name.try(:gsub, /(.+)$/, '\1:') %> - - - <%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %> +
      +
        +

        +

        + 该学校未开设任何课程,您可以查看其他学校课程 +

        +

        + <% find_all_new_hot_course(9).map do |project| %> +
      • > +
        + <%= image_tag(get_course_avatar(project), :class => "avatar-4") %> +
        + +
        + + <% course = Course.find_by_extra(project.identifier)%> + <% if(course.school == nil) %> +               + <% else %> + <%= course.school.name.try(:gsub, /(.+)$/, '\1:') %> + <% end %> + + + <%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %> <%#=course.try(:teacher).try(:name)%> - -
        - - -
      • - <% end; reset_cycle %> + +
      +
      + [<%= get_course_term project %>] + <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%> + (<%= link_to "#{studentCount(project)}人", project_member_path(project, :role => 2) ,:course =>'1' %>) + <% 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) %>资料) +
      + +
      + <% if !course_endTime_timeout?(project)%> +
      + <%= new_watcher_link(project, User.current)%> +
      + <% end %> +
      + <% end %> -
    -
    + +
    + <% else %> + <%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => params[:school_id]} %> +
    +
      + +
    +
      + <% find_miracle_course(10, 7,params[:school_id]).map do |project| %> +
    • > +
      + <%= image_tag(get_course_avatar(project), :class => "avatar-4") %> +
      + +
      + + <% course = Course.find_by_extra(project.identifier) %> + <%= course.school.name.try(:gsub, /(.+)$/, '\1:') %> + + + <%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %> + <%#=course.try(:teacher).try(:name)%> + +
      +
      + [<%= get_course_term project %>] + <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%> + (<%= link_to "#{studentCount(project)}人", project_member_path(project, :role => 2) ,:course =>'1' %>) + <% 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) %>资料) +
      + + +
    • + <% end; reset_cycle %> +
    +
    + <% end %>
    -

    - 问题和反馈动态 - <%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> - <%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> -

    - <%= link_to "更多>>", forums_path %> -
    -
      - <% find_new_forum_topics(10).each do |topic|%> -
    • -
      +

      + 问题和反馈动态 + <%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> + <%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> +

      + <%= link_to "更多>>", forums_path %> +
      +
        + <% find_new_forum_topics(10).each do |topic|%> +
      • +
              <%= 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;" %> -
        - <%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前 +
        + <%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前 由 <%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);" %> 发表 - 回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url %>) -
        -
      • - <% end %> -
      -
      + 回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url %>) +
      +
    • + <% end %> +
    +
    \ No newline at end of file From 75f584a6e25b2f69891ac07aaf0538d3829c40ee Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 13 May 2014 11:54:21 +0800 Subject: [PATCH 15/39] =?UTF-8?q?1.=E5=AE=8C=E6=88=90=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=B8=8B=E8=BD=BD=E8=A7=86=E5=9B=BE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=202.=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 21 +- app/controllers/school_controller.rb | 2 +- app/views/files/_show_all_attachment.html.erb | 61 +++ app/views/files/_show_by_attachtype.html.erb | 421 ------------------ app/views/files/_sort_by_attachtypel.html.erb | 57 +++ app/views/files/getattachtype.js.erb | 5 + app/views/files/index.html.erb | 151 +------ app/views/files/show_by_attachtype.html.erb | 421 ------------------ config/routes.rb | 9 +- 9 files changed, 158 insertions(+), 990 deletions(-) create mode 100644 app/views/files/_show_all_attachment.html.erb delete mode 100644 app/views/files/_show_by_attachtype.html.erb create mode 100644 app/views/files/_sort_by_attachtypel.html.erb create mode 100644 app/views/files/getattachtype.js.erb delete mode 100644 app/views/files/show_by_attachtype.html.erb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c67310f6..075a54f6 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -19,8 +19,8 @@ class FilesController < ApplicationController layout 'base_projects'#by young menu_item :files - before_filter :find_project_by_project_id - before_filter :authorize + before_filter :find_project_by_project_id#, :except => [:getattachtype] + before_filter :authorize, :except => [:getattachtype] helper :sort include SortHelper @@ -62,20 +62,21 @@ class FilesController < ApplicationController redirect_to project_files_path(@project) end - def showbyattachtype - sort_init 'created_on', 'desc' - sort_update 'created_on' => "#{Attachment.table_name}.created_on", + # 返回制定资源类型的资源列表 + def getattachtype + sort_init 'created_on', 'desc' + sort_update 'created_on' => "#{Attachment.table_name}.created_on", 'filename' => "#{Attachment.table_name}.filename", 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" - + @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort + + @attachtype = params[:type].to_i - if @project.project_type == 1 - render :layout => 'base_courses' - else - render :layout => !request.xhr? + respond_to do |format| + format.js end end end diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index b4f5b046..b8fb7a6f 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -23,7 +23,7 @@ class SchoolController < ApplicationController end end - + def upload_logo end diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb new file mode 100644 index 00000000..c65f58cc --- /dev/null +++ b/app/views/files/_show_all_attachment.html.erb @@ -0,0 +1,61 @@ +<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> +
      + + + + + + + + + + <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> + <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> + <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> + <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> + <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> + <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> + + + + <% @containers.each do |container| %> + <% next if container.attachments.empty? -%> + <% if container.is_a?(Version) -%> + + + + <% end -%> + <% container.attachments.each do |file| %> + "> + + + + + + + + + + + + <% end -%> + <% reset_cycle %> + <% end -%> + + + + +
      + <%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %> +
      <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> + <%= link_to(image_tag('delete.png'), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> +
      +
      + <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> +
      +
      + +
      +
    diff --git a/app/views/files/_show_by_attachtype.html.erb b/app/views/files/_show_by_attachtype.html.erb deleted file mode 100644 index eedc9068..00000000 --- a/app/views/files/_show_by_attachtype.html.erb +++ /dev/null @@ -1,421 +0,0 @@ - -<%isCategoryBrowser=true%> -<% selAttachType =1%> -<% attachmenttypes = @project.attachmenttypes %> - - - -<%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区 - -
    - <%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %> -
    -
    - <%#= link_to('上传文件', new_project_file_path(@project), :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %> - <%= link_to( l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %> - <%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %> - - <% if attachmenttypes.any? %> - - <%= select_tag "attachment_browse", content_tag('option', '') +options_from_collection_for_select(attachmenttypes, "id", "typeName"), - :onchange=>"attachmenttypes_search(this.value)"%> - <% end %> - - - -
    - -
    -<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:project_id => @project.id, :format => 'js') }')" %> - - -<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> - -<%if !isCategoryBrowser%> -
    -
      - - - - - - - - - - <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> - <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> - <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> - <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> - <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> - <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> - - - - <% @containers.each do |container| %> - <% next if container.attachments.empty? -%> - <% if container.is_a?(Version) -%> - - - - <% end -%> - <% container.attachments.each do |file| %> - "> - - - - - - - - - - - - <% end -%> - <% reset_cycle %> - <% end -%> - - - - -
      - <%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %> -
      <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> - <%= link_to(image_tag('delete.png'), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> -
      -
      - <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> -
      -
      - -
      -
    -
    -<%else%> -
    -
      - - - - - - - - - - <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> - <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> - <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> - <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> - <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> - <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> - - - - <% @containers.each do |container| %> - <% next if container.attachments.empty? -%> - <% container.attachments.each do |file| %> - <% if file.attachtype==selAttachType%> - "> - - - - - - - - - - - - <% end -%> - <% end -%> - <% reset_cycle %> - <% end -%> - - - - -
      <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> - <%= link_to(image_tag('delete.png'), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> -
      -
      - <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> -
      -
      - -
      -
    -
    -<%end%> -<% html_title(l(:label_attachment_plural)) -%> - - - -<%inited=false%> - \ No newline at end of file diff --git a/app/views/files/_sort_by_attachtypel.html.erb b/app/views/files/_sort_by_attachtypel.html.erb new file mode 100644 index 00000000..d07ed399 --- /dev/null +++ b/app/views/files/_sort_by_attachtypel.html.erb @@ -0,0 +1,57 @@ +<% selAttachType =@attachtype%> +<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> +
    +
      + + + + + + + + + + <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> + <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> + <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> + <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> + <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> + <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> + + + + <% @containers.each do |container| %> + <% next if container.attachments.empty? -%> + <% container.attachments.each do |file| %> + <% if file.attachtype==selAttachType%> + "> + + + + + + + + + + + + <% end -%> + <% end -%> + <% reset_cycle %> + <% end -%> + + + + +
      <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> + <%= link_to(image_tag('delete.png'), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> +
      +
      + <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> +
      +
      + +
      diff --git a/app/views/files/getattachtype.js.erb b/app/views/files/getattachtype.js.erb new file mode 100644 index 00000000..4f13cc88 --- /dev/null +++ b/app/views/files/getattachtype.js.erb @@ -0,0 +1,5 @@ + <% if @attachtype==0%> + $("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>'); + <%else%> + $("#all_browse_div").html('<%= j(render partial: "sort_by_attachtypel")%>'); + <%end%> diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 0a367e7e..490f74f9 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,6 +1,4 @@ -<%isCategoryBrowser=false%> -<% selAttachType =1%> <% attachmenttypes = @project.attachmenttypes %> - - -<%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区 - -
      - <%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %> -
      -
      - <%#= link_to('上传文件', new_project_file_path(@project), :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %> - <%= link_to( l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %> - <%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %> - - <% if attachmenttypes.any? %> - - <%= select_tag "attachment_browse", content_tag('option', '') +options_from_collection_for_select(attachmenttypes, "id", "typeName"), - :onchange=>"attachmenttypes_search(this.value)"%> - <% end %> - - - -
      - -
      -<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:project_id => @project.id, :format => 'js') }')" %> - - -<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> - -<%if !isCategoryBrowser%> -
      -
        - - - - - - - - - - <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> - <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> - <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> - <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> - <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> - <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> - - - - <% @containers.each do |container| %> - <% next if container.attachments.empty? -%> - <% if container.is_a?(Version) -%> - - - - <% end -%> - <% container.attachments.each do |file| %> - "> - - - - - - - - - - - - <% end -%> - <% reset_cycle %> - <% end -%> - - - - -
        - <%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %> -
        <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> - <%= link_to(image_tag('delete.png'), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> -
        -
        - <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> -
        -
        - -
        -
      -
      -<%else%> -
      -
        - - - - - - - - - - <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> - <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> - <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> - <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> - <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> - <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> - - - - <% @containers.each do |container| %> - <% next if container.attachments.empty? -%> - <% container.attachments.each do |file| %> - <% if file.attachtype==selAttachType%> - "> - - - - - - - - - - - - <% end -%> - <% end -%> - <% reset_cycle %> - <% end -%> - - - - -
        <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> - <%= link_to(image_tag('delete.png'), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> -
        -
        - <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> -
        -
        - -
        -
      -
      -<%end%> -<% html_title(l(:label_attachment_plural)) -%> - - - -<%inited=false%> - \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d804e5b0..a5dc322c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,7 +19,7 @@ RedmineApp::Application.routes.draw do resources :no_uses delete 'no_uses', :to => 'no_uses#delete' - resources :apply_project_masters + resources :apply_project_masters delete 'apply_project_masters', :to => 'apply_project_masters#delete' @@ -299,7 +299,12 @@ RedmineApp::Application.routes.draw do # issue form update match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form' - resources :files, :only => [:index, :new, :create,:showbyattachtype] + resources :files, :only => [:index, :new, :create] do + collection do + match "getattachtype" , via: [:get, :post] + #match 'getattachtype/:attachtype', :to => 'files#getattachtype', via: [:get, :post] + end + end resources :versions, :except => [:index, :show, :edit, :update, :destroy] do collection do From 79b498914a18963f157c733e86037ae70d8c6b72 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 13 May 2014 11:56:36 +0800 Subject: [PATCH 16/39] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_sort_by_attachtypel.html.erb | 83 ++++++++++--------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/app/views/files/_sort_by_attachtypel.html.erb b/app/views/files/_sort_by_attachtypel.html.erb index d07ed399..0544a4b6 100644 --- a/app/views/files/_sort_by_attachtypel.html.erb +++ b/app/views/files/_sort_by_attachtypel.html.erb @@ -1,51 +1,54 @@ -<% selAttachType =@attachtype%> +<% selAttachType =@attachtype %> <% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> -
      +
        - +
        - - - - - + + + + + - - <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> - <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> - <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> - <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> - <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> - <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> + + + <%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %> + <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope => "col", :id => "vzebra-comedy") %> + <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %> + <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %> + <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %> + <%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %> - + + <% @containers.each do |container| %> <% next if container.attachments.empty? -%> <% container.attachments.each do |file| %> - <% if file.attachtype==selAttachType%> - "> - - - - - - - - - - - + <% if file.attachtype==selAttachType %> + "> + + + + + + + + + + + <% end -%> <% end -%> <% reset_cycle %> @@ -55,3 +58,5 @@
        <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> - <%= link_to(image_tag('delete.png'), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> -
        -
        - <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> -
        -
        - -
        <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= format_time(file.created_on) %><%= number_to_human_size(file.filesize) %><%= file.attachmentstype.typeName %><%= file.downloads %> + <%= link_to(image_tag('delete.png'), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> +
        +
        + <% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> +
        +
        + +
        +
      +
      \ No newline at end of file From 6e14e0b262c4e16629d92c3d4dbabcbdad3c6b8a Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 13 May 2014 12:01:43 +0800 Subject: [PATCH 17/39] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=88=A0=E9=99=A4=E5=85=A8=E9=83=A8=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E4=BD=8D=E7=BD=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/application.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 723b93bd..7b0a0099 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1840,7 +1840,7 @@ a.remove-upload:hover {text-decoration:none !important;} /*gcm upload file count and deleteall*/ #upload_file_count #count {color:red; font-size:1.5em;} -span.add_attachment .remove_all {background:none;background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block;position:absolute;right:21px;text-decoration:none;} +span.add_attachment .remove_all {background:none;background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block;position:absolute;right:61px;text-decoration:none;} div.fileover { background-color: lavender; } From 73dcf3679d5125d4b07d517bff661cdfb02dd12c Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 13 May 2014 15:11:37 +0800 Subject: [PATCH 18/39] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E3=80=81=E9=A1=B9=E7=9B=AE=E9=85=8D=E7=BD=AE=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/projects_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 5bd677bd..708c23ca 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -32,7 +32,7 @@ module ProjectsHelper {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural}, # {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki}, {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural}, - {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}, + #{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}, {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities} ] tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} @@ -145,7 +145,7 @@ module ProjectsHelper #Added by young def course_settings_tabs tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'}, - {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural, :project_type => 1}, + #{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural, :project_type => 1}, # {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural}, {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural} ] From 284e6ba20aa295a485502caaac69f8ac4aefc927 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 13 May 2014 15:49:14 +0800 Subject: [PATCH 19/39] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E9=83=A8=E5=88=86?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=95=B0=E6=8D=AE=202.=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=B5=84=E6=BA=90=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 24 +++++++++ app/models/attachmentstype.rb | 7 +++ app/models/project.rb | 8 +++ app/views/files/_show_all_attachment.html.erb | 5 +- app/views/files/_sort_by_attachtypel.html.erb | 5 +- app/views/files/index.html.erb | 46 ++++++++++++----- config/environment.rb | 1 + config/locales/en.yml | 5 +- config/locales/zh.yml | 3 +- .../20140508030039_create_attachmentstypes.rb | 6 +++ db/schema.rb | 50 ++++++++++++++++++- 11 files changed, 142 insertions(+), 18 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 6a62613b..3bfd705f 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -66,6 +66,30 @@ class Attachment < ActiveRecord::Base copy end + #获取资源的后缀类型 + def suffix_type + childArr = self.filename.split('.') + suffix = '*' + if childArr.length > 1 + suffix = childArr[childArr.length-1] + end + suffix + end + + #获取用来显示的后缀名称 + def show_suffix_type + suffix = 'other' + temp = self.suffix_type.downcase + if self.attachmentstype.suffixArr.include?(temp) + suffix = temp + end + suffix + end + + def suffixArr + @@SuffixArr + end + def validate_max_file_size if @temp_file && self.filesize > Setting.attachment_max_size.to_i.kilobytes errors.add(:base, l(:error_attachment_too_big, :max_size => Setting.attachment_max_size.to_i.kilobytes)) diff --git a/app/models/attachmentstype.rb b/app/models/attachmentstype.rb index 54102ee7..6a37cc51 100644 --- a/app/models/attachmentstype.rb +++ b/app/models/attachmentstype.rb @@ -1,4 +1,11 @@ class Attachmentstype < ActiveRecord::Base attr_accessible :typeId, :typeName has_many :attachments, :foreign_key => "attachtype",:primary_key => "id" + + # 当前使用的文件内容分类列表 + @@SuffixArr = ['pdf','zip','doc','docx','rar','txt','jpg','bmp','xls','xlsx'] + + def suffixArr + @@SuffixArr + end end diff --git a/app/models/project.rb b/app/models/project.rb index 007f7e30..3c2956a9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -164,6 +164,14 @@ class Project < ActiveRecord::Base @attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ]) end + # 获取资源后缀名列表 + def contenttypes + attachmenttypes + if @attachmenttypes.length >0 + @attachmenttypes.last().suffixArr + end + end + #自定义验证 def validation if !class_period.match([0-9]) diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb index c65f58cc..57ac897d 100644 --- a/app/views/files/_show_all_attachment.html.erb +++ b/app/views/files/_show_all_attachment.html.erb @@ -1,4 +1,5 @@ <% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> +<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
        @@ -12,7 +13,8 @@ <%= sort_header_tag('filename', :caption => l(:field_filename), :scope =>"col" , :id => "vzebra-adventure")%> <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope =>"col" , :id => "vzebra-comedy")%> <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope =>"col", :id=> "vzebra-children")%> - <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> + <%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-attachmenttype")%> + <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%> <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope =>"col", :id => "vzebra-action") %> <%= sort_header_tag('operation', :caption => "", :scope =>"col", :id => "vzebra-children") %> @@ -33,6 +35,7 @@ +
        <%= format_time(file.created_on) %> <%= number_to_human_size(file.filesize) %> <%= file.attachmentstype.typeName %><%= file.show_suffix_type %> <%= file.downloads %> diff --git a/app/views/files/_sort_by_attachtypel.html.erb b/app/views/files/_sort_by_attachtypel.html.erb index 0544a4b6..82d2a7b8 100644 --- a/app/views/files/_sort_by_attachtypel.html.erb +++ b/app/views/files/_sort_by_attachtypel.html.erb @@ -1,5 +1,6 @@ <% selAttachType =@attachtype %> <% delete_allowed = User.current.allowed_to?(:manage_files, @project) %> +<% edit_allowed = User.current.allowed_to?(:manage_files, @project) %>
          @@ -15,7 +16,8 @@ <%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %> <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope => "col", :id => "vzebra-comedy") %> <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %> - <%= sort_header_tag('attach_type', :caption => l(:attachment_type), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %> + <%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %> + <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%> <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %> <%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %> @@ -31,6 +33,7 @@ +
          <%= format_time(file.created_on) %> <%= number_to_human_size(file.filesize) %> <%= file.attachmentstype.typeName %><%= file.show_suffix_type %> <%= file.downloads %> diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 490f74f9..5abacf29 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,5 +1,6 @@ <% attachmenttypes = @project.attachmenttypes %> +<% sufixtypes = @project.contenttypes %> - -<%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区 +<%= (@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区
          <%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
          <%#= link_to('上传文件', new_project_file_path(@project), :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %> - <%= link_to( l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %> + <%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %> <%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %> <% if attachmenttypes.any? %>       - - <%= select_tag "attachment_browse", content_tag('option',l(:attachment_all)) +options_from_collection_for_select(attachmenttypes, "id", "typeName"), - :onchange=>"attachmenttypes_searchex(this.value)"%> - <% end %> - <% if sufixtypes.any? %> + + <%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"), + :onchange => "attachmenttypes_searchex(this.value)" %> + <% end %> + <% if sufixtypes.any? %>   - - <%= select_tag "attach_sufix_browse", content_tag('option', l(:attachment_all)) +options_for_select(sufixtypes), - :onchange=>"attachment_contenttypes_searchex(this.value)"%> + + <%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes), + :onchange => "attachment_contenttypes_searchex(this.value)" %> <% end %> -