diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb
index 999544e7b..b998c44d2 100644
--- a/app/controllers/boards_controller.rb
+++ b/app/controllers/boards_controller.rb
@@ -33,6 +33,9 @@ class BoardsController < ApplicationController
@board = @boards.first
show
end
+ if @project.project_type
+ render :layout => 'base_courses'
+ end
end
def show
@@ -54,7 +57,11 @@ class BoardsController < ApplicationController
preload(:author, {:last_reply => :author}).
all
@message = Message.new(:board => @board)
- render :action => 'show', :layout => !request.xhr?
+ if @project.project_type
+ render :action => 'show', :layout => 'base_courses'
+ else
+ render :action => 'show', :layout => !request.xhr?
+ end
}
format.atom {
@messages = @board.messages.
@@ -70,6 +77,9 @@ class BoardsController < ApplicationController
def new
@board = @project.boards.build
@board.safe_attributes = params[:board]
+ if @project.project_type
+ render :layout => 'base_courses'
+ end
end
def create
@@ -90,6 +100,9 @@ class BoardsController < ApplicationController
end
def update
+ if @project.project_type
+ render :layout => 'base_courses'
+ end
@board.safe_attributes = params[:board]
if @board.save
redirect_to_settings_in_projects
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb
index a311fc765..d00535aba 100644
--- a/app/controllers/documents_controller.rb
+++ b/app/controllers/documents_controller.rb
@@ -40,11 +40,18 @@ class DocumentsController < ApplicationController
@grouped = documents.group_by(&:category)
end
@document = @project.documents.build
- render :layout => false if request.xhr?
+ if @project.project_type
+ render :layout => 'base_courses'
+ else
+ render :layout => false if request.xhr?
+ end
end
def show
@attachments = @document.attachments.all
+ if @project.project_type
+ render :action => 'show', :layout => 'base_courses'
+ end
end
def new
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index cb4c1b8ff..f47d4797f 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -34,11 +34,20 @@ class FilesController < ApplicationController
@containers = [ Project.includes(:attachments).reorder(sort_clause).find(@project.id)]
@containers += @project.versions.includes(:attachments).reorder(sort_clause).all.sort.reverse
- render :layout => !request.xhr?
+ @course_tag = @project.project_type
+ if @course_tag
+ render :layout => 'base_courses'
+ else
+ render :layout => !request.xhr?
+ end
end
def new
@versions = @project.versions.sort
+ @course_tag = @project.project_type
+ if @course_tag
+ render :layout => 'base_courses'
+ end
end
def create
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index 27d195f0d..56422dcd6 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -49,7 +49,11 @@ class MessagesController < ApplicationController
all
@reply = Message.new(:subject => "RE: #{@message.subject}")
- render :action => "show", :layout => "base_projects"#by young
+ if @message.board.project.project_type
+ render :action => "show", :layout => "base_courses"#by young
+ else
+ render :action => "show", :layout => "base_projects"#by young
+ end
end
# Create a new topic
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 9a3e2d70f..875a8db0c 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -19,14 +19,15 @@ class ProjectsController < ApplicationController
layout 'base_projects'# by young
menu_item :overview
menu_item :roadmap, :only => :roadmap
-# menu_item :settings, :only => :settings
+ menu_item :settings, :only => :settings
+ menu_item :homework, :only => :homework
- before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ]
- before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback]
+ before_filter :find_project, :except => [ :index, :list, :new, :create, :copy, :statistics]
+ before_filter :authorize, :except => [:new_homework, :homework, :statistics, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback]
before_filter :authorize_global, :only => [:new, :create]
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
#by young
- before_filter :member, :file, :statistics
+ before_filter :member, :file
#
accept_rss_auth :index
accept_api_auth :index, :show, :create, :update, :destroy
@@ -36,7 +37,9 @@ class ProjectsController < ApplicationController
controller.send :expire_action, :controller => 'welcome', :action => 'robots'
end
end
-
+
+ helper :bids
+ include BidsHelper
helper :sort
include SortHelper
helper :custom_fields
@@ -51,32 +54,11 @@ class ProjectsController < ApplicationController
helper :activities
helper :documents
helper :watchers
-
+
### added by william
include ActsAsTaggableOn::TagsHelper
-
- # Lists visible projects
-# def index
-# respond_to do |format|
-# format.html {
-# scope = Project
-# unless params[:closed]
-# scope = scope.active
-# end
-# @projects = scope.visible.order('lft').all
-# }
-# format.api {
-# @offset, @limit = api_offset_and_limit
-# @project_count = Project.visible.count
-# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
-# }
-# format.atom {
-# projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
-# render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
-# }
-# end
-# end
-
+
+
def index
#Modified by nie
# @offset, @limit = api_offset_and_limit({:limit => 10})
@@ -123,6 +105,33 @@ class ProjectsController < ApplicationController
end
end
+ #Added by young
+ def homework
+ @offset, @limit = api_offset_and_limit({:limit => 10})
+ @bids = Bid.visible
+ @bids = @bids.like(params[:name]) if params[:name].present?
+ @bid_count = @bids.count
+ @bid_pages = Paginator.new @bid_count, @limit, params['page']
+
+ @offset ||= @bid_pages.reverse_offset
+ #@bids = @bids.offset(@offset).limit(@limit).all.reverse
+ unless @offset == 0
+ @bids = @bids.offset(@offset).limit(@limit).all.reverse
+ else
+ limit = @bid_count % @limit
+ @bids = @bids.offset(@offset).limit(limit).all.reverse
+ end
+ render :layout => 'base_courses'
+ end
+
+ def new_homework
+ @homework = Bid.new
+ @homework.safe_attributes = params[:bid]
+ render :layout => 'base_courses'
+ end
+#Ended by young
+
+
def feedback
@jours = @project.journals_for_messages.reverse
@limit = 10
@@ -134,14 +143,17 @@ class ProjectsController < ApplicationController
end
def new
+ @course_tag = params[:course]
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
@project.safe_attributes = params[:project]
render :layout => 'base'
end
+
def create
+ @course_tag = params[:project][:project_type]
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
@@ -163,8 +175,12 @@ class ProjectsController < ApplicationController
if params[:continue]
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
redirect_to new_project_path(attrs)
+ #Added by young
+ elsif params[:course_continue]
+ redirect_to new_project_path(:course => '1')
+ #Ended by young
else
- redirect_to settings_project_path(@project)
+ redirect_to settings_project_path(@project, :course => @course_tag)
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
@@ -276,8 +292,9 @@ class ProjectsController < ApplicationController
end
@document = @project.documents.build
#
+ @base_courses_tag = @project.project_type
respond_to do |format|
- format.html
+ format.html{render :layout => 'base_courses' if @base_courses_tag }
format.api
end
end
@@ -289,6 +306,12 @@ class ProjectsController < ApplicationController
@member ||= @project.members.new
@trackers = Tracker.sorted.all
@wiki ||= @project.wiki
+ #Added by young
+ @course_tag = params[:course]
+ if @course_tag == '1'
+ render :layout => 'base_courses'
+ end
+ #Ended by young
end
def edit
@@ -302,9 +325,6 @@ class ProjectsController < ApplicationController
def file
end
- def statistics
-
- end
#end
def update
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 94de4bfbb..0657ddfe4 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -43,15 +43,26 @@ class RepositoriesController < ApplicationController
@repository = Repository.factory(scm)
@repository.is_default = @project.repository.nil?
@repository.project = @project
- render :layout => 'base_projects'
+ @course_tag = params[:course]
+ if @course_tag
+ render :layout => 'base_courses'
+ else
+ render :layout => 'base_projects'
+ end
end
+
def newrepo
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
@repository = Repository.factory(scm)
@repository.is_default = @project.repository.nil?
@repository.project = @project
- render :layout => 'base_projects'
+ @course_tag = params[:course]
+ if @course_tag
+ render :layout => 'base_courses'
+ else
+ render :layout => 'base_projects'
+ end
end
def fork
@@ -209,7 +220,12 @@ class RepositoriesController < ApplicationController
@changesets = @repository.latest_changesets(@path, @rev)
@properties = @repository.properties(@path, @rev)
@repositories = @project.repositories
- render :action => 'show', :layout => 'base_projects'
+ @course_tag = params[:course]
+ if @course_tag
+ render :action => 'show', :layout => 'base_courses'
+ else
+ render :action => 'show', :layout => 'base_projects'
+ end
end
end
@@ -369,6 +385,8 @@ class RepositoriesController < ApplicationController
end
def stats
+ @project_id = params[:id]
+ @repository_id = @repository.identifier
render :layout => 'base_projects'
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index cbe57d1c7..4b465a11e 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -35,8 +35,20 @@ module ProjectsHelper
{:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities}
]
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
+
end
-
+
+ #Added by young
+ def course_settings_tabs
+ tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
+ {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural},
+ {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural}
+ ]
+ tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
+
+ end
+ #Ended by young
+
def parent_project_select_tag(project)
selected = project.parent
# retrieve the requested parent project
@@ -54,7 +66,13 @@ module ProjectsHelper
# Renders the projects index
def render_project_hierarchy(projects)
render_project_nested_lists(projects) do |project|
- s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
+ #Modified by young
+ if project.project_type
+ s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")+"(#{l(:label_course)})".html_safe
+ else
+ s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
+ end
+ #Ended by young
if project.description.present?
#Delete by nie.
# s << content_tag('td', textilizable(project.short_description, :project => project), :class => 'wiki description')
diff --git a/app/models/journals_for_message_observer.rb b/app/models/journals_for_message_observer.rb
new file mode 100644
index 000000000..3bca47791
--- /dev/null
+++ b/app/models/journals_for_message_observer.rb
@@ -0,0 +1,7 @@
+# Added by young
+class JournalsForMessageObserver < ActiveRecord::Observer
+ def after_create(journal_for_message)
+ Mailer.journals_for_message_add(User.current, journal_for_message).deliver
+ end
+end
+
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 1db19f14e..b9d3fe847 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -26,6 +26,15 @@ class Mailer < ActionMailer::Base
def self.default_url_options
{ :host => Setting.host_name, :protocol => Setting.protocol }
end
+
+ # Builds a Mail::Message object used to email recipients of the added journals for message.
+ #
+ def journals_for_message_add(user, journals_for_message)
+ @user = User.current
+ @url = url_for(:controller => 'users', :action => 'user_newfeedback')
+ mail :to => user.mail,
+ :subject => "hello"
+ end
# Builds a Mail::Message object used to email recipients of the added issue.
#
diff --git a/app/models/project.rb b/app/models/project.rb
index 7af230aa4..d249ec02a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -681,7 +681,8 @@ class Project < ActiveRecord::Base
'custom_field_values',
'custom_fields',
'tracker_ids',
- 'issue_custom_field_ids'
+ 'issue_custom_field_ids',
+ 'project_type'
safe_attributes 'enabled_module_names',
:if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) }
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
new file mode 100644
index 000000000..d59980b75
--- /dev/null
+++ b/app/views/layouts/base_courses.html.erb
@@ -0,0 +1,146 @@
+
+
+
+
+ <%= h html_title %>
+
+
+ <%= csrf_meta_tag %>
+ <%= favicon %>
+ <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %>
+ <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
+ <%= javascript_heads %>
+ <%= heads_for_theme %>
+ <%= call_hook :view_layouts_base_html_head %>
+
+ <%= yield :header_tags -%>
+
+
+
+
+
+
+ <%= render :partial => 'layouts/base_header'%>
+
+
+
+
+
+
教师名称:XXX
+
所在单位:并行与分布重点实验室
+
课程学分:X学分
+
课程学时:XX学时
+
XXXX:XXXXXXXX
+
+
+ - <%= link_to(l(:label_overview), project_path(@project))%>
+ - <%= link_to(l(:label_homework), {:controller => 'projects', :action => 'homework'})%>
+ - <%= link_to(l(:label_repository), { :controller => 'repositories', :action => 'show', :id => @project, :repository_id => nil, :path => nil, :rev => nil, :course => 1 })%>
+ - <%= link_to(l(:label_settings),{:controller => 'projects', :action => 'settings', :id => @project, :course => 1})%>
+
+ <%= yield %>
+ <%= call_hook :view_layouts_base_content %>
+
+ <%= render_flash_messages %>
+
+
+ <%= render :partial => 'layouts/base_footer'%>
+
+
+
+ <%= l(:label_loading) %>
+
+
+
+
+ <%= call_hook :view_layouts_base_body_bottom %>
+
+
diff --git a/app/views/mailer/journals_for_message_added.html.erb b/app/views/mailer/journals_for_message_added.html.erb
new file mode 100644
index 000000000..f68026492
--- /dev/null
+++ b/app/views/mailer/journals_for_message_added.html.erb
@@ -0,0 +1,2 @@
+
<%= link_to("hello", @url) %>
+
<%=h @user %>
diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb
index 1b68e5b20..071dbec88 100644
--- a/app/views/news/index.html.erb
+++ b/app/views/news/index.html.erb
@@ -39,7 +39,7 @@
<%= l(:label_no_data) %>
<% else %>
<% @newss.each do |news| %>
-
+
<%= image_tag(url_to_avatar(news.author), :class => "avatar") %> |
diff --git a/app/views/projects/_course_form.html.erb b/app/views/projects/_course_form.html.erb
new file mode 100644
index 000000000..72dc3cd1e
--- /dev/null
+++ b/app/views/projects/_course_form.html.erb
@@ -0,0 +1,47 @@
+<%= error_messages_for 'project' %>
+
+<% unless @project.new_record? %>
+<%= render :partial=>"avatar/avatar_form",:locals=> {source:@project} %>
+<% end %>
+<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;" %>
+
+<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
+<%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
+<% unless @project.identifier_frozen? %>
+ <%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %>
+<% end %>
+<%= f.text_field :homepage, :size => 60, :style => "width:488px;margin-left: 10px;" %>
+<%= f.check_box :is_public, :style => "margin-left:10px;" %>
+<%= f.text_field :project_type, :value => 1 %>
+
+
+<%= wikitoolbar_for 'project_description' %>
+
+<% @project.custom_field_values.each do |value| %>
+ <%= custom_field_tag_with_label :project, value %>
+<% end %>
+<%= call_hook(:view_projects_form, :project => @project, :form => f) %>
+
+
+
+
+
+<% unless @project.identifier_frozen? %>
+ <% content_for :header_tags do %>
+ <%= javascript_include_tag 'project_identifier' %>
+ <% end %>
+<% end %>
+
+<% if !User.current.admin? && @project.inherit_members? && @project.parent && User.current.member_of?(@project.parent) %>
+ <%= javascript_tag do %>
+ $(document).ready(function() {
+ $("#project_inherit_members").change(function(){
+ if (!$(this).is(':checked')) {
+ if (!confirm("<%= escape_javascript(l(:text_own_membership_delete_confirmation)) %>")) {
+ $("#project_inherit_members").attr("checked", true);
+ }
+ }
+ });
+ });
+ <% end %>
+<% end %>
diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb
index f752c7d0b..0802d9b2a 100644
--- a/app/views/projects/_form.html.erb
+++ b/app/views/projects/_form.html.erb
@@ -11,8 +11,8 @@
<%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %>
<% end %>
<%= f.text_field :homepage, :size => 60, :style => "width:488px;margin-left: 10px;" %>
-<%= f.check_box :is_public, :style => "margin-left:10px;" %>
-
+<%= f.check_box :is_public, :style => "margin-left:10px;" %><%= l(:label_public_info) %>
+<%= f.text_field :project_type, :value => 0 %>
<%= wikitoolbar_for 'project_description' %>
diff --git a/app/views/projects/homework.html.erb b/app/views/projects/homework.html.erb
new file mode 100644
index 000000000..50a439db1
--- /dev/null
+++ b/app/views/projects/homework.html.erb
@@ -0,0 +1,34 @@
+
+
+
+
+
+ <%= l(:label_course_homework_list)%> |
+ <% if User.current.logged? %>
+
+
+ <%= link_to(l(:label_course_homework_new), {:controller => 'projects', :action => 'new_homework'}, :class => 'icon icon-add') %>
+
+
+ <% end %> |
+
+
+
+
+ <%= text_field_tag 'name', params[:name], :size => 30 %>
+ <%= submit_tag l(:label_search), :class => "small", :name => nil %>
+ |
+
+
+
+
+<% if User.current.logged? %>
+
+ <%= render :partial => 'bids/new_bid' %>
+
+<% end %>
+
+
+ <%= render :partial => 'bids/bid_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %>
+
+
diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb
index 8f4852ef5..814d221f0 100644
--- a/app/views/projects/index.html.erb
+++ b/app/views/projects/index.html.erb
@@ -7,8 +7,8 @@
<%= l(:label_project_plural)%> |
- <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> |
-
+ <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> |
+ <%= link_to(l(:label_course_new), {:controller => 'projects', :action => 'new', :course => 1}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> |
<%= text_field_tag 'name', params[:name], :size => 30 %>
@@ -17,12 +17,12 @@
|
-<%end%>
+<% end %>
<%= render_project_hierarchy(@projects)%>
-
+
|