实训任务模块

This commit is contained in:
huang 2017-02-17 19:29:00 +08:00
parent 5d19288f1c
commit d4eb4c0d56
19 changed files with 1293 additions and 66 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the training_tasks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
module TrainingTasksHelper
end

View File

@ -57,6 +57,7 @@ class Project < ActiveRecord::Base
has_many :enabled_modules, :dependent => :delete_all
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
has_many :issues, :dependent => :destroy, :include => [:status, :tracker],:order => "issues.id ASC"
has_many :training_tasks, :dependent => :destroy, :order => "training_tasks.id ASC"
has_many :issue_changes, :through => :issues, :source => :journals
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
has_many :time_entries, :dependent => :delete_all

View File

@ -0,0 +1,4 @@
class TrainingTask < ActiveRecord::Base
attr_accessible :description, :project_id, :subject, :tracker_id
belongs_to :project,:touch=> true
end

View File

@ -37,6 +37,12 @@
<%= link_to project_issue_count > 0 ? "#{l(:label_issue_tracking)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_issue_count}</span>".html_safe : "#{l(:label_issue_tracking)}", project_issues_path(@project, :remote => true), :class => "pro_new_proname", :title => "#{project_issue_count}" %>
</li>
<% end %>
<!--实训任务-->
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
<li id="project_menu_11">
<%= link_to project_issue_count > 0 ? "#{l(:project_module_training_tasks)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_issue_count}</span>".html_safe : "#{l(:project_module_training_tasks)}", project_issues_path(@project, :remote => true), :class => "pro_new_proname", :title => "#{project_issue_count}" %>
</li>
<% end %>
<!--讨论区-->
<% unless @project.enabled_modules.where("name = 'boards'").empty? %>
<li id="project_menu_03">

View File

@ -0,0 +1,55 @@
<%= labelled_fields_for :training_task, @training_task do |f| %>
<ul class="fl pro_new_conbox_left">
<li class="clear">
<span class="fl mt6 mr12">类&nbsp;&nbsp;&nbsp;型</span>
<%= f.select :tracker_id, Tracker.all.collect{ |t| [t.name, t.id] },{:required => true, :no_label => true},
:class => "fl", :style => "width:160px;padding-left:0px;" %>
</li>
<li>
<label class="label"><span class="c_red f12">*</span>&nbsp;主题&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :subject, :style => "font-size:small;width:606px;", :no_label => true %>
<!--Added by young-->
<%= javascript_tag do %>
observeAutocompleteField('issue_subject',
'<%= escape_javascript auto_complete_issues_path(:project_id => @project, :scope => (Setting.cross_project_issue_relations? ? 'all' : nil)) %>',
{ select: function(event, ui) {
$('input#issue_subject').val(ui.item.value);
}
});
<% end %>
</li>
<li class="clear">
<% if @issue.safe_attribute? 'description' %>
<label class="label">&nbsp;描述&nbsp;&nbsp;:&nbsp;</label>
<%= f.label_for_field :description, :no_label => true, :class => "label" %>
<%#= link_to_function image_tag('edit.png'), '$(this).hide(); $("#issue_description_and_toolbar").show()' unless @issue.new_record? %>
<%#= content_tag 'span', :id => "issue_description_and_toolbar" do %>
<%= f.kindeditor :description,:editor_id => "training_task_desc_editor", :width=>'85%', :height =>159, :resizeType => 0, :no_label => true, at_id: @project.id, at_type: @project.class.to_s %>
<%# end %>
<%#= wikitoolbar_for 'issue_description' %>
<% end %>
</li>
<li class="clear">
<label class="label"><%= l(:label_attachment_plural) %></label>
<%#= render :partial => 'attachments/form', :locals => {:container => @training_task} %>
</li>
<li class="clear">
<% if params[:action] == "new" %>
<a href="<%= project_training_tasks_url(@project, :remote => true) %>" class="sy_btn_grey mr5 fr"> 取消</a>
<% else %>
<%= link_to "取消", training_task_path(@training_task), :class => "sy_btn_grey mr5 fr" %>
<% end %>
<!--<a href="javascript:void(0);" class="sy_btn_blue mr5 fr"> 保存并继续</a>-->
<!--<a href="javascript:void(0);" onclick="issue_desc_editor.sync();$('#issue-form').submit();" class="sy_btn_blue mr5 fr" id="issue_confirm"> 保存</a>-->
<input onclick="issue_create();" class="sy_btn_blue fr mr5" onfocus="this.blur()" id="issue_confirm" style="width: 28px;color: #FFF" value="保存">
</li>
</ul>
<% end %>
<script>
function issue_create(){
training_task_desc_editor.sync();
$('#project_training_form').submit();
}
</script>

