Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

Conflicts:
	db/schema.rb
This commit is contained in:
caishi 2018-02-07 14:16:11 +08:00
commit 617970ddd2
29 changed files with 6491 additions and 2719 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 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 main_categories controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

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

View File

@ -0,0 +1,88 @@
# encoding=utf-8
class MainCategoriesController < ApplicationController
# GET /main_categories
# GET /main_categories.json
layout 'admin'
before_filter :require_admin
def index
@main_categories = MainCategory.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @main_categories }
end
end
# GET /main_categories/1
# GET /main_categories/1.json
def show
@main_category = MainCategory.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @main_category }
end
end
# GET /main_categories/new
# GET /main_categories/new.json
def new
@main_category = MainCategory.new
respond_to do |format|
format.html # new.html.erb
format.js
format.json { render json: @main_category }
end
end
# GET /main_categories/1/edit
def edit
@main_category = MainCategory.find(params[:id])
end
# POST /main_categories
# POST /main_categories.json
def create
@main_category = MainCategory.new(params[:main_category])
respond_to do |format|
if @main_category.save
format.html { redirect_to main_categories_path, notice: '朱类别创建成功' }
format.js
format.json { render json: @main_category, status: :created, location: @main_category }
else
format.html { render action: "new" }
format.json { render json: @main_category.errors, status: :unprocessable_entity }
end
end
end
# PUT /main_categories/1
# PUT /main_categories/1.json
def update
@main_category = MainCategory.find(params[:id])
respond_to do |format|
if @main_category.update_attributes(params[:main_category])
format.html { redirect_to @main_category, notice: 'Main category was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @main_category.errors, status: :unprocessable_entity }
end
end
end
# DELETE /main_categories/1
# DELETE /main_categories/1.json
def destroy
@main_category = MainCategory.find(params[:id])
@main_category.destroy
respond_to do |format|
format.html { redirect_to main_categories_url }
format.json { head :no_content }
end
end
end

View File

@ -0,0 +1,85 @@
class SubCategoriesController < ApplicationController
layout 'admin'
before_filter :require_admin
# GET /sub_categories
# GET /sub_categories.json
def index
@sub_categories = SubCategory.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sub_categories }
end
end
# GET /sub_categories/1
# GET /sub_categories/1.json
def show
@sub_category = SubCategory.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @sub_category }
end
end
# GET /sub_categories/new
# GET /sub_categories/new.json
def new
@sub_category = SubCategory.new
@main_categories = MainCategory.all
respond_to do |format|
format.html # new.html.erb
format.json { render json: @sub_category }
end
end
# GET /sub_categories/1/edit
def edit
@sub_category = SubCategory.find(params[:id])
end
# POST /sub_categories
# POST /sub_categories.json
def create
@sub_category = SubCategory.new(params[:sub_category])
respond_to do |format|
if @sub_category.save
format.html { redirect_to @sub_category, notice: 'Sub category was successfully created.' }
format.json { render json: @sub_category, status: :created, location: @sub_category }
else
format.html { render action: "new" }
format.json { render json: @sub_category.errors, status: :unprocessable_entity }
end
end
end
# PUT /sub_categories/1
# PUT /sub_categories/1.json
def update
@sub_category = SubCategory.find(params[:id])
respond_to do |format|
if @sub_category.update_attributes(params[:sub_category])
format.html { redirect_to @sub_category, notice: 'Sub category was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @sub_category.errors, status: :unprocessable_entity }
end
end
end
# DELETE /sub_categories/1
# DELETE /sub_categories/1.json
def destroy
@sub_category = SubCategory.find(params[:id])
@sub_category.destroy
respond_to do |format|
format.html { redirect_to sub_categories_url }
format.json { head :no_content }
end
end
end

View File

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

View File

@ -0,0 +1,6 @@
module SubCategoriesHelper
def main_category_option
end
end

View File

@ -0,0 +1,4 @@
class MainCategory < ActiveRecord::Base
attr_accessible :name
has_many :sub_categories
end

View File

@ -0,0 +1,4 @@
class SubCategory < ActiveRecord::Base
attr_accessible :main_category_id, :name
belongs_to :main_category
end

View File

@ -0,0 +1,21 @@
<%= form_for(@main_category) do |f| %>
<% if @main_category.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@main_category.errors.count, "error") %> prohibited this main_category from being saved:</h2>
<ul>
<% @main_category.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

View File

View File

@ -0,0 +1,6 @@
<h1>Editing main_category</h1>
<%= render 'form' %>
<%= link_to 'Show', @main_category %> |
<%= link_to 'Back', main_categories_path %>

View File

@ -0,0 +1,23 @@
<h1>Listing main_categories</h1>
<table>
<tr>
<th>Name</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @main_categories.each do |main_category| %>
<tr>
<td><%= main_category.name %></td>
<td><%= link_to 'Show', main_category %></td>
<td><%= link_to 'Edit', edit_main_category_path(main_category) %></td>
<td><%= link_to 'Destroy', main_category, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Main category', new_main_category_path, :remote => true %>

View File

@ -0,0 +1,5 @@
<h1>New main_category</h1>
<%= render 'form' %>
<%= link_to 'Back', main_categories_path %>

View File

@ -0,0 +1,2 @@
var html_value = "<%= escape_javascript(render :partial => 'main_categories/form') %>";
pop_up_box(html_value, 530);

View File

@ -0,0 +1,10 @@
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @main_category.name %>
</p>
<%= link_to 'Edit', edit_main_category_path(@main_category) %> |
<%= link_to 'Back', main_categories_path %>

View File

@ -14,7 +14,7 @@
<div class="field line_field"> <div class="field line_field">
<label><span>*</span>数据名称:</label> <label><span>*</span>数据名称:</label>
<%= f.text_field :name,:class=>"wb85" %> <%= f.text_field :name, :class => "wb85" %>
</div> </div>
<div class="field line_field"> <div class="field line_field">
<label><span>*</span>数据分类:</label> <label><span>*</span>数据分类:</label>

View File

@ -0,0 +1,26 @@
<%= form_for(@sub_category) do |f| %>
<% if @sub_category.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@sub_category.errors.count, "error") %> prohibited this sub_category from being saved:</h2>
<ul>
<% @sub_category.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :main_category_id %><br />
<%= f.select :main_category_id, (@main_categories.collect { |mc| [mc.name, mc.id] }),
{:no_label => true}, :class => "w150" %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

View File

@ -0,0 +1,6 @@
<h1>Editing sub_category</h1>
<%= render 'form' %>
<%= link_to 'Show', @sub_category %> |
<%= link_to 'Back', sub_categories_path %>

View File

@ -0,0 +1,25 @@
<h1>Listing sub_categories</h1>
<table>
<tr>
<th>Name</th>
<th>Main category</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @sub_categories.each do |sub_category| %>
<tr>
<td><%= sub_category.name %></td>
<td><%= sub_category.main_category_id %></td>
<td><%= link_to 'Show', sub_category %></td>
<td><%= link_to 'Edit', edit_sub_category_path(sub_category) %></td>
<td><%= link_to 'Destroy', sub_category, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Sub category', new_sub_category_path %>

View File

@ -0,0 +1,5 @@
<h1>New sub_category</h1>
<%= render 'form' %>
<%= link_to 'Back', sub_categories_path %>

View File

@ -0,0 +1,15 @@
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @sub_category.name %>
</p>
<p>
<b>Main category:</b>
<%= @sub_category.main_category_id %>
</p>
<%= link_to 'Edit', edit_sub_category_path(@sub_category) %> |
<%= link_to 'Back', sub_categories_path %>

View File

@ -396,6 +396,8 @@ zh:
label_organization_edit: 修改组织 label_organization_edit: 修改组织
label_project_plural: 项目列表 label_project_plural: 项目列表
label_contest_plural: 竞赛列表 label_contest_plural: 竞赛列表
label_main_categories: 数据主类
label_sub_categories: 数据子类
label_first_page_made: 首页定制 label_first_page_made: 首页定制
label_project_first_page: 项目托管平台首页 label_project_first_page: 项目托管平台首页

View File

@ -26,6 +26,12 @@
# Example: :via => :get ====> :via => :get # Example: :via => :get ====> :via => :get
RedmineApp::Application.routes.draw do RedmineApp::Application.routes.draw do
resources :sub_categories
resources :main_categories
resources :statistics resources :statistics

View File

@ -0,0 +1,9 @@
class CreateMainCategories < ActiveRecord::Migration
def change
create_table :main_categories do |t|
t.string :name
t.timestamps
end
end
end

View File

@ -0,0 +1,10 @@
class CreateSubCategories < ActiveRecord::Migration
def change
create_table :sub_categories do |t|
t.string :name
t.integer :main_category_id
t.timestamps
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -381,6 +381,8 @@ Redmine::MenuManager.map :admin_menu do |menu|
menu.push :syllabuses, {:controller => 'admin', :action => 'syllabuses'}, :caption => :label_course_all menu.push :syllabuses, {:controller => 'admin', :action => 'syllabuses'}, :caption => :label_course_all
menu.push :contests, {:controller => 'admin', :action => 'contests'}, :caption => :label_contest_plural menu.push :contests, {:controller => 'admin', :action => 'contests'}, :caption => :label_contest_plural
menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural
menu.push :main_categories, {:controller => 'main_categories', :action => 'index'}, :caption => :label_main_categories
menu.push :sub_categories, {:controller => 'sub_categories', :action => 'index'}, :caption => :label_sub_categories
menu.push :messages, {:controller => 'admin', :action => 'messages'}, :caption => :label_system_message menu.push :messages, {:controller => 'admin', :action => 'messages'}, :caption => :label_system_message
menu.push :schools, {:controller => 'admin', :action => 'schools'}, :caption => :label_school_plural menu.push :schools, {:controller => 'admin', :action => 'schools'}, :caption => :label_school_plural
menu.push :applied_schools, {:controller => 'admin', :action => 'applied_schools'}, :caption => :label_applied_shcools menu.push :applied_schools, {:controller => 'admin', :action => 'applied_schools'}, :caption => :label_applied_shcools