From f741b0581c76712d47ae3e65a67aa4c4b61223b9 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 10 Jun 2014 15:44:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=96=87=E4=BB=B6=E8=A7=86=E5=9B=BEBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 2 +- app/models/course_journals_for_message.rb | 2 +- app/views/courses/_course.html.erb | 50 +++++++++---------- app/views/courses/index.html.erb | 4 +- app/views/files/_course_new.html.erb | 21 +++----- app/views/files/index.html.erb | 41 +++++++++------ config/locales/en.yml | 1 + ...20140603042015_stored_course_procedure.rb} | 0 db/schema.rb | 6 +-- lib/redmine.rb | 6 ++- 10 files changed, 69 insertions(+), 64 deletions(-) rename db/migrate/{20140530102015_stored_course_procedure.rb => 20140603042015_stored_course_procedure.rb} (100%) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 048a234f1..74a17f671 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -35,8 +35,8 @@ class FilesController < ApplicationController if params[:project_id] @isproject = true - @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] + @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort render :layout => !request.xhr? elsif params[:course_id] @isproject = false diff --git a/app/models/course_journals_for_message.rb b/app/models/course_journals_for_message.rb index c3f1c699d..4d5f3f92e 100644 --- a/app/models/course_journals_for_message.rb +++ b/app/models/course_journals_for_message.rb @@ -37,7 +37,7 @@ class CourseJournalsForMessage < ActiveRecord::Base }#{:controller => 'documents', :action => 'show', :id => o.id}} acts_as_activity_provider :author_key => :user_id, :timestamp => "#{self.table_name}.updated_on", - :find_options => {:include => :course } + :find_options => {:include => :course } has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy diff --git a/app/views/courses/_course.html.erb b/app/views/courses/_course.html.erb index 6ea802037..3bf42bf2d 100644 --- a/app/views/courses/_course.html.erb +++ b/app/views/courses/_course.html.erb @@ -1,24 +1,24 @@ -
+
- <% if get_avatar?(project)%> - <%= image_tag(url_to_avatar(project), :class => "avatar2") %> + <% if get_avatar?(course)%> + <%= image_tag(url_to_avatar(course), :class => "avatar2") %> <% else %> - <%= image_tag('../images/avatars/Project/course.jpg', :class => "avatar2") %> + <%= image_tag('../images/avatars/course/course.jpg', :class => "avatar2") %> <% end %>

<%= content_tag('span',"#{l(:label_bid_show_course_name)}:", :class => "course-font")%> - <%= content_tag('span', link_to("#{@project.name}", project_path(@project), :class => "info"))%> + <%= content_tag('span', link_to("#{@course.name}", course_path(@course), :class => "info"))%>

<%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%> - <% @admin = @project.project_infos%> + <% @admin = @course.course_infos%> <%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%> - <%# unless @project.course_extra.school.nil? %> - <%= @project.course_extra.teacher.user_extensions.school.try(:name) %> + <%# unless @course.course_extra.school.nil? %> + <%= @course.course_extra.teacher.user_extensions.school.try(:name) %> <%# end %> <% end %>

@@ -33,41 +33,39 @@

- <%= content_tag('span', link_to("#{@project.homeworks.count}", homework_project_path(@project)), :class => "info") %> - <%= content_tag('span', l(:label_x_task, :count => @project.homeworks.count)) %> + <%= content_tag('span', link_to("#{@course.homeworks.count}", homework_course_path(@course)), :class => "info") %> + <%= content_tag('span', l(:label_x_task, :count => @course.homeworks.count)) %>

- <% files_count = @project.attachments.count %> - <% @project.versions.each do |version| %> + <% files_count = @course.attachments.count %> + <% @course.versions.each do |version| %> <% files_count += version.attachments.count %> <% end %> - <%= content_tag('span', link_to(files_count, project_files_path(@project)), :class => "info") %> + <%= content_tag('span', link_to(files_count, course_files_path(@course)), :class => "info") %> <%= content_tag('span', l(:label_x_data,:count => files_count)) %>