View File

@ -0,0 +1,27 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
<% end %>
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
});
</script>
<!--新建缺陷开始-->
<div class="pro_new_con ">
<div class="pro_newissue_con clear">
<%= call_hook(:view_issues_new_top, {:training_task => @training_task}) %>
<%= labelled_form_for @training_task, :url => project_training_tasks_url(@project),
:html => {:id => 'project_training_form', :multipart => true} do |f| %>
<%= error_messages_for 'training_task' %>
<%= hidden_field_tag 'copy_from', params[:copy_from] if params[:copy_from] %>
<div>
<%= render :partial => 'training_tasks/form', :locals => {:f => f} %>
</div>
<% end %>
</div>
</div>
<!--新建缺陷结束-->

View File

@ -390,6 +390,8 @@ zh:
project_module_time_tracking: 时间跟踪
#project_module_course: 课程
project_module_training_tasks: 实训任务
# 成员配置
label_approve: 批准
label_refusal: 拒绝

View File

@ -965,6 +965,18 @@ RedmineApp::Application.routes.draw do
end
end
resources :training_tasks do
collection do
end
member do
post 'add_journal'
get 'delete_journal'
get 'reply'
post 'add_reply'
end
end
resources :pull_requests do
collection do
end

View File

@ -201,6 +201,7 @@ default_projects_modules:
- calendar
- gantt
- course
- training_tasks
# - dts
default_projects_tracker_ids:
serialized: true

View File

@ -0,0 +1,12 @@
class CreateTrainingTasks < ActiveRecord::Migration
def change
create_table :training_tasks do |t|
t.integer :project_id
t.integer :tracker_id
t.string :subject
t.text :description
t.timestamps
end
end
end

View File

@ -0,0 +1,6 @@
class AddAuthorIdToTrainingTasks < ActiveRecord::Migration
def change
add_column :training_tasks, :author_id, :integer
add_column :training_tasks, :status, :integer, :limit => 1, :default => 1
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20170209020934) do
ActiveRecord::Schema.define(:version => 20170217092859) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -316,6 +316,7 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.integer "course_id"
t.integer "org_subfield_id"
t.integer "contest_id"
t.integer "training_project_id"
end
add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id"
@ -358,6 +359,8 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.date "commit_date"
t.string "scmid"
t.integer "user_id"
t.integer "project_id"
t.integer "type", :default => 0
end
add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on"
@ -628,20 +631,6 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.integer "container_id", :default => 0
end
create_table "course_class_post", :id => false, :force => true do |t|
t.integer "班级id", :default => 0, :null => false
t.string "班级名"
t.integer "帖子id", :default => 0, :null => false
t.integer "主贴id"
t.string "帖子标题", :default => "", :null => false
t.text "帖子内容"
t.integer "帖子用户id"
t.integer "帖子回复数", :default => 0, :null => false
t.integer "最后回帖id"
t.datetime "发帖时间", :null => false
t.datetime "帖子更新时间", :null => false
end
create_table "course_contributor_scores", :force => true do |t|
t.integer "course_id"
t.integer "user_id"
@ -756,6 +745,7 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.string "invite_code"
t.string "qrcode"
t.integer "qrcode_expiretime", :default => 0
t.integer "professional_level_id", :limit => 1
t.integer "invite_code_halt", :limit => 1, :default => 0
t.integer "os_allow", :default => 0
end
@ -832,6 +822,11 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
create_table "disciplines", :force => true do |t|
t.string "name"
t.integer "professional_level_id", :limit => 1
end
create_table "discuss_demos", :force => true do |t|
t.string "title"
t.text "body"
@ -962,8 +957,6 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.datetime "publish_time"
t.datetime "end_time"
t.integer "show_result"
t.integer "question_random", :default => 0
t.integer "choice_random", :default => 0
end
create_table "first_pages", :force => true do |t|
@ -988,6 +981,7 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.integer "org_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "training_project_id"
end
add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id"
@ -1153,6 +1147,10 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.datetime "updated_at", :null => false
end
create_table "innodb_monitor", :id => false, :force => true do |t|
t.integer "a"
end
create_table "invite_lists", :force => true do |t|
t.integer "project_id"
t.integer "user_id"
@ -1685,9 +1683,12 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
end
create_table "professional_levels", :force => true do |t|
t.string "level"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "level"
end
create_table "professions", :force => true do |t|
t.string "name"
t.integer "discipline_id", :limit => 1
end
create_table "project_infos", :force => true do |t|
@ -1712,6 +1713,7 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.integer "attach_num", :default => 0
t.datetime "commit_time"
t.integer "pull_request_num", :default => 0
t.integer "training_project_id", :default => -1
end
create_table "project_statuses", :force => true do |t|
@ -1750,7 +1752,6 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.boolean "hidden_repo", :default => false, :null => false
t.integer "attachmenttype", :default => 1
t.integer "user_id"
t.integer "dts_test", :default => 0
t.string "enterprise_name"
t.integer "organization_id"
t.integer "project_new_type"
@ -1758,6 +1759,11 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.integer "forked_from_project_id"
t.integer "forked_count"
t.integer "publish_resource", :default => 0
t.integer "boards_count", :default => 0
t.integer "news_count", :default => 0
t.integer "acts_count", :default => 0
t.integer "journals_count", :default => 0
t.integer "boards_reply_count", :default => 0
t.integer "visits", :default => 0
t.integer "hot", :default => 0
t.string "invite_code"
@ -2168,6 +2174,7 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.string "pre_course"
t.integer "visits", :default => 0
t.integer "des_status", :default => 0
t.integer "professional_level_id", :limit => 1
end
add_index "syllabuses", ["user_id"], :name => "index_syllabuses_on_user_id"
@ -2248,6 +2255,57 @@ ActiveRecord::Schema.define(:version => 20170209020934) do
t.integer "fields_bits", :default => 0
end
create_table "trackers_training_projects", :id => false, :force => true do |t|
t.integer "training_project_id", :default => 0, :null => false
t.integer "tracker_id", :default => 0, :null => false
end
add_index "trackers_training_projects", ["training_project_id"], :name => "projects_trackers_training_project_id"
create_table "training_projects", :force => true do |t|
t.string "name", :limit => 30, :null => false
t.text "description"
t.string "homepage", :limit => 60
t.boolean "is_public", :default => true, :null => false
t.integer "parent_id"
t.integer "projects_count", :default => 0
t.string "identifier", :null => false
t.integer "status", :default => 1
t.integer "lft"
t.integer "rgt"
t.boolean "inherit_members", :default => false, :null => false
t.integer "project_type"
t.boolean "hidden_repo", :default => false, :null => false
t.integer "attachmenttype", :default => 1
t.integer "user_id"
t.integer "dts_test", :default => 0
t.string "enterprise_name"
t.integer "organization_id"
t.integer "project_new_type"
t.integer "gpid"
t.integer "forked_from_project_id"
t.integer "forked_count"
t.integer "publish_resource", :default => 0
t.integer "visits", :default => 0
t.integer "hot", :default => 0
t.string "invite_code"
t.string "qrcode"
t.integer "qrcode_expiretime", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "training_tasks", :force => true do |t|
t.integer "project_id"
t.integer "tracker_id"
t.string "subject"
t.text "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "author_id"
t.integer "status", :limit => 1, :default => 1
end
create_table "user_actions", :force => true do |t|
t.integer "user_id"
t.string "action_type"

View File

@ -193,6 +193,11 @@ Redmine::AccessControl.map do |map|
map.permission :delete_issue_watchers, {:watchers => :destroy}
end
map.project_module :training_tasks do |map|
# map.permission :manage_training_tasks, {:training_tasks => [:new, :create]}, :require => :loggedin
# map.permission :view_training_tasks, {:training_tasks => :index, :versions => :download}, :read => true
end
# map.project_module :time_tracking do |map|
# map.permission :log_time, {:timelog => [:new, :create]}, :require => :loggedin
# map.permission :view_time_entries, {:timelog => [:index, :report, :show]}, :read => true

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe TrainingTasksController, :type => :controller do
end

View File

@ -0,0 +1,9 @@
FactoryGirl.define do
factory :training_task do
project_id 1
tracker_id 1
subject "MyString"
description "MyText"
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe TrainingTask, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end