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 @@ -
<%= 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])) %>
-
<%= 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|