- <%= content_tag('span', "#{garble @project.members.count}", :class => "info") %> - <%= content_tag('span', l(:label_x_member, :count => @project.members.count)) %> + <%= content_tag('span', "#{garble @course.members.count}", :class => "info") %> + <%= content_tag('span', l(:label_x_member, :count => @course.members.count)) %>

- <%= content_tag('span', link_to("#{@project_activity_count[@project.id]}", project_path(@project)), :class => "info") %> - <%= content_tag('span', l(:label_x_activity, :count => @project_activity_count[@project.id])) %> + <%= content_tag('span', link_to("#{@course_activity_count[@course.id]}", course_path(@course)), :class => "info") %> + <%= content_tag('span', l(:label_x_activity, :count => @course_activity_count[@course.id])) %>

- <% if @project.project_type==Project::ProjectType_course %> -<% if(course_endTime_timeout? @project) %> + <% if(course_endTime_timeout? @project) %> 课程学期已结束 -<% else %> - <%= join_in_course_for_list(@project, User.current,['regular'])%> -<% end -%> - <% end %> + <% else %> + <%= join_in_course_for_list(@project, User.current,['regular'])%> + <% end -%>
@@ -75,18 +73,18 @@
<%= content_tag "span","#{l(:label_duration_time)}:", :class => "course-font"%> - <%= get_course_term @project %> + <%= get_course_term @course %>
<%= content_tag "span", "#{l(:label_course_brief_introduction)}:", :class => "course-font" %> - <%= content_tag "div", project.short_description, :class => "brief_introduction", :title => project.short_description %> + <%= content_tag "div", course.short_description, :class => "brief_introduction", :title => course.short_description %>
<%= image_tag( "/images/sidebar/tags.png") %> - <%= render :partial => 'tags/tag_name', :locals => {:obj => @project,:object_flag => "2",:non_list_all => true }%> + <%= render :partial => 'tags/tag_name', :locals => {:obj => @course,:object_flag => "9",:non_list_all => true }%>
diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index ea32d3863..f5f903d36 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -23,8 +23,8 @@ - <%= link_to request.host()+"/course", :controller => 'courses', :action => 'course', :course_type => 1 %> - <%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'course', :course_type => 1 %> + <%= link_to request.host()+"/course", :controller => 'courses', :action => 'index', :course_type => 1 %> + <%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index', :course_type => 1 %> <% end %> diff --git a/app/views/files/_course_new.html.erb b/app/views/files/_course_new.html.erb index 151d7950d..659543201 100644 --- a/app/views/files/_course_new.html.erb +++ b/app/views/files/_course_new.html.erb @@ -4,21 +4,12 @@ <%= form_tag(course_files_path(course), :multipart => true,:remote => false,:method => :post,:name=>"upload_form", :class => "tabular") do %>

- - - - <% if attachmenttypes.any? %> - - - <% end %> - -
<%= l(:attachment_type) %> - <%= select_tag "attachment_type", - options_from_collection_for_select(attachmenttypes, "id", - "typeName", 2), {style: 'width:100px'} %> -
- - + <% if attachmenttypes.any? %> + <%= l(:attachment_type) %> + <%= select_tag "attachment_type", + options_from_collection_for_select(attachmenttypes, "id", + "typeName", 2), {style: 'width:100px'} %> + <% end %>

<%=l(:label_attachment_plural)%><%= render :partial => 'attachments/form' %>

diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 639d99974..b5990109f 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -59,20 +59,24 @@ } - - function course_attachmenttypes_searchex(value) { + function attachment_contenttypes_searchex(value) { + <% if @project%> $.ajax({ - url: '<%=getattachtype_course_files_path(course_id: @course)%>', + url: '<%=getattachtype_project_files_path(project_id: @project)%>', type: "POST", data: { - type: encodeURIComponent(value), - contentType: $('#attach_sufix_browse').val() + type: $('#attachment_browse').val(), + contentType: encodeURIComponent(value) } }).complete(eval_ajax); + <%end%> } - function attachment_contenttypes_searchex(value) { + + + function attachtype_edit(value) { + <% if @project%> $.ajax({ url: '<%=getattachtype_project_files_path(project_id: @project)%>', @@ -83,25 +87,29 @@ } }).complete(eval_ajax); + <%end%> } - function course_attachment_contenttypes_searchex(value) { - $.ajax({ + function course_attachmenttypes_searchex(value) { + <% if @course%> + $.ajax({ url: '<%=getattachtype_course_files_path(course_id: @course)%>', type: "POST", data: { - type: $('#attachment_browse').val(), - contentType: encodeURIComponent(value) + type: encodeURIComponent(value), + contentType: $('#attach_sufix_browse').val() } }).complete(eval_ajax); + <%end%> } - function attachtype_edit(value) { + function course_attachment_contenttypes_searchex(value) { + <% if @course%> $.ajax({ - url: '<%=getattachtype_project_files_path(project_id: @project)%>', + url: '<%=getattachtype_course_files_path(course_id: @course)%>', type: "POST", data: { type: $('#attachment_browse').val(), @@ -109,11 +117,11 @@ } }).complete(eval_ajax); + <%end%> } - function course_attachtype_edit(value) { + <% if @course%> $.ajax({ - url: '<%=getattachtype_course_files_path(course_id: @course)%>', type: "POST", data: { @@ -122,9 +130,11 @@ } }).complete(eval_ajax); + <%end%> } function attachmenttypes_change(id, type) { + <% if @project%> $.ajax({ url: '<%=updateType_attachments_path%>', type: "POST", @@ -134,6 +144,7 @@ } }).complete(function (xhr, textStatus) { + if (textStatus == 'success') { $.ajax({ url: '<%=getattachtype_project_files_path(project_id: @project)%>', @@ -149,6 +160,8 @@ alert('An error has occurred'); } }); + <%end%> + } diff --git a/config/locales/en.yml b/config/locales/en.yml index 23911e568..08c6c0ffa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1126,6 +1126,7 @@ en: label_joined_course: Joined Courses label_created_course: Created Courses + label_borad_course: Course Borad #huang label_file_new: Download diff --git a/db/migrate/20140530102015_stored_course_procedure.rb b/db/migrate/20140603042015_stored_course_procedure.rb similarity index 100% rename from db/migrate/20140530102015_stored_course_procedure.rb rename to db/migrate/20140603042015_stored_course_procedure.rb diff --git a/db/schema.rb b/db/schema.rb index e8e5f5a87..8430c487a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -242,8 +242,8 @@ ActiveRecord::Schema.define(:version => 20140606028512) do t.string "code" t.integer "time" t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "location" t.string "term" t.string "string" @@ -257,7 +257,7 @@ ActiveRecord::Schema.define(:version => 20140606028512) do t.integer "attachmenttype", :default => 2 t.integer "lft" t.integer "rgt" - t.boolean "is_public", :default => true + t.integer "is_public", :limit => 1, :default => 1 t.integer "inherit_members", :limit => 1, :default => 1 end diff --git a/lib/redmine.rb b/lib/redmine.rb index e376a3e1f..0a4dbd52b 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -108,7 +108,9 @@ Redmine::AccessControl.map do |map| map.permission :select_course_modules, {:courses => :modules}, :require => :member map.permission :view_course_journals_for_messages, {:gantts => [:show, :update]}, :read => true - map.course_module :course do + map.course_module :files do |map| + map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin + map.permission :view_files, {:files => :index, :versions => :download}, :read => true end #end @@ -415,7 +417,7 @@ Redmine::Activity.map do |activity| activity.register :journals_for_messages # end #added by nwb - activity.register :course_journals_for_messages + #activity.register :course_journals_for_messages end Redmine::Search.map do |search|