new course table

This commit is contained in:
xianbo 2013-09-06 16:39:38 +08:00
parent 4d82cad51d
commit 1e7d127998
11 changed files with 78 additions and 20 deletions

View File

@ -88,9 +88,11 @@ class AccountController < ApplicationController
# create a new token for password recovery
token = Token.new(:user => user, :action => "recovery")
if token.save
Mailer.lost_password(token).deliver
flash[:notice] = l(:notice_account_lost_email_sent)
redirect_to signin_path
Thread.new do
Mailer.lost_password(token).deliver
end
flash[:notice] = l(:notice_account_lost_email_sent)
redirect_to signin_path
return
end
end

View File

@ -148,17 +148,25 @@ class ProjectsController < ApplicationController
@trackers = Tracker.sorted.all
@project = Project.new
@project.safe_attributes = params[:project]
##add by xianbo
@course=Course.new
@course.safe_attributes = params[:course]
##end
render :layout => 'base'
end
def create
@course_tag = params[:project][:project_type]
@course_tag = params[:project][:project_type]
@course = Course.new
@course.extra=params[:project][:identifier]
@course.safe_attributes = params[:project][:course]
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
@project.safe_attributes = params[:project]
@course.save
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
# Add current user as a project member if he is not admin
@ -174,8 +182,9 @@ class ProjectsController < ApplicationController
flash[:notice] = l(:notice_successful_create)
if params[:continue]
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
redirect_to new_project_path(attrs)
redirect_to new_project_path(attrs, :course => '1')
#Added by young
elsif params[:course_continue]
redirect_to new_project_path(:course => '1')
#Ended by young
@ -233,9 +242,7 @@ class ProjectsController < ApplicationController
@subprojects = @project.children.visible.all
@news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").all
@trackers = @project.rolled_up_trackers
cond = @project.project_condition(Setting.display_subprojects_issues?)
@open_issues_by_tracker = Issue.visible.open.where(cond).count(:group => :tracker)
@total_issues_by_tracker = Issue.visible.where(cond).count(:group => :tracker)
@ -329,6 +336,8 @@ class ProjectsController < ApplicationController
def update
@project.safe_attributes = params[:project]
@Course.safe_attributes=params[:project][:course]
@Course.save
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
respond_to do |format|

View File

@ -40,7 +40,7 @@ module ProjectsHelper
#Added by young
def course_settings_tabs
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
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},
{:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural}
]

View File

@ -4,6 +4,7 @@ class Bid < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :author, :class_name => 'User', :foreign_key => :author_id
belongs_to :course
has_many :biding_projects, :dependent => :destroy
has_many :projects, :through => :biding_projects
has_many :journals_for_messages, :as => :jour, :dependent => :destroy

View File

@ -58,7 +58,11 @@ class Project < ActiveRecord::Base
has_many :project_infos, :dependent => :destroy
#end
has_one :wiki, :dependent => :destroy
# Custom field for the project issues
##added by xianbo
has_one :course, :dependent => :destroy
accepts_nested_attributes_for :course
##end
# Custom field for the project issues
has_and_belongs_to_many :issue_custom_fields,
:class_name => 'IssueCustomField',
:order => "#{CustomField.table_name}.position",
@ -684,6 +688,7 @@ class Project < ActiveRecord::Base
'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) }
@ -1027,6 +1032,9 @@ class Project < ActiveRecord::Base
def update_position_under_parent
set_or_update_position_under(parent)
end
def course
@course
end
# Inserts/moves the project so that target's children or root projects stay alphabetically sorted
def set_or_update_position_under(target_parent)

View File

@ -150,8 +150,11 @@ class User < Principal
end
def set_mail_notification
##add byxianbo
thread=Thread.new do
self.mail_notification = Setting.default_notification_option if self.mail_notification.blank?
true
end
end
def update_hashed_password

View File

@ -29,6 +29,7 @@
<!--informations-->
<div class="inf_user_image">
<% @project = Project.find_by_id(@project.id)%>
<% @course= Course.find_by_extra(@project.identifier)%>
<table>
<tr>
<td><%= link_to image_tag(url_to_avatar(@project), :class => 'avatar2') %></td>
@ -114,10 +115,10 @@
</div>
</div>
<div id="content">
<div>教师名称:XXX</div>
<div>教师名称:<%= @course.name%></div>
<div>所在单位:并行与分布重点实验室</div>
<div>课程学分:X学分</div>
<div>课程学时:XX学时</div>
<div>课程学分:<%=@course.code%></div>
<div>课程学时:<%=@course.time%></div>
<div>XXXXXXXXXXXX</div>
<div class="tabs">
<ul>

View File

@ -11,6 +11,11 @@
<em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %></em>
<% end %></p>
<p style="margin-left:-10px;"><%= f.text_field :homepage, :size => 60, :style => "width:488px;margin-left: 10px;" %></p>
<%= f.fields_for @course do |m| %>
<p style="margin-left:-10px;"><%= m.text_field :time, :size => 60, :style => "width:488px;margin-left: 10px;" %></p>
<p style="margin-left:-10px;"><%= m.text_field :code, :size => 60, :style => "width:488px;margin-left: 10px;" %></p>
<p style="margin-left:-10px;"><%= m.text_field :name, :size => 60, :style => "width:488px;margin-left: 10px;" %></p>
<% end %>
<p style="margin-left:-10px;"><%= f.check_box :is_public, :style => "margin-left:10px;" %></p>
<p style="display:none;"><%= f.text_field :project_type, :value => 1 %></p>

View File

@ -1,6 +1,8 @@
<div class="box tabular" style="margin-right:10px;" >
<%= labelled_form_for @project do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>
</div>

View File

@ -252,6 +252,8 @@ zh:
field_principal: 用户/用户组
field_role: 角色
field_homepage: 主页
field_time: 课时
field_code: 学分
field_is_public: 公开
field_parent: 上级项目
field_is_in_roadmap: 在路线图中显示

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130827003308) do
ActiveRecord::Schema.define(:version => 20130904075504) do
create_table "a_user_watchers", :force => true do |t|
t.string "name"
@ -161,6 +161,17 @@ ActiveRecord::Schema.define(:version => 20130827003308) do
add_index "comments", ["author_id"], :name => "index_comments_on_author_id"
add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type"
create_table "courses", :force => true do |t|
t.integer "tea_id"
t.string "name"
t.integer "state"
t.string "code"
t.integer "time"
t.string "extra"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "custom_fields", :force => true do |t|
t.string "type", :limit => 30, :default => "", :null => false
t.string "name", :limit => 30, :default => "", :null => false
@ -565,10 +576,11 @@ ActiveRecord::Schema.define(:version => 20130827003308) do
t.string "title"
t.string "share_type"
t.string "url"
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.integer "project_id"
t.integer "user_id"
t.string "description"
end
create_table "students", :force => true do |t|
@ -594,6 +606,16 @@ ActiveRecord::Schema.define(:version => 20130827003308) do
t.string "name"
end
create_table "teachers", :force => true do |t|
t.string "tea_name"
t.string "location"
t.integer "couurse_time"
t.integer "course_code"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "extra"
end
create_table "time_entries", :force => true do |t|
t.integer "project_id", :null => false
t.integer "user_id", :null => false
@ -663,6 +685,9 @@ ActiveRecord::Schema.define(:version => 20130827003308) do
t.datetime "updated_at", :null => false
end
add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count"
add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count"
create_table "user_tags", :force => true do |t|
t.integer "user_id"
t.integer "tag_id"