From be88914e3905f02fe2b8499c11faeb20f5d745e3 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 25 Jul 2016 13:59:10 +0800 Subject: [PATCH 01/17] =?UTF-8?q?=E5=8E=BB=E6=8E=89id=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 7 ------- app/models/user.rb | 5 ----- 2 files changed, 12 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 58622a089..d64d95223 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -33,13 +33,6 @@ module ApplicationHelper extend Forwardable def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter - def user_path(resource, parameters = {}) - if Fixnum === resource - resource = User.find(resource) - end - super - end - # def user_blogs_path(resource,parameters={}) # super # end diff --git a/app/models/user.rb b/app/models/user.rb index 7e592248e..996aa9be7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -311,11 +311,6 @@ class User < Principal ) end - # id 转换成 登录名 - def to_param - Fixnum === self.login ? id : login - end - # ====================================================================== def my_workplace self.user_extensions.try(:occupation).to_s From 84d1adbf259678134c2941daefde22c1b461e298 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 25 Jul 2016 14:36:52 +0800 Subject: [PATCH 02/17] =?UTF-8?q?=E7=94=9F=E6=88=90=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 17 + app/views/layouts/base_projects.html.erb | 2 +- config/locales/projects/zh.yml | 1 + ...160725062343_add_invite_code_to_project.rb | 5 + db/schema.rb | 429 +++++++++++++++++- 5 files changed, 443 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20160725062343_add_invite_code_to_project.rb diff --git a/app/models/project.rb b/app/models/project.rb index bbc639f3d..3333c805b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -904,6 +904,23 @@ class Project < ActiveRecord::Base User.find(self.user_id) end + # 延迟生成邀请码 + def invite_code + return generate_invite_code + end + + # 生成邀请码 + CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) + def generate_invite_code + code = read_attribute(:invite_code) + if !code || code.size <5 + code = CODES.sample(5).join + return generate_invite_code if Project.where(invite_code: code).present? + update_attribute(:invite_code, code) + end + code + end + private def after_parent_changed(parent_was) diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index a19295233..f68f4c86f 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -53,7 +53,7 @@ <%= image_tag(url_to_avatar(@project), :width => "60", :height => "60") %>
- <%= l(:label_project_id)%><%= @project.id %> + <%= l(:label_project_ivite_code)%><%= @project.generate_invite_code %>
diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 076b905c3..5d2520b19 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -48,6 +48,7 @@ zh: # 左边栏 # label_project_id: "项目ID:" + label_project_ivite_code: "邀请码:" label_agree_join_project: 同意加入 label_apply_project: "+申请加入" diff --git a/db/migrate/20160725062343_add_invite_code_to_project.rb b/db/migrate/20160725062343_add_invite_code_to_project.rb new file mode 100644 index 000000000..5eb8beace --- /dev/null +++ b/db/migrate/20160725062343_add_invite_code_to_project.rb @@ -0,0 +1,5 @@ +class AddInviteCodeToProject < ActiveRecord::Migration + def change + add_column :projects, :invite_code, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 3a92d4fc0..fbdbb29a9 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 => 20160720094503) do +ActiveRecord::Schema.define(:version => 20160725062343) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -52,6 +52,28 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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 @@ -168,6 +190,20 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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 @@ -265,6 +301,17 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -294,14 +341,16 @@ ActiveRecord::Schema.define(:version => 20160720094503) do add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false + t.integer "repository_id", :null => false + t.string "revision", :null => false t.string "committer" - t.datetime "committed_on", :null => false + t.datetime "committed_on", :null => false t.text "comments" 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" @@ -395,6 +444,17 @@ ActiveRecord::Schema.define(:version => 20160720094503) do add_index "comments", ["author_id"], :name => "index_comments_on_author_id" add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" + create_table "commits", :force => true do |t| + t.integer "repository_id" + t.string "version" + t.string "committer" + t.text "comments" + t.datetime "committed_on" + t.integer "project_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "contest_notifications", :force => true do |t| t.text "title" t.text "content" @@ -570,8 +630,11 @@ ActiveRecord::Schema.define(:version => 20160720094503) do t.string "qrcode" end + add_index "courses", ["id"], :name => "id", :unique => true add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true add_index "courses", ["syllabus_id"], :name => "index_courses_on_syllabus_id" + 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 @@ -634,6 +697,15 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -683,6 +755,16 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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 @@ -705,6 +787,25 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -807,6 +908,15 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -936,6 +1046,17 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -1082,6 +1203,20 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -1093,6 +1228,27 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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 @@ -1143,6 +1299,47 @@ ActiveRecord::Schema.define(:version => 20160720094503) do t.integer "viewed_count", :default => 0 end + 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" @@ -1177,6 +1374,39 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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 @@ -1202,6 +1432,31 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -1211,6 +1466,49 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -1368,6 +1666,23 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -1450,6 +1765,11 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -1527,6 +1847,7 @@ ActiveRecord::Schema.define(:version => 20160720094503) do t.integer "boards_reply_count", :default => 0 t.integer "visits", :default => 0 t.integer "hot", :default => 0 + t.string "invite_code" end add_index "projects", ["lft"], :name => "index_projects_on_lft" @@ -1540,6 +1861,16 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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 "quality_analyses", :force => true do |t| t.integer "project_id" t.string "author_login" @@ -1688,6 +2019,25 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -1726,6 +2076,26 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" @@ -1806,9 +2176,9 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" t.integer "work_status", :default => 0 end @@ -1857,13 +2227,13 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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| @@ -1873,6 +2243,17 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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 "syllabuses", :force => true do |t| t.string "title" t.text "description" @@ -2133,6 +2514,17 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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 @@ -2184,6 +2576,23 @@ ActiveRecord::Schema.define(:version => 20160720094503) 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" From 774650c819b5f64044219addf384cd8358ddcdda Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 25 Jul 2016 15:22:34 +0800 Subject: [PATCH 03/17] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E7=A0=81=E7=9B=B4=E6=8E=A5=E6=95=B0=E6=8D=AE=E5=BA=93=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=EF=BC=8C=E6=9D=83=E9=99=90=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 1 + app/views/layouts/_join_exit_project.html.erb | 2 -- app/views/layouts/base_projects.html.erb | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 3333c805b..520407589 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -910,6 +910,7 @@ class Project < ActiveRecord::Base end # 生成邀请码 + # 如果已有改邀请码,则重新生成 CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) def generate_invite_code code = read_attribute(:invite_code) diff --git a/app/views/layouts/_join_exit_project.html.erb b/app/views/layouts/_join_exit_project.html.erb index 35d8f87ef..e893949f4 100644 --- a/app/views/layouts/_join_exit_project.html.erb +++ b/app/views/layouts/_join_exit_project.html.erb @@ -2,9 +2,7 @@ <% if !User.current.member_of?(@project) && User.current.login? && !User.current.admin %> <%= watcher_link_for_project(@project, User.current) %> - <% end %> - <% if !User.current.member_of?(@project) && User.current.login? && !User.current.admin %> <%= join_in_project_link(@project, User.current) %> <% end %> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index f68f4c86f..e7b23b3b5 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -53,7 +53,8 @@ <%= image_tag(url_to_avatar(@project), :width => "60", :height => "60") %>
- <%= l(:label_project_ivite_code)%><%= @project.generate_invite_code %> + <%= l(:label_project_ivite_code)%> + <%= (User.current.member_of?(@project) || User.current.admin?) ? @project.invite_code : "******" %>
From 463c09f02ce609ad4c64ca209a62ff4c4997989c Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 26 Jul 2016 08:55:07 +0800 Subject: [PATCH 04/17] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- app/controllers/applied_project_controller.rb | 75 +++++++------- app/helpers/watchers_helper.rb | 27 +++-- .../_applied_join_project.html.erb | 28 ++++++ .../applied_join_project.js.erb | 21 ++-- config/routes.rb | 4 +- public/images/sy/sy_icons_close02.png | Bin 0 -> 18724 bytes public/javascripts/application.js | 16 +++ public/stylesheets/css/common.css | 31 ++++++ public/stylesheets/css/popup.css | 93 +++++++++++++++++- public/stylesheets/sy_public.css | 56 +++++------ 11 files changed, 260 insertions(+), 93 deletions(-) create mode 100644 app/views/applied_project/_applied_join_project.html.erb create mode 100644 public/images/sy/sy_icons_close02.png diff --git a/Gemfile b/Gemfile index 03dbb5785..a94f1b33b 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,7 @@ gem 'elasticsearch-rails' ### profile -gem 'oneapm_rpm' +# gem 'oneapm_rpm' group :development do gem 'grape-swagger' diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index b9824976b..39491c0e6 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -2,44 +2,45 @@ class AppliedProjectController < ApplicationController #申请加入项目 def applied_join_project - @user_id = params[:user_id] - @project = Project.find_by_id(params[:project_id]) - if params[:project_join] - if @project - user = User.find @user_id - if user.member_of?(@project) - @status = 3 - else - @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id]) - if @applieds.count == 0 - appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) - Mailer.run.applied_project(appliedproject) - @status = 2 - else - @status = 1 - end - end - else - @status = 0 - end - respond_to do |format| - format.js - end - return - end - - @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id]) - if @applieds.count == 0 - appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) - Mailer.run.applied_project(appliedproject) - end - #redirect_to project_path(params[:project_id]) - #redirect_to_referer_or {render :text => ( 'applied success.'), :layout => true} - respond_to do |format| - format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} - format.js { render :partial => 'set_applied'} - end + # @user_id = params[:user_id] + # @project = Project.find_by_id(params[:project_id]) + # if params[:project_join] + # if @project + # user = User.find @user_id + # if user.member_of?(@project) + # @status = 3 + # else + # @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id]) + # if @applieds.count == 0 + # appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) + # Mailer.run.applied_project(appliedproject) + # @status = 2 + # else + # @status = 1 + # end + # end + # else + # @status = 0 + # end + # respond_to do |format| + # format.js + # end + # return + # end + # + # @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id]) + # if @applieds.count == 0 + # appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id]) + # Mailer.run.applied_project(appliedproject) + # end + # + # #redirect_to project_path(params[:project_id]) + # #redirect_to_referer_or {render :text => ( 'applied success.'), :layout => true} + # respond_to do |format| + # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} + # format.js { render :partial => 'set_applied'} + # end end #取消申请 diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 52f2ea119..823fe534b 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -366,20 +366,27 @@ module WatchersHelper #申请加入项目 def join_in_project_link(project, user, options=[]) - return '' unless user && user.logged? applied = project.applied_projects.find_by_user_id(user.id) text = applied ? l(:label_unapply_project) : l(:label_apply_project) - @applied_flag = project.instance_of?(Project) + url = applied ? unapplied_join_project_path(:object_id => project.id) : applied_join_project_path(:object_id => project.id) + method = applied ? 'delete' : 'post' + @applied_flag = project.instance_of?(Project) if applied - appliedid = applied.id + link = link_to(text, url, :remote => true, :method => method, :class => "sy_btn_grey fl", :id => "#{project.id}") + else + link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "sy_btn_grey fl") end - id = applied_css(project) - url = appliedproject_path( - :id=>appliedid, - :user_id => user.id, - :project_id => project.id) - method = applied ? 'delete' : 'post' - link_to text, url, :remote => true, :method => method , :class => "pr_join_a",:id => id + link.html_safe + # if applied + # appliedid = applied.id + # end + # id = applied_css(project) + # url = appliedproject_path( + # :id=>appliedid, + # :user_id => user.id, + # :project_id => project.id) + # method = applied ? 'delete' : 'post' + # link_to text, url, :remote => true, :method => method , :class => "pr_join_a",:id => id end def paginateHelper obj, pre_size=20 diff --git a/app/views/applied_project/_applied_join_project.html.erb b/app/views/applied_project/_applied_join_project.html.erb new file mode 100644 index 000000000..baa49ef01 --- /dev/null +++ b/app/views/applied_project/_applied_join_project.html.erb @@ -0,0 +1,28 @@ + +
+

欢迎加入项目

+ +
+
+
+
    +
  • + + +
    +
  • +
  • + + 管理人员 + 开发人员 + 报告人员 +
    +
  • +
  • + + 确  定 + 取  消 +
    +
  • +
+
diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb index ae9d3f467..f79e9ac20 100644 --- a/app/views/applied_project/applied_join_project.js.erb +++ b/app/views/applied_project/applied_join_project.js.erb @@ -1,14 +1,7 @@ -// @status: 0 该项目不存在;1 不重复加入;2 成功加入; 3 已是项目成员;其它 加入失败 -<% if @status == 0%> - alert("<%= l('project.join.tips.notexist') %>"); -<% elsif @status == 1%> - alert("<%= l('project.join.tips.repeat') %>"); -<% elsif @status == 2%> - alert("<%= l('project.join.tips.success') %>"); - hideModal($("#popbox")); - $("#applied_project_link_<%= @project.id%>").replaceWith("<%=escape_javascript(link_to '取消申请',appliedproject_applied_path(:project_id => @project.id,:user_id => User.current.id),:class => "blue_n_btn fr mt20", :remote => "true",:method => "delete",:id => "applied_project_link_#{@project.id}")%>"); -<% elsif @status == 3%> - alert("<%= l('project.join.tips.has') %>"); -<%else%> - alert("<%= l('project.join.tips.fail') %>"); -<%end%> \ No newline at end of file +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'applied_join_project', locals: { :course => @course}) %>'); +showModal('ajax-modal', '500px'); + +$('#ajax-modal').siblings().remove(); + +$('#ajax-modal').parent().css("top","").css("left",""); + diff --git a/config/routes.rb b/config/routes.rb index 1124080b7..4b9027335 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -721,8 +721,8 @@ RedmineApp::Application.routes.draw do post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue' delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue' - post 'appliedproject/applied', :to => 'applied_project#applied_join_project', :as => 'appliedproject' - delete 'appliedproject/applied', :to => 'applied_project#unapplied_join_project' + post 'applied_project/applied_join', :to => 'applied_project#applied_join_project', :as => 'applied_join_project' + delete 'applied_project/applied', :to => 'applied_project#unapplied_join_project', :as => 'unapplied_join_project' resources :projects do member do diff --git a/public/images/sy/sy_icons_close02.png b/public/images/sy/sy_icons_close02.png new file mode 100644 index 0000000000000000000000000000000000000000..456f2ea67183dcba533dfed2c7591e2b37b9c787 GIT binary patch literal 18724 zcmeI43pAA7*T5g7P$btPVWhWW%mp)MVqD88B6ms|GlR+8niCj zbP?qiMM6c}3IIXP$qs?8(L)M^wjt_lXS1e(3vu*q08ArGtU}uDr1TMhv{PEf zq-@t-31>O^IY~sPTiY8Xh{=1Or7kY;G2Oq{{eaUtgV(C98JD(%^!N3Be)#!XcT)FA zO>ph(@HsMz4nIG+5y08+GQ>BjM%of@-6;wemM6APQ+rt${wiDajcL7D&_*Y4u4Z5fEWOv2Zx%$ zfU}Z7?|UnPDA1G{-Kq#Qot&R31{@Ls;ul*k6gIgEcsgyf*A_0l0inyEs~0?FKN%*z}{6r6aq>sW2@s< z)$7U?#NJa1d^^zoO#Rsn`UNwR;u2|Z@lIG$T%v|7v0KEtW)=V_4cA@&YG54I{k-$( zbMJ0?|NF9&U;PGHFoODd`Oa(Sedc)^6L<)t6^ns-%~Oy%rKaAmv&g0GNcmgCA6yc^HuP(L)Ch z0YG%gaHNTr5KtYL-T?sDUd&y0CPvZvwip0dq;6Z9YdT}rb-Aoksif;F*Gd(INz*M% zW-Tl=ls22*89ra)#N4B%^Bha@P17#riYTSdNq8!qcO7LQ+1)O)Zd(sqak}T+lpAxe z?G~SAS|KJ&QpfL|;}y{as}WO-kC+A{5%rFQr>ni(E4Kz#R>4UZ&NSP2*n_C?7S55w z9a?AdDXOJH4ZVM4|20cg%(jbbL>>tHn_M}gsBEM2W#&Ch7|YUIfjin)mI*onIF7cBaWZJuU`%r`p{-_G`4L-)@N|cCLcKIC$$C*w6ywg5PO*#O zS!!{I^P^@**&g|P=VoWV9KLMtGi&ja3+>ZmWLD}^jk~6uI*vArPd&S)Iy2>g*x9}K zO=+e%5->I!@UHW4{gX7@sd|4{&>fN<#G4o>iu5Kc-j4O z$NRuplDj2$loP!c&-0tNd0xic{CS9Y>(iq5J_~RV-3Z3==hvjxrz*R7H_r_#LAa)D7%>dS*_gZ{guvzG-zfQkiP^UT5*clB&*UPP)GrxyU^b(AM|vfC6MCoj;XaT)XntUP zs8y+&FQd}9jJGV5!}G5SptG;_q(9ZWnRzSo=1UhJWuFt=w>+O;sJq z8HpJ;-bHmI)(5P2TmQLef$iT(i&7eqjEa_9Yuk$|H+$jV42ut&F_Q9m*{8}cksnK*2ESE!vs%bzQ$=fK;<8`5sf>U8_;Qxx$gGV|b- zWi1;oa{_#_Hq!0sd6bh9|pFyl-FUt)^Q>`#QM7-ShSL?|uiqBuxRHg(Py6L+`g&OQSCKGqjxNC=+nH^%TZC3`-1C#7JG zIHMJ`cJA7s0%8%-{eft2Z=+4hA!to1d)AzuVVC>`CuoW(~QOoL^bA z(X`>-?g7bc< zONrckYV(W_%lmsa@>ulN^Ccx0#ToXPLkoy_c2{CJt2wbRA@CC0eW}z9)2{1(wVe*# z++p|PM9t0Co7HXcTk{9SdWgYV_4pG1EO;6t)#yY~|BHiZ$tvqrEQ|BMh4rI4$o}Q} zkuE8z$%~EN40mpi?#Q5Iq$IC4HhK`>8a!k@67T1+#-qr`yf(#Hk@wmyAnDe*b z9`3pBwlB{x$3o=V52vuN3v^Lw)7YD7q*ob zsm3oJG5KouuI>}LJma425TQHt>j+|K=ey6E^~ZI=yU*)1M^~P!jWwRkV(5@4EHA1~ z5Q7cghJrfdAU28YN9Cz`QGIAkBUt~{5||o|Vgz&1w?W#l&8faLVhD%o5VG2l9O6gD zQDDXd3Bw>f=zu}xk<@}1bS4)cWCR=YiwD1tHX~qaV_kTDMljRS0o7b>?9|Lz9IBeW z4hBv}Vz6phoDNDKi`BzwtD%u7eFRb$p^Jp0b@6&gydGNZ`yY%T0e&;&P`vT>7Aw9F z2TDdTUmlN*M<4krBfN82^YM0 z)Ne0={p0-c(|pQh{8ayO_B@*R#Nte`9o78Nj2cAygW0HN+-xiq##hJ?j6b|Nhf3nH zIF2k9oiH9{6Q?Ke@H84#YKvWHObRQIyTlLyHJMoN32#&j5|2s%EirH;7LG6q^JXy~Gjq#$Q;reJK8ID3xF>nJU2@5CTyeK$| zE*7JwkNGjsBxk=2WXl2XjhQ6+q&}l_p@4&VdE>BDGzkUw!g+zqh1T;x}%78Hz~bg3%N_DaycD8_PTn)J;=ce<jc9_d3-K>fR7Bnycxw|AU3#k^=sB%b<@jpkT0Q5}ZuY zMZvM&dIoSWaF@aL&=@2VNyg$R2G}3V{9nEd6H!d|B{6-d6awPM%ziZdH?7=1%ZLBt z4fJc~|Nq-S|Jurp@5HG&@kgHhHHR8f$arrShe6^IXbh4M6~Siu7$PPbC!)o0qI#IK z=q!#6i$W#n8X|tz{97yV7gM|OA4~~cdrLDltL5ex6b^%dqjgY|-AwBDTR%T)jVV|= zM@s^CYR(xe31%dpsjZ`Uzh|i5S43SZ27}W@8i4f)MH#P%BrMecPSV#$8F=f1#TN%A ziQgr;@z$v$PM#0H>opv`>%xQO4@||Rv9bfA_@!+UhB2M%Xc?pXkM+l*!5oG}phn-n zn@(0kP2KpLPF6!rCoG+qG#&vg-eVU7X`W;?dTWRuixmg(6hkF|Q-d}^d)v{1sB~8g z8hG=<9WBBba86@3P{nTz-6jmtQw%35z8j7&+N86_Sh$S0f+rd95QX@8iuxszewO}! z^UK7H{!OnCUxGm(K=_LST>SY!v;tfZApAuEF8+KVS^+Ky5dNY77k@qwtpFDU2!Bz4 zi$5QTR)7lvguf`j#h(vEE5HQ-!e12N;?D=772tvZ;V%ks@#h243UEPy@D~NR`165i z1-KwU_=^Hu{P{q%0$dOv{6zsS{(K->0WJs-{-OXEe?Abc02c%Ze^G#oKOcxzfC~bI zzbL@PpASSUzy$%qUlict&j+Fv;DP|*FA8w+=L69Sa6y3Z7X`TZ^MPmuxFA6IivnEy z`9QP+To54qMFB4Ud>~o@E(j3*q5v0vJ`k+{7X%1@kuNTZiRY53Oz>gkK=7$!arKbV z|D~fwCfeHoK!_#)gzo@=;cwvQO91dk0>CRz0Kgvu07cf34P`3;Kxn6xg{fmub7zz3 z>YGUET~ABqxV(Uen@cx7wwE$BeT&nU-?Z=IV8RU*U)EvsnCgX`j!kH{X)b5uY}OUo z%GRcPB(44{hvu~IQK1mK2EI*Y;8l^aJ9b$&b6cQiUlHrM#1;4K!cg^{9Xq#p6ib`Q zx_p!k0*XaR*PjTrU1VXoq{7hcxtFxS-$}>8Y^LTmcDt`v(8i8*}g z$J_qn4KF|c=$oFwhf3mVOAUcEV*&?adWHXt1WWOJh%S`5G2^? literal 0 HcmV?d00001 diff --git a/public/javascripts/application.js b/public/javascripts/application.js index b7468366a..e86ad8ddc 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1492,6 +1492,22 @@ function pop_up_box(value,tWidth,tTop,tLeft){ } } +// 公共弹框样式 +// title +function pop_box_new(value, tWidth, tTop, tLeft){ + $("#ajax-modal").html(value); + showModal('ajax-modal', tWidth + "px"); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top", tTop+"%").css("left", tLeft+"%").css("padding-top", "10px").css("position", "fixed"); + $('#ajax-modal').parent().addClass("resourceUploadPopup"); + $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); + + function hideModal(){ + $('#ajax-modal').hide(); + } +} + //显示的时候根据当前网址是http 还是https 选择视频显示方式直接显示还是弹框 function autoMedia(id){ var rootPath = getRootPath(); diff --git a/public/stylesheets/css/common.css b/public/stylesheets/css/common.css index b72a8ef56..888cb3ca3 100644 --- a/public/stylesheets/css/common.css +++ b/public/stylesheets/css/common.css @@ -542,6 +542,37 @@ a:hover.BlueCirBtnMini{ background:#269ac9; color:#fff;} .borderRadius {border-radius:5px;} a.Blue-btn{ display:block; margin-right:15px;width:65px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} a:hover.Blue-btn{ background:#3598db; color:#fff;} + +/*20160725 项目申请按钮*/ +a.sy_btn_grey{ + color: #333; + background: #e1e1e1; + text-align: center; + font-size: 12px; + padding:0 15px; + height: 30px; + line-height: 30px; + -webkit-border-radius:3px; + -moz-border-radius:3px; + -o-border-radius:3px; + border-radius:3px; +} +a:hover.sy_btn_grey{ background: #c3c3c3;} +a.sy_btn_blue{ + display:block; + width:80px; + height: 30px; + text-align:center; + color: #fff; + background: #3b94d6; + font-size: 12px; + line-height: 30px; + -webkit-border-radius:3px; + -moz-border-radius:3px; + -o-border-radius:3px; + border-radius:3px; +} +a:hover.sy_btn_blue{ background: #2788d0;} /* commonpic */ .pic_date{ display:block; background:url(/images/public_icon.png) -31px 0 no-repeat; width:16px; height:15px; } .pic_add{ display:block; background:url(/images/public_icon.png) -31px -273px no-repeat; width:16px; height:15px; } diff --git a/public/stylesheets/css/popup.css b/public/stylesheets/css/popup.css index ea2034a5e..c9f8ccf09 100644 --- a/public/stylesheets/css/popup.css +++ b/public/stylesheets/css/popup.css @@ -332,4 +332,95 @@ a.contributor_course{float: right; color: #888; font-size: 12px; font-weight: no .relatePWrap{max-height: 210px;overflow:hidden;} /*20160622代码分析弹窗*/ -.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;} \ No newline at end of file +.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;} + +/*公共弹框*/ +/* 按钮*/ + + + + + +/* 加入班级弹窗 */ +#sy_popup_box{ + width:460px; + background:#fff; + padding-bottom:30px; + -webkit-border-radius:5px; + -moz-border-radius:5px; + -o-border-radius:5px; + border-radius:5px; + box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); +} +.sy_popup_top{ + background:#3b94d6; + height:40px; + -webkit-border-radius: 5px 5px 0px 0px; + -moz-border-radius: 5px 5px 0px 0px; + -o-border-radius: 5px 5px 0px 0px; + border-radius: 5px 5px 0px 0px; +} +.sy_popup_top h3{ + font-size:18px; + color:#fff; + font-weight:normal; + line-height:40px; + padding-left:10px; +} +a.sy_icons_close{ + width:20px; + height:20px; + display:block; + background: url(../images/sy/sy_icons_close.png) 0 0px no-repeat; + margin:8px 10px 0 0; +} +a:hover.sy_icons_close{ + background: url(../images/sy/sy_icons_close.png) -40px 0px no-repeat; +} +.sy_popup_con{ + margin:30px auto 0; + font-size:14px; + width:330px; +} +.sy_popup_add label{ + display:block; + float:left; + width:85px; + text-align:right; + line-height:40px; +} +.sy_popup_add li{ + line-height:40px; +} +.sy_input_txt{ + border:1px solid #dedede; + height:36px; + background:#fff; + padding:0 5px; + width:220px; +} +.sy_popup_con02{ + margin:30px auto 0; + font-size:14px; + text-align:center; + width:360px; +} +.sy_popup_con02 ul li p{ + margin-bottom:15px; + text-align:center; + font-size:14px; + color:#616161; +} +.sy_popup_con02 a{ margin:0 auto;} +.sy_popup_top_tishi{ background:#ededed; } +.sy_popup_top_tishi h3{color:#616161; font-size:16px;} +a.sy_icons_close02{ + width:20px; + height:20px; + display:block; + background: url(../images/sy/sy_icons_close02.png) 0 0px no-repeat; + margin:8px 10px 0 0; +} +a:hover.sy_icons_close02{ + background: url(../images/sy/sy_icons_close02.png) -40px 0px no-repeat; +} \ No newline at end of file diff --git a/public/stylesheets/sy_public.css b/public/stylesheets/sy_public.css index 7c79bf6e6..77c782698 100644 --- a/public/stylesheets/sy_public.css +++ b/public/stylesheets/sy_public.css @@ -62,34 +62,34 @@ a.sy_btn_green{ border-radius:3px; } a:hover.sy_btn_green{ background: #51a74f;} -a.sy_btn_grey{ - color: #333; - background: #e1e1e1; - text-align: center; - font-size: 12px; - padding:0 15px; - height: 30px; - line-height: 30px; - -webkit-border-radius:3px; - -moz-border-radius:3px; - -o-border-radius:3px; - border-radius:3px; -} -a:hover.sy_btn_grey{ background: #c3c3c3;} -a.sy_btn_blue{ - color: #fff; - background: #3b94d6; - text-align: center; - font-size: 12px; - padding:0 15px; - height: 30px; - line-height: 30px; - -webkit-border-radius:3px; - -moz-border-radius:3px; - -o-border-radius:3px; - border-radius:3px; -} -a:hover.sy_btn_blue{ background: #2788d0;} +/*a.sy_btn_grey{*/ + /*color: #333;*/ + /*background: #e1e1e1;*/ + /*text-align: center;*/ + /*font-size: 12px;*/ + /*padding:0 15px;*/ + /*height: 30px;*/ + /*line-height: 30px;*/ + /*-webkit-border-radius:3px;*/ + /*-moz-border-radius:3px;*/ + /*-o-border-radius:3px;*/ + /*border-radius:3px;*/ +/*}*/ +/*a:hover.sy_btn_grey{ background: #c3c3c3;}*/ +/*a.sy_btn_blue{*/ + /*color: #fff;*/ + /*background: #3b94d6;*/ + /*text-align: center;*/ + /*font-size: 12px;*/ + /*padding:0 15px;*/ + /*height: 30px;*/ + /*line-height: 30px;*/ + /*-webkit-border-radius:3px;*/ + /*-moz-border-radius:3px;*/ + /*-o-border-radius:3px;*/ + /*border-radius:3px;*/ +/*}*/ +/*a:hover.sy_btn_blue{ background: #2788d0;}*/ /* 排序 */ .sy_category{ height: 50px; From b1f69140c73737bcc53462ff9e5cc1d063de8072 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 27 Jul 2016 14:47:13 +0800 Subject: [PATCH 05/17] =?UTF-8?q?issue=E7=94=A8=E6=88=B7=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=EF=BC=8Cissue=E9=93=BE=E6=8E=A5=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/_project_file_links.html.erb | 2 +- app/views/issues/_detail.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/attachments/_project_file_links.html.erb b/app/views/attachments/_project_file_links.html.erb index 0f7e8a012..759a9a735 100644 --- a/app/views/attachments/_project_file_links.html.erb +++ b/app/views/attachments/_project_file_links.html.erb @@ -92,7 +92,7 @@ <% end %> <% if options[:author] %> - <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author),:class => "c_orange" %>, + <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author),:class => "link-blue" %>, <%= format_time(attachment.created_on) %> <% end %> diff --git a/app/views/issues/_detail.html.erb b/app/views/issues/_detail.html.erb index ec9a0bc54..ac912a71c 100644 --- a/app/views/issues/_detail.html.erb +++ b/app/views/issues/_detail.html.erb @@ -20,7 +20,7 @@ <%= get_issue_priority(@issue.priority_id)[1] %>


- 由<%= @issue.author %>添加于 <%= format_time(@issue.created_on).html_safe %> + 由<%=link_to @issue.author, user_path(@issue.author), :class => "link-blue" %>添加于 <%= format_time(@issue.created_on).html_safe %>
From 7413298aad2a2218449addc9bc8af2d38b72acf3 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 28 Jul 2016 10:18:35 +0800 Subject: [PATCH 06/17] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E7=A0=81=E7=94=B3=E8=AF=B7=E5=8F=8A=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 18 ++++++ app/helpers/watchers_helper.rb | 2 +- .../_applied_join_project.html.erb | 57 ++++++++++--------- .../applied_join_project.js.erb | 8 +-- .../applied_project_info.js.erb | 0 config/routes.rb | 1 + 6 files changed, 52 insertions(+), 34 deletions(-) create mode 100644 app/views/applied_project/applied_project_info.js.erb diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index 39491c0e6..9ae3a5c4e 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -43,6 +43,24 @@ class AppliedProjectController < ApplicationController # end end + # @flage:提示语标志(1 邀请码错误;2 已经是项目成员; 3 角色没有选择; 4 申请成功) + # 申请成功则发送消息 + def applied_project_info + @project = Project.find(params[:project_id]) + if params[:invite_code].to_s != @project.invite_code + @flag = 1 + elsif User.current.member_of?(@project) + @flag = 2 + elsif params[:member_manager] != "on" || params[:member_developer] != "on" || params[:member_reporter] != "on" + @flag = 3 + else + @flag = 4 + end + if @flag == 4 + + end + end + #取消申请 def unapplied_join_project @project = Project.find(params[:project_id]) diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 823fe534b..8c2db4005 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -364,7 +364,7 @@ module WatchersHelper :class => "pr_join_a" ,:id=>id end - #申请加入项目 + # 申请加入项目 def join_in_project_link(project, user, options=[]) applied = project.applied_projects.find_by_user_id(user.id) text = applied ? l(:label_unapply_project) : l(:label_apply_project) diff --git a/app/views/applied_project/_applied_join_project.html.erb b/app/views/applied_project/_applied_join_project.html.erb index baa49ef01..435be7f5e 100644 --- a/app/views/applied_project/_applied_join_project.html.erb +++ b/app/views/applied_project/_applied_join_project.html.erb @@ -1,28 +1,29 @@ - -
-

欢迎加入项目

- -
-
-
-
    -
  • - - -
    -
  • -
  • - - 管理人员 - 开发人员 - 报告人员 -
    -
  • -
  • - - 确  定 - 取  消 -
    -
  • -
-
+
+

欢迎加入项目

+ +
+
+
+ <%= form_tag( url_for(:controller => 'applied_project', :action => 'applied_project_info', :project_id => @project.id), :id => 'project_applied_form') do %> +
    +
  • + + +
    +
  • +
  • + + 管理人员 + 开发人员 + 报告人员 +
    +
  • +
  • + + + 取  消 +
    +
  • +
+ <% end %> +
diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb index f79e9ac20..ed5dc51ac 100644 --- a/app/views/applied_project/applied_join_project.js.erb +++ b/app/views/applied_project/applied_join_project.js.erb @@ -1,7 +1,5 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'applied_join_project', locals: { :course => @course}) %>'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'applied_join_project', locals: { }) %>'); showModal('ajax-modal', '500px'); - $('#ajax-modal').siblings().remove(); - -$('#ajax-modal').parent().css("top","").css("left",""); - +$('#ajax-modal').parent().css({"top":"40%","left":"50%","transform":"translate(-50%,-50%)","padding":"0","border":"none"}); +$('#ajax-modal').css({"padding":"0"}); diff --git a/app/views/applied_project/applied_project_info.js.erb b/app/views/applied_project/applied_project_info.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/config/routes.rb b/config/routes.rb index 4b9027335..7ef684491 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -722,6 +722,7 @@ RedmineApp::Application.routes.draw do delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue' post 'applied_project/applied_join', :to => 'applied_project#applied_join_project', :as => 'applied_join_project' + post 'applied_project/applied_project_info', :to => 'applied_project#applied_project_info', :as => 'applied_project_info' delete 'applied_project/applied', :to => 'applied_project#unapplied_join_project', :as => 'unapplied_join_project' resources :projects do From 4a9eec0ccec9a220be803da7522264a78ad30343 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 28 Jul 2016 14:42:36 +0800 Subject: [PATCH 07/17] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E9=82=80=E8=AF=B7=E5=8F=8A=E5=85=AC=E5=85=B1=E5=BC=B9=E6=A1=86?= =?UTF-8?q?=E7=9A=84=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 14 +++++----- app/helpers/watchers_helper.rb | 8 +++--- app/models/project.rb | 5 ++++ .../_applied_join_project.html.erb | 10 +++---- .../_applied_project_tip.js.erb | 25 ++++++++++++++++++ .../applied_join_project.js.erb | 8 +++--- .../applied_project_info.js.erb | 2 ++ config/locales/projects/zh.yml | 2 +- .../20160728041943_add_qrcode_to_project.rb | 5 ++++ db/schema.rb | 14 +++++++++- public/javascripts/application.js | 26 ++++++++++--------- public/stylesheets/css/popup.css | 10 ++++--- 12 files changed, 91 insertions(+), 38 deletions(-) create mode 100644 app/views/applied_project/_applied_project_tip.js.erb create mode 100644 db/migrate/20160728041943_add_qrcode_to_project.rb diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index 9ae3a5c4e..d8e6c5f12 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -2,9 +2,8 @@ class AppliedProjectController < ApplicationController #申请加入项目 def applied_join_project - + @project = Project.find_by_id(params[:object_id]) # @user_id = params[:user_id] - # @project = Project.find_by_id(params[:project_id]) # if params[:project_join] # if @project # user = User.find @user_id @@ -51,13 +50,16 @@ class AppliedProjectController < ApplicationController @flag = 1 elsif User.current.member_of?(@project) @flag = 2 - elsif params[:member_manager] != "on" || params[:member_developer] != "on" || params[:member_reporter] != "on" + elsif params[:member].nil? @flag = 3 else @flag = 4 - end - if @flag == 4 - + applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id]) + # 申请成功则给项目管理员发送邮件及发送消息 + Mailer.run.applied_project(appliedproject) + @project.managers.each do |member| + AppliedMessage.create(:user_id => member.user_id, :status => true, :applied_id => applied_project.id, :applied_type => "AppliedProject", :viewed => true) + end end end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 8c2db4005..254ce1ad7 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -368,13 +368,13 @@ module WatchersHelper def join_in_project_link(project, user, options=[]) applied = project.applied_projects.find_by_user_id(user.id) text = applied ? l(:label_unapply_project) : l(:label_apply_project) - url = applied ? unapplied_join_project_path(:object_id => project.id) : applied_join_project_path(:object_id => project.id) - method = applied ? 'delete' : 'post' + url = applied_join_project_path(:object_id => project.id) + method = 'post' @applied_flag = project.instance_of?(Project) if applied - link = link_to(text, url, :remote => true, :method => method, :class => "sy_btn_grey fl", :id => "#{project.id}") + link = "text" else - link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "sy_btn_grey fl") + link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "pr_join_a") end link.html_safe # if applied diff --git a/app/models/project.rb b/app/models/project.rb index 520407589..edeee4f33 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -268,6 +268,11 @@ class Project < ActiveRecord::Base notified.collect(&:mail) end + # 返回为member类型数组 + def managers + self.members.includes(:roles).select{|member| member.roles[0].try(:name) == "Manager"} + end + def initialize(attributes=nil, *args) super diff --git a/app/views/applied_project/_applied_join_project.html.erb b/app/views/applied_project/_applied_join_project.html.erb index 435be7f5e..ad2d020c2 100644 --- a/app/views/applied_project/_applied_join_project.html.erb +++ b/app/views/applied_project/_applied_join_project.html.erb @@ -1,10 +1,10 @@

欢迎加入项目

- +
- <%= form_tag( url_for(:controller => 'applied_project', :action => 'applied_project_info', :project_id => @project.id), :id => 'project_applied_form') do %> + <%= form_tag( url_for(:controller => 'applied_project', :action => 'applied_project_info', :project_id => @project.id), :remote => true, :id => 'project_applied_form') do %>
  • @@ -13,9 +13,9 @@
  • - 管理人员 - 开发人员 - 报告人员 + 管理人员 + 开发人员 + 报告人员
  • diff --git a/app/views/applied_project/_applied_project_tip.js.erb b/app/views/applied_project/_applied_project_tip.js.erb new file mode 100644 index 000000000..56e5270d6 --- /dev/null +++ b/app/views/applied_project/_applied_project_tip.js.erb @@ -0,0 +1,25 @@ +
    +
    +

    提示

    + +
    +
    +
    +
      +
    • + <% if @flag == 1 %> +

      您输入的邀请码错误

      + <% elsif @flag == 2 %> +

      您已经是该项目成员

      + <% elsif @flag == 3 %> +

      请选择一个角色

      + <% elsif @flag == 4 %> +

      您的申请已提交,请等待项目管理员审批

      + <% end %> +
    • +
    • + 知道了 +
    • +
    +
    +
    \ No newline at end of file diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb index ed5dc51ac..6aa4481a4 100644 --- a/app/views/applied_project/applied_join_project.js.erb +++ b/app/views/applied_project/applied_join_project.js.erb @@ -1,5 +1,3 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'applied_join_project', locals: { }) %>'); -showModal('ajax-modal', '500px'); -$('#ajax-modal').siblings().remove(); -$('#ajax-modal').parent().css({"top":"40%","left":"50%","transform":"translate(-50%,-50%)","padding":"0","border":"none"}); -$('#ajax-modal').css({"padding":"0"}); +var htmlvalue = "<%= escape_javascript(render :partial => 'applied_join_project', locals: {:project_id => @project.id}) %>"; +pop_box_new(htmlvalue,460,40,50); + diff --git a/app/views/applied_project/applied_project_info.js.erb b/app/views/applied_project/applied_project_info.js.erb index e69de29bb..9c5564f33 100644 --- a/app/views/applied_project/applied_project_info.js.erb +++ b/app/views/applied_project/applied_project_info.js.erb @@ -0,0 +1,2 @@ +var htmlvalue = "<%= escape_javascript(render :partial => 'applied_project/applied_project_tip', locals: {:project_id => @project.id}) %>"; +pop_box_new(htmlvalue,380,40,50); diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 5d2520b19..91cc96791 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -56,7 +56,7 @@ zh: label_exit_project: 退出项目 label_apply_project_waiting: 已处理申请,请等待管理员审核 label_member_of_project: 该用户已经是项目成员了! - label_unapply_project: 取消申请 + label_unapply_project: 等待审批 lable_sure_exit_project: 是否确认退出该项目 label_friend_organization: 圈子模式 label_research_group: 研讨模式 diff --git a/db/migrate/20160728041943_add_qrcode_to_project.rb b/db/migrate/20160728041943_add_qrcode_to_project.rb new file mode 100644 index 000000000..fea91e225 --- /dev/null +++ b/db/migrate/20160728041943_add_qrcode_to_project.rb @@ -0,0 +1,5 @@ +class AddQrcodeToProject < ActiveRecord::Migration + def change + add_column :projects, :qrcode, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index fbdbb29a9..123d474f4 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 => 20160725062343) do +ActiveRecord::Schema.define(:version => 20160728041943) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -74,6 +74,16 @@ ActiveRecord::Schema.define(:version => 20160725062343) do t.integer "session_expire_delay", :default => 10080, :null => false end + create_table "applied_messages", :force => true do |t| + t.integer "user_id" + t.integer "applied_id" + t.string "applied_type" + t.integer "viewed", :default => 0 + t.integer "status", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "applied_projects", :force => true do |t| t.integer "project_id", :null => false t.integer "user_id", :null => false @@ -89,6 +99,7 @@ ActiveRecord::Schema.define(:version => 20160725062343) do t.integer "status", :default => 0 t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.integer "user_id" end create_table "apply_homeworks", :force => true do |t| @@ -1848,6 +1859,7 @@ ActiveRecord::Schema.define(:version => 20160725062343) do t.integer "visits", :default => 0 t.integer "hot", :default => 0 t.string "invite_code" + t.string "qrcode" end add_index "projects", ["lft"], :name => "index_projects_on_lft" diff --git a/public/javascripts/application.js b/public/javascripts/application.js index e86ad8ddc..d2cd50d0e 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1493,20 +1493,22 @@ function pop_up_box(value,tWidth,tTop,tLeft){ } // 公共弹框样式 -// title -function pop_box_new(value, tWidth, tTop, tLeft){ +function pop_box_new(value, Width, Top, Left){ $("#ajax-modal").html(value); - showModal('ajax-modal', tWidth + "px"); + showModal('ajax-modal', Width + 'px'); $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top", tTop+"%").css("left", tLeft+"%").css("padding-top", "10px").css("position", "fixed"); - $('#ajax-modal').parent().addClass("resourceUploadPopup"); - $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); - - function hideModal(){ - $('#ajax-modal').hide(); - } -} + $('#ajax-modal').parent().css({"top": Top+"%","left": Left+"%","transform":"translate(-50%,-50%)","padding":"0","border":"none"}); + $('#ajax-modal').css({"padding":"0"}); +} + +// 公共提示弹框样式 +//function pop_box_tip_new(value, Width, Top, Left){ +// $("#ajax-modal").html(value); +// showModal('ajax-modal', Width + 'px'); +// $('#ajax-modal').siblings().remove(); +// $('#ajax-modal').parent().css({"top": Top+"%","left": Left+"%","transform":"translate(-50%,-50%)","padding":"0","border":"none"}); +// $('#ajax-modal').css({"padding":"0"}); +//} //显示的时候根据当前网址是http 还是https 选择视频显示方式直接显示还是弹框 function autoMedia(id){ diff --git a/public/stylesheets/css/popup.css b/public/stylesheets/css/popup.css index c9f8ccf09..2aa4ae3be 100644 --- a/public/stylesheets/css/popup.css +++ b/public/stylesheets/css/popup.css @@ -371,11 +371,11 @@ a.sy_icons_close{ width:20px; height:20px; display:block; - background: url(../images/sy/sy_icons_close.png) 0 0px no-repeat; + background: url(/images/sy/sy_icons_close.png) 0 0px no-repeat; margin:8px 10px 0 0; } a:hover.sy_icons_close{ - background: url(../images/sy/sy_icons_close.png) -40px 0px no-repeat; + background: url(/images/sy/sy_icons_close.png) -40px 0px no-repeat; } .sy_popup_con{ margin:30px auto 0; @@ -418,9 +418,11 @@ a.sy_icons_close02{ width:20px; height:20px; display:block; - background: url(../images/sy/sy_icons_close02.png) 0 0px no-repeat; + background: url(/images/sy/sy_icons_close02.png) 0 0px no-repeat; margin:8px 10px 0 0; + border: none; + outline: none; } a:hover.sy_icons_close02{ - background: url(../images/sy/sy_icons_close02.png) -40px 0px no-repeat; + background: url(/images/sy/sy_icons_close02.png) -40px 0px no-repeat; } \ No newline at end of file From a8fa4a55e301e0bb5d82db6f40cb8b0c3fba8199 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 28 Jul 2016 16:22:33 +0800 Subject: [PATCH 08/17] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 11 +++++------ app/helpers/users_helper.rb | 12 ++++++++++++ app/helpers/watchers_helper.rb | 2 +- app/models/applied_project.rb | 12 +++++------- .../applied_project/applied_project_info.js.erb | 1 + app/views/layouts/_join_exit_project.html.erb | 4 +++- app/views/users/_user_message_applied.html.erb | 17 +++++++++++++++++ ...0160728075947_add_role_to_applied_project.rb | 5 +++++ db/schema.rb | 7 ++++--- 9 files changed, 53 insertions(+), 18 deletions(-) create mode 100644 db/migrate/20160728075947_add_role_to_applied_project.rb diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index d8e6c5f12..117d022d6 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -42,7 +42,8 @@ class AppliedProjectController < ApplicationController # end end - # @flage:提示语标志(1 邀请码错误;2 已经是项目成员; 3 角色没有选择; 4 申请成功) + # @flage:提示语标志(1:邀请码错误;2:已经是项目成员; 3:角色没有选择; 4:申请成功) + # role:成员角色 => 0(1:管理人员;2:开发人员;3:报告人员) # 申请成功则发送消息 def applied_project_info @project = Project.find(params[:project_id]) @@ -54,12 +55,10 @@ class AppliedProjectController < ApplicationController @flag = 3 else @flag = 4 - applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id]) + role = params[:member] == "member_manager" ? 1 : (params[:member] = "member_developer" ? 2 : 3) + applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id], :role => role) # 申请成功则给项目管理员发送邮件及发送消息 - Mailer.run.applied_project(appliedproject) - @project.managers.each do |member| - AppliedMessage.create(:user_id => member.user_id, :status => true, :applied_id => applied_project.id, :applied_type => "AppliedProject", :viewed => true) - end + Mailer.run.applied_project(applied_project) end end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 98b993183..e9abe43a3 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -54,6 +54,18 @@ module UsersHelper end end + # 获取消息角色 + def applied_project_message_type role + case role + when 1 + "管理员" + when 2 + "开发人员" + when 3 + "报告人员" + end + end + def get_resource_origin attach type = attach.container_type content = attach.container diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 254ce1ad7..d846071b5 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -372,7 +372,7 @@ module WatchersHelper method = 'post' @applied_flag = project.instance_of?(Project) if applied - link = "text" + link = "#{text}" else link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "pr_join_a") end diff --git a/app/models/applied_project.rb b/app/models/applied_project.rb index fb8bf90af..8dbed9cda 100644 --- a/app/models/applied_project.rb +++ b/app/models/applied_project.rb @@ -1,18 +1,16 @@ class AppliedProject < ActiveRecord::Base - attr_accessible :project_id, :user_id + attr_accessible :project_id, :user_id, :role belongs_to :user belongs_to :project - has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy + has_many :applied_messages, :class_name => 'AppliedMessage', :as => :applied, :dependent => :destroy after_create :send_appliled_message + # 仅仅给项目管理人员发送消息 def send_appliled_message - # if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? - self.project.members.each do |m| - if m.roles.first.to_s.include?("Manager") - self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false) - end + self.project.managers.each do |member| + self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false) end # end end diff --git a/app/views/applied_project/applied_project_info.js.erb b/app/views/applied_project/applied_project_info.js.erb index 9c5564f33..1ac627b3e 100644 --- a/app/views/applied_project/applied_project_info.js.erb +++ b/app/views/applied_project/applied_project_info.js.erb @@ -1,2 +1,3 @@ var htmlvalue = "<%= escape_javascript(render :partial => 'applied_project/applied_project_tip', locals: {:project_id => @project.id}) %>"; pop_box_new(htmlvalue,380,40,50); +//$("#join_in_project").attr('href','<%#= join_in_project_link(@project, User.current) %>'); diff --git a/app/views/layouts/_join_exit_project.html.erb b/app/views/layouts/_join_exit_project.html.erb index e893949f4..d39d3d67b 100644 --- a/app/views/layouts/_join_exit_project.html.erb +++ b/app/views/layouts/_join_exit_project.html.erb @@ -3,7 +3,9 @@ <% if !User.current.member_of?(@project) && User.current.login? && !User.current.admin %> <%= watcher_link_for_project(@project, User.current) %> - <%= join_in_project_link(@project, User.current) %> + + <%= join_in_project_link(@project, User.current) %> + <% end %> <% if User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project) %> diff --git a/app/views/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb index dc3e51b4d..efd2bf8da 100644 --- a/app/views/users/_user_message_applied.html.erb +++ b/app/views/users/_user_message_applied.html.erb @@ -14,5 +14,22 @@
  • <%= time_tag(ma.created_at).html_safe %>
+ <% elsif ma && ma.applied_type == "AppliedProject" %> + <% end %> <% end %> \ No newline at end of file diff --git a/db/migrate/20160728075947_add_role_to_applied_project.rb b/db/migrate/20160728075947_add_role_to_applied_project.rb new file mode 100644 index 000000000..964af6f19 --- /dev/null +++ b/db/migrate/20160728075947_add_role_to_applied_project.rb @@ -0,0 +1,5 @@ +class AddRoleToAppliedProject < ActiveRecord::Migration + def change + add_column :applied_projects, :role, :integer, :default => 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 123d474f4..4747a74e3 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 => 20160728041943) do +ActiveRecord::Schema.define(:version => 20160728075947) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -85,8 +85,9 @@ ActiveRecord::Schema.define(:version => 20160728041943) do end create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false + t.integer "project_id", :null => false + t.integer "user_id", :null => false + t.integer "role", :default => 0 end create_table "apply_add_schools", :force => true do |t| From c07677ef996237ddc06254baa475a33df8278c8f Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 14:49:37 +0800 Subject: [PATCH 09/17] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=20=E6=8B=92=E7=BB=9D=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 6 +- app/controllers/members_controller.rb | 58 ++++++++++++++++++- app/helpers/users_helper.rb | 33 ++++++++++- app/models/applied_message.rb | 2 +- app/models/applied_project.rb | 2 +- app/models/project.rb | 4 +- .../applied_project_info.js.erb | 3 +- .../members/allow_to_join_project.js.erb | 6 ++ .../refused_allow_to_join_project.js.erb | 1 + .../_user_message_applide_action.html.erb | 12 ++++ .../_user_message_applide_users.html.erb | 2 + .../users/_user_message_applied.html.erb | 9 +-- config/routes.rb | 2 + ..._add_applied_user_id_to_applied_message.rb | 5 ++ public/javascripts/application.js | 1 + 15 files changed, 129 insertions(+), 17 deletions(-) create mode 100644 app/views/members/allow_to_join_project.js.erb create mode 100644 app/views/members/refused_allow_to_join_project.js.erb create mode 100644 app/views/users/_user_message_applide_action.html.erb create mode 100644 app/views/users/_user_message_applide_users.html.erb create mode 100644 db/migrate/20160729020903_add_applied_user_id_to_applied_message.rb diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index 117d022d6..b726ea504 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -1,5 +1,5 @@ class AppliedProjectController < ApplicationController - + helper :watchers #申请加入项目 def applied_join_project @project = Project.find_by_id(params[:object_id]) @@ -43,7 +43,7 @@ class AppliedProjectController < ApplicationController end # @flage:提示语标志(1:邀请码错误;2:已经是项目成员; 3:角色没有选择; 4:申请成功) - # role:成员角色 => 0(1:管理人员;2:开发人员;3:报告人员) + # role:成员角色 => 0(4:管理人员;5:开发人员;6:报告人员) # 申请成功则发送消息 def applied_project_info @project = Project.find(params[:project_id]) @@ -55,7 +55,7 @@ class AppliedProjectController < ApplicationController @flag = 3 else @flag = 4 - role = params[:member] == "member_manager" ? 1 : (params[:member] = "member_developer" ? 2 : 3) + role = params[:member] == "member_manager" ? 4 : (params[:member] = "member_developer" ? 5 : 6) applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id], :role => role) # 申请成功则给项目管理员发送邮件及发送消息 Mailer.run.applied_project(applied_project) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 4dc2c52f5..dca6c6dd0 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -17,10 +17,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class MembersController < ApplicationController + helper :users model_object Member - before_filter :find_model_object, :except => [:index, :create, :autocomplete] + before_filter :find_model_object, :except => [:index, :create, :autocomplete, :allow_to_join_project, :refused_allow_to_join_project] #before_filter :find_model_object_contest, :except => [:index, :create, :autocomplete] - before_filter :find_project_from_association, :except => [:index, :create, :autocomplete] + before_filter :find_project_from_association, :except => [:index, :create, :autocomplete, :allow_to_join_project, :refused_allow_to_join_project] before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete] before_filter :authorize accept_api_auth :index, :show, :create, :update, :destroy @@ -49,6 +50,59 @@ class MembersController < ApplicationController end end + # 同意消息中申请加入项目 + # 之所以role不在参数中传送是考虑到安全问题 + # status(1:申请的消息;2:已操作过该消息(包括同意或者拒绝,消息状态更新);3:决绝消息;4:被拒人收到消息;5:拒绝者收到消息;6:同意后申请人收到消息;7:同意后批准人收到消息) + def allow_to_join_project + @applied_message = AppliedMessage.find(params[:applied_message_id]) + applied_project = @applied_message.applied + user = User.find(@applied_message.applied_user_id) + project = Project.find(applied_project.project_id) + + # applied_project = AppliedProject.where(:project_id => params[:project_id], :user_id => params[:user_id]).first + # @applied_message = AppliedMessage.find(params[:applied_id]) + if user.member_of?(project) + @flash_message = "您已经是项目成员了" + @applied_message.update_attribute(:status, 2) + else + ap_role = applied_project.try(:role) + if ap_role + begin + members = [] + user_grades = [] + project_info = [] + members << Member.new(:role_ids => ["#{ap_role}"], :user_id => params[:user_id]) + user_grades << UserGrade.new(:user_id => params[:user_id], :project_id => params[:project_id]) + role = Role.find(ap_role) + project_info << ProjectInfo.new(:project_id => params[:project_id], :user_id => params[:user_id]) if role.allowed_to?(:is_manager) + project.members << members + project.project_infos << project_info + project.user_grades << user_grades unless user_grades.first.user_id.nil? + # 添加成功后,申请人收到消息 + AppliedMessage.create(:user_id => params[:send_id], :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 6, :viewed => true, :applied_user_id => params[:user_id]) + # 添加成功后,批准人收到消息 + AppliedMessage.create(:user_id => params[:user_id], :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 7, :viewed => true, :applied_user_id => params[:send_id]) + rescue Exception => e + puts e + end + end + end + end + + # 同意消息中拒绝加入项目 + # params[:user_id]为申请者ID + # params[:send_id]为拒绝人ID + # status(1:申请的消息;2:已操作过该消息(包括同意或者拒绝,消息状态更新);3:拒绝消息;4:被拒人收到消息;5:拒绝者收到消息;6:同意后申请人收到消息;7:同意后批准人收到消息) + def refused_allow_to_join_project + @applied_message = AppliedMessage.find(params[:applied_message_id]) + @applied_message.update_attribute(:status, 3) + applied_project = @applied_message.applied + # 发送消息给被拒者,user_id对应的收到信息的用户 + AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4, :viewed => true, :applied_user_id => @applied_message.user_id) + # 发送消息给拒绝者 + AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5, :viewed => true, :applied_user_id => @applied_message.applied_user_id) + end + def create if params[:refusal_button] members = [] diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index e9abe43a3..6d6c83d4a 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -57,15 +57,42 @@ module UsersHelper # 获取消息角色 def applied_project_message_type role case role - when 1 + when 4 "管理员" - when 2 + when 5 "开发人员" - when 3 + when 6 "报告人员" end end + # 判断当前用户能否对消息进行操作 + def allow_to_show applied_message + (User.current.id == applied_message.user_id && applied_message.status == 1) ? true : false + end + + # 项目申请消息通过状态判断用户 + # status(1:申请的消息;2:已操作过该消息(包括同意或者拒绝,消息状态更新);3:拒绝消息;4:被拒人收到消息;5:拒绝者收到消息;6:同意后申请人收到消息;7:同意后批准人收到消息) + def applied_project_users applied_message + case applied_message.status + when 3,2,1,5,4 + user = User.find(applied_message.applied_user_id) + when 6 + user = User.find(applied_message.user_id) + + end + end + + # 项目申请消息通过状态判断tip描述 + def applied_project_tip applied_message + case applied_message.status + when 4 + "拒绝申请加入项目:" + when 5,3,2,1 + "申请加入项目:" + end + end + def get_resource_origin attach type = attach.container_type content = attach.container diff --git a/app/models/applied_message.rb b/app/models/applied_message.rb index 1c6b3a8e7..0175fcf47 100644 --- a/app/models/applied_message.rb +++ b/app/models/applied_message.rb @@ -1,6 +1,6 @@ class AppliedMessage < ActiveRecord::Base # status: 0表示未批准; status:1表示已批准; status: 2表示已拒绝 - attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed + attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed, :applied_user_id belongs_to :applied ,:polymorphic => true belongs_to :apply_add_schools belongs_to :user diff --git a/app/models/applied_project.rb b/app/models/applied_project.rb index 8dbed9cda..fdc9a602e 100644 --- a/app/models/applied_project.rb +++ b/app/models/applied_project.rb @@ -10,7 +10,7 @@ class AppliedProject < ActiveRecord::Base # 仅仅给项目管理人员发送消息 def send_appliled_message self.project.managers.each do |member| - self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false) + self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false, :applied_user_id => self.user_id) end # end end diff --git a/app/models/project.rb b/app/models/project.rb index edeee4f33..dcc01eb09 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -919,8 +919,8 @@ class Project < ActiveRecord::Base CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) def generate_invite_code code = read_attribute(:invite_code) - if !code || code.size <5 - code = CODES.sample(5).join + if !code || code.size <6 + code = CODES.sample(6).join return generate_invite_code if Project.where(invite_code: code).present? update_attribute(:invite_code, code) end diff --git a/app/views/applied_project/applied_project_info.js.erb b/app/views/applied_project/applied_project_info.js.erb index 1ac627b3e..7fff1b516 100644 --- a/app/views/applied_project/applied_project_info.js.erb +++ b/app/views/applied_project/applied_project_info.js.erb @@ -1,3 +1,4 @@ -var htmlvalue = "<%= escape_javascript(render :partial => 'applied_project/applied_project_tip', locals: {:project_id => @project.id}) %>"; +var htmlvalue = "<%= escape_javascript(render :partial => 'applied_project/applied_project_tip') %>"; pop_box_new(htmlvalue,380,40,50); + //$("#join_in_project").attr('href','<%#= join_in_project_link(@project, User.current) %>'); diff --git a/app/views/members/allow_to_join_project.js.erb b/app/views/members/allow_to_join_project.js.erb new file mode 100644 index 000000000..df3ac6de3 --- /dev/null +++ b/app/views/members/allow_to_join_project.js.erb @@ -0,0 +1,6 @@ +<% if @flash_message %> + alert("<%= @flash_message %>"); +<% else%> + $("#applied_project_<%= @applied_message.id %>").html('<%= render :partial => "users/user_message_applide_action", :locals =>{:ma => @applied_message} %>'); +<% end%> + diff --git a/app/views/members/refused_allow_to_join_project.js.erb b/app/views/members/refused_allow_to_join_project.js.erb new file mode 100644 index 000000000..109ed3a62 --- /dev/null +++ b/app/views/members/refused_allow_to_join_project.js.erb @@ -0,0 +1 @@ +$("#applied_project_<%= @applied_message.id %>").html('<%= render :partial => "users/user_message_applide_action", :locals =>{:ma => @applied_message} %>'); \ No newline at end of file diff --git a/app/views/users/_user_message_applide_action.html.erb b/app/views/users/_user_message_applide_action.html.erb new file mode 100644 index 000000000..24f2471b5 --- /dev/null +++ b/app/views/users/_user_message_applide_action.html.erb @@ -0,0 +1,12 @@ +<% if allow_to_show(ma) %> + :<%= link_to "同意", allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :post %> | + <%= link_to "拒绝", refused_allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :get %> +<% elsif ma.status == 4 %> + 被拒绝 +<% elsif ma.status == 5 %> + 您已拒绝 +<% elsif ma.status == 6 %> + 已通过 +<% elsif ma.status == 7 %> + 您已同意 +<% end %> \ No newline at end of file diff --git a/app/views/users/_user_message_applide_users.html.erb b/app/views/users/_user_message_applide_users.html.erb new file mode 100644 index 000000000..18539c628 --- /dev/null +++ b/app/views/users/_user_message_applide_users.html.erb @@ -0,0 +1,2 @@ +<%=link_to applied_project_users(ma), user_path(applied_project_users(ma)), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> +<%= applied_project_tip(ma) %> \ No newline at end of file diff --git a/app/views/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb index efd2bf8da..a2eff7189 100644 --- a/app/views/users/_user_message_applied.html.erb +++ b/app/views/users/_user_message_applied.html.erb @@ -20,13 +20,14 @@ <%=link_to image_tag(url_to_avatar(ma.applied.user), :width => "30", :height => "30"), user_path(ma.applied.user), :target => '_blank' %>
  • - <%=link_to ma.applied.user, user_path(ma.applied.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> - ">申请加入项目: + <%= render :partial => "users/user_message_applide_users", :locals =>{:ma => ma} %>
  • 以“<%= applied_project_message_type(ma.applied.role) %>”身份加入 - <%= link_to ma.applied.project, settings_project_path(:id => ma.applied.project.id, :tab => "members"), :class => "link-blue", :target => '_blank' %> - :同意 | 拒绝 + <%= link_to ma.applied.project, project_path(ma.applied.project), :class => "link-blue", :target => '_blank' %> + + <%= render :partial => "users/user_message_applide_action", :locals =>{:ma => ma} %> +
  • <%= time_tag(ma.created_at).html_safe %>
  • diff --git a/config/routes.rb b/config/routes.rb index 52b7bab94..20fe203fa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -767,6 +767,8 @@ RedmineApp::Application.routes.draw do collection do get 'autocomplete' get 'appliedproject' + post 'allow_to_join_project' + get 'refused_allow_to_join_project' end end diff --git a/db/migrate/20160729020903_add_applied_user_id_to_applied_message.rb b/db/migrate/20160729020903_add_applied_user_id_to_applied_message.rb new file mode 100644 index 000000000..480123b05 --- /dev/null +++ b/db/migrate/20160729020903_add_applied_user_id_to_applied_message.rb @@ -0,0 +1,5 @@ +class AddAppliedUserIdToAppliedMessage < ActiveRecord::Migration + def change + add_column :applied_messages, :applied_user_id, :integer + end +end diff --git a/public/javascripts/application.js b/public/javascripts/application.js index d2cd50d0e..b4ccd1533 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1499,6 +1499,7 @@ function pop_box_new(value, Width, Top, Left){ $('#ajax-modal').siblings().remove(); $('#ajax-modal').parent().css({"top": Top+"%","left": Left+"%","transform":"translate(-50%,-50%)","padding":"0","border":"none"}); $('#ajax-modal').css({"padding":"0"}); + } // 公共提示弹框样式 From 450217e7c27c06ec770d9ca3e2e6d7656f5f33d7 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 15:58:24 +0800 Subject: [PATCH 10/17] =?UTF-8?q?=E5=90=8C=E6=84=8F=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81=EF=BC=8C=E5=8F=8A=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=88=90=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 2 +- app/controllers/members_controller.rb | 15 +++++++------ app/helpers/users_helper.rb | 21 +++++++++---------- .../members/allow_to_join_project.js.erb | 1 - 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index b726ea504..221adc7bc 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -55,7 +55,7 @@ class AppliedProjectController < ApplicationController @flag = 3 else @flag = 4 - role = params[:member] == "member_manager" ? 4 : (params[:member] = "member_developer" ? 5 : 6) + role = params[:member] == "member_manager" ? 3 : (params[:member] = "member_developer" ? 4 :5) applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id], :role => role) # 申请成功则给项目管理员发送邮件及发送消息 Mailer.run.applied_project(applied_project) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index dca6c6dd0..6d3cf6aa5 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -58,9 +58,6 @@ class MembersController < ApplicationController applied_project = @applied_message.applied user = User.find(@applied_message.applied_user_id) project = Project.find(applied_project.project_id) - - # applied_project = AppliedProject.where(:project_id => params[:project_id], :user_id => params[:user_id]).first - # @applied_message = AppliedMessage.find(params[:applied_id]) if user.member_of?(project) @flash_message = "您已经是项目成员了" @applied_message.update_attribute(:status, 2) @@ -71,17 +68,18 @@ class MembersController < ApplicationController members = [] user_grades = [] project_info = [] - members << Member.new(:role_ids => ["#{ap_role}"], :user_id => params[:user_id]) - user_grades << UserGrade.new(:user_id => params[:user_id], :project_id => params[:project_id]) + members << Member.new(:role_ids => ["#{ap_role}"], :user_id => @applied_message.applied_user_id) + user_grades << UserGrade.new(:user_id => @applied_message.applied_user_id, :project_id => project.id) role = Role.find(ap_role) - project_info << ProjectInfo.new(:project_id => params[:project_id], :user_id => params[:user_id]) if role.allowed_to?(:is_manager) + project_info << ProjectInfo.new(:project_id => project.id, :user_id => @applied_message.applied_user_id) if role.allowed_to?(:is_manager) project.members << members project.project_infos << project_info project.user_grades << user_grades unless user_grades.first.user_id.nil? + @applied_message.update_attribute(:status, 2) # 添加成功后,申请人收到消息 - AppliedMessage.create(:user_id => params[:send_id], :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 6, :viewed => true, :applied_user_id => params[:user_id]) + AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 6, :viewed => true, :applied_user_id => @applied_message.user_id) # 添加成功后,批准人收到消息 - AppliedMessage.create(:user_id => params[:user_id], :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 7, :viewed => true, :applied_user_id => params[:send_id]) + AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id) rescue Exception => e puts e end @@ -101,6 +99,7 @@ class MembersController < ApplicationController AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4, :viewed => true, :applied_user_id => @applied_message.user_id) # 发送消息给拒绝者 AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5, :viewed => true, :applied_user_id => @applied_message.applied_user_id) + # applied_project.delete end def create diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 6d6c83d4a..a8427c326 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -57,11 +57,11 @@ module UsersHelper # 获取消息角色 def applied_project_message_type role case role - when 4 + when 3 "管理员" - when 5 + when 4 "开发人员" - when 6 + when 5 "报告人员" end end @@ -74,13 +74,10 @@ module UsersHelper # 项目申请消息通过状态判断用户 # status(1:申请的消息;2:已操作过该消息(包括同意或者拒绝,消息状态更新);3:拒绝消息;4:被拒人收到消息;5:拒绝者收到消息;6:同意后申请人收到消息;7:同意后批准人收到消息) def applied_project_users applied_message - case applied_message.status - when 3,2,1,5,4 - user = User.find(applied_message.applied_user_id) - when 6 - user = User.find(applied_message.user_id) - - end + # case applied_message.status + # when 3,2,1,5,4,7,6 + user = User.find(applied_message.applied_user_id) + # end end # 项目申请消息通过状态判断tip描述 @@ -88,8 +85,10 @@ module UsersHelper case applied_message.status when 4 "拒绝申请加入项目:" - when 5,3,2,1 + when 5,3,2,1,7 "申请加入项目:" + when 6 + "同意申请加入项目" end end diff --git a/app/views/members/allow_to_join_project.js.erb b/app/views/members/allow_to_join_project.js.erb index df3ac6de3..cbd37e188 100644 --- a/app/views/members/allow_to_join_project.js.erb +++ b/app/views/members/allow_to_join_project.js.erb @@ -3,4 +3,3 @@ <% else%> $("#applied_project_<%= @applied_message.id %>").html('<%= render :partial => "users/user_message_applide_action", :locals =>{:ma => @applied_message} %>'); <% end%> - From 769a07bd9449429e64aee9324029b6828afbaedf Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 16:00:46 +0800 Subject: [PATCH 11/17] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=88=90=E5=91=98=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/settings/_new_members.html.erb | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/app/views/projects/settings/_new_members.html.erb b/app/views/projects/settings/_new_members.html.erb index b73ef647f..0773f7732 100644 --- a/app/views/projects/settings/_new_members.html.erb +++ b/app/views/projects/settings/_new_members.html.erb @@ -92,32 +92,6 @@ <% if roles.any? %>
    - <% if @project.applied_projects.any? %> -
    -

    <%= l(:label_apply_project) %>

    - <%= form_for(@applied_members, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %> -
    - <%= render_principals_for_applied_members_new(@project) %> -
    -
      -
    • <%= l(:label_role_plural) %>:
    • - <% roles.each do |role| %> -
    • - <%= check_box_tag 'membership[role_ids][]', role.id %> - -
    • - <% end %> -
    - - <%= l(:label_approve) %> - - - <%= l(:label_refusal) %> - - <% end %> -
    -
    - <% end %>

    <%= l(:label_member_new) %>

    From 824b430fbde392398fe5572ea25ea1a6eca88dd3 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 17:38:21 +0800 Subject: [PATCH 12/17] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=B4=A8=E9=87=8F?= =?UTF-8?q?=E5=88=86=E6=94=AF=E5=BC=B9=E5=87=BA=E7=A9=BA=E7=99=BD=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/quality_analysis_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 80c5a2468..c9873ade4 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -37,7 +37,7 @@ class QualityAnalysisController < ApplicationController quality_an.delete unless quality_an.blank? end # Checks if the given job exists in Jenkins. - unless @client.job.exists?(job_name) + # unless @client.job.exists?(job_name) @g = Gitlab.client branch = params[:branch] language = swith_language_type(params[:language]) @@ -111,7 +111,7 @@ class QualityAnalysisController < ApplicationController end end end - end + # end rescue => e @message = e.message end From 48a72ff816e1278063293f4b3b4cede170359f76 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 17:46:24 +0800 Subject: [PATCH 13/17] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=85=A5=E5=8F=A3=E6=94=BE=E7=BD=AE=E5=9C=A8?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/_development_group.html.erb | 6 ------ app/views/repositories/show.html.erb | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb index 6961fcbac..2c7d36fb5 100644 --- a/app/views/projects/_development_group.html.erb +++ b/app/views/projects/_development_group.html.erb @@ -55,12 +55,6 @@ <%= link_to "+"+l(:project_gitlab_create_repository), url_for(:controller => 'projects', :action => 'settings', :id => @project.id, :tab=>'repositories') , :class => "subnav_green" %> <% end %>
    - - <% unless QualityAnalysis.where(:project_id => @project.id).first.nil? %> - - <% end %> <% end %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 823d0c1ad..b80d9ee5b 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -7,6 +7,10 @@ <%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch ), :remote => true, :class => "btn_zipdown fr" %> <% end %> <% end %> + + <% unless QualityAnalysis.where(:project_id => @project.id).first.nil? %> + <%= link_to "代码分析结果", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fr" %> + <% end %>
    <% if @entries.nil? %> From 60417b2db732b3d3f50596a2b5160c4945e065df Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 19:30:53 +0800 Subject: [PATCH 14/17] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=A0=B7=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../users/_user_message_applide_action.html.erb | 12 ++++++------ app/views/users/_user_message_applied.html.erb | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/views/users/_user_message_applide_action.html.erb b/app/views/users/_user_message_applide_action.html.erb index 24f2471b5..850f6d456 100644 --- a/app/views/users/_user_message_applide_action.html.erb +++ b/app/views/users/_user_message_applide_action.html.erb @@ -1,12 +1,12 @@ <% if allow_to_show(ma) %> - :<%= link_to "同意", allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :post %> | - <%= link_to "拒绝", refused_allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :get %> + :<%= link_to "同意", allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :post, :class => "link-blue"%> | + <%= link_to "拒绝", refused_allow_to_join_project_project_memberships_path(:project_id => ma.applied.project, :applied_message_id => ma.id), :remote => true, :method => :get, :class => "link-blue" %> <% elsif ma.status == 4 %> - 被拒绝 + 被拒绝 <% elsif ma.status == 5 %> - 您已拒绝 + 您已拒绝 <% elsif ma.status == 6 %> - 已通过 + 已通过 <% elsif ma.status == 7 %> - 您已同意 + 您已同意 <% end %> \ No newline at end of file diff --git a/app/views/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb index a2eff7189..d15d8aac7 100644 --- a/app/views/users/_user_message_applied.html.erb +++ b/app/views/users/_user_message_applied.html.erb @@ -22,13 +22,15 @@
  • <%= render :partial => "users/user_message_applide_users", :locals =>{:ma => ma} %>
  • -
  • +
  • 以“<%= applied_project_message_type(ma.applied.role) %>”身份加入 <%= link_to ma.applied.project, project_path(ma.applied.project), :class => "link-blue", :target => '_blank' %> + +
  • +
  • <%= render :partial => "users/user_message_applide_action", :locals =>{:ma => ma} %> -
  • <%= time_tag(ma.created_at).html_safe %>
  • From 153efb7edabfd3afb228ba15524fef85c3ccdaf8 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 19:42:21 +0800 Subject: [PATCH 15/17] =?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_join_exit_project.html.erb | 10 +++------- app/views/projects/_applied_status.html.erb | 9 +++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 app/views/projects/_applied_status.html.erb diff --git a/app/views/layouts/_join_exit_project.html.erb b/app/views/layouts/_join_exit_project.html.erb index d39d3d67b..7d2f1b4d2 100644 --- a/app/views/layouts/_join_exit_project.html.erb +++ b/app/views/layouts/_join_exit_project.html.erb @@ -1,12 +1,8 @@
    - <% if !User.current.member_of?(@project) && User.current.login? && !User.current.admin %> - <%= watcher_link_for_project(@project, User.current) %> - - - <%= join_in_project_link(@project, User.current) %> - - <% end %> +
    + <%= render :partial => "projects/applied_status" %> +
    <% if User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project) %> <%= link_to "#{l(:button_configure)}".html_safe, settings_project_path(@project), :class => "pr_join_a" %> diff --git a/app/views/projects/_applied_status.html.erb b/app/views/projects/_applied_status.html.erb new file mode 100644 index 000000000..d29819c03 --- /dev/null +++ b/app/views/projects/_applied_status.html.erb @@ -0,0 +1,9 @@ +<% if !User.current.member_of?(@project) && User.current.login? && !User.current.admin %> + <%= watcher_link_for_project(@project, User.current) %> + + <% if AppliedProject.where(:user_id => User.current, :project_id => @project_id).first.nil? %> + <%= join_in_project_link(@project, User.current) %> + <% else %> + 等待审批 + <% end %> +<% end %> \ No newline at end of file From 0bf9b5c6e6ce213cfb2a0049bff5aae11ff1173e Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 20:31:24 +0800 Subject: [PATCH 16/17] =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=BA=A2=E7=82=B9?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=20=20=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=A0=E5=85=A5=E9=A1=B9=E7=9B=AE=E5=85=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/applied_project_controller.rb | 14 +++++++---- app/models/user.rb | 3 ++- .../_applied_join_project.html.erb | 2 +- .../applied_join_project.js.erb | 2 +- app/views/layouts/new_base_user.html.erb | 23 +++++++++++++++++-- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index 221adc7bc..d779c7759 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -2,7 +2,9 @@ class AppliedProjectController < ApplicationController helper :watchers #申请加入项目 def applied_join_project - @project = Project.find_by_id(params[:object_id]) + if params[:object_id] + @project = Project.find_by_id(params[:object_id]) + end # @user_id = params[:user_id] # if params[:project_join] # if @project @@ -46,8 +48,12 @@ class AppliedProjectController < ApplicationController # role:成员角色 => 0(4:管理人员;5:开发人员;6:报告人员) # 申请成功则发送消息 def applied_project_info - @project = Project.find(params[:project_id]) - if params[:invite_code].to_s != @project.invite_code + if params[:project_id].nil? + @project = Project.where(:invite_code => params[:invite_code]).first + else + @project = Project.find(params[:project_id]) + end + if !@project || params[:invite_code].to_s != @project.invite_code @flag = 1 elsif User.current.member_of?(@project) @flag = 2 @@ -56,7 +62,7 @@ class AppliedProjectController < ApplicationController else @flag = 4 role = params[:member] == "member_manager" ? 3 : (params[:member] = "member_developer" ? 4 :5) - applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => params[:project_id], :role => role) + applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => @project.id, :role => role) # 申请成功则给项目管理员发送邮件及发送消息 Mailer.run.applied_project(applied_project) end diff --git a/app/models/user.rb b/app/models/user.rb index 996aa9be7..8de109169 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -369,7 +369,8 @@ class User < Principal system_messages_count = SystemMessage.where("created_at >?", onclick_time).count at_count = AtMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count org_count = OrgMessage.where("user_id=? and viewed =? and created_at >?", user.id,0, onclick_time).count - messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count = AppliedMessage.where("user_id=? and viewed =? and created_at >?", user.id, 0, onclick_time).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count end # 查询指派给我的缺陷记录 diff --git a/app/views/applied_project/_applied_join_project.html.erb b/app/views/applied_project/_applied_join_project.html.erb index ad2d020c2..457cdf9cc 100644 --- a/app/views/applied_project/_applied_join_project.html.erb +++ b/app/views/applied_project/_applied_join_project.html.erb @@ -4,7 +4,7 @@
    - <%= form_tag( url_for(:controller => 'applied_project', :action => 'applied_project_info', :project_id => @project.id), :remote => true, :id => 'project_applied_form') do %> + <%= form_tag( url_for(:controller => 'applied_project', :action => 'applied_project_info', :project_id => (@project.nil? ? nil : @project.id)), :remote => true, :id => 'project_applied_form') do %>
    • diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb index 6aa4481a4..5d9f7f87a 100644 --- a/app/views/applied_project/applied_join_project.js.erb +++ b/app/views/applied_project/applied_join_project.js.erb @@ -1,3 +1,3 @@ -var htmlvalue = "<%= escape_javascript(render :partial => 'applied_join_project', locals: {:project_id => @project.id}) %>"; +var htmlvalue = "<%= escape_javascript(render :partial => 'applied_join_project', locals: {:project_id => (@project.nil? ? nil : @project.id)}) %>"; pop_box_new(htmlvalue,460,40,50); diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index f280f6506..bcf00dd2c 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -245,8 +245,21 @@
    <%= link_to '项目',{:controller => "users", :action => "user_projectlist", :id => @user.id}, :class => "homepageMenuText" %> - <% if is_current_user%> - <%=link_to "", new_project_path(:host=> Setting.host_name), :class => "homepageMenuSetting fr", :style => "margin-right:10px;", :title => "新建项目"%> + <% if is_current_user %> +
    +
      +
    • +
        +
      • + <%= link_to "新建项目", new_project_path(:host=> Setting.host_name), :class => "menuGrey"%> +
      • +
      • + <%= link_to "加入项目", applied_join_project_path,:remote => true,:class => "menuGrey",:method => "post"%> +
      • +
      +
    • +
    +
    <% end%>
    <%# if @user.projects.visible.count > 0 @@ -362,6 +375,12 @@ $("#courseMenu").mouseleave(function(){ $("#topnav_course_menu").hide(); }); + $("#projectMenu").mouseenter(function(){ + $("#topnav_project_menu").show(); + }); + $("#projectMenu").mouseleave(function(){ + $("#topnav_project_menu").hide(); + }); function leftCourseslistChange(){ $('#homepageLeftMenuCourses').slideToggle(); $('#hide_show_courseicon').toggleClass("homepageLeftMenuHideIcon"); From 643b06484b34adeebe62fcaa4a7586e05b29db23 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 Jul 2016 20:50:55 +0800 Subject: [PATCH 17/17] =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=A1=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 8 ++++---- app/models/applied_message.rb | 2 +- app/models/applied_project.rb | 2 +- .../users/_user_message_applied.html.erb | 2 +- ...60729124038_add_role_to_applied_message.rb | 5 +++++ ...24833_add_project_id_to_applied_message.rb | 5 +++++ db/schema.rb | 20 +++++++++++-------- 7 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 db/migrate/20160729124038_add_role_to_applied_message.rb create mode 100644 db/migrate/20160729124833_add_project_id_to_applied_message.rb diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 6d3cf6aa5..31d32bb59 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -77,9 +77,9 @@ class MembersController < ApplicationController project.user_grades << user_grades unless user_grades.first.user_id.nil? @applied_message.update_attribute(:status, 2) # 添加成功后,申请人收到消息 - AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 6, :viewed => true, :applied_user_id => @applied_message.user_id) + AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 6, :viewed => true, :applied_user_id => @applied_message.user_id, :role => applied_project.role) # 添加成功后,批准人收到消息 - AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id) + AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role) rescue Exception => e puts e end @@ -96,9 +96,9 @@ class MembersController < ApplicationController @applied_message.update_attribute(:status, 3) applied_project = @applied_message.applied # 发送消息给被拒者,user_id对应的收到信息的用户 - AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4, :viewed => true, :applied_user_id => @applied_message.user_id) + AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4, :viewed => true, :applied_user_id => @applied_message.user_id, :role => applied_project.role) # 发送消息给拒绝者 - AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5, :viewed => true, :applied_user_id => @applied_message.applied_user_id) + AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5, :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role) # applied_project.delete end diff --git a/app/models/applied_message.rb b/app/models/applied_message.rb index 0175fcf47..ee22f21c8 100644 --- a/app/models/applied_message.rb +++ b/app/models/applied_message.rb @@ -1,6 +1,6 @@ class AppliedMessage < ActiveRecord::Base # status: 0表示未批准; status:1表示已批准; status: 2表示已拒绝 - attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed, :applied_user_id + attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed, :applied_user_id, :role, :project_id belongs_to :applied ,:polymorphic => true belongs_to :apply_add_schools belongs_to :user diff --git a/app/models/applied_project.rb b/app/models/applied_project.rb index fdc9a602e..b1945a937 100644 --- a/app/models/applied_project.rb +++ b/app/models/applied_project.rb @@ -10,7 +10,7 @@ class AppliedProject < ActiveRecord::Base # 仅仅给项目管理人员发送消息 def send_appliled_message self.project.managers.each do |member| - self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false, :applied_user_id => self.user_id) + self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false, :applied_user_id => self.user_id, :role => self.role, :project_id => self.project_id) end # end end diff --git a/app/views/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb index d15d8aac7..af62276e0 100644 --- a/app/views/users/_user_message_applied.html.erb +++ b/app/views/users/_user_message_applied.html.erb @@ -23,7 +23,7 @@ <%= render :partial => "users/user_message_applide_users", :locals =>{:ma => ma} %>
  • - 以“<%= applied_project_message_type(ma.applied.role) %>”身份加入 + 以“<%= applied_project_message_type(ma.role) %>”身份加入 <%= link_to ma.applied.project, project_path(ma.applied.project), :class => "link-blue", :target => '_blank' %>
  • diff --git a/db/migrate/20160729124038_add_role_to_applied_message.rb b/db/migrate/20160729124038_add_role_to_applied_message.rb new file mode 100644 index 000000000..c6a73c794 --- /dev/null +++ b/db/migrate/20160729124038_add_role_to_applied_message.rb @@ -0,0 +1,5 @@ +class AddRoleToAppliedMessage < ActiveRecord::Migration + def change + add_column :applied_messages, :role, :integer + end +end diff --git a/db/migrate/20160729124833_add_project_id_to_applied_message.rb b/db/migrate/20160729124833_add_project_id_to_applied_message.rb new file mode 100644 index 000000000..803c5d8aa --- /dev/null +++ b/db/migrate/20160729124833_add_project_id_to_applied_message.rb @@ -0,0 +1,5 @@ +class AddProjectIdToAppliedMessage < ActiveRecord::Migration + def change + add_column :applied_messages, :project_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 4747a74e3..f8a113834 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 => 20160728075947) do +ActiveRecord::Schema.define(:version => 20160729124833) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -78,16 +78,20 @@ ActiveRecord::Schema.define(:version => 20160728075947) do t.integer "user_id" t.integer "applied_id" t.string "applied_type" - t.integer "viewed", :default => 0 - t.integer "status", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "viewed", :default => 0 + t.integer "status", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "applied_user_id" + t.integer "role" + t.integer "project_id" end create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - t.integer "role", :default => 0 + t.integer "project_id", :null => false + t.integer "user_id", :null => false + t.integer "role", :default => 0 + t.integer "applied_user_id" end create_table "apply_add_schools", :force => true do |t|