diff --git a/app/assets/javascripts/memos.js b/app/assets/javascripts/memos.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/memos.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/memos.css b/app/assets/stylesheets/memos.css new file mode 100644 index 000000000..afad32db0 --- /dev/null +++ b/app/assets/stylesheets/memos.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 806ba2574..82ac7480b 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -1,6 +1,7 @@ class ForumsController < ApplicationController # GET /forums # GET /forums.json + layout "base_admin" def index @forums = Forum.all @@ -41,6 +42,7 @@ class ForumsController < ApplicationController # POST /forums.json def create @forum = Forum.new(params[:forum]) + @forum.creator_id = User.current.id respond_to do |format| if @forum.save diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb new file mode 100644 index 000000000..7b55a1761 --- /dev/null +++ b/app/controllers/memos_controller.rb @@ -0,0 +1,2 @@ +class MemosController < ApplicationController +end diff --git a/app/helpers/memos_helper.rb b/app/helpers/memos_helper.rb new file mode 100644 index 000000000..0e732a176 --- /dev/null +++ b/app/helpers/memos_helper.rb @@ -0,0 +1,2 @@ +module MemosHelper +end diff --git a/app/models/forum.rb b/app/models/forum.rb index e87540e7e..6a56972b3 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -1,3 +1,17 @@ class Forum < ActiveRecord::Base - # attr_accessible :title, :body + include Redmine::SafeAttributes + has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL" + has_many :memos, :dependent => :destroy + belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id' + safe_attributes 'name', + 'description', + 'topic_count', + 'memo_count', + 'last_memo_id', + 'creator_id' + validates_presence_of :name, :creator_id + validates_length_of :name, maximum: 50 + validates_length_of :description, maximum: 255 + validates :name, :uniqueness => true + end diff --git a/app/models/memo.rb b/app/models/memo.rb new file mode 100644 index 000000000..3668182b0 --- /dev/null +++ b/app/models/memo.rb @@ -0,0 +1,17 @@ +class Memo < ActiveRecord::Base + include Redmine::SafeAttributes + belongs_to :forums + belongs_to :author, :class_name => "User", :foreign_key => 'author_id' + safe_attributes "author_id", + "subject", + "content", + "forum_id", + "last_reply_id", + "lock", + "parent_id", + "replies_count", + "sticky" + validates_presence_of :author_id, :content, :forum_id, :subject + validates_length_of :subject, maximum: 50 + validates_length_of :content, maximum: 2048 +end diff --git a/app/views/forums/_form.html.erb b/app/views/forums/_form.html.erb index 2eaf28e33..cbda66a04 100644 --- a/app/views/forums/_form.html.erb +++ b/app/views/forums/_form.html.erb @@ -1,4 +1,5 @@ -<%= form_for(@forum) do |f| %> + +<%= labelled_form_for(@forum) do |f| %> <% if @forum.errors.any? %>

<%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:

@@ -10,8 +11,9 @@
<% end %> -
+

<%= f.text_field :name, :required => true %>

+

<%= f.text_field :description, :required => true, :size => 80 %>

<%= f.submit %>
<% end %> diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index a1f650d12..d9ad7b901 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -2,6 +2,9 @@ + + + @@ -9,6 +12,9 @@ <% @forums.each do |forum| %> + + + diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index b7cea417b..63ac98bbf 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -1,5 +1,6 @@

<%= notice %>

- +

<%= %>

+

<%= %>

<%= link_to 'Edit', edit_forum_path(@forum) %> | <%= link_to 'Back', forums_path %> diff --git a/config/routes.rb b/config/routes.rb index b2b90e7fa..b44dcf025 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,27 +17,7 @@ RedmineApp::Application.routes.draw do resources :forums do - - member do - get 'settings(/:tab)', :action => 'settings', :as => 'settings' - post 'modules' - post 'archive' - post 'unarchive' - post 'close' - post 'reopen' - match 'copy', :via => [:get, :post] - end - - shallow do - resources :memberships, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do - collection do - get 'autocomplete' - end - end - end - - resources :boards - + resources :memos end diff --git a/db/migrate/20131122020026_create_forums.rb b/db/migrate/20131122020026_create_forums.rb index b6b06237b..4b2f42d9b 100644 --- a/db/migrate/20131122020026_create_forums.rb +++ b/db/migrate/20131122020026_create_forums.rb @@ -1,8 +1,13 @@ class CreateForums < ActiveRecord::Migration - def change - create_table :forums do |t| - - t.timestamps - end - end + def change + create_table :forums do |t| + t.column "name", :string, :default => nil, :null => false + t.column "description", :string, :default => '', :null => true + t.column "topic_count", :integer, :default => 0 + t.column "memo_count", :integer, :default => 0 + t.column "last_memo_id",:integer, :default => 0 + t.column "creator_id", :integer, :null => false + t.timestamps + end + end end diff --git a/db/migrate/20131122132942_create_memos.rb b/db/migrate/20131122132942_create_memos.rb new file mode 100644 index 000000000..fcb3f9967 --- /dev/null +++ b/db/migrate/20131122132942_create_memos.rb @@ -0,0 +1,17 @@ +class CreateMemos < ActiveRecord::Migration + def change + create_table :memos do |t| + t.integer :forum_id, :null => false + t.integer :parent_id, null: true + t.string :subject, null: false + t.text :content, null: false + t.integer :author_id, null: false + t.integer :replies_count + t.integer :last_reply_id + t.boolean :lock, default: false + t.boolean :sticky, default: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index bced5ea86..fc038ed17 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,15 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20131113124237) do +ActiveRecord::Schema.define(:version => 20131122132942) do + + create_table "a_user_watchers", :force => true do |t| + t.string "name" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "member_id" + end create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -253,6 +261,17 @@ ActiveRecord::Schema.define(:version => 20131113124237) do add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" + create_table "forums", :force => true do |t| + t.string "name", :null => false + t.string "description", :default => "" + t.integer "topic_count", :default => 0 + t.integer "memo_count", :default => 0 + t.integer "last_memo_id", :default => 0 + t.integer "creator_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "groups_users", :id => false, :force => true do |t| t.integer "group_id", :null => false t.integer "user_id", :null => false @@ -283,9 +302,9 @@ ActiveRecord::Schema.define(:version => 20131113124237) do add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" create_table "issue_relations", :force => true do |t| - t.integer "issue_from_id", :null => false - t.integer "issue_to_id", :null => false - t.string "relation_type", :default => "", :null => false + t.integer "issue_from_id", :null => false + t.integer "issue_to_id", :null => false + t.string "relation_type", :null => false t.integer "delay" end @@ -414,6 +433,20 @@ ActiveRecord::Schema.define(:version => 20131113124237) do add_index "members", ["user_id", "project_id"], :name => "index_members_on_user_id_and_project_id", :unique => true add_index "members", ["user_id"], :name => "index_members_on_user_id" + create_table "memos", :force => true do |t| + t.integer "forum_id", :null => false + t.integer "parent_id" + t.string "subject", :null => false + t.text "content", :null => false + t.integer "author_id", :null => false + t.integer "replies_count" + t.integer "last_reply_id" + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "messages", :force => true do |t| t.integer "board_id", :null => false t.integer "parent_id" @@ -434,6 +467,22 @@ ActiveRecord::Schema.define(:version => 20131113124237) do add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" add_index "messages", ["parent_id"], :name => "messages_parent_id" + create_table "messages_for_bids", :force => true do |t| + t.string "message" + t.integer "user_id" + t.integer "bid_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "messages_for_users", :force => true do |t| + t.integer "messager_id" + t.integer "user_id" + t.string "message" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "news", :force => true do |t| t.integer "project_id" t.string "title", :limit => 60, :default => "", :null => false @@ -493,11 +542,22 @@ ActiveRecord::Schema.define(:version => 20131113124237) do t.integer "watchers_count" t.integer "project_id" t.integer "project_type" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 + t.integer "gitlab_group_id", :limit => 8 + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 end - add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" + add_index "project_statuses", ["changesets_count"], :name => "index_project_statuses_on_changesets_count" + add_index "project_statuses", ["watchers_count"], :name => "index_project_statuses_on_watchers_count" + + create_table "project_tags", :force => true do |t| + t.integer "project_id" + t.integer "tag_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "user_id" + end create_table "projects", :force => true do |t| t.string "name", :default => "", :null => false @@ -516,9 +576,6 @@ ActiveRecord::Schema.define(:version => 20131113124237) do t.boolean "hidden_repo", :default => false, :null => false end - add_index "projects", ["lft"], :name => "index_projects_on_lft" - add_index "projects", ["rgt"], :name => "index_projects_on_rgt" - create_table "projects_trackers", :id => false, :force => true do |t| t.integer "project_id", :default => 0, :null => false t.integer "tracker_id", :default => 0, :null => false @@ -543,17 +600,18 @@ ActiveRecord::Schema.define(:version => 20131113124237) do add_index "queries", ["user_id"], :name => "index_queries_on_user_id" create_table "repositories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "url", :default => "", :null => false - t.string "login", :limit => 60, :default => "" - t.string "password", :default => "" - t.string "root_url", :default => "" + t.integer "project_id", :default => 0, :null => false + t.string "url", :default => "", :null => false + t.string "login", :limit => 60, :default => "" + t.string "password", :default => "" + t.string "root_url", :default => "" t.string "type" - t.string "path_encoding", :limit => 64 - t.string "log_encoding", :limit => 64 + t.string "path_encoding", :limit => 64 + t.string "log_encoding", :limit => 64 t.text "extra_info" t.string "identifier" - t.boolean "is_default", :default => false + t.boolean "is_default", :default => false + t.string "git_project_id" end add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" @@ -567,26 +625,6 @@ ActiveRecord::Schema.define(:version => 20131113124237) do t.string "issues_visibility", :limit => 30, :default => "default", :null => false end - create_table "seems_rateable_cached_ratings", :force => true do |t| - t.integer "cacheable_id", :limit => 8 - t.string "cacheable_type" - t.float "avg", :null => false - t.integer "cnt", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "seems_rateable_rates", :force => true do |t| - t.integer "rater_id", :limit => 8 - t.integer "rateable_id" - t.string "rateable_type" - t.float "stars", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "settings", :force => true do |t| t.string "name", :default => "", :null => false t.text "value" @@ -597,13 +635,20 @@ ActiveRecord::Schema.define(:version => 20131113124237) do create_table "shares", :force => true do |t| t.date "created_on" - t.string "url" t.string "title" - t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.string "share_type" + t.string "url" + 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| + t.string "name" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "students_for_courses", :force => true do |t| @@ -664,7 +709,7 @@ ActiveRecord::Schema.define(:version => 20131113124237) do create_table "tokens", :force => true do |t| t.integer "user_id", :default => 0, :null => false t.string "action", :limit => 30, :default => "", :null => false - t.string "value", :limit => 40, :default => "", :null => false + t.string "value", :limit => 40 t.datetime "created_on", :null => false end @@ -696,6 +741,7 @@ ActiveRecord::Schema.define(:version => 20131113124237) do t.string "teacher_realname" t.string "student_realname" t.string "location_city" + t.string "git_token" end create_table "user_grades", :force => true do |t| @@ -732,6 +778,14 @@ ActiveRecord::Schema.define(:version => 20131113124237) do add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" 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" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "users", :force => true do |t| t.string "login", :default => "", :null => false t.string "hashed_password", :limit => 40, :default => "", :null => false
namedescriptioncreator
<%= forum.name %><%= forum.description %><%= forum.creator.show_name %> <%= link_to 'Show', forum %> <%= link_to 'Edit', edit_forum_path(forum) %> <%= link_to 'Destroy', forum, method: :delete, data: { confirm: 'Are you sure?' } %>