From 658ea0cf1ecd9a50df74f32bced5c8cd1ce7d7c5 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 May 2016 14:49:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BC=95=E7=94=A8=20?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E6=90=AD=E5=BB=BA=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/apply_resource.rb | 14 + app/models/attachment.rb | 6 + app/models/user.rb | 1 + app/views/users/_apply_for_resource.html.erb | 16 + app/views/users/_apply_resource.html.erb | 28 ++ app/views/users/_resources_list.html.erb | 15 +- app/views/users/apply_for_resource.js.erb | 15 + app/views/users/apply_resource.js.erb | 10 + app/views/users/user_resource.html.erb | 2 +- config/routes.rb | 2 + .../20160517091224_create_apply_resources.rb | 11 + ...0518031514_add_column_to_apply_resource.rb | 6 + ...43_add_column_content_to_apply_resource.rb | 6 + db/schema.rb | 435 +++++++++++++++++- public/stylesheets/public.css | 3 + spec/factories/apply_resources.rb | 8 + spec/models/apply_resource_spec.rb | 5 + 17 files changed, 557 insertions(+), 26 deletions(-) create mode 100644 app/models/apply_resource.rb create mode 100644 app/views/users/_apply_for_resource.html.erb create mode 100644 app/views/users/_apply_resource.html.erb create mode 100644 app/views/users/apply_for_resource.js.erb create mode 100644 app/views/users/apply_resource.js.erb create mode 100644 db/migrate/20160517091224_create_apply_resources.rb create mode 100644 db/migrate/20160518031514_add_column_to_apply_resource.rb create mode 100644 db/migrate/20160518060243_add_column_content_to_apply_resource.rb create mode 100644 spec/factories/apply_resources.rb create mode 100644 spec/models/apply_resource_spec.rb diff --git a/app/models/apply_resource.rb b/app/models/apply_resource.rb new file mode 100644 index 000000000..50fdeebcb --- /dev/null +++ b/app/models/apply_resource.rb @@ -0,0 +1,14 @@ +class ApplyResource < ActiveRecord::Base + attr_accessible :attachment_id, :status, :user_id, :container_type, :container_id, :apply_user_id, :content + belongs_to :user + belongs_to :attachment + has_many :course_messages, :class_name => 'CourseMessage', :as => :course_message, :dependent => :destroy + after_create :act_as_apply_resource_message + + def act_as_apply_resource_message + self.course_messages << CourseMessage.new(:user_id => self.user_id, :course_id => self.container_id, :viewed => false, :status => 5) + # REDO:发送邮件 + # Mailer.run.apply_for_resource_request(self.container_id, User.current) + end + +end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index b3f5ce4ed..72205fdc5 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -35,6 +35,7 @@ class Attachment < ActiveRecord::Base # end include UserScoreHelper has_many :attachment_histories + has_many :apply_resources, :dependent => :destroy validates :filename, presence: true, length: {maximum: 254} validates :author, presence: true @@ -536,6 +537,11 @@ class Attachment < ActiveRecord::Base end end + # 获取资源申请状态 + def get_status_by_attach user_id + ApplyResource.where("user_id =? and attachment_id =?", user_id, self.id).first.try(:status) + end + private # Physically deletes the file from the file system diff --git a/app/models/user.rb b/app/models/user.rb index 3956d936e..44ef54c95 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -109,6 +109,7 @@ class User < Principal has_many :student_works_scores, :dependent => :destroy has_many :student_work_projects, :dependent => :destroy has_many :apply_homeworks, :dependent => :destroy + has_many :apply_resources, :dependent => :destroy #end has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, diff --git a/app/views/users/_apply_for_resource.html.erb b/app/views/users/_apply_for_resource.html.erb new file mode 100644 index 000000000..1a0df801b --- /dev/null +++ b/app/views/users/_apply_for_resource.html.erb @@ -0,0 +1,16 @@ +
+
+

+ <% if state == 2 %> + 请求已发送至<%= attachment.author.show_name %>,希望他同意与你分享:) + <% elsif state == 3 %> + 您已发送过分享请求,请勿重复发送。 + <% end %> +

+ +
+
\ No newline at end of file diff --git a/app/views/users/_apply_resource.html.erb b/app/views/users/_apply_resource.html.erb new file mode 100644 index 000000000..2f5732030 --- /dev/null +++ b/app/views/users/_apply_resource.html.erb @@ -0,0 +1,28 @@ +
+
+ <%= form_tag(apply_for_resource_user_path(:id => User.current.id, :attachment_id => attachment.id), :multipart => true, :remote => true, :name=>"apply_for_homework_form", :id=>'apply_for_homework_form') do %> +

申请分享

+

+ 申请说明(必选): + +

+ + + <% end %> +
+
+ \ No newline at end of file diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index ebe111507..720fed133 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -11,13 +11,22 @@
  • <%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename, :class => 'resourcesBlack resource-list-middle hidden mw280' %> - <% if attach.is_public == 0 && @type == "6" %> + <% if attach.is_public == 0 && @type == "6" && attach.author != User.current %> 私有 <% end %>
  • - <% if attach.is_public == 0 && @type == "6" %> - 请求分享 + <% if attach.is_public == 0 && @type == "6" && attach.author != User.current %> + <% ah = attach.get_status_by_attach(attach.author_id) %> + <% if ah.nil? %> + <%= link_to("请求分享", apply_resource_user_path(User.current.id, :attachment_id => attach.id), :class => 'green_btn_share c_white', :remote => true) %> + <% elsif ah.status == 1 %> + 等待回复 + <% elsif ah.status == 2 %> + 可引用 + <% elsif ah.status == 3 %> + 已拒绝 + <% end %> <% else %> -- <% end %> diff --git a/app/views/users/apply_for_resource.js.erb b/app/views/users/apply_for_resource.js.erb new file mode 100644 index 000000000..c37632810 --- /dev/null +++ b/app/views/users/apply_for_resource.js.erb @@ -0,0 +1,15 @@ +<% if @state == 1 %> +hideModal(); +alert("您还未登录,请先登录"); +<% elsif @state == 2 %> +$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/apply_for_resource', :locals => {:attachment => @attachment, :state => @state}) %>'); +showModal('ajax-modal', '500px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().css("top","30%").css("left","50%").css("position","fixed").css("border","3px solid #269ac9"); +$("#homework_apply_status_<%= @attachment.id %>").html("等待回复"); +<% elsif @state == 3 %> +hideModal(); +alert("您已申请过该资源"); +<% end %> \ No newline at end of file diff --git a/app/views/users/apply_resource.js.erb b/app/views/users/apply_resource.js.erb new file mode 100644 index 000000000..62afcfd48 --- /dev/null +++ b/app/views/users/apply_resource.js.erb @@ -0,0 +1,10 @@ +<% if @state == 1 %> +alert("您还未登录"); +<% elsif @state == 2 %> +$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/apply_resource', :locals => {:attachment => @attachment}) %>'); +showModal('ajax-modal', '500px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().css("top","30%").css("left","30%").css("position","fixed").css("border","3px solid #269ac9"); +<% end %> \ No newline at end of file diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 9420fa3ff..f7e239d97 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -56,7 +56,7 @@ 我的资源
  • - 私有资源 + 私有资源
  •  
  • diff --git a/config/routes.rb b/config/routes.rb index 6554d1779..85e3198a3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -561,6 +561,7 @@ RedmineApp::Application.routes.draw do match 'apply_homework', :to => 'users#apply_homework', :via => :get match 'user_homeworks', :to => 'users#user_homeworks', :via => :get match 'student_homeworks', :to => 'users#student_homeworks', :via => :get + get 'apply_resource' get 'user_import_homeworks' get 'user_search_homeworks' get 'choose_user_course' @@ -630,6 +631,7 @@ RedmineApp::Application.routes.draw do get 'user_ref_homework_search' get 'show_homework_detail' post 'apply_for_homework' + post 'apply_for_resource' # end end #resources :blogs diff --git a/db/migrate/20160517091224_create_apply_resources.rb b/db/migrate/20160517091224_create_apply_resources.rb new file mode 100644 index 000000000..8e2516966 --- /dev/null +++ b/db/migrate/20160517091224_create_apply_resources.rb @@ -0,0 +1,11 @@ +class CreateApplyResources < ActiveRecord::Migration + def change + create_table :apply_resources do |t| + t.integer :status + t.integer :user_id + t.integer :attachment_id + + t.timestamps + end + end +end diff --git a/db/migrate/20160518031514_add_column_to_apply_resource.rb b/db/migrate/20160518031514_add_column_to_apply_resource.rb new file mode 100644 index 000000000..164bad7b7 --- /dev/null +++ b/db/migrate/20160518031514_add_column_to_apply_resource.rb @@ -0,0 +1,6 @@ +class AddColumnToApplyResource < ActiveRecord::Migration + def change + add_column :apply_resources, :container_id, :integer + add_column :apply_resources, :container_type, :string + end +end diff --git a/db/migrate/20160518060243_add_column_content_to_apply_resource.rb b/db/migrate/20160518060243_add_column_content_to_apply_resource.rb new file mode 100644 index 000000000..e741527e0 --- /dev/null +++ b/db/migrate/20160518060243_add_column_content_to_apply_resource.rb @@ -0,0 +1,6 @@ +class AddColumnContentToApplyResource < ActiveRecord::Migration + def change + add_column :apply_resources, :content, :text + add_column :apply_resources, :apply_user_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 092252062..58cb9b8ae 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160513120002) do +ActiveRecord::Schema.define(:version => 20160518060243) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -52,6 +52,28 @@ ActiveRecord::Schema.define(:version => 20160513120002) do add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" + create_table "application_settings", :force => true do |t| + t.integer "default_projects_limit" + t.boolean "signup_enabled" + t.boolean "signin_enabled" + t.boolean "gravatar_enabled" + t.text "sign_in_text" + t.datetime "created_at" + t.datetime "updated_at" + t.string "home_page_url" + t.integer "default_branch_protection", :default => 2 + t.boolean "twitter_sharing_enabled", :default => true + t.text "restricted_visibility_levels" + t.boolean "version_check_enabled", :default => true + t.integer "max_attachment_size", :default => 10, :null => false + t.integer "default_project_visibility" + t.integer "default_snippet_visibility" + t.text "restricted_signup_domains" + t.boolean "user_oauth_applications", :default => true + t.string "after_sign_out_path" + t.integer "session_expire_delay", :default => 10080, :null => false + end + create_table "applied_projects", :force => true do |t| t.integer "project_id", :null => false t.integer "user_id", :null => false @@ -77,6 +99,18 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.datetime "updated_at", :null => false end + create_table "apply_resources", :force => true do |t| + t.integer "status" + t.integer "user_id" + t.integer "attachment_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "container_id" + t.string "container_type" + t.text "content" + t.integer "apply_user_id" + end + create_table "at_messages", :force => true do |t| t.integer "user_id" t.integer "at_message_id" @@ -144,6 +178,20 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.string "typeName", :limit => 50 end + create_table "audit_events", :force => true do |t| + t.integer "author_id", :null => false + t.string "type", :null => false + t.integer "entity_id", :null => false + t.string "entity_type", :null => false + t.text "details" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "audit_events", ["author_id"], :name => "index_audit_events_on_author_id" + add_index "audit_events", ["entity_id", "entity_type"], :name => "index_audit_events_on_entity_id_and_entity_type" + add_index "audit_events", ["type"], :name => "index_audit_events_on_type" + create_table "auth_sources", :force => true do |t| t.string "type", :limit => 30, :default => "", :null => false t.string "name", :limit => 60, :default => "", :null => false @@ -241,6 +289,17 @@ ActiveRecord::Schema.define(:version => 20160513120002) do add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" add_index "boards", ["project_id"], :name => "boards_project_id" + create_table "broadcast_messages", :force => true do |t| + t.text "message", :null => false + t.datetime "starts_at" + t.datetime "ends_at" + t.integer "alert_type" + t.datetime "created_at" + t.datetime "updated_at" + t.string "color" + t.string "font" + end + create_table "bug_to_osps", :force => true do |t| t.integer "osp_id" t.integer "relative_memo_id" @@ -540,6 +599,10 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.integer "visits", :default => 0 end + add_index "courses", ["id"], :name => "id", :unique => true + add_index "courses", ["tea_id"], :name => "tea_id" + add_index "courses", ["visits"], :name => "visits" + create_table "custom_fields", :force => true do |t| t.string "type", :limit => 30, :default => "", :null => false t.string "name", :limit => 30, :default => "", :null => false @@ -601,6 +664,15 @@ ActiveRecord::Schema.define(:version => 20160513120002) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + create_table "deploy_keys_projects", :force => true do |t| + t.integer "deploy_key_id", :null => false + t.integer "project_id", :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "deploy_keys_projects", ["project_id"], :name => "index_deploy_keys_projects_on_project_id" + create_table "discuss_demos", :force => true do |t| t.string "title" t.text "body" @@ -650,6 +722,16 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.datetime "created_at" end + create_table "emails", :force => true do |t| + t.integer "user_id", :null => false + t.string "email", :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "emails", ["email"], :name => "index_emails_on_email", :unique => true + add_index "emails", ["user_id"], :name => "index_emails_on_user_id" + create_table "enabled_modules", :force => true do |t| t.integer "project_id" t.string "name", :null => false @@ -672,6 +754,25 @@ ActiveRecord::Schema.define(:version => 20160513120002) 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 "events", :force => true do |t| + t.string "target_type" + t.integer "target_id" + t.string "title" + t.text "data" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "action" + t.integer "author_id" + end + + add_index "events", ["action"], :name => "index_events_on_action" + add_index "events", ["author_id"], :name => "index_events_on_author_id" + add_index "events", ["created_at"], :name => "index_events_on_created_at" + add_index "events", ["project_id"], :name => "index_events_on_project_id" + add_index "events", ["target_id"], :name => "index_events_on_target_id" + add_index "events", ["target_type"], :name => "index_events_on_target_type" + create_table "exercise_answers", :force => true do |t| t.integer "user_id" t.integer "exercise_question_id" @@ -774,6 +875,15 @@ ActiveRecord::Schema.define(:version => 20160513120002) do add_index "forge_messages", ["forge_message_id", "forge_message_type"], :name => "index_forge_messages_on_forge_message_id_and_forge_message_type" add_index "forge_messages", ["user_id", "project_id", "created_at"], :name => "index_forge_messages_on_user_id_and_project_id_and_created_at" + create_table "forked_project_links", :force => true do |t| + t.integer "forked_to_project_id", :null => false + t.integer "forked_from_project_id", :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "forked_project_links", ["forked_to_project_id"], :name => "index_forked_project_links_on_forked_to_project_id", :unique => true + create_table "forums", :force => true do |t| t.string "name", :null => false t.text "description" @@ -903,6 +1013,17 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.datetime "updated_at", :null => false end + create_table "identities", :force => true do |t| + t.string "extern_uid" + t.string "provider" + t.integer "user_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "identities", ["created_at", "id"], :name => "index_identities_on_created_at_and_id" + add_index "identities", ["user_id"], :name => "index_identities_on_user_id" + create_table "invite_lists", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -1046,6 +1167,20 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.integer "private", :default => 0 end + create_table "keys", :force => true do |t| + t.integer "user_id" + t.datetime "created_at" + t.datetime "updated_at" + t.text "key" + t.string "title" + t.string "type" + t.string "fingerprint" + t.boolean "public", :default => false, :null => false + end + + add_index "keys", ["created_at", "id"], :name => "index_keys_on_created_at_and_id" + add_index "keys", ["user_id"], :name => "index_keys_on_user_id" + create_table "kindeditor_assets", :force => true do |t| t.string "asset" t.integer "file_size" @@ -1057,6 +1192,27 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.integer "owner_type", :default => 0 end + create_table "label_links", :force => true do |t| + t.integer "label_id" + t.integer "target_id" + t.string "target_type" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "label_links", ["label_id"], :name => "index_label_links_on_label_id" + add_index "label_links", ["target_id", "target_type"], :name => "index_label_links_on_target_id_and_target_type" + + create_table "labels", :force => true do |t| + t.string "title" + t.string "color" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "labels", ["project_id"], :name => "index_labels_on_project_id" + create_table "member_roles", :force => true do |t| t.integer "member_id", :null => false t.integer "role_id", :null => false @@ -1107,23 +1263,47 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.integer "viewed_count", :default => 0 end - create_table "mess", :id => false, :force => true do |t| - t.string "课程名" - t.integer "课程ID", :default => 0, :null => false - t.string "教师姓", :default => "", :null => false - t.string "教师名", :limit => 30, :default => "", :null => false - t.string "主贴名", :default => "", :null => false - t.integer "主贴或回帖ID", :default => 0, :null => false - t.integer "回帖对应主贴ID" - t.integer "帖子点赞数" - t.integer "主贴回复数", :default => 0, :null => false - t.text "主贴或回帖内容" - t.datetime "发帖时间", :null => false - t.integer "发帖或回帖用户ID", :default => 0, :null => false - t.string "发帖或回帖用户姓", :default => "", :null => false - t.string "发帖或回帖用户名", :limit => 30, :default => "", :null => false + create_table "merge_request_diffs", :force => true do |t| + t.string "state" + t.text "st_commits", :limit => 2147483647 + t.text "st_diffs", :limit => 2147483647 + t.integer "merge_request_id", :null => false + t.datetime "created_at" + t.datetime "updated_at" end + add_index "merge_request_diffs", ["merge_request_id"], :name => "index_merge_request_diffs_on_merge_request_id", :unique => true + + create_table "merge_requests", :force => true do |t| + t.string "target_branch", :null => false + t.string "source_branch", :null => false + t.integer "source_project_id", :null => false + t.integer "author_id" + t.integer "assignee_id" + t.string "title" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "milestone_id" + t.string "state" + t.string "merge_status" + t.integer "target_project_id", :null => false + t.integer "iid" + t.text "description" + t.integer "position", :default => 0 + t.datetime "locked_at" + end + + add_index "merge_requests", ["assignee_id"], :name => "index_merge_requests_on_assignee_id" + add_index "merge_requests", ["author_id"], :name => "index_merge_requests_on_author_id" + add_index "merge_requests", ["created_at", "id"], :name => "index_merge_requests_on_created_at_and_id" + add_index "merge_requests", ["created_at"], :name => "index_merge_requests_on_created_at" + add_index "merge_requests", ["milestone_id"], :name => "index_merge_requests_on_milestone_id" + add_index "merge_requests", ["source_branch"], :name => "index_merge_requests_on_source_branch" + add_index "merge_requests", ["source_project_id"], :name => "index_merge_requests_on_source_project_id" + add_index "merge_requests", ["target_branch"], :name => "index_merge_requests_on_target_branch" + add_index "merge_requests", ["target_project_id", "iid"], :name => "index_merge_requests_on_target_project_id_and_iid", :unique => true + add_index "merge_requests", ["title"], :name => "index_merge_requests_on_title" + create_table "message_alls", :force => true do |t| t.integer "user_id" t.integer "message_id" @@ -1158,6 +1338,39 @@ ActiveRecord::Schema.define(:version => 20160513120002) 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 "milestones", :force => true do |t| + t.string "title", :null => false + t.integer "project_id", :null => false + t.text "description" + t.date "due_date" + t.datetime "created_at" + t.datetime "updated_at" + t.string "state" + t.integer "iid" + end + + add_index "milestones", ["created_at", "id"], :name => "index_milestones_on_created_at_and_id" + add_index "milestones", ["due_date"], :name => "index_milestones_on_due_date" + add_index "milestones", ["project_id", "iid"], :name => "index_milestones_on_project_id_and_iid", :unique => true + add_index "milestones", ["project_id"], :name => "index_milestones_on_project_id" + + create_table "namespaces", :force => true do |t| + t.string "name", :null => false + t.string "path", :null => false + t.integer "owner_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "type" + t.string "description", :default => "", :null => false + t.string "avatar" + end + + add_index "namespaces", ["created_at", "id"], :name => "index_namespaces_on_created_at_and_id" + add_index "namespaces", ["name"], :name => "index_namespaces_on_name", :unique => true + add_index "namespaces", ["owner_id"], :name => "index_namespaces_on_owner_id" + add_index "namespaces", ["path"], :name => "index_namespaces_on_path", :unique => true + add_index "namespaces", ["type"], :name => "index_namespaces_on_type" + create_table "news", :force => true do |t| t.integer "project_id" t.string "title", :limit => 60, :default => "", :null => false @@ -1183,6 +1396,31 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.datetime "updated_at", :null => false end + create_table "notes", :force => true do |t| + t.text "note" + t.string "noteable_type" + t.integer "author_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "project_id" + t.string "attachment" + t.string "line_code" + t.string "commit_id" + t.integer "noteable_id" + t.boolean "system", :default => false, :null => false + t.text "st_diff", :limit => 2147483647 + end + + add_index "notes", ["author_id"], :name => "index_notes_on_author_id" + add_index "notes", ["commit_id"], :name => "index_notes_on_commit_id" + add_index "notes", ["created_at", "id"], :name => "index_notes_on_created_at_and_id" + add_index "notes", ["created_at"], :name => "index_notes_on_created_at" + add_index "notes", ["noteable_id", "noteable_type"], :name => "index_notes_on_noteable_id_and_noteable_type" + add_index "notes", ["noteable_type"], :name => "index_notes_on_noteable_type" + add_index "notes", ["project_id", "noteable_type"], :name => "index_notes_on_project_id_and_noteable_type" + add_index "notes", ["project_id"], :name => "index_notes_on_project_id" + add_index "notes", ["updated_at"], :name => "index_notes_on_updated_at" + create_table "notificationcomments", :force => true do |t| t.string "notificationcommented_type" t.integer "notificationcommented_id" @@ -1192,6 +1430,49 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.datetime "updated_at", :null => false end + create_table "oauth_access_grants", :force => true do |t| + t.integer "resource_owner_id", :null => false + t.integer "application_id", :null => false + t.string "token", :null => false + t.integer "expires_in", :null => false + t.text "redirect_uri", :null => false + t.datetime "created_at", :null => false + t.datetime "revoked_at" + t.string "scopes" + end + + add_index "oauth_access_grants", ["token"], :name => "index_oauth_access_grants_on_token", :unique => true + + create_table "oauth_access_tokens", :force => true do |t| + t.integer "resource_owner_id" + t.integer "application_id" + t.string "token", :null => false + t.string "refresh_token" + t.integer "expires_in" + t.datetime "revoked_at" + t.datetime "created_at", :null => false + t.string "scopes" + end + + add_index "oauth_access_tokens", ["refresh_token"], :name => "index_oauth_access_tokens_on_refresh_token", :unique => true + add_index "oauth_access_tokens", ["resource_owner_id"], :name => "index_oauth_access_tokens_on_resource_owner_id" + add_index "oauth_access_tokens", ["token"], :name => "index_oauth_access_tokens_on_token", :unique => true + + create_table "oauth_applications", :force => true do |t| + t.string "name", :null => false + t.string "uid", :null => false + t.string "secret", :null => false + t.text "redirect_uri", :null => false + t.string "scopes", :default => "", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "owner_id" + t.string "owner_type" + end + + add_index "oauth_applications", ["owner_id", "owner_type"], :name => "index_oauth_applications_on_owner_id_and_owner_type" + add_index "oauth_applications", ["uid"], :name => "index_oauth_applications_on_uid", :unique => true + create_table "onclick_times", :force => true do |t| t.integer "user_id" t.datetime "onclick_time" @@ -1348,6 +1629,23 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.integer "allow_teacher", :default => 0 end + create_table "permissions", :force => true do |t| + t.string "controller", :limit => 30, :default => "", :null => false + t.string "action", :limit => 30, :default => "", :null => false + t.string "description", :limit => 60, :default => "", :null => false + t.boolean "is_public", :default => false, :null => false + t.integer "sort", :default => 0, :null => false + t.boolean "mail_option", :default => false, :null => false + t.boolean "mail_enabled", :default => false, :null => false + end + + create_table "permissions_roles", :id => false, :force => true do |t| + t.integer "permission_id", :default => 0, :null => false + t.integer "role_id", :default => 0, :null => false + end + + add_index "permissions_roles", ["role_id"], :name => "permissions_roles_role_id" + create_table "phone_app_versions", :force => true do |t| t.string "version" t.text "description" @@ -1430,6 +1728,11 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.datetime "updated_at", :null => false end + create_table "project_import_data", :force => true do |t| + t.integer "project_id" + t.text "data" + end + create_table "project_infos", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -1519,6 +1822,16 @@ ActiveRecord::Schema.define(:version => 20160513120002) do add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" + create_table "protected_branches", :force => true do |t| + t.integer "project_id", :null => false + t.string "name", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "developers_can_push", :default => false, :null => false + end + + add_index "protected_branches", ["project_id"], :name => "index_protected_branches_on_project_id" + create_table "queries", :force => true do |t| t.integer "project_id" t.string "name", :default => "", :null => false @@ -1653,6 +1966,25 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.integer "is_teacher_score", :default => 0 end + create_table "services", :force => true do |t| + t.string "type" + t.string "title" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "active", :default => false, :null => false + t.text "properties" + t.boolean "template", :default => false + t.boolean "push_events", :default => true + t.boolean "issues_events", :default => true + t.boolean "merge_requests_events", :default => true + t.boolean "tag_push_events", :default => true + t.boolean "note_events", :default => true, :null => false + end + + add_index "services", ["created_at", "id"], :name => "index_services_on_created_at_and_id" + add_index "services", ["project_id"], :name => "index_services_on_project_id" + create_table "settings", :force => true do |t| t.string "name", :default => "", :null => false t.text "value" @@ -1691,6 +2023,26 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.datetime "updated_at", :null => false end + create_table "snippets", :force => true do |t| + t.string "title" + t.text "content", :limit => 2147483647 + t.integer "author_id", :null => false + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "file_name" + t.datetime "expires_at" + t.string "type" + t.integer "visibility_level", :default => 0, :null => false + end + + add_index "snippets", ["author_id"], :name => "index_snippets_on_author_id" + add_index "snippets", ["created_at", "id"], :name => "index_snippets_on_created_at_and_id" + add_index "snippets", ["created_at"], :name => "index_snippets_on_created_at" + add_index "snippets", ["expires_at"], :name => "index_snippets_on_expires_at" + add_index "snippets", ["project_id"], :name => "index_snippets_on_project_id" + add_index "snippets", ["visibility_level"], :name => "index_snippets_on_visibility_level" + create_table "softapplications", :force => true do |t| t.string "name" t.text "description" @@ -1763,9 +2115,9 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.integer "absence_penalty", :default => 0 t.float "system_score", :default => 0.0 t.boolean "is_test", :default => false + t.float "work_score" t.integer "simi_id" t.integer "simi_value" - t.float "work_score" end add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" @@ -1813,13 +2165,13 @@ ActiveRecord::Schema.define(:version => 20160513120002) do create_table "sub_domains", :force => true do |t| t.integer "org_subfield_id" - t.integer "priority", :default => 0 + t.integer "priority" t.string "name" t.string "field_type" - t.integer "hide", :default => 0 - t.integer "status", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "hide" + t.integer "status" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "subfield_subdomain_dirs", :force => true do |t| @@ -1829,6 +2181,17 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.datetime "updated_at", :null => false end + create_table "subscriptions", :force => true do |t| + t.integer "user_id" + t.integer "subscribable_id" + t.string "subscribable_type" + t.boolean "subscribed" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "subscriptions", ["subscribable_id", "subscribable_type", "user_id"], :name => "subscriptions_user_id_and_ref_fields", :unique => true + create_table "system_messages", :force => true do |t| t.integer "user_id" t.string "content" @@ -2068,6 +2431,17 @@ ActiveRecord::Schema.define(:version => 20160513120002) do add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" add_index "users", ["type"], :name => "index_users_on_type" + create_table "users_star_projects", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "users_star_projects", ["project_id"], :name => "index_users_star_projects_on_project_id" + add_index "users_star_projects", ["user_id", "project_id"], :name => "index_users_star_projects_on_user_id_and_project_id", :unique => true + add_index "users_star_projects", ["user_id"], :name => "index_users_star_projects_on_user_id" + create_table "versions", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.string "name", :default => "", :null => false @@ -2119,6 +2493,23 @@ ActiveRecord::Schema.define(:version => 20160513120002) do t.datetime "updated_at", :null => false end + create_table "web_hooks", :force => true do |t| + t.string "url" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "type", :default => "ProjectHook" + t.integer "service_id" + t.boolean "push_events", :default => true, :null => false + t.boolean "issues_events", :default => false, :null => false + t.boolean "merge_requests_events", :default => false, :null => false + t.boolean "tag_push_events", :default => false + t.boolean "note_events", :default => false, :null => false + end + + add_index "web_hooks", ["created_at", "id"], :name => "index_web_hooks_on_created_at_and_id" + add_index "web_hooks", ["project_id"], :name => "index_web_hooks_on_project_id" + create_table "wechat_logs", :force => true do |t| t.string "openid", :null => false t.text "request_raw" diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index fcbd79e0b..8489b0fa1 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -1134,3 +1134,6 @@ a.st_down{ display: block; width:8px; float:left; height:13px; background:url(.. .likeText{color: #7f7f7f} .likeNum{color: #7f7f7f} + +/*弹框*/ +.apply_content{ border:1px solid #ddd;line-height: 16px; height:80px;width:420px; background:#fff; margin-bottom:10px;} \ No newline at end of file diff --git a/spec/factories/apply_resources.rb b/spec/factories/apply_resources.rb new file mode 100644 index 000000000..92e48632b --- /dev/null +++ b/spec/factories/apply_resources.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :apply_resource do + status 1 +user_id 1 +attachment_id 1 + end + +end diff --git a/spec/models/apply_resource_spec.rb b/spec/models/apply_resource_spec.rb new file mode 100644 index 000000000..a0d4b48b1 --- /dev/null +++ b/spec/models/apply_resource_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ApplyResource, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end