添加自动生成课程标识功能

This commit is contained in:
fanqiang 2013-09-16 08:58:53 +08:00
parent 466922d13b
commit 9d2ea5639f
2 changed files with 6 additions and 3 deletions

View File

@ -344,7 +344,7 @@ class ProjectsController < ApplicationController
@course_tag = params[:project][:project_type]
if(@course_tag=="1")
@course = Course.new
@course.extra=params[:project][:identifier]
@course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
@course.safe_attributes = params[:project][:course]
@course.tea_id = User.current.id
@course.save
@ -355,6 +355,9 @@ class ProjectsController < ApplicationController
@trackers = Tracker.sorted.all
@project = Project.new
@project.safe_attributes = params[:project]
if @course_tag == '1'
@project.identifier = @course.extra
end
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')

View File

@ -6,10 +6,10 @@
<p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;" %></p>
<p style="margin-left:-10px;padding-right: 20px;"><%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %></p><!--by young-->
<p><%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
<!-- <p><%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
<% unless @project.identifier_frozen? %>
<em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %></em>
<% end %></p>
<% end %></p> -->
<%= f.fields_for @course do |m| %>