From c1ed8bd36d07eed14c49c204f4069f5ce80596d3 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sun, 29 Mar 2015 12:32:10 +0800 Subject: [PATCH 01/23] =?UTF-8?q?#2096=20=20course=E3=80=81forge=E7=9A=84?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E9=80=9A=E7=9F=A5=E7=B3=BB=E7=BB=9F=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=8F=AF=E4=BB=A5=E6=AF=8F=E6=97=A5=E4=B8=80?= =?UTF-8?q?=E6=8A=A5=E3=80=81=E4=B8=80=E4=BA=8B=E4=B8=80=E6=8A=A5=E3=80=81?= =?UTF-8?q?=E4=B8=8D=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 18 +- app/models/user.rb | 3 +- config/initializers/send_mail.rb | 29 +- config/locales/zh.yml | 4 +- ...30_chnage_mail_notification_week_to_day.rb | 8 + db/schema.rb | 2886 ++++++++--------- 6 files changed, 1467 insertions(+), 1481 deletions(-) create mode 100644 db/migrate/20150328115230_chnage_mail_notification_week_to_day.rb diff --git a/app/models/mailer.rb b/app/models/mailer.rb index e1c538fd0..0511e2128 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -114,15 +114,17 @@ class Mailer < ActionMailer::Base @forums = Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc") @memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id})) and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc") - if days == 1 - subject = "[ #{user.show_name} : #{l(:label_day_mail)}]" - @subject = " #{user.show_name} : #{date_to - 1.days} #{l(:label_day_mail)}" - else - subject = "[ #{user.show_name} : #{l(:label_week_mail)}]" - @subject = "#{user.show_name} : #{l(:label_week_mail)}" - end - mail :to => user.mail,:subject => subject + subject = "[ #{user.show_name} : #{l(:label_day_mail)}]" + @subject = " #{user.show_name} : #{date_to - 1.days} #{l(:label_day_mail)}" + + has_content = [@issues,@homeworks,@course_messages,@project_messages,@course_news,@project_news, + @course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| + !o.empty? + } + binding.pry + #有内容才发,没有不发 + mail :to => user.mail,:subject => subject if has_content end # 公共讨论区发帖、回帖添加邮件发送信息 diff --git a/app/models/user.rb b/app/models/user.rb index 9abe80779..35c29cbcc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -64,9 +64,10 @@ class User < Principal }, } + #每日一报、一事一报、不报 MAIL_NOTIFICATION_OPTIONS = [ ['all', :label_user_mail_option_all], - ['week', :label_user_mail_option_week], + #['week', :label_user_mail_option_week], ['day', :label_user_mail_option_day], ['none', :label_user_mail_option_none] ] diff --git a/config/initializers/send_mail.rb b/config/initializers/send_mail.rb index 86b3a53fd..203624104 100644 --- a/config/initializers/send_mail.rb +++ b/config/initializers/send_mail.rb @@ -1,27 +1,12 @@ -#!/usr/bin/env ruby - -require 'rubygems' -require 'rufus-scheduler' - -#users = User.where("mail_notification = 'week' or mail_notification = 'day'") +#coding=utf-8 scheduler = Rufus::Scheduler.new -scheduler.cron('0 0 * * 1') do - users = User.where("mail_notification = 'week'") - users.each do |user| - #Rails.logger.info "send mail to #{user.show_name}(#{user.mail}) at #{Time.now}" - Thread.start do - Mailer.send_for_user_activities(user, Date.today, 7).deliver - end - end -end -scheduler.cron('0 0 * * *') do - users = User.where("mail_notification = 'day'") + +#每天18:00发送当天的邮件汇总 +scheduler.cron('0 18 * * *') do + users = User.where(mail_notification: 'day') users.each do |user| - #Rails.logger.info "send mail to #{user.show_name}(#{user.mail}) at #{Time.now}" - Thread.start do - Mailer.send_for_user_activities(user, Date.today, 1).deliver - end + mailer = Mailer.send_for_user_activities(user, Date.today, 1) + mailer.deliver if mailer end end - diff --git a/config/locales/zh.yml b/config/locales/zh.yml index f1dbe7d3c..b668c3aff 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -80,7 +80,7 @@ zh: field_enterprise_name: 组织 label_week_mail: 一周动态 - label_day_mail: 一日动态 + label_day_mail: 今日动态 #added by huang field_tea_name: 教师 field_couurse_time: 学时 @@ -2031,5 +2031,5 @@ zh: label_name_not_null: 名称不能为空 modal_valid_unpassing: 该分班已经存在 - + mail_footer: 点击修改邮件发送设置 diff --git a/db/migrate/20150328115230_chnage_mail_notification_week_to_day.rb b/db/migrate/20150328115230_chnage_mail_notification_week_to_day.rb new file mode 100644 index 000000000..37cce673c --- /dev/null +++ b/db/migrate/20150328115230_chnage_mail_notification_week_to_day.rb @@ -0,0 +1,8 @@ +class ChnageMailNotificationWeekToDay < ActiveRecord::Migration + def up + User.where(mail_notification: 'week').update_all(mail_notification: 'day') + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index b149a870b..21279c72b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,1448 +1,1438 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - -ActiveRecord::Schema.define(:version => 20150309090143) do - - create_table "activities", :force => true do |t| - t.integer "act_id", :null => false - t.string "act_type", :null => false - t.integer "user_id", :null => false - end - - add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" - add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" - add_index "activities", ["user_id"], :name => "index_activities_on_user_id" - - create_table "api_keys", :force => true do |t| - t.string "access_token" - t.datetime "expires_at" - t.integer "user_id" - t.boolean "active", :default => true - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - 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 "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - end - - create_table "apply_project_masters", :force => true do |t| - t.integer "user_id" - t.string "apply_type" - t.integer "apply_id" - t.integer "status" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "attachments", :force => true do |t| - t.integer "container_id" - t.string "container_type", :limit => 30 - t.string "filename", :default => "", :null => false - t.string "disk_filename", :default => "", :null => false - t.integer "filesize", :default => 0, :null => false - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "", :null => false - t.integer "downloads", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype", :default => 1 - t.integer "is_public", :default => 1 - t.integer "copy_from" - t.integer "quotes" - end - - add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" - add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" - add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" - - create_table "attachmentstypes", :force => true do |t| - t.integer "typeId", :null => false - t.string "typeName", :limit => 50 - end - - create_table "auth_sources", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 60, :default => "", :null => false - t.string "host", :limit => 60 - t.integer "port" - t.string "account" - t.string "account_password", :default => "" - t.string "base_dn" - t.string "attr_login", :limit => 30 - t.string "attr_firstname", :limit => 30 - t.string "attr_lastname", :limit => 30 - t.string "attr_mail", :limit => 30 - t.boolean "onthefly_register", :default => false, :null => false - t.boolean "tls", :default => false, :null => false - t.string "filter" - t.integer "timeout" - end - - add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" - - create_table "biding_projects", :force => true do |t| - t.integer "project_id" - t.integer "bid_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "bids", :force => true do |t| - t.string "name" - t.string "budget", :null => false - t.integer "author_id" - t.date "deadline" - t.text "description" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.integer "commit" - t.integer "reward_type" - t.integer "homework_type" - t.integer "parent_id" - t.string "password" - t.integer "is_evaluation" - t.integer "proportion", :default => 60 - t.integer "comment_status", :default => 0 - t.integer "evaluation_num", :default => 3 - t.integer "open_anonymous_evaluation", :default => 1 - end - - create_table "boards", :force => true do |t| - t.integer "project_id", :null => false - t.string "name", :default => "", :null => false - t.string "description" - t.integer "position", :default => 1 - t.integer "topics_count", :default => 0, :null => false - t.integer "messages_count", :default => 0, :null => false - t.integer "last_message_id" - t.integer "parent_id" - t.integer "course_id" - end - - add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" - add_index "boards", ["project_id"], :name => "boards_project_id" - - create_table "bug_to_osps", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "changes", :force => true do |t| - t.integer "changeset_id", :null => false - t.string "action", :limit => 1, :default => "", :null => false - t.text "path", :null => false - t.text "from_path" - t.string "from_revision" - t.string "revision" - t.string "branch" - end - - add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" - - create_table "changeset_parents", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "parent_id", :null => false - end - - add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" - 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.string "committer" - t.datetime "committed_on", :null => false - t.text "comments" - t.date "commit_date" - t.string "scmid" - t.integer "user_id" - end - - add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" - add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true - add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" - add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" - add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" - - create_table "changesets_issues", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "issue_id", :null => false - end - - add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - - create_table "comments", :force => true do |t| - t.string "commented_type", :limit => 30, :default => "", :null => false - t.integer "commented_id", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.text "comments" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - 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 "contest_notifications", :force => true do |t| - t.text "title" - t.text "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contesting_projects", :force => true do |t| - t.integer "project_id" - t.string "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contesting_softapplications", :force => true do |t| - t.integer "softapplication_id" - t.integer "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contestnotifications", :force => true do |t| - t.integer "contest_id" - t.string "title" - t.string "summary" - t.text "description" - t.integer "author_id" - t.integer "notificationcomments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contests", :force => true do |t| - t.string "name" - t.string "budget", :default => "" - t.integer "author_id" - t.date "deadline" - t.string "description" - t.integer "commit" - t.string "password" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - create_table "course_attachments", :force => true do |t| - t.string "filename" - t.string "disk_filename" - t.integer "filesize" - t.string "content_type" - t.string "digest" - t.integer "downloads" - t.string "author_id" - t.string "integer" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "container_id", :default => 0 - end - - create_table "course_groups", :force => true do |t| - t.string "name" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_infos", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "course_id" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "courses", :force => true do |t| - t.integer "tea_id" - t.string "name" - t.integer "state" - t.string "code" - t.integer "time" - t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "location" - t.string "term" - t.string "string" - t.string "password" - t.string "setup_time" - t.string "endup_time" - t.string "class_period" - t.integer "school_id" - t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 - t.integer "lft" - t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - t.integer "open_student", :default => 0 - end - - create_table "custom_fields", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.string "field_format", :limit => 30, :default => "", :null => false - t.text "possible_values" - t.string "regexp", :default => "" - t.integer "min_length", :default => 0, :null => false - t.integer "max_length", :default => 0, :null => false - t.boolean "is_required", :default => false, :null => false - t.boolean "is_for_all", :default => false, :null => false - t.boolean "is_filter", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "searchable", :default => false - t.text "default_value" - t.boolean "editable", :default => true - t.boolean "visible", :default => true, :null => false - t.boolean "multiple", :default => false - end - - add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" - - create_table "custom_fields_projects", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "project_id", :default => 0, :null => false - end - - add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true - - create_table "custom_fields_trackers", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true - - create_table "custom_values", :force => true do |t| - t.string "customized_type", :limit => 30, :default => "", :null => false - t.integer "customized_id", :default => 0, :null => false - t.integer "custom_field_id", :default => 0, :null => false - t.text "value" - end - - add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" - add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" - - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "documents", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "category_id", :default => 0, :null => false - t.string "title", :limit => 60, :default => "", :null => false - t.text "description" - t.datetime "created_on" - t.integer "user_id", :default => 0 - t.integer "is_public", :default => 1 - end - - add_index "documents", ["category_id"], :name => "index_documents_on_category_id" - add_index "documents", ["created_on"], :name => "index_documents_on_created_on" - add_index "documents", ["project_id"], :name => "documents_project_id" - - create_table "enabled_modules", :force => true do |t| - t.integer "project_id" - t.string "name", :null => false - t.integer "course_id" - end - - add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" - - create_table "enumerations", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "is_default", :default => false, :null => false - t.string "type" - t.boolean "active", :default => true, :null => false - t.integer "project_id" - t.integer "parent_id" - t.string "position_name", :limit => 30 - end - - 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 "first_pages", :force => true do |t| - t.string "web_title" - t.string "title" - t.text "description" - t.string "page_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sort_type" - t.integer "image_width", :default => 107 - t.integer "image_height", :default => 63 - t.integer "show_course", :default => 1 - t.integer "show_contest", :default => 1 - end - - create_table "forge_activities", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_act_id" - t.string "forge_act_type" - t.integer "org_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" - - create_table "forums", :force => true do |t| - t.string "name", :null => false - t.text "description" - t.integer "topic_count", :default => 0 - t.integer "memo_count", :default => 0 - t.integer "last_memo_id", :default => 0 - t.integer "creator_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sticky" - t.integer "locked" - end - - create_table "groups_users", :id => false, :force => true do |t| - t.integer "group_id", :null => false - t.integer "user_id", :null => false - end - - add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true - - create_table "homework_attaches", :force => true do |t| - t.integer "bid_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - t.string "name" - t.text "description" - t.integer "state" - t.integer "project_id", :default => 0 - t.float "score", :default => 0.0 - t.integer "is_teacher_score", :default => 0 - end - - create_table "homework_evaluations", :force => true do |t| - t.string "user_id" - t.string "homework_attach_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_for_courses", :force => true do |t| - t.integer "course_id" - t.integer "bid_id" - end - - create_table "homework_users", :force => true do |t| - t.string "homework_attach_id" - t.string "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "issue_categories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.integer "assigned_to_id" - end - - add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" - add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" - - create_table "issue_relations", :force => true do |t| - t.integer "issue_from_id", :null => false - t.integer "issue_to_id", :null => false - t.string "relation_type", :default => "", :null => false - t.integer "delay" - end - - add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true - add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" - add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" - - create_table "issue_statuses", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_closed", :default => false, :null => false - t.boolean "is_default", :default => false, :null => false - t.integer "position", :default => 1 - t.integer "default_done_ratio" - end - - add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" - add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" - add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" - - create_table "issues", :force => true do |t| - t.integer "tracker_id", :null => false - t.integer "project_id", :null => false - t.string "subject", :default => "", :null => false - t.text "description" - t.date "due_date" - t.integer "category_id" - t.integer "status_id", :null => false - t.integer "assigned_to_id" - t.integer "priority_id", :null => false - t.integer "fixed_version_id" - t.integer "author_id", :null => false - t.integer "lock_version", :default => 0, :null => false - t.datetime "created_on" - t.datetime "updated_on" - t.date "start_date" - t.integer "done_ratio", :default => 0, :null => false - t.float "estimated_hours" - t.integer "parent_id" - t.integer "root_id" - t.integer "lft" - t.integer "rgt" - t.boolean "is_private", :default => false, :null => false - t.datetime "closed_on" - t.integer "project_issues_index" - end - - add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" - add_index "issues", ["author_id"], :name => "index_issues_on_author_id" - add_index "issues", ["category_id"], :name => "index_issues_on_category_id" - add_index "issues", ["created_on"], :name => "index_issues_on_created_on" - add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" - add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" - add_index "issues", ["project_id"], :name => "issues_project_id" - add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" - add_index "issues", ["status_id"], :name => "index_issues_on_status_id" - add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" - - create_table "join_in_competitions", :force => true do |t| - t.integer "user_id" - t.integer "competition_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "join_in_contests", :force => true do |t| - t.integer "user_id" - t.integer "bid_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "journal_details", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - - create_table "journal_replies", :id => false, :force => true do |t| - t.integer "journal_id" - t.integer "user_id" - t.integer "reply_id" - end - - add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" - add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" - add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" - - create_table "journals", :force => true do |t| - t.integer "journalized_id", :default => 0, :null => false - t.string "journalized_type", :limit => 30, :default => "", :null => false - t.integer "user_id", :default => 0, :null => false - t.text "notes" - t.datetime "created_on", :null => false - t.boolean "private_notes", :default => false, :null => false - end - - add_index "journals", ["created_on"], :name => "index_journals_on_created_on" - add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" - add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" - add_index "journals", ["user_id"], :name => "index_journals_on_user_id" - - create_table "journals_for_messages", :force => true do |t| - t.integer "jour_id" - t.string "jour_type" - t.integer "user_id" - t.text "notes" - t.integer "status" - t.integer "reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.string "m_parent_id" - t.boolean "is_readed" - t.integer "m_reply_count" - t.integer "m_reply_id" - t.integer "is_comprehensive_evaluation" - end - - create_table "kindeditor_assets", :force => true do |t| - t.string "asset" - t.integer "file_size" - t.string "file_type" - t.integer "owner_id" - t.string "asset_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "owner_type", :default => 0 - end - - create_table "member_roles", :force => true do |t| - t.integer "member_id", :null => false - t.integer "role_id", :null => false - t.integer "inherited_from" - end - - add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" - add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" - - create_table "members", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "project_id", :default => 0 - t.datetime "created_on" - t.boolean "mail_notification", :default => false, :null => false - t.integer "course_id", :default => -1 - t.integer "course_group_id", :default => 0 - end - - add_index "members", ["project_id"], :name => "index_members_on_project_id" - add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true - add_index "members", ["user_id"], :name => "index_members_on_user_id" - - create_table "memos", :force => true do |t| - t.integer "forum_id", :null => false - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false - t.integer "author_id", :null => false - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count", :default => 0 - end - - create_table "messages", :force => true do |t| - t.integer "board_id", :null => false - t.integer "parent_id" - t.string "subject", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "replies_count", :default => 0, :null => false - t.integer "last_reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - end - - add_index "messages", ["author_id"], :name => "index_messages_on_author_id" - add_index "messages", ["board_id"], :name => "messages_board_id" - add_index "messages", ["created_on"], :name => "index_messages_on_created_on" - add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" - add_index "messages", ["parent_id"], :name => "messages_parent_id" - - create_table "news", :force => true do |t| - t.integer "project_id" - t.string "title", :limit => 60, :default => "", :null => false - t.string "summary", :default => "" - t.text "description" - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.integer "comments_count", :default => 0, :null => false - t.integer "course_id" - end - - add_index "news", ["author_id"], :name => "index_news_on_author_id" - add_index "news", ["created_on"], :name => "index_news_on_created_on" - add_index "news", ["project_id"], :name => "news_project_id" - - create_table "no_uses", :force => true do |t| - t.integer "user_id", :null => false - t.string "no_use_type" - t.integer "no_use_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "notificationcomments", :force => true do |t| - t.string "notificationcommented_type" - t.integer "notificationcommented_id" - t.integer "author_id" - t.text "notificationcomments" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "open_id_authentication_associations", :force => true do |t| - t.integer "issued" - t.integer "lifetime" - t.string "handle" - t.string "assoc_type" - t.binary "server_url" - t.binary "secret" - end - - create_table "open_id_authentication_nonces", :force => true do |t| - t.integer "timestamp", :null => false - t.string "server_url" - t.string "salt", :null => false - end - - create_table "open_source_projects", :force => true do |t| - t.string "name" - t.text "description" - t.integer "commit_count", :default => 0 - t.integer "code_line", :default => 0 - t.integer "users_count", :default => 0 - t.date "last_commit_time" - t.string "url" - t.date "date_collected" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "option_numbers", :force => true do |t| - t.integer "user_id" - t.integer "memo" - t.integer "messages_for_issues" - t.integer "issues_status" - t.integer "replay_for_message" - t.integer "replay_for_memo" - t.integer "follow" - t.integer "tread" - t.integer "praise_by_one" - t.integer "praise_by_two" - t.integer "praise_by_three" - t.integer "tread_by_one" - t.integer "tread_by_two" - t.integer "tread_by_three" - t.integer "changeset" - t.integer "document" - t.integer "attachment" - t.integer "issue_done_ratio" - t.integer "post_issue" - t.integer "score_type" - t.integer "total_score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - end - - create_table "organizations", :force => true do |t| - t.string "name" - t.string "logo_link" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "phone_app_versions", :force => true do |t| - t.string "version" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_answers", :force => true do |t| - t.integer "poll_question_id" - t.text "answer_text" - t.integer "answer_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_questions", :force => true do |t| - t.string "question_title" - t.integer "question_type" - t.integer "is_necessary" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_number" - end - - create_table "poll_users", :force => true do |t| - t.integer "user_id" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_votes", :force => true do |t| - t.integer "user_id" - t.integer "poll_question_id" - t.integer "poll_answer_id" - t.text "vote_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "polls", :force => true do |t| - t.string "polls_name" - t.string "polls_type" - t.integer "polls_group_id" - t.integer "polls_status" - t.integer "user_id" - t.datetime "published_at" - t.datetime "closed_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "polls_description" - t.integer "show_result", :default => 1 - end - - create_table "praise_tread_caches", :force => true do |t| - t.integer "object_id", :null => false - t.string "object_type" - t.integer "praise_num" - t.integer "tread_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "praise_treads", :force => true do |t| - t.integer "user_id", :null => false - t.integer "praise_tread_object_id" - t.string "praise_tread_object_type" - t.integer "praise_or_tread" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_infos", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_scores", :force => true do |t| - t.string "project_id" - t.integer "score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "issue_num", :default => 0 - t.integer "issue_journal_num", :default => 0 - t.integer "news_num", :default => 0 - t.integer "documents_num", :default => 0 - t.integer "changeset_num", :default => 0 - t.integer "board_message_num", :default => 0 - end - - create_table "project_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "project_id" - t.integer "project_type" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - end - - add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" - - create_table "projecting_softapplictions", :force => true do |t| - t.integer "user_id" - t.integer "softapplication_id" - t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "projects", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.string "homepage", :default => "" - t.boolean "is_public", :default => true, :null => false - t.integer "parent_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "identifier" - t.integer "status", :default => 1, :null => false - t.integer "lft" - t.integer "rgt" - t.boolean "inherit_members", :default => false, :null => false - t.integer "project_type" - t.boolean "hidden_repo", :default => false, :null => false - t.integer "attachmenttype", :default => 1 - t.integer "user_id" - t.integer "dts_test", :default => 0 - t.string "enterprise_name" - t.integer "organization_id" - end - - add_index "projects", ["lft"], :name => "index_projects_on_lft" - add_index "projects", ["rgt"], :name => "index_projects_on_rgt" - - create_table "projects_trackers", :id => false, :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - 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 "queries", :force => true do |t| - t.integer "project_id" - t.string "name", :default => "", :null => false - t.text "filters" - t.integer "user_id", :default => 0, :null => false - t.boolean "is_public", :default => false, :null => false - t.text "column_names" - t.text "sort_criteria" - t.string "group_by" - t.string "type" - end - - add_index "queries", ["project_id"], :name => "index_queries_on_project_id" - add_index "queries", ["user_id"], :name => "index_queries_on_user_id" - - create_table "relative_memo_to_open_source_projects", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "relative_memos", :force => true do |t| - t.integer "osp_id" - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :limit => 16777215, :null => false - t.integer "author_id" - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 - t.string "url" - t.string "username" - t.string "userhomeurl" - t.date "date_collected" - t.string "topic_resource" - end - - create_table "repositories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "url", :default => "", :null => false - t.string "login", :limit => 60, :default => "" - t.string "password", :default => "" - t.string "root_url", :default => "" - t.string "type" - t.string "path_encoding", :limit => 64 - t.string "log_encoding", :limit => 64 - t.text "extra_info" - t.string "identifier" - t.boolean "is_default", :default => false - end - - add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - - create_table "roles", :force => true do |t| - t.string "name", :limit => 90 - t.integer "position" - t.boolean "assignable" - t.integer "builtin" - t.text "permissions" - t.string "issues_visibility", :limit => 90 - end - - create_table "schools", :force => true do |t| - t.string "name" - t.string "province" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "logo_link" - end - - create_table "seems_rateable_cached_ratings", :force => true do |t| - t.integer "cacheable_id", :limit => 8 - t.string "cacheable_type" - t.float "avg", :null => false - t.integer "cnt", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "seems_rateable_rates", :force => true do |t| - t.integer "rater_id", :limit => 8 - t.integer "rateable_id" - t.string "rateable_type" - t.float "stars", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "is_teacher_score", :default => 0 - end - - create_table "settings", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "value" - t.datetime "updated_on" - end - - add_index "settings", ["name"], :name => "index_settings_on_name" - - create_table "shares", :force => true do |t| - t.date "created_on" - t.string "url" - t.string "title" - t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - t.integer "user_id" - t.string "description" - end - - create_table "softapplications", :force => true do |t| - t.string "name" - t.text "description" - t.integer "app_type_id" - t.string "app_type_name" - t.string "android_min_version_available" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "contest_id" - t.integer "softapplication_id" - t.integer "is_public" - t.string "application_developers" - t.string "deposit_project_url" - t.string "deposit_project" - t.integer "project_id" - end - - create_table "students_for_courses", :force => true do |t| - t.integer "student_id" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "taggings", :force => true do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", :limit => 128 - t.datetime "created_at" - end - - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" - add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" - - create_table "tags", :force => true do |t| - t.string "name" - end - - create_table "teachers", :force => true do |t| - t.string "tea_name" - t.string "location" - t.integer "couurse_time" - t.integer "course_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "extra" - end - - create_table "time_entries", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - t.integer "issue_id" - t.float "hours", :null => false - t.string "comments" - t.integer "activity_id", :null => false - t.date "spent_on", :null => false - t.integer "tyear", :null => false - t.integer "tmonth", :null => false - t.integer "tweek", :null => false - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" - add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" - add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" - add_index "time_entries", ["project_id"], :name => "time_entries_project_id" - add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - - create_table "tokens", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.string "action", :limit => 30, :default => "", :null => false - t.string "value", :limit => 40, :default => "", :null => false - t.datetime "created_on", :null => false - end - - add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" - add_index "tokens", ["value"], :name => "tokens_value", :unique => true - - create_table "trackers", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_in_chlog", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "is_in_roadmap", :default => true, :null => false - t.integer "fields_bits", :default => 0 - end - - create_table "user_extensions", :force => true do |t| - t.integer "user_id", :null => false - t.date "birthday" - t.string "brief_introduction" - t.integer "gender" - t.string "location" - t.string "occupation" - t.integer "work_experience" - t.integer "zip_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "technical_title" - t.integer "identity" - t.string "student_id" - t.string "teacher_realname" - t.string "student_realname" - t.string "location_city" - t.integer "school_id" - end - - create_table "user_grades", :force => true do |t| - t.integer "user_id", :null => false - t.integer "project_id", :null => false - t.float "grade", :default => 0.0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" - add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" - add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" - - create_table "user_levels", :force => true do |t| - t.integer "user_id" - t.integer "level" - end - - create_table "user_preferences", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.text "others" - t.boolean "hide_mail", :default => false - t.string "time_zone" - end - - add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" - - create_table "user_score_details", :force => true do |t| - t.integer "current_user_id" - t.integer "target_user_id" - t.string "score_type" - t.string "score_action" - t.integer "user_id" - t.integer "old_score" - t.integer "new_score" - t.integer "current_user_level" - t.integer "target_user_level" - t.integer "score_changeable_obj_id" - t.string "score_changeable_obj_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_scores", :force => true do |t| - t.integer "user_id", :null => false - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "active" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "grade", :default => 0.0 - end - - add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" - add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" - add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" - - create_table "users", :force => true do |t| - t.string "login", :default => "", :null => false - t.string "hashed_password", :limit => 40, :default => "", :null => false - t.string "firstname", :limit => 30, :default => "", :null => false - t.string "lastname", :default => "", :null => false - t.string "mail", :limit => 60, :default => "", :null => false - t.boolean "admin", :default => false, :null => false - t.integer "status", :default => 1, :null => false - t.datetime "last_login_on" - t.string "language", :limit => 5, :default => "" - t.integer "auth_source_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "type" - t.string "identity_url" - t.string "mail_notification", :default => "", :null => false - t.string "salt", :limit => 64 - end - - add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" - add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" - add_index "users", ["type"], :name => "index_users_on_type" - - create_table "versions", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :default => "", :null => false - t.string "description", :default => "" - t.date "effective_date" - t.datetime "created_on" - t.datetime "updated_on" - t.string "wiki_page_title" - t.string "status", :default => "open" - t.string "sharing", :default => "none", :null => false - end - - add_index "versions", ["project_id"], :name => "versions_project_id" - add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - - create_table "watchers", :force => true do |t| - t.string "watchable_type", :default => "", :null => false - t.integer "watchable_id", :default => 0, :null => false - t.integer "user_id" - end - - add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" - add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" - add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" - - create_table "web_footer_companies", :force => true do |t| - t.string "name" - t.string "logo_size" - t.string "url" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "web_footer_oranizers", :force => true do |t| - t.string "name" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "wiki_content_versions", :force => true do |t| - t.integer "wiki_content_id", :null => false - t.integer "page_id", :null => false - t.integer "author_id" - t.binary "data", :limit => 2147483647 - t.string "compression", :limit => 6, :default => "" - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" - add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" - - create_table "wiki_contents", :force => true do |t| - t.integer "page_id", :null => false - t.integer "author_id" - t.text "text", :limit => 2147483647 - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" - add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" - - create_table "wiki_pages", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title", :null => false - t.datetime "created_on", :null => false - t.boolean "protected", :default => false, :null => false - t.integer "parent_id" - end - - add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" - add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" - add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" - - create_table "wiki_redirects", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title" - t.string "redirects_to" - t.datetime "created_on", :null => false - end - - add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" - add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" - - create_table "wikis", :force => true do |t| - t.integer "project_id", :null => false - t.string "start_page", :null => false - t.integer "status", :default => 1, :null => false - end - - add_index "wikis", ["project_id"], :name => "wikis_project_id" - - create_table "workflows", :force => true do |t| - t.integer "tracker_id", :default => 0, :null => false - t.integer "old_status_id", :default => 0, :null => false - t.integer "new_status_id", :default => 0, :null => false - t.integer "role_id", :default => 0, :null => false - t.boolean "assignee", :default => false, :null => false - t.boolean "author", :default => false, :null => false - t.string "type", :limit => 30 - t.string "field_name", :limit => 30 - t.string "rule", :limit => 30 - end - - add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" - add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" - add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" - add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" - - create_table "works_categories", :force => true do |t| - t.string "category" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - -end +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20150328115230) do + + create_table "activities", :force => true do |t| + t.integer "act_id", :null => false + t.string "act_type", :null => false + t.integer "user_id", :null => false + end + + add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" + add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" + add_index "activities", ["user_id"], :name => "index_activities_on_user_id" + + create_table "api_keys", :force => true do |t| + t.string "access_token" + t.datetime "expires_at" + t.integer "user_id" + t.boolean "active", :default => true + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + 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 "applied_projects", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + end + + create_table "apply_project_masters", :force => true do |t| + t.integer "user_id" + t.string "apply_type" + t.integer "apply_id" + t.integer "status" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "attachments", :force => true do |t| + t.integer "container_id" + t.string "container_type", :limit => 30 + t.string "filename", :default => "", :null => false + t.string "disk_filename", :default => "", :null => false + t.integer "filesize", :default => 0, :null => false + t.string "content_type", :default => "" + t.string "digest", :limit => 40, :default => "", :null => false + t.integer "downloads", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false + t.datetime "created_on" + t.string "description" + t.string "disk_directory" + t.integer "attachtype", :default => 1 + t.integer "is_public", :default => 1 + t.integer "copy_from" + t.integer "quotes" + end + + add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" + add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" + add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" + + create_table "attachmentstypes", :force => true do |t| + t.integer "typeId", :null => false + t.string "typeName", :limit => 50 + end + + create_table "auth_sources", :force => true do |t| + t.string "type", :limit => 30, :default => "", :null => false + t.string "name", :limit => 60, :default => "", :null => false + t.string "host", :limit => 60 + t.integer "port" + t.string "account" + t.string "account_password", :default => "" + t.string "base_dn" + t.string "attr_login", :limit => 30 + t.string "attr_firstname", :limit => 30 + t.string "attr_lastname", :limit => 30 + t.string "attr_mail", :limit => 30 + t.boolean "onthefly_register", :default => false, :null => false + t.boolean "tls", :default => false, :null => false + t.string "filter" + t.integer "timeout" + end + + add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" + + create_table "biding_projects", :force => true do |t| + t.integer "project_id" + t.integer "bid_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "bids", :force => true do |t| + t.string "name" + t.string "budget", :null => false + t.integer "author_id" + t.date "deadline" + t.text "description" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.integer "commit" + t.integer "reward_type" + t.integer "homework_type" + t.integer "parent_id" + t.string "password" + t.integer "is_evaluation" + t.integer "proportion", :default => 60 + t.integer "comment_status", :default => 0 + t.integer "evaluation_num", :default => 3 + t.integer "open_anonymous_evaluation", :default => 1 + end + + create_table "boards", :force => true do |t| + t.integer "project_id", :null => false + t.string "name", :default => "", :null => false + t.string "description" + t.integer "position", :default => 1 + t.integer "topics_count", :default => 0, :null => false + t.integer "messages_count", :default => 0, :null => false + t.integer "last_message_id" + t.integer "parent_id" + t.integer "course_id" + end + + add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" + add_index "boards", ["project_id"], :name => "boards_project_id" + + create_table "bug_to_osps", :force => true do |t| + t.integer "osp_id" + t.integer "relative_memo_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "changes", :force => true do |t| + t.integer "changeset_id", :null => false + t.string "action", :limit => 1, :default => "", :null => false + t.text "path", :null => false + t.text "from_path" + t.string "from_revision" + t.string "revision" + t.string "branch" + end + + add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" + + create_table "changeset_parents", :id => false, :force => true do |t| + t.integer "changeset_id", :null => false + t.integer "parent_id", :null => false + end + + add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" + 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.string "committer" + t.datetime "committed_on", :null => false + t.text "comments" + t.date "commit_date" + t.string "scmid" + t.integer "user_id" + end + + add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" + add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true + add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" + add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" + add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" + + create_table "changesets_issues", :id => false, :force => true do |t| + t.integer "changeset_id", :null => false + t.integer "issue_id", :null => false + end + + add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true + + create_table "code_review_assignments", :force => true do |t| + t.integer "issue_id" + t.integer "change_id" + t.integer "attachment_id" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.string "action_type" + t.integer "changeset_id" + end + + create_table "code_review_project_settings", :force => true do |t| + t.integer "project_id" + t.integer "tracker_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "updated_by" + t.boolean "hide_code_review_tab", :default => false + t.integer "auto_relation", :default => 1 + t.integer "assignment_tracker_id" + t.text "auto_assign" + t.integer "lock_version", :default => 0, :null => false + t.boolean "tracker_in_review_dialog", :default => false + end + + create_table "code_review_user_settings", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "mail_notification", :default => 0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "code_reviews", :force => true do |t| + t.integer "project_id" + t.integer "change_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "line" + t.integer "updated_by_id" + t.integer "lock_version", :default => 0, :null => false + t.integer "status_changed_from" + t.integer "status_changed_to" + t.integer "issue_id" + t.string "action_type" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.integer "attachment_id" + t.integer "file_count", :default => 0, :null => false + t.boolean "diff_all" + end + + create_table "comments", :force => true do |t| + t.string "commented_type", :limit => 30, :default => "", :null => false + t.integer "commented_id", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false + t.text "comments" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + 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 "contest_notifications", :force => true do |t| + t.text "title" + t.text "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "contesting_projects", :force => true do |t| + t.integer "project_id" + t.string "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contesting_softapplications", :force => true do |t| + t.integer "softapplication_id" + t.integer "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contestnotifications", :force => true do |t| + t.integer "contest_id" + t.string "title" + t.string "summary" + t.text "description" + t.integer "author_id" + t.integer "notificationcomments_count" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "contests", :force => true do |t| + t.string "name" + t.string "budget", :default => "" + t.integer "author_id" + t.date "deadline" + t.string "description" + t.integer "commit" + t.string "password" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + create_table "course_attachments", :force => true do |t| + t.string "filename" + t.string "disk_filename" + t.integer "filesize" + t.string "content_type" + t.string "digest" + t.integer "downloads" + t.string "author_id" + t.string "integer" + t.string "description" + t.string "disk_directory" + t.integer "attachtype" + t.integer "is_public" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "container_id", :default => 0 + end + + create_table "course_groups", :force => true do |t| + t.string "name" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_infos", :force => true do |t| + t.integer "course_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "course_id" + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "courses", :force => true do |t| + t.integer "tea_id" + t.string "name" + t.integer "state" + t.string "code" + t.integer "time" + t.string "extra" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "location" + t.string "term" + t.string "string" + t.string "password" + t.string "setup_time" + t.string "endup_time" + t.string "class_period" + t.integer "school_id" + t.text "description" + t.integer "status", :default => 1 + t.integer "attachmenttype", :default => 2 + t.integer "lft" + t.integer "rgt" + t.integer "is_public", :limit => 1, :default => 1 + t.integer "inherit_members", :limit => 1, :default => 1 + t.integer "open_student", :default => 0 + end + + create_table "custom_fields", :force => true do |t| + t.string "type", :limit => 30, :default => "", :null => false + t.string "name", :limit => 30, :default => "", :null => false + t.string "field_format", :limit => 30, :default => "", :null => false + t.text "possible_values" + t.string "regexp", :default => "" + t.integer "min_length", :default => 0, :null => false + t.integer "max_length", :default => 0, :null => false + t.boolean "is_required", :default => false, :null => false + t.boolean "is_for_all", :default => false, :null => false + t.boolean "is_filter", :default => false, :null => false + t.integer "position", :default => 1 + t.boolean "searchable", :default => false + t.text "default_value" + t.boolean "editable", :default => true + t.boolean "visible", :default => true, :null => false + t.boolean "multiple", :default => false + end + + add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" + + create_table "custom_fields_projects", :id => false, :force => true do |t| + t.integer "custom_field_id", :default => 0, :null => false + t.integer "project_id", :default => 0, :null => false + end + + add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true + + create_table "custom_fields_trackers", :id => false, :force => true do |t| + t.integer "custom_field_id", :default => 0, :null => false + t.integer "tracker_id", :default => 0, :null => false + end + + add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true + + create_table "custom_values", :force => true do |t| + t.string "customized_type", :limit => 30, :default => "", :null => false + t.integer "customized_id", :default => 0, :null => false + t.integer "custom_field_id", :default => 0, :null => false + t.text "value" + end + + add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" + add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" + + create_table "discuss_demos", :force => true do |t| + t.string "title" + t.text "body" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "documents", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.integer "category_id", :default => 0, :null => false + t.string "title", :limit => 60, :default => "", :null => false + t.text "description" + t.datetime "created_on" + t.integer "user_id", :default => 0 + t.integer "is_public", :default => 1 + end + + add_index "documents", ["category_id"], :name => "index_documents_on_category_id" + add_index "documents", ["created_on"], :name => "index_documents_on_created_on" + add_index "documents", ["project_id"], :name => "documents_project_id" + + create_table "enabled_modules", :force => true do |t| + t.integer "project_id" + t.string "name", :null => false + t.integer "course_id" + end + + add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" + + create_table "enumerations", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "is_default", :default => false, :null => false + t.string "type" + t.boolean "active", :default => true, :null => false + t.integer "project_id" + t.integer "parent_id" + t.string "position_name", :limit => 30 + end + + 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 "first_pages", :force => true do |t| + t.string "web_title" + t.string "title" + t.text "description" + t.string "page_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sort_type" + t.integer "image_width", :default => 107 + t.integer "image_height", :default => 63 + t.integer "show_course", :default => 1 + t.integer "show_contest", :default => 1 + end + + create_table "forge_activities", :force => true do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "forge_act_id" + t.string "forge_act_type" + t.integer "org_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" + + create_table "forums", :force => true do |t| + t.string "name", :null => false + t.text "description" + t.integer "topic_count", :default => 0 + t.integer "memo_count", :default => 0 + t.integer "last_memo_id", :default => 0 + t.integer "creator_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sticky" + t.integer "locked" + end + + create_table "groups_users", :id => false, :force => true do |t| + t.integer "group_id", :null => false + t.integer "user_id", :null => false + end + + add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true + + create_table "homework_attaches", :force => true do |t| + t.integer "bid_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + t.string "name" + t.text "description" + t.integer "state" + t.integer "project_id", :default => 0 + t.float "score", :default => 0.0 + t.integer "is_teacher_score", :default => 0 + end + + create_table "homework_evaluations", :force => true do |t| + t.string "user_id" + t.string "homework_attach_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "homework_for_courses", :force => true do |t| + t.integer "course_id" + t.integer "bid_id" + end + + create_table "homework_users", :force => true do |t| + t.string "homework_attach_id" + t.string "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "issue_categories", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "name", :limit => 30, :default => "", :null => false + t.integer "assigned_to_id" + end + + add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" + add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" + + create_table "issue_relations", :force => true do |t| + t.integer "issue_from_id", :null => false + t.integer "issue_to_id", :null => false + t.string "relation_type", :default => "", :null => false + t.integer "delay" + end + + add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true + add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" + add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" + + create_table "issue_statuses", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.boolean "is_closed", :default => false, :null => false + t.boolean "is_default", :default => false, :null => false + t.integer "position", :default => 1 + t.integer "default_done_ratio" + end + + add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" + add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" + add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" + + create_table "issues", :force => true do |t| + t.integer "tracker_id", :null => false + t.integer "project_id", :null => false + t.string "subject", :default => "", :null => false + t.text "description" + t.date "due_date" + t.integer "category_id" + t.integer "status_id", :null => false + t.integer "assigned_to_id" + t.integer "priority_id", :null => false + t.integer "fixed_version_id" + t.integer "author_id", :null => false + t.integer "lock_version", :default => 0, :null => false + t.datetime "created_on" + t.datetime "updated_on" + t.date "start_date" + t.integer "done_ratio", :default => 0, :null => false + t.float "estimated_hours" + t.integer "parent_id" + t.integer "root_id" + t.integer "lft" + t.integer "rgt" + t.boolean "is_private", :default => false, :null => false + t.datetime "closed_on" + t.integer "project_issues_index" + end + + add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" + add_index "issues", ["author_id"], :name => "index_issues_on_author_id" + add_index "issues", ["category_id"], :name => "index_issues_on_category_id" + add_index "issues", ["created_on"], :name => "index_issues_on_created_on" + add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" + add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" + add_index "issues", ["project_id"], :name => "issues_project_id" + add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" + add_index "issues", ["status_id"], :name => "index_issues_on_status_id" + add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" + + create_table "join_in_competitions", :force => true do |t| + t.integer "user_id" + t.integer "competition_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "join_in_contests", :force => true do |t| + t.integer "user_id" + t.integer "bid_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "journal_details", :force => true do |t| + t.integer "journal_id", :default => 0, :null => false + t.string "property", :limit => 30, :default => "", :null => false + t.string "prop_key", :limit => 30, :default => "", :null => false + t.text "old_value" + t.text "value" + end + + add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" + + create_table "journal_replies", :id => false, :force => true do |t| + t.integer "journal_id" + t.integer "user_id" + t.integer "reply_id" + end + + add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" + add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" + add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" + + create_table "journals", :force => true do |t| + t.integer "journalized_id", :default => 0, :null => false + t.string "journalized_type", :limit => 30, :default => "", :null => false + t.integer "user_id", :default => 0, :null => false + t.text "notes" + t.datetime "created_on", :null => false + t.boolean "private_notes", :default => false, :null => false + end + + add_index "journals", ["created_on"], :name => "index_journals_on_created_on" + add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" + add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" + add_index "journals", ["user_id"], :name => "index_journals_on_user_id" + + create_table "journals_for_messages", :force => true do |t| + t.integer "jour_id" + t.string "jour_type" + t.integer "user_id" + t.text "notes" + t.integer "status" + t.integer "reply_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.string "m_parent_id" + t.boolean "is_readed" + t.integer "m_reply_count" + t.integer "m_reply_id" + t.integer "is_comprehensive_evaluation" + end + + create_table "kindeditor_assets", :force => true do |t| + t.string "asset" + t.integer "file_size" + t.string "file_type" + t.integer "owner_id" + t.string "asset_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "owner_type", :default => 0 + end + + create_table "member_roles", :force => true do |t| + t.integer "member_id", :null => false + t.integer "role_id", :null => false + t.integer "inherited_from" + end + + add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" + add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" + + create_table "members", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "project_id", :default => 0 + t.datetime "created_on" + t.boolean "mail_notification", :default => false, :null => false + t.integer "course_id", :default => -1 + t.integer "course_group_id", :default => 0 + end + + add_index "members", ["project_id"], :name => "index_members_on_project_id" + add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true + add_index "members", ["user_id"], :name => "index_members_on_user_id" + + create_table "memos", :force => true do |t| + t.integer "forum_id", :null => false + t.integer "parent_id" + t.string "subject", :null => false + t.text "content", :null => false + t.integer "author_id", :null => false + t.integer "replies_count", :default => 0 + t.integer "last_reply_id" + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count", :default => 0 + end + + create_table "messages", :force => true do |t| + t.integer "board_id", :null => false + t.integer "parent_id" + t.string "subject", :default => "", :null => false + t.text "content" + t.integer "author_id" + t.integer "replies_count", :default => 0, :null => false + t.integer "last_reply_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + end + + add_index "messages", ["author_id"], :name => "index_messages_on_author_id" + add_index "messages", ["board_id"], :name => "messages_board_id" + add_index "messages", ["created_on"], :name => "index_messages_on_created_on" + add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" + add_index "messages", ["parent_id"], :name => "messages_parent_id" + + create_table "news", :force => true do |t| + t.integer "project_id" + t.string "title", :limit => 60, :default => "", :null => false + t.string "summary", :default => "" + t.text "description" + t.integer "author_id", :default => 0, :null => false + t.datetime "created_on" + t.integer "comments_count", :default => 0, :null => false + t.integer "course_id" + end + + add_index "news", ["author_id"], :name => "index_news_on_author_id" + add_index "news", ["created_on"], :name => "index_news_on_created_on" + add_index "news", ["project_id"], :name => "news_project_id" + + create_table "no_uses", :force => true do |t| + t.integer "user_id", :null => false + t.string "no_use_type" + t.integer "no_use_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "notificationcomments", :force => true do |t| + t.string "notificationcommented_type" + t.integer "notificationcommented_id" + t.integer "author_id" + t.text "notificationcomments" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "open_id_authentication_associations", :force => true do |t| + t.integer "issued" + t.integer "lifetime" + t.string "handle" + t.string "assoc_type" + t.binary "server_url" + t.binary "secret" + end + + create_table "open_id_authentication_nonces", :force => true do |t| + t.integer "timestamp", :null => false + t.string "server_url" + t.string "salt", :null => false + end + + create_table "open_source_projects", :force => true do |t| + t.string "name" + t.text "description" + t.integer "commit_count", :default => 0 + t.integer "code_line", :default => 0 + t.integer "users_count", :default => 0 + t.date "last_commit_time" + t.string "url" + t.date "date_collected" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "option_numbers", :force => true do |t| + t.integer "user_id" + t.integer "memo" + t.integer "messages_for_issues" + t.integer "issues_status" + t.integer "replay_for_message" + t.integer "replay_for_memo" + t.integer "follow" + t.integer "tread" + t.integer "praise_by_one" + t.integer "praise_by_two" + t.integer "praise_by_three" + t.integer "tread_by_one" + t.integer "tread_by_two" + t.integer "tread_by_three" + t.integer "changeset" + t.integer "document" + t.integer "attachment" + t.integer "issue_done_ratio" + t.integer "post_issue" + t.integer "score_type" + t.integer "total_score" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "project_id" + end + + create_table "organizations", :force => true do |t| + t.string "name" + t.string "logo_link" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "phone_app_versions", :force => true do |t| + t.string "version" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_answers", :force => true do |t| + t.integer "poll_question_id" + t.text "answer_text" + t.integer "answer_position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_questions", :force => true do |t| + t.string "question_title" + t.integer "question_type" + t.integer "is_necessary" + t.integer "poll_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "question_number" + end + + create_table "poll_users", :force => true do |t| + t.integer "user_id" + t.integer "poll_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_votes", :force => true do |t| + t.integer "user_id" + t.integer "poll_question_id" + t.integer "poll_answer_id" + t.text "vote_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "polls", :force => true do |t| + t.string "polls_name" + t.string "polls_type" + t.integer "polls_group_id" + t.integer "polls_status" + t.integer "user_id" + t.datetime "published_at" + t.datetime "closed_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "polls_description" + t.integer "show_result", :default => 1 + end + + create_table "praise_tread_caches", :force => true do |t| + t.integer "object_id", :null => false + t.string "object_type" + t.integer "praise_num" + t.integer "tread_num" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "praise_treads", :force => true do |t| + t.integer "user_id", :null => false + t.integer "praise_tread_object_id" + t.string "praise_tread_object_type" + t.integer "praise_or_tread" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "project_infos", :force => true do |t| + t.integer "project_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "project_scores", :force => true do |t| + t.string "project_id" + t.integer "score" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "issue_num", :default => 0 + t.integer "issue_journal_num", :default => 0 + t.integer "news_num", :default => 0 + t.integer "documents_num", :default => 0 + t.integer "changeset_num", :default => 0 + t.integer "board_message_num", :default => 0 + end + + create_table "project_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "project_id" + t.integer "project_type" + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 + end + + add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" + + create_table "projecting_softapplictions", :force => true do |t| + t.integer "user_id" + t.integer "softapplication_id" + t.integer "project_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "projects", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "description" + t.string "homepage", :default => "" + t.boolean "is_public", :default => true, :null => false + t.integer "parent_id" + t.datetime "created_on" + t.datetime "updated_on" + t.string "identifier" + t.integer "status", :default => 1, :null => false + t.integer "lft" + t.integer "rgt" + t.boolean "inherit_members", :default => false, :null => false + t.integer "project_type" + t.boolean "hidden_repo", :default => false, :null => false + t.integer "attachmenttype", :default => 1 + t.integer "user_id" + t.integer "dts_test", :default => 0 + t.string "enterprise_name" + t.integer "organization_id" + end + + add_index "projects", ["lft"], :name => "index_projects_on_lft" + add_index "projects", ["rgt"], :name => "index_projects_on_rgt" + + create_table "projects_trackers", :id => false, :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.integer "tracker_id", :default => 0, :null => false + end + + 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 "queries", :force => true do |t| + t.integer "project_id" + t.string "name", :default => "", :null => false + t.text "filters" + t.integer "user_id", :default => 0, :null => false + t.boolean "is_public", :default => false, :null => false + t.text "column_names" + t.text "sort_criteria" + t.string "group_by" + t.string "type" + end + + add_index "queries", ["project_id"], :name => "index_queries_on_project_id" + add_index "queries", ["user_id"], :name => "index_queries_on_user_id" + + create_table "relative_memo_to_open_source_projects", :force => true do |t| + t.integer "osp_id" + t.integer "relative_memo_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "relative_memos", :force => true do |t| + t.integer "osp_id" + t.integer "parent_id" + t.string "subject", :null => false + t.text "content", :limit => 16777215, :null => false + t.integer "author_id" + t.integer "replies_count", :default => 0 + t.integer "last_reply_id" + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.boolean "is_quote", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count_crawl", :default => 0 + t.integer "viewed_count_local", :default => 0 + t.string "url" + t.string "username" + t.string "userhomeurl" + t.date "date_collected" + t.string "topic_resource" + end + + create_table "repositories", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "url", :default => "", :null => false + t.string "login", :limit => 60, :default => "" + t.string "password", :default => "" + t.string "root_url", :default => "" + t.string "type" + t.string "path_encoding", :limit => 64 + t.string "log_encoding", :limit => 64 + t.text "extra_info" + t.string "identifier" + t.boolean "is_default", :default => false + end + + add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" + + create_table "rich_rich_files", :force => true do |t| + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "rich_file_file_name" + t.string "rich_file_content_type" + t.integer "rich_file_file_size" + t.datetime "rich_file_updated_at" + t.string "owner_type" + t.integer "owner_id" + t.text "uri_cache" + t.string "simplified_type", :default => "file" + end + + create_table "roles", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "assignable", :default => true + t.integer "builtin", :default => 0, :null => false + t.text "permissions" + t.string "issues_visibility", :limit => 30, :default => "default", :null => false + end + + create_table "schools", :force => true do |t| + t.string "name" + t.string "province" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "logo_link" + end + + create_table "seems_rateable_cached_ratings", :force => true do |t| + t.integer "cacheable_id", :limit => 8 + t.string "cacheable_type" + t.float "avg", :null => false + t.integer "cnt", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "seems_rateable_rates", :force => true do |t| + t.integer "rater_id", :limit => 8 + t.integer "rateable_id" + t.string "rateable_type" + t.float "stars", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "is_teacher_score", :default => 0 + end + + create_table "settings", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "value" + t.datetime "updated_on" + end + + add_index "settings", ["name"], :name => "index_settings_on_name" + + create_table "shares", :force => true do |t| + t.date "created_on" + t.string "url" + t.string "title" + t.integer "share_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "project_id" + t.integer "user_id" + t.string "description" + end + + create_table "softapplications", :force => true do |t| + t.string "name" + t.text "description" + t.integer "app_type_id" + t.string "app_type_name" + t.string "android_min_version_available" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "contest_id" + t.integer "softapplication_id" + t.integer "is_public" + t.string "application_developers" + t.string "deposit_project_url" + t.string "deposit_project" + t.integer "project_id" + end + + create_table "students_for_courses", :force => true do |t| + t.integer "student_id" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "taggings", :force => true do |t| + t.integer "tag_id" + t.integer "taggable_id" + t.string "taggable_type" + t.integer "tagger_id" + t.string "tagger_type" + t.string "context", :limit => 128 + t.datetime "created_at" + end + + add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" + add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" + add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" + + create_table "tags", :force => true do |t| + t.string "name" + end + + create_table "teachers", :force => true do |t| + t.string "tea_name" + t.string "location" + t.integer "couurse_time" + t.integer "course_code" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "extra" + end + + create_table "time_entries", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + t.integer "issue_id" + t.float "hours", :null => false + t.string "comments" + t.integer "activity_id", :null => false + t.date "spent_on", :null => false + t.integer "tyear", :null => false + t.integer "tmonth", :null => false + t.integer "tweek", :null => false + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" + add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" + add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" + add_index "time_entries", ["project_id"], :name => "time_entries_project_id" + add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" + + create_table "tokens", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.string "action", :limit => 30, :default => "", :null => false + t.string "value", :limit => 40, :default => "", :null => false + t.datetime "created_on", :null => false + end + + add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" + add_index "tokens", ["value"], :name => "tokens_value", :unique => true + + create_table "trackers", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.boolean "is_in_chlog", :default => false, :null => false + t.integer "position", :default => 1 + t.boolean "is_in_roadmap", :default => true, :null => false + t.integer "fields_bits", :default => 0 + end + + create_table "user_extensions", :force => true do |t| + t.integer "user_id", :null => false + t.date "birthday" + t.string "brief_introduction" + t.integer "gender" + t.string "location" + t.string "occupation" + t.integer "work_experience" + t.integer "zip_code" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "technical_title" + t.integer "identity" + t.string "student_id" + t.string "teacher_realname" + t.string "student_realname" + t.string "location_city" + t.integer "school_id" + end + + create_table "user_grades", :force => true do |t| + t.integer "user_id", :null => false + t.integer "project_id", :null => false + t.float "grade", :default => 0.0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" + add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" + add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" + + create_table "user_levels", :force => true do |t| + t.integer "user_id" + t.integer "level" + end + + create_table "user_preferences", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.text "others" + t.boolean "hide_mail", :default => false + t.string "time_zone" + end + + add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" + + create_table "user_score_details", :force => true do |t| + t.integer "current_user_id" + t.integer "target_user_id" + t.string "score_type" + t.string "score_action" + t.integer "user_id" + t.integer "old_score" + t.integer "new_score" + t.integer "current_user_level" + t.integer "target_user_level" + t.integer "score_changeable_obj_id" + t.string "score_changeable_obj_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_scores", :force => true do |t| + t.integer "user_id", :null => false + t.integer "collaboration" + t.integer "influence" + t.integer "skill" + t.integer "active" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.float "grade", :default => 0.0 + end + + add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" + add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" + add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" + + create_table "users", :force => true do |t| + t.string "login", :default => "", :null => false + t.string "hashed_password", :limit => 40, :default => "", :null => false + t.string "firstname", :limit => 30, :default => "", :null => false + t.string "lastname", :default => "", :null => false + t.string "mail", :limit => 60, :default => "", :null => false + t.boolean "admin", :default => false, :null => false + t.integer "status", :default => 1, :null => false + t.datetime "last_login_on" + t.string "language", :limit => 5, :default => "" + t.integer "auth_source_id" + t.datetime "created_on" + t.datetime "updated_on" + t.string "type" + t.string "identity_url" + t.string "mail_notification", :default => "", :null => false + t.string "salt", :limit => 64 + end + + add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" + add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" + add_index "users", ["type"], :name => "index_users_on_type" + + create_table "versions", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "name", :default => "", :null => false + t.string "description", :default => "" + t.date "effective_date" + t.datetime "created_on" + t.datetime "updated_on" + t.string "wiki_page_title" + t.string "status", :default => "open" + t.string "sharing", :default => "none", :null => false + end + + add_index "versions", ["project_id"], :name => "versions_project_id" + add_index "versions", ["sharing"], :name => "index_versions_on_sharing" + + create_table "watchers", :force => true do |t| + t.string "watchable_type", :default => "", :null => false + t.integer "watchable_id", :default => 0, :null => false + t.integer "user_id" + end + + add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" + add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" + add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" + + create_table "web_footer_companies", :force => true do |t| + t.string "name" + t.string "logo_size" + t.string "url" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "web_footer_oranizers", :force => true do |t| + t.string "name" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "wiki_content_versions", :force => true do |t| + t.integer "wiki_content_id", :null => false + t.integer "page_id", :null => false + t.integer "author_id" + t.binary "data", :limit => 2147483647 + t.string "compression", :limit => 6, :default => "" + t.string "comments", :default => "" + t.datetime "updated_on", :null => false + t.integer "version", :null => false + end + + add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" + add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" + + create_table "wiki_contents", :force => true do |t| + t.integer "page_id", :null => false + t.integer "author_id" + t.text "text", :limit => 2147483647 + t.string "comments", :default => "" + t.datetime "updated_on", :null => false + t.integer "version", :null => false + end + + add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" + add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" + + create_table "wiki_pages", :force => true do |t| + t.integer "wiki_id", :null => false + t.string "title", :null => false + t.datetime "created_on", :null => false + t.boolean "protected", :default => false, :null => false + t.integer "parent_id" + end + + add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" + add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" + add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" + + create_table "wiki_redirects", :force => true do |t| + t.integer "wiki_id", :null => false + t.string "title" + t.string "redirects_to" + t.datetime "created_on", :null => false + end + + add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" + add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" + + create_table "wikis", :force => true do |t| + t.integer "project_id", :null => false + t.string "start_page", :null => false + t.integer "status", :default => 1, :null => false + end + + add_index "wikis", ["project_id"], :name => "wikis_project_id" + + create_table "workflows", :force => true do |t| + t.integer "tracker_id", :default => 0, :null => false + t.integer "old_status_id", :default => 0, :null => false + t.integer "new_status_id", :default => 0, :null => false + t.integer "role_id", :default => 0, :null => false + t.boolean "assignee", :default => false, :null => false + t.boolean "author", :default => false, :null => false + t.string "type", :limit => 30 + t.string "field_name", :limit => 30 + t.string "rule", :limit => 30 + end + + add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" + add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" + add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" + add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" + + create_table "works_categories", :force => true do |t| + t.string "category" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + +end From 51dbc43ecf3841eb9cc3502ed748a9587e64da96 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 30 Mar 2015 16:05:55 +0800 Subject: [PATCH 02/23] =?UTF-8?q?=E4=BF=AE=E6=94=B9apache=E4=B8=ADgit?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=EF=BC=8C?= =?UTF-8?q?user.passwd=20=3D=3D>=20htdocs/user.passwd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 6c115fc11..01e470c91 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -131,7 +131,7 @@ update @project_path=@root_path+"htdocs/"+@repository_name @repository_tag=params[:repository][:upassword] || params[:repository][:password] @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] - logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag + logger.info "htpasswd -mb "+@root_path+"htdocs/user.passwd "+@repo_name+": "+@repository_tag logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name attrs = pickup_extra_info if((@repository_tag!="")&¶ms[:repository_scm]=="Git") @@ -147,9 +147,9 @@ update @repository.project = @project if request.post? && @repository.save if(params[:repository_scm]=="Git") - system "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+" "+@repository_tag + system "htpasswd -mb "+@root_path+"htdocs/user.passwd "+@repo_name+" "+@repository_tag system "echo -e '"+@repo_name+"-write:"+ - " "+@repo_name+"' >> "+@root_path+"group.passwd" + " "+@repo_name+"' >> "+@root_path+"htdocs/group.passwd" system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s system "git init --bare "+@project_path system "mv "+@project_path+"/hooks/post-update{.sample,}" @@ -243,8 +243,8 @@ update if(@repository.type=="Repository::Git") logger.info "destory the repository value"+"root path"+@root_path+"repo_name"+@repo_name+ "repository_name"+@repository_name+"user group"+@middle - system "sed -i /"+@repo_name+"/{d} "+@root_path+"user.passwd" - system "sed -i /"+@middle+"/{d} "+@root_path+"group.passwd" + system "sed -i /"+@repo_name+"/{d} "+@root_path+"htdocs/user.passwd" + system "sed -i /"+@middle+"/{d} "+@root_path+"htdocs/group.passwd" system "rm -r "+@root_path+"htdocs/"+@repository_name # if(@sed_user&&@sed_group&&@remove) # else From eabcd4e92b68348c90f6eeb06c2c97aaa3d6ade4 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 30 Mar 2015 17:14:52 +0800 Subject: [PATCH 03/23] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=96=B0=E7=95=8C=E9=9D=A2=EF=BC=88=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=8E=92=E5=BA=8F=E7=AD=89?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=A0=B7=E5=BC=8F=E5=B0=9A=E6=9C=AA?= =?UTF-8?q?=E8=B0=83=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 34 +++++++---- app/helpers/attachments_helper.rb | 10 ++++ app/helpers/files_helper.rb | 11 ++++ app/views/files/_course_file.html.erb | 2 +- app/views/files/_project_file_list.html.erb | 58 ++++++++++++++++++ app/views/files/_project_file_new.html.erb | 65 +++++++++++++++++++++ app/views/files/index.html.erb | 2 +- config/locales/projects/zh.yml | 3 +- db/schema.rb | 22 ++----- 9 files changed, 178 insertions(+), 29 deletions(-) create mode 100644 app/views/files/_project_file_list.html.erb create mode 100644 app/views/files/_project_file_new.html.erb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 28156ac0c..0d459e3ba 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -41,8 +41,8 @@ class FilesController < ApplicationController @feedback_count = @all_attachments.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @offset ||= @feedback_pages.offset - @curse_attachments_all = @all_attachments[@offset, @limit] - @curse_attachments = paginateHelper @all_attachments,10 + #@curse_attachments_all = @all_attachments[@offset, @limit] + @obj_attachments = paginateHelper @all_attachments,10 end def search @@ -132,16 +132,30 @@ class FilesController < ApplicationController attribute = "downloads" when "created_on" attribute = "created_on" + when "quotes" + attribute = "quotes" end - - if order_by.count == 1 - sort += "#{Attachment.table_name}.#{attribute} asc " if attribute - elsif order_by.count == 2 - sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " if attribute && order_by[1] - end - if sort_type != params[:sort].split(",").last - sort += "," + @sort = order_by[0] + @order = order_by[1] + if order_by.count == 1 && attribute + sort += "#{Attachment.table_name}.#{attribute} asc " + if sort_type != params[:sort].split(",").last + sort += "," + end + elsif order_by.count == 2 && order_by[1] + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + if sort_type != params[:sort].split(",").last + sort += "," + end end + # if order_by.count == 1 + # sort += "#{Attachment.table_name}.#{attribute} asc " if attribute + # elsif order_by.count == 2 + # sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " if attribute && order_by[1] + # end + # if sort_type != params[:sort].split(",").last + # sort += "," + # end end end diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 2e07421f8..8843b1a76 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -77,6 +77,7 @@ module AttachmentsHelper end end + #判断课程course中是否包含课件attachment,course中引用了attachment也算作包含 def course_contains_attachment? course,attachment course.attachments.each do |att| if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from @@ -85,6 +86,15 @@ module AttachmentsHelper end false end + #判断项目project中是否包含课件attachment,project中引用了attachment也算作包含 + def project_contains_attachment? project,attachment + project.attachments.each do |att| + if att.id == attachment.id || (!att.copy_from.nil? && !attachment.copy_from.nil? && att.copy_from == attachment.copy_from) || att.copy_from == attachment.id || att.id == attachment.copy_from + return true + end + end + false + end def get_qute_number attachment if attachment.copy_from diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 884ebc2eb..08b17ea7a 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -66,6 +66,17 @@ module FilesHelper result end + #判断用户是否拥有不包含当前资源的项目,需用户在该项目中有资源管理相关资源 + def has_project? user,file + result = false + user.projects.each do |project| + if !project_contains_attachment?(project,file) && User.current.allowed_to?(:manage_files, project) + return true + end + end + result + end + # 判断指定的资源时候符合类型 def isTypeOk(attachment, type, contentType) result = false diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index ea499477a..b6f65e9b2 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -55,7 +55,7 @@
- <%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@curse_attachments} %> + <%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb new file mode 100644 index 000000000..60675194b --- /dev/null +++ b/app/views/files/_project_file_list.html.erb @@ -0,0 +1,58 @@ + +
+

共有 <%= all_attachments.count%> 个资源

+

+ <% if order == "asc" %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% else %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>  /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% end %> +

+
+
+
+ <% project_attachments.each do |file| %> +
+
+ <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> + <% if User.current.logged? %> + <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> + <%= link_to(l(:label_slected_to_other_project),quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> + + <% if manage_allowed && file.container_id == project.id && file.container_type == "Project" %> + + <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> + + <% else %> + + <% end %> + <% else %> + <%= link_to(l(:label_slected_to_project),quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_course?(User.current,file) %> + <% end %> + <% else %> + <% end %> +
+
+
+

文件大小:<%= number_to_human_size(file.filesize) %>

+ <%= link_to( l(:button_delete), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if manage_allowed && file.container_id == project.id && file.container_type == "Project"%> +

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

+
+
+
+ <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "10"} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "10"} %> +
+
+
+ <% end %> +
+ +
\ No newline at end of file diff --git a/app/views/files/_project_file_new.html.erb b/app/views/files/_project_file_new.html.erb new file mode 100644 index 000000000..977a7e5ab --- /dev/null +++ b/app/views/files/_project_file_new.html.erb @@ -0,0 +1,65 @@ + +
+

<%= l(:lable_file_sharingarea) %>

+
+ + + + +
+
+
+ <%#= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search f_l",:remote=>true) do %> + <%#= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> + <%#= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()" %> + <%#= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> + <%# end %> + <% manage_allowed = User.current.allowed_to?(:manage_files, @project) %> + <% if manage_allowed %> + 上传资源 + <% end %> +
+
+ +
+ <%= render :partial => 'project_file_list',:locals => {project: @project,all_attachments: @all_attachments,sort:@sort,order:@order,project_attachments:@obj_attachments,:manage_allowed => manage_allowed} %> +
+ +
+
+<% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 4b6df47cb..aefa1a5a9 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,6 +1,6 @@
<% if @isproject %> - <%= render :partial => 'project_file', locals: {project: @project} %> + <%= render :partial => 'project_file_new', locals: {project: @project} %> <% else %> <%= render :partial => 'course_file', locals: {course: @course} %> <% end %> diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 9f1a95201..bb78fda4d 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -106,7 +106,8 @@ zh: lable_file_sharingarea: 资源共享区 label_upload_files: 上传文件 - + label_slected_to_other_project: 选入我的其他项目 + label_slected_to_project: 选入我的项目 # 资源库(附件)公用 > 关联资源 label_relation_files: 关联已有资源 diff --git a/db/schema.rb b/db/schema.rb index b149a870b..295b459e6 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 => 20150309090143) do +ActiveRecord::Schema.define(:version => 20150324021043) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -638,16 +638,6 @@ ActiveRecord::Schema.define(:version => 20150309090143) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" @@ -1069,12 +1059,12 @@ ActiveRecord::Schema.define(:version => 20150309090143) do end create_table "roles", :force => true do |t| - t.string "name", :limit => 90 - t.integer "position" - t.boolean "assignable" - t.integer "builtin" + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "assignable", :default => true + t.integer "builtin", :default => 0, :null => false t.text "permissions" - t.string "issues_visibility", :limit => 90 + t.string "issues_visibility", :limit => 30, :default => "default", :null => false end create_table "schools", :force => true do |t| From 77134c8dde83621f94806968002a5ba3f812c59e Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 30 Mar 2015 20:56:42 +0800 Subject: [PATCH 04/23] =?UTF-8?q?=E5=B0=86=E6=AF=8F=E6=97=A5=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E7=A7=BB=E5=85=A5crontab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/initializers/send_mail.rb | 21 ++++++++++++--------- lib/tasks/email.rake | 9 +++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/config/initializers/send_mail.rb b/config/initializers/send_mail.rb index 203624104..4dda7d0c9 100644 --- a/config/initializers/send_mail.rb +++ b/config/initializers/send_mail.rb @@ -1,12 +1,15 @@ #coding=utf-8 -scheduler = Rufus::Scheduler.new -#每天18:00发送当天的邮件汇总 -scheduler.cron('0 18 * * *') do - users = User.where(mail_notification: 'day') - users.each do |user| - mailer = Mailer.send_for_user_activities(user, Date.today, 1) - mailer.deliver if mailer - end -end +## 移入crontab + +# scheduler = Rufus::Scheduler.new +# +# #每天18:00发送当天的邮件汇总 +# scheduler.cron('0 18 * * *') do +# users = User.where(mail_notification: 'day') +# users.each do |user| +# mailer = Mailer.send_for_user_activities(user, Date.today, 1) +# mailer.deliver if mailer +# end +# end diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake index 934070e54..676618825 100644 --- a/lib/tasks/email.rake +++ b/lib/tasks/email.rake @@ -194,5 +194,14 @@ END_DESC abort l(:notice_email_error, e.message) end end + + desc "send a email for day" + task :day => :environment do + users = User.where(mail_notification: 'day') + users.each do |user| + mailer = Mailer.send_for_user_activities(user, Date.today, 1) + mailer.deliver if mailer + end + end end end From efdfa67c64cbac8126dd04e2bf52ebe735e9eaac Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 30 Mar 2015 21:32:48 +0800 Subject: [PATCH 05/23] =?UTF-8?q?=E6=97=A5=E6=8A=A5homework=20created=5Fon?= =?UTF-8?q?=20to=20created=5Fat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 2 +- app/views/mailer/send_for_user_activities.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 0511e2128..50b0c075b 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -122,7 +122,7 @@ class Mailer < ActionMailer::Base @course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| !o.empty? } - binding.pry + binding.pry if Rails.env.development? #有内容才发,没有不发 mail :to => user.mail,:subject => subject if has_content end diff --git a/app/views/mailer/send_for_user_activities.html.erb b/app/views/mailer/send_for_user_activities.html.erb index 1735bd899..d5c4212cd 100644 --- a/app/views/mailer/send_for_user_activities.html.erb +++ b/app/views/mailer/send_for_user_activities.html.erb @@ -90,7 +90,7 @@ :class => 'wmail_info', :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> - <%= format_time(homework.created_on) %> + <%= format_time(homework.created_at) %> <% end %> <% end %> From e2eaae63f4df72fdb858eb3ef4bc4617f9d6e3b8 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 31 Mar 2015 09:34:27 +0800 Subject: [PATCH 06/23] =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=EF=BC=8C=E9=BB=98=E8=AE=A4=E6=8C=89=E6=97=B6=E9=97=B4=E9=99=8D?= =?UTF-8?q?=E5=BA=8F=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 16 ++++++++-------- app/views/files/_project_file_list.html.erb | 2 +- app/views/files/_show_all_attachment.html.erb | 4 ++-- app/views/files/index.html.erb | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 0d459e3ba..21d2254c1 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -134,6 +134,8 @@ class FilesController < ApplicationController attribute = "created_on" when "quotes" attribute = "quotes" + else + attribute = "created_on" end @sort = order_by[0] @order = order_by[1] @@ -148,15 +150,9 @@ class FilesController < ApplicationController sort += "," end end - # if order_by.count == 1 - # sort += "#{Attachment.table_name}.#{attribute} asc " if attribute - # elsif order_by.count == 2 - # sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " if attribute && order_by[1] - # end - # if sort_type != params[:sort].split(",").last - # sort += "," - # end end + else + sort = "#{Attachment.table_name}.created_on desc" end @containers = [ Project.includes(:attachments).find(@project.id)] @@ -198,6 +194,8 @@ class FilesController < ApplicationController attribute = "created_on" when "quotes" attribute = "quotes" + else + attribute = "created_on" end @sort = order_by[0] @order = order_by[1] @@ -213,6 +211,8 @@ class FilesController < ApplicationController end end end + else + sort = "#{Attachment.table_name}.created_on desc" end @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index 60675194b..136be38e1 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -20,7 +20,7 @@
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> <% if User.current.logged? %> - <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> + <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> <%= link_to(l(:label_slected_to_other_project),quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> <% if manage_allowed && file.container_id == project.id && file.container_type == "Project" %> diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb index 6935c186f..729f0a483 100644 --- a/app/views/files/_show_all_attachment.html.erb +++ b/app/views/files/_show_all_attachment.html.erb @@ -24,8 +24,8 @@ - <% if @curse_attachments != nil %> - <% @curse_attachments.each do |file| %> + <% if @obj_attachments != nil %> + <% @obj_attachments.each do |file| %> <%if file.is_public == 0 && !User.current.member_of?(@project)%> <%next%> <%end%> diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index aefa1a5a9..4b6df47cb 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,6 +1,6 @@
<% if @isproject %> - <%= render :partial => 'project_file_new', locals: {project: @project} %> + <%= render :partial => 'project_file', locals: {project: @project} %> <% else %> <%= render :partial => 'course_file', locals: {course: @course} %> <% end %> From c4e9321e148daa52b00fe11e9b926564141deaac Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 31 Mar 2015 10:03:52 +0800 Subject: [PATCH 07/23] =?UTF-8?q?=E5=B0=86attachment=5Fcandown=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=8F=90=E5=8F=96=E5=88=B0application=5Fhelp=E9=87=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 33 ++----------------- app/controllers/files_controller.rb | 1 + app/helpers/application_helper.rb | 36 +++++++++++++++++++++ app/helpers/files_helper.rb | 35 -------------------- app/views/files/_project_file_list.html.erb | 2 +- 5 files changed, 40 insertions(+), 67 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index d458b73e4..ddda15ce7 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -27,7 +27,7 @@ class AttachmentsController < ApplicationController accept_api_auth :show, :download, :upload require 'iconv' include AttachmentsHelper - + include ApplicationHelper def show respond_to do |format| @@ -65,36 +65,7 @@ class AttachmentsController < ApplicationController def download # modify by nwb # 下载添加权限设置 - candown = false - if @attachment.container.class.to_s != "HomeworkAttach" && (@attachment.container.has_attribute?(:project) || @attachment.container.has_attribute?(:project_id)) && @attachment.container.project - project = @attachment.container.project - candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) - elsif @attachment.container.is_a?(Project) - project = @attachment.container - candown= User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) - elsif (@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board && - @attachment.container.board.project - project = @attachment.container.board.project - candown = User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) - elsif (@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course - course = @attachment.container.course - candown = User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) - elsif @attachment.container.is_a?(Course) - course = @attachment.container - candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) - elsif (@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.board && - @attachment.container.board.course - course = @attachment.container.board.course - candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) - elsif @attachment.container.class.to_s=="HomeworkAttach" && @attachment.container.bid.reward_type == 3 - candown = true - elsif @attachment.container_type == "Bid" && @attachment.container && @attachment.container.courses.first - course = @attachment.container.courses.first - candown = User.current.member_of_course?(course) || (course.is_public == 1 && @attachment.is_public == 1) - else - - candown = @attachment.is_public == 1 - end + candown = attachment_candown @attachment if candown || User.current.admin? || User.current.id == @attachment.author_id @attachment.increment_download if stale?(:etag => @attachment.digest) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 21d2254c1..4a6daf77a 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -30,6 +30,7 @@ class FilesController < ApplicationController include FilesHelper helper :project_score include CoursesHelper + include ApplicationHelper def show_attachments obj @attachments = [] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c8168455c..fd567c1fa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1676,6 +1676,42 @@ module ApplicationHelper courses_doing end + + def attachment_candown attachment + candown = false + if attachment.container + if attachment.container.class.to_s != "HomeworkAttach" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project + project = attachment.container.project + candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) + elsif attachment.container.is_a?(Project) + project = attachment.container + candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) + elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board && + attachment.container.board.project + project = attachment.container.board.project + candown = User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) + elsif (attachment.container.has_attribute?(:course) ||attachment.container.has_attribute?(:course_id) ) && attachment.container.course + course = attachment.container.course + candown = User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) + elsif attachment.container.is_a?(Course) + course = attachment.container + candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) + elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board && + attachment.container.board.course + course = attachment.container.board.course + candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) + elsif attachment.container.class.to_s=="HomeworkAttach" && attachment.container.bid.reward_type == 3 + candown = true + elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses + course = attachment.container.courses.first + candown = User.current.member_of_course?(attachment.container.courses.first) || (course.is_public == 1 && attachment.is_public == 1) + else + candown = (attachment.is_public == 1 || attachment.is_public == true) + end + end + candown + end + private def wiki_helper diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 503e3d6ed..02699f6aa 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -118,41 +118,6 @@ module FilesHelper result end - def attachment_candown attachment - candown = false - if attachment.container - if attachment.container.class.to_s != "HomeworkAttach" && (attachment.container.has_attribute?(:project) || attachment.container.has_attribute?(:project_id)) && attachment.container.project - project = attachment.container.project - candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) - elsif attachment.container.is_a?(Project) - project = attachment.container - candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) - elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board && - attachment.container.board.project - project = attachment.container.board.project - candown = User.current.member_of?(project) || (project.is_public && attachment.is_public == 1) - elsif (attachment.container.has_attribute?(:course) ||attachment.container.has_attribute?(:course_id) ) && attachment.container.course - course = attachment.container.course - candown = User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) - elsif attachment.container.is_a?(Course) - course = attachment.container - candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) - elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board && - attachment.container.board.course - course = attachment.container.board.course - candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) - elsif attachment.container.class.to_s=="HomeworkAttach" && attachment.container.bid.reward_type == 3 - candown = true - elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses - course = attachment.container.courses.first - candown = User.current.member_of_course?(attachment.container.courses.first) || (course.is_public == 1 && attachment.is_public == 1) - else - candown = (attachment.is_public == 1 || attachment.is_public == true) - end - end - candown - end - end \ No newline at end of file diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index 136be38e1..42c454965 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -21,7 +21,7 @@ <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> <% if User.current.logged? %> <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> - <%= link_to(l(:label_slected_to_other_project),quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> + <%= link_to(l(:label_slected_to_other_project),quote_resource_show_course_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> <% if manage_allowed && file.container_id == project.id && file.container_type == "Project" %> From 02e83ea776115a92daf2afe607e5c190bf01ec7d Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 31 Mar 2015 11:42:36 +0800 Subject: [PATCH 08/23] =?UTF-8?q?=E5=B0=86=E9=82=AE=E4=BB=B6=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=94=BE=E5=88=B0=E5=90=8E=E5=8F=B0=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 ++ app/controllers/account_controller.rb | 10 ++++----- app/controllers/applied_project_controller.rb | 4 ++-- app/controllers/documents_controller.rb | 2 +- app/controllers/files_controller.rb | 4 ++-- app/controllers/projects_controller.rb | 2 +- app/controllers/users_controller.rb | 6 ++--- app/helpers/account_helper.rb | 4 ++-- app/models/comment_observer.rb | 5 +---- app/models/document_observer.rb | 5 +---- app/models/forum.rb | 4 +--- app/models/issue_observer.rb | 4 +--- app/models/journal_observer.rb | 4 +--- app/models/journals_for_message_observer.rb | 4 +--- app/models/mail_handler.rb | 2 +- app/models/mailer.rb | 18 +++++++++++++++ app/models/memo.rb | 6 ++--- app/models/memo_observer.rb | 4 +--- app/models/message_observer.rb | 5 +---- app/models/news_observer.rb | 5 +---- app/models/relative_memo.rb | 2 +- app/models/wiki_content_observer.rb | 10 ++------- app/services/users_service.rb | 4 +--- config/settings.yml | 5 +++++ .../20150331031554_create_delayed_jobs.rb | 22 +++++++++++++++++++ ...032810_add_delayjob_enabled_to_settings.rb | 5 +++++ db/schema.rb | 18 ++++++++++++++- lib/tasks/email.rake | 3 +-- script/delayed_job | 5 +++++ 29 files changed, 106 insertions(+), 68 deletions(-) create mode 100644 db/migrate/20150331031554_create_delayed_jobs.rb create mode 100644 db/migrate/20150331032810_add_delayjob_enabled_to_settings.rb create mode 100644 script/delayed_job diff --git a/Gemfile b/Gemfile index 70281fedf..045642faf 100644 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,8 @@ unless RUBY_PLATFORM =~ /w32/ gem 'zip-zip' end +gem 'delayed_job_active_record'#, :group => :production +gem 'daemons' gem 'grape', '~> 0.9.0' gem 'grape-entity' gem 'seems_rateable', '~> 1.0.13' diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 2cf404ffb..f8d0f5dd1 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -88,9 +88,7 @@ class AccountController < ApplicationController # create a new token for password recovery token = Token.new(:user => user, :action => "recovery") if token.save - Thread.new do - Mailer.lost_password(token).deliver - end + Mailer.run.lost_password(token) flash[:notice] = l(:notice_account_lost_email_sent) redirect_to signin_url return @@ -228,7 +226,7 @@ class AccountController < ApplicationController user = User.find(params[:user]) if params[:user] token = Token.new(:user => user, :action => "register") if token.save - Mailer.register(token).deliver + Mailer.run.register(token) else yield if block_given? @@ -366,7 +364,7 @@ class AccountController < ApplicationController token = Token.new(:user => user, :action => "register") if user.save and token.save UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) - Mailer.register(token).deliver + Mailer.run.register(token) flash[:notice] = l(:notice_account_register_done) @@ -401,7 +399,7 @@ class AccountController < ApplicationController if user.save UserStatus.create(:user_id => user.id ,:changsets_count => 0, :watchers_count => 0) # Sends an email to the administrators - Mailer.account_activation_request(user).deliver + Mailer.run.account_activation_request(user) account_pending else yield if block_given? diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb index f2c0eb056..8e70ed32c 100644 --- a/app/controllers/applied_project_controller.rb +++ b/app/controllers/applied_project_controller.rb @@ -13,7 +13,7 @@ class AppliedProjectController < ApplicationController @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.applied_project(appliedproject).deliver + Mailer.run.applied_project(appliedproject) @status = 2 else @status = 1 @@ -31,7 +31,7 @@ class AppliedProjectController < ApplicationController @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.applied_project(appliedproject).deliver + Mailer.run.applied_project(appliedproject) end #redirect_to project_path(params[:project_id]) diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 9bf2ee846..570726320 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -110,7 +110,7 @@ class DocumentsController < ApplicationController render_attachment_warning_if_needed(@document) if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added') - Mailer.attachments_added(attachments[:files]).deliver + Mailer.run.attachments_added(attachments[:files]) end redirect_to document_url(@document) end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 28156ac0c..0575294d5 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -241,7 +241,7 @@ class FilesController < ApplicationController render_attachment_warning_if_needed(container) if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') - Mailer.attachments_added(attachments[:files]).deliver + Mailer.run.attachments_added(attachments[:files]) end # TODO: 临时用 nyan @@ -270,7 +270,7 @@ class FilesController < ApplicationController attachments = Attachment.attach_filesex(@course, params[:attachments], params[:attachment_type]) if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') - Mailer.attachments_added(attachments[:files]).deliver + Mailer.run.attachments_added(attachments[:files]) end # TODO: 临时用 nyan diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 41876e041..8ed9fcfef 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -336,7 +336,7 @@ class ProjectsController < ApplicationController def send_mail_to_member if !params[:mail].blank? && User.find_by_mail(params[:mail].to_s).nil? email = params[:mail] - Mailer.send_invite_in_project(email, @project, User.current).deliver + Mailer.run.send_invite_in_project(email, @project, User.current) @is_zhuce =false flash[:notice] = l(:notice_email_sent, :value => email) else diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4db471ab4..a230688dc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -553,7 +553,7 @@ class UsersController < ApplicationController @user.pref.save @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) - Mailer.account_information(@user, params[:user][:password]).deliver if params[:send_information] + Mailer.run.account_information(@user, params[:user][:password]) if params[:send_information] respond_to do |format| format.html { @@ -620,9 +620,9 @@ class UsersController < ApplicationController @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) if was_activated - Mailer.account_activated(@user).deliver + Mailer.run.account_activated(@user) elsif @user.active? && params[:send_information] && !params[:user][:password].blank? && @user.auth_source_id.nil? - Mailer.account_information(@user, params[:user][:password]).deliver + Mailer.run.account_information(@user, params[:user][:password]) end respond_to do |format| diff --git a/app/helpers/account_helper.rb b/app/helpers/account_helper.rb index 8ef2d6095..445a1670e 100644 --- a/app/helpers/account_helper.rb +++ b/app/helpers/account_helper.rb @@ -23,7 +23,7 @@ module AccountHelper token = Token.new(:user => user, :action => "register") if user.save and token.save UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) - Mailer.register(token).deliver + Mailer.run.register(token) #flash[:notice] = l(:notice_account_register_done) #render action: 'email_valid', locals: {:mail => user.mail} else @@ -51,7 +51,7 @@ module AccountHelper if user.save UserStatus.create(:user_id => user.id ,:changsets_count => 0, :watchers_count => 0) # Sends an email to the administrators - Mailer.account_activation_request(user).deliver + Mailer.run.account_activation_request(user) #account_pending else yield if block_given? diff --git a/app/models/comment_observer.rb b/app/models/comment_observer.rb index a46e53ab9..ff5b31446 100644 --- a/app/models/comment_observer.rb +++ b/app/models/comment_observer.rb @@ -18,10 +18,7 @@ class CommentObserver < ActiveRecord::Observer def after_create(comment) if comment.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added') - ##by senluo - thread3=Thread.new do - Mailer.news_comment_added(comment).deliver - end + Mailer.run.news_comment_added(comment) end end end diff --git a/app/models/document_observer.rb b/app/models/document_observer.rb index 447952c70..72516916c 100644 --- a/app/models/document_observer.rb +++ b/app/models/document_observer.rb @@ -17,9 +17,6 @@ class DocumentObserver < ActiveRecord::Observer def after_create(document) - ##by senluo - thread2=Thread.new do - Mailer.document_added(document).deliver if Setting.notified_events.include?('document_added') - end + Mailer.run.document_added(document) if Setting.notified_events.include?('document_added') end end diff --git a/app/models/forum.rb b/app/models/forum.rb index 6843ab678..0e664fded 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -36,9 +36,7 @@ class Forum < ActiveRecord::Base end def send_email - Thread.start do - Mailer.forum_add(self).deliver if Setting.notified_events.include?('forum_add') - end + Mailer.run.forum_add(self) if Setting.notified_events.include?('forum_add') end # Updates topic_count, memo_count and last_memo_id attributes for +board_id+ def self.reset_counters!(forum_id) diff --git a/app/models/issue_observer.rb b/app/models/issue_observer.rb index e404a4a1c..51f64c783 100644 --- a/app/models/issue_observer.rb +++ b/app/models/issue_observer.rb @@ -18,13 +18,11 @@ class IssueObserver < ActiveRecord::Observer def after_create(issue) - Thread.start do # 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送, recipients = issue.recipients - issue.watcher_recipients + issue.watcher_recipients recipients.each do |rec| - Mailer.issue_add(issue,rec).deliver if Setting.notified_events.include?('issue_added') + Mailer.run.issue_add(issue,rec) if Setting.notified_events.include?('issue_added') end - end end end diff --git a/app/models/journal_observer.rb b/app/models/journal_observer.rb index b58464a9b..1fca58f37 100644 --- a/app/models/journal_observer.rb +++ b/app/models/journal_observer.rb @@ -23,14 +23,12 @@ class JournalObserver < ActiveRecord::Observer (Setting.notified_events.include?('issue_status_updated') && journal.new_status.present?) || (Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?) ) - Thread.start do # 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送, recipients = journal.recipients - journal.watcher_recipients + journal.watcher_recipients recipients.each do |rec| - Mailer.issue_edit(journal,rec).deliver + Mailer.run.issue_edit(journal,rec) end - end end end end diff --git a/app/models/journals_for_message_observer.rb b/app/models/journals_for_message_observer.rb index 0e5f29d03..ee8e28b86 100644 --- a/app/models/journals_for_message_observer.rb +++ b/app/models/journals_for_message_observer.rb @@ -1,9 +1,7 @@ # Added by young class JournalsForMessageObserver < ActiveRecord::Observer def after_create(journals_for_message) - thread1 = Thread.start do - Mailer.journals_for_message_add(User.current, journals_for_message).deliver - end + Mailer.run.journals_for_message_add(User.current, journals_for_message) end end diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index 8421fb67d..da1af66a8 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -101,7 +101,7 @@ class MailHandler < ActionMailer::Base end add_user_to_group(@@handler_options[:default_group]) unless @@handler_options[:no_account_notice] - Mailer.account_information(@user, @user.password).deliver + Mailer.run.account_information(@user, @user.password) end else if logger && logger.error diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 50b0c075b..7a6061835 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -27,6 +27,24 @@ class Mailer < ActionMailer::Base { :host => Setting.host_name, :protocol => Setting.protocol } end + + class MailerProxy + def initialize(cls) + @target = cls + end + def method_missing(name, *args, &block) + if Setting.delayjob_enabled && Object.const_defined?('Delayed::Worker') + @target.delay.send(name, *args, &block) + else + @target.send(name, *args, &block).deliver + end + end + end + + def self.run + MailerProxy.new(self) + end + # author: alan # 发送邀请未注册用户加入项目邮件 # 功能: 在加入项目的同时自动注册用户 diff --git a/app/models/memo.rb b/app/models/memo.rb index eb0c86855..e3e66d251 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -56,9 +56,7 @@ class Memo < ActiveRecord::Base # } def sendmail - thread1=Thread.new do - Mailer.forum_message_added(self).deliver if Setting.notified_events.include?('forum_message_added') - end + Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added') end def cannot_reply_to_locked_topic @@ -115,7 +113,7 @@ class Memo < ActiveRecord::Base def send_notification if Setting.notified_events.include?('message_posted') - Mailer.message_posted(self).deliver + Mailer.run.message_posted(self) end end diff --git a/app/models/memo_observer.rb b/app/models/memo_observer.rb index 66cabe923..621dcf3d8 100644 --- a/app/models/memo_observer.rb +++ b/app/models/memo_observer.rb @@ -1,8 +1,6 @@ class MemoObserver < ActiveRecord::Observer def after_create(memo) - thread1=Thread.new do - Mailer.forum_message_added(memo).deliver if Setting.notified_events.include?('forum_message_added') - end + Mailer.run.forum_message_added(memo) if Setting.notified_events.include?('forum_message_added') end end diff --git a/app/models/message_observer.rb b/app/models/message_observer.rb index 383301664..1f438f77a 100644 --- a/app/models/message_observer.rb +++ b/app/models/message_observer.rb @@ -17,9 +17,6 @@ class MessageObserver < ActiveRecord::Observer def after_create(message) - ##by senluo - thread5=Thread.new do - Mailer.message_posted(message).deliver if Setting.notified_events.include?('message_posted') - end + Mailer.run.message_posted(message) if Setting.notified_events.include?('message_posted') end end diff --git a/app/models/news_observer.rb b/app/models/news_observer.rb index 8b9bc7b4b..12258e7ca 100644 --- a/app/models/news_observer.rb +++ b/app/models/news_observer.rb @@ -17,9 +17,6 @@ class NewsObserver < ActiveRecord::Observer def after_create(news) - ##by senluo - thread6=Thread.new do - Mailer.news_added(news).deliver if Setting.notified_events.include?('news_added') - end + Mailer.run.news_added(news) if Setting.notified_events.include?('news_added') end end diff --git a/app/models/relative_memo.rb b/app/models/relative_memo.rb index f087fce2b..181aa89f6 100644 --- a/app/models/relative_memo.rb +++ b/app/models/relative_memo.rb @@ -159,7 +159,7 @@ class RelativeMemo < ActiveRecord::Base def send_notification if Setting.notified_events.include?('message_posted') - Mailer.message_posted(self).deliver + Mailer.run.message_posted(self) end end diff --git a/app/models/wiki_content_observer.rb b/app/models/wiki_content_observer.rb index 187c02288..6e13d1a8a 100644 --- a/app/models/wiki_content_observer.rb +++ b/app/models/wiki_content_observer.rb @@ -17,18 +17,12 @@ class WikiContentObserver < ActiveRecord::Observer def after_create(wiki_content) - ##by senluo - thread7=Thread.new do - Mailer.wiki_content_added(wiki_content).deliver if Setting.notified_events.include?('wiki_content_added') - end + Mailer.run.wiki_content_added(wiki_content) if Setting.notified_events.include?('wiki_content_added') end def after_update(wiki_content) if wiki_content.text_changed? - ##by senluo - thread8=Thread.new do - Mailer.wiki_content_updated(wiki_content).deliver if Setting.notified_events.include?('wiki_content_updated') - end + Mailer.run.wiki_content_updated(wiki_content) if Setting.notified_events.include?('wiki_content_updated') end end end diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 39ca37d26..80aa34d45 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -95,9 +95,7 @@ class UsersService # create a new token for password recovery token = Token.new(:user => user, :action => "recovery") if token.save - Thread.new do - Mailer.lost_password(token).deliver - end + Mailer.run.lost_password(token) return l(:notice_account_lost_email_sent,:locale => user.language) end end diff --git a/config/settings.yml b/config/settings.yml index 56cb8ac6c..cd3f2974e 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -60,6 +60,11 @@ per_page_options: default: '25,50,100' mail_from: default: trustieforge@gmail.com + +### delayjob for send email. +delayjob_enabled: + default: 1 + bcc_recipients: default: 1 plain_text_mail: diff --git a/db/migrate/20150331031554_create_delayed_jobs.rb b/db/migrate/20150331031554_create_delayed_jobs.rb new file mode 100644 index 000000000..27fdcf6cc --- /dev/null +++ b/db/migrate/20150331031554_create_delayed_jobs.rb @@ -0,0 +1,22 @@ +class CreateDelayedJobs < ActiveRecord::Migration + def self.up + create_table :delayed_jobs, force: true do |table| + table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue + table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually. + table.text :handler, null: false # YAML-encoded string of the object that will do work + table.text :last_error # reason for last failure (See Note below) + table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future. + table.datetime :locked_at # Set when a client is working on this object + table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) + table.string :locked_by # Who is working on this object (if locked) + table.string :queue # The name of the queue this job is in + table.timestamps null: true + end + + add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority" + end + + def self.down + drop_table :delayed_jobs + end +end diff --git a/db/migrate/20150331032810_add_delayjob_enabled_to_settings.rb b/db/migrate/20150331032810_add_delayjob_enabled_to_settings.rb new file mode 100644 index 000000000..2f87ba720 --- /dev/null +++ b/db/migrate/20150331032810_add_delayjob_enabled_to_settings.rb @@ -0,0 +1,5 @@ +class AddDelayjobEnabledToSettings < ActiveRecord::Migration + def change + Setting.create(name: 'delayjob_enabled', value: 1 ) + end +end diff --git a/db/schema.rb b/db/schema.rb index 21279c72b..6f215e48f 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 => 20150328115230) do +ActiveRecord::Schema.define(:version => 20150331032810) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -422,6 +422,22 @@ ActiveRecord::Schema.define(:version => 20150328115230) do add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" + create_table "delayed_jobs", :force => true do |t| + t.integer "priority", :default => 0, :null => false + t.integer "attempts", :default => 0, :null => false + t.text "handler", :null => false + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by" + t.string "queue" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + create_table "discuss_demos", :force => true do |t| t.string "title" t.text "body" diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake index 676618825..efd3efdd8 100644 --- a/lib/tasks/email.rake +++ b/lib/tasks/email.rake @@ -199,8 +199,7 @@ END_DESC task :day => :environment do users = User.where(mail_notification: 'day') users.each do |user| - mailer = Mailer.send_for_user_activities(user, Date.today, 1) - mailer.deliver if mailer + Mailer.run.send_for_user_activities(user, Date.today, 1) end end end diff --git a/script/delayed_job b/script/delayed_job new file mode 100644 index 000000000..edf195985 --- /dev/null +++ b/script/delayed_job @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby + +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) +require 'delayed/command' +Delayed::Command.new(ARGV).daemonize From 27e123f9fde6b00e0991fa540a4fd9bac9687a85 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 31 Mar 2015 12:02:33 +0800 Subject: [PATCH 09/23] =?UTF-8?q?const=5Fdefined=3F=E5=B0=8F=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 7a6061835..919e5bb00 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -33,7 +33,7 @@ class Mailer < ActionMailer::Base @target = cls end def method_missing(name, *args, &block) - if Setting.delayjob_enabled && Object.const_defined?('Delayed::Worker') + if Setting.delayjob_enabled && Object.const_defined?('Delayed') @target.delay.send(name, *args, &block) else @target.send(name, *args, &block).deliver From 5eac7275849c626e13823f3e7413a29bc4bf5f9c Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 31 Mar 2015 15:57:15 +0800 Subject: [PATCH 10/23] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90=EF=BC=88?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E5=B0=9A=E6=9C=AA=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=B0=9A=E6=9C=AA=E5=BA=94=E7=94=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 40 ++++++++++ app/controllers/files_controller.rb | 60 ++++++++++++++- app/helpers/files_helper.rb | 31 ++++++-- .../add_exist_file_to_projects.js.erb | 7 ++ app/views/files/_project_file_list.html.erb | 4 +- app/views/files/_project_file_new.html.erb | 76 +++++++++---------- .../_show_quote_resource_project.html.erb | 31 ++++++++ app/views/files/_upload_show_project.html.erb | 29 +++++++ app/views/files/create.js.erb | 50 ++++++------ .../files/quote_resource_show_project.js.erb | 11 +++ app/views/files/search_project.js.erb | 1 + config/locales/zh.yml | 1 + config/routes.rb | 5 ++ 13 files changed, 274 insertions(+), 72 deletions(-) create mode 100644 app/views/attachments/add_exist_file_to_projects.js.erb create mode 100644 app/views/files/_show_quote_resource_project.html.erb create mode 100644 app/views/files/_upload_show_project.html.erb create mode 100644 app/views/files/quote_resource_show_project.js.erb create mode 100644 app/views/files/search_project.js.erb diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index ddda15ce7..d880ebe35 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -320,6 +320,46 @@ class AttachmentsController < ApplicationController end end + def add_exist_file_to_projects + file = Attachment.find(params[:file_id]) + projects = params[:projects][:project] + @message = "" + projects.each do |project| + c = Project.find(project); + if project_contains_attachment?(c,file) + if @message && @message == "" + @message += l(:label_project_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed) + next + else + @message += "
" + l(:label_project_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed) + next + end + end + attach_copied_obj = file.copy + attach_copied_obj.tag_list.add(file.tag_list) # tag关联 + attach_copied_obj.container = c + attach_copied_obj.created_on = Time.now + attach_copied_obj.author_id = User.current.id + attach_copied_obj.copy_from = file.copy_from.nil? ? file.id : file.copy_from + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 4 + end + @obj = c + @save_flag = attach_copied_obj.save + @save_message = attach_copied_obj.errors.full_messages + update_quotes attach_copied_obj + end + respond_to do |format| + format.js + end + rescue NoMethodError + @save_flag = false + @save_message = [] << l(:label_course_empty_select) + respond_to do |format| + format.js + end + end + def add_exist_file_to_courses file = Attachment.find(params[:file_id]) courses = params[:courses][:course] diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 4a6daf77a..b48569f2c 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -23,7 +23,7 @@ class FilesController < ApplicationController before_filter :auth_login1, :only => [:index] before_filter :logged_user_by_apptoken,:only => [:index] before_filter :find_project_by_project_id#, :except => [:getattachtype] - before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search] + before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search,:search_project,:quote_resource_show_project] helper :sort include SortHelper @@ -79,6 +79,39 @@ class FilesController < ApplicationController end end + def search_project + sort = "" + @sort = "" + @order = "" + @is_remote = true + if params[:sort] + order_by = params[:sort].split(":") + @sort = order_by[0] + if order_by.count > 1 + @order = order_by[1] + end + sort = "#{@sort} #{@order}" + end + + begin + q = "%#{params[:name].strip}%" + #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? + if params[:insite] + @result = find_public_attache q,sort + @result = visable_attachemnts_insite @result,@project + @searched_attach = paginateHelper @result,10 + else + @result = find_project_attache q,@project,sort + @result = visable_attachemnts @result + @searched_attach = paginateHelper @result,10 + end + + #rescue Exception => e + # #render 'stores' + # redirect_to search_course_files_url + end + end + def find_course_attache keywords,course,sort = "" if sort == "" sort = "created_on DESC" @@ -88,6 +121,26 @@ class FilesController < ApplicationController #resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC") end + def find_project_attache keywords,project,sort = "" + if sort == "" + sort = "created_on DESC" + end + ids = "" + len = 0 + count = project.versions.count + project.versions.each do |version| + len = len + 1 + if len != count + ids += version.id.to_s + ',' + else + ids += version.id.to_s + end + end + resultSet = Attachment.where("((attachments.container_type = 'Project' And attachments.container_id = '#{project.id}') OR (container_type = 'Version' AND container_id IN (#{ids}))) AND filename LIKE :like ", like: "%#{keywords}%"). + reorder(sort) + #resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC") + end + def find_public_attache keywords,sort = "" # StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map # 此时内容不多速度还可,但文件增长,每条判断多则进行3-4次表连接。 @@ -230,6 +283,11 @@ class FilesController < ApplicationController @can_quote = attachment_candown @file end + def quote_resource_show_project + @file = Attachment.find(params[:id]) + @can_quote = attachment_candown @file + end + def new @versions = @project.versions.sort @course_tag = @project.project_type diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 02699f6aa..3c8ed63d4 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -45,6 +45,7 @@ module FilesHelper File.new(zipfile_name,'w+') end + #带勾选框的课程列表 def courses_check_box_tags(name,courses,current_course,attachment) s = '' courses.each do |course| @@ -55,6 +56,17 @@ module FilesHelper s.html_safe end + #带勾选框的项目列表 + def projects_check_box_tags(name,projects,current_project,attachment) + s = '' + projects.each do |project| + if !project_contains_attachment?(project,attachment) && User.current.allowed_to?(:manage_files, project) + s << "" + end + end + s.html_safe + end + #判断用户是否拥有不包含当前资源的课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期 def has_course? user,file result = false @@ -108,14 +120,23 @@ module FilesHelper result end - def visable_attachemnts_insite attachments,course + def visable_attachemnts_insite attachments,obj result = [] - attachments.each do |attachment| - if attachment.is_public? || (attachment.container_type == "Course" && attachment.container_id == course.id && User.current.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id - result << attachment + if obj.is_a?(Course) + attachments.each do |attachment| + if attachment.is_public? || (attachment.container_type == "Course" && attachment.container_id == obj.id && User.current.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id + result << attachment + end end + else if obj.is_a?(Project) + attachments.each do |attachment| + if attachment.is_public? || (attachment.container_type == "Project" && attachment.container_id == obj.id && User.current.member_of_course?(Project.find(attachment.container_id)))|| attachment.author_id == User.current.id + result << attachment + end + end end - result + end + result end diff --git a/app/views/attachments/add_exist_file_to_projects.js.erb b/app/views/attachments/add_exist_file_to_projects.js.erb new file mode 100644 index 000000000..88f45e2cf --- /dev/null +++ b/app/views/attachments/add_exist_file_to_projects.js.erb @@ -0,0 +1,7 @@ +<% if !@save_flag && @save_message %> +$("#error_show").html("<%= @save_message.join(', ') %>"); +<% elsif @message && @message != "" %> +$("#error_show").html("<%= @message.html_safe %>"); +<% else %> +closeModal(); +<% end %> \ No newline at end of file diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index 42c454965..c7e0cec29 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -21,7 +21,7 @@ <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> <% if User.current.logged? %> <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> - <%= link_to(l(:label_slected_to_other_project),quote_resource_show_course_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> + <%= link_to(l(:label_slected_to_other_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> <% if manage_allowed && file.container_id == project.id && file.container_type == "Project" %> @@ -31,7 +31,7 @@ <% end %> <% else %> - <%= link_to(l(:label_slected_to_project),quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_course?(User.current,file) %> + <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> <% end %> <% else %> <% end %> diff --git a/app/views/files/_project_file_new.html.erb b/app/views/files/_project_file_new.html.erb index 977a7e5ab..89088a295 100644 --- a/app/views/files/_project_file_new.html.erb +++ b/app/views/files/_project_file_new.html.erb @@ -5,50 +5,50 @@
- <%#= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search f_l",:remote=>true) do %> - <%#= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> - <%#= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()" %> - <%#= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> - <%# end %> + <%= form_tag( search_project_project_files_path(@project), method: 'get',:class => "re_search f_l",:remote=>true) do %> + <%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> + <%= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()" %> + <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> + <% end %> <% manage_allowed = User.current.allowed_to?(:manage_files, @project) %> <% if manage_allowed %> 上传资源 diff --git a/app/views/files/_show_quote_resource_project.html.erb b/app/views/files/_show_quote_resource_project.html.erb new file mode 100644 index 000000000..7df1dc2f3 --- /dev/null +++ b/app/views/files/_show_quote_resource_project.html.erb @@ -0,0 +1,31 @@ +
+
+

将此课件引入我的资源库

+ <% if error == '403' %> +
+
您没有权限引用此资源
+
+ <% else %> +
+
+ <%= form_tag attach_relations_path, + method: :post, + remote: true, + id: "relation_file_form" do %> + <%= hidden_field_tag(:file_id, file.id) %> + <%= content_tag('div', projects_check_box_tags('projects[project][]', User.current.projects,project,file), :id => 'projects')%> + 引  用取  消 + <% end -%> +
+ <% end %> + + +
+
+ + \ No newline at end of file diff --git a/app/views/files/_upload_show_project.html.erb b/app/views/files/_upload_show_project.html.erb new file mode 100644 index 000000000..25a03b347 --- /dev/null +++ b/app/views/files/_upload_show_project.html.erb @@ -0,0 +1,29 @@ + +
+
+

<%= l(:label_upload_files)%>

+
+ <%= error_messages_for 'attachment' %> + + + <%= form_tag(project_files_path(project), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> + + <%= render :partial => 'attachement_list',:locals => {:project => project} %> +
+ <%= l(:button_cancel)%> + <%= l(:button_confirm)%> + <% end %> +
+ +
+ <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
+ + \ No newline at end of file diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index 69ea896c9..b00ae3612 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -1,35 +1,33 @@ -<%if @addTag%> -<% if @obj_flag == '3'%> - -$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name', +<% if @addTag%> + <% if @obj_flag == '3'%> + $('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); -//$('#put-tag-form-issue').hide(); -$('#name-issue').val(""); -<% elsif @obj_flag == '6'%> -$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); -$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name', + //$('#put-tag-form-issue').hide(); + $('#name-issue').val(""); + <% elsif @obj_flag == '6'%> + $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); + $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); -$("#put-tag-form- <%=@obj.class%>- <%=@obj.id%>").hide(); -$("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val(""); -<% else %> - -$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name', + $("#put-tag-form- <%=@obj.class%>- <%=@obj.id%>").hide(); + $("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val(""); + <% else %> + $('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); -$('#tags_show').html('<%=render_attachments_tag_save(@project, nil)%>'); -$('#put-tag-form #name').val(""); -//$('#put-tag-form').hide(); -<% end %> -<%else%> + $('#tags_show').html('<%=render_attachments_tag_save(@project, nil)%>'); + $('#put-tag-form #name').val(""); + //$('#put-tag-form').hide(); + <% end %> +<% else %> $("#attachments_fields").children().remove(); $("#upload_file_count").text("未上传文件"); $('#upload_file_div').slideToggle('slow'); -<%if @project%> -$("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>'); -<%elsif @course%> -$("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>'); -closeModal(); -$("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>'); -<%end%> + <% if @project%> + closeModal(); + $("#resource_list").html('<%= j(render partial: "project_file_new" ,locals: {project: @project}) %>'); + <%elsif @course%> + closeModal(); + $("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>'); + <% end %> <% end %> $(document).ready(img_thumbnails); diff --git a/app/views/files/quote_resource_show_project.js.erb b/app/views/files/quote_resource_show_project.js.erb new file mode 100644 index 000000000..440004357 --- /dev/null +++ b/app/views/files/quote_resource_show_project.js.erb @@ -0,0 +1,11 @@ +<% if @can_quote %> + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource_project',:locals => {:project => @project,:file => @file,:error => ''}) %>'); +<% else %> + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource_project',:locals => {:project => @project,:file => @file,:error => '403'}) %>'); +<% end %> + +showModal('ajax-modal', '513px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("popbox_polls"); \ No newline at end of file diff --git a/app/views/files/search_project.js.erb b/app/views/files/search_project.js.erb new file mode 100644 index 000000000..f64b8beeb --- /dev/null +++ b/app/views/files/search_project.js.erb @@ -0,0 +1 @@ +$("#course_list").html("<%= escape_javascript(render :partial => 'project_file_list',:locals => {project: @project,all_attachments: @result,sort:@sort,order:@order,project_attachments:@searched_attach,:manage_allowed => User.current.allowed_to?(:manage_files, @project)})%>"); \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index f1dbe7d3c..3c8bb5a6d 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1966,6 +1966,7 @@ zh: field_open_anonymous_evaluation: 是否使用匿评 label_course_empty_select: 尚未选择课程! label_course_prompt: 课程: + label_project_prompt: 项目: label_contain_resource: 已包含资源: label_quote_resource_failed: ",此资源引用失败! " label_file_lost: 以下无法成功下载,请联系相关人员重新上传: diff --git a/config/routes.rb b/config/routes.rb index 27bc59ffc..6ca3edd67 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -431,8 +431,12 @@ RedmineApp::Application.routes.draw do match 'issues/update_form', :to => 'issues#update_form', :via => [:put, :post], :as => 'issue_form' resources :files, :only => [:index, :new, :create] do + member do + match "quote_resource_show_project",:via => [:get] + end collection do match "getattachtype" , :via => [:get, :post] + match "search_project",:via => [:post,:get] #match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post] end end @@ -590,6 +594,7 @@ RedmineApp::Application.routes.draw do get 'attachments/autocomplete' match 'attachments/autocomplete', :to => 'attachments#autocomplete', :via => [:post] post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation' + post 'attachments/relationfiles', to: 'attachments#add_exist_file_to_projects', as: 'attach_relations' post 'attachments/courserelationfile', to: 'attachments#add_exist_file_to_course', as: 'course_attach_relation' post 'attachments/courserelationfiles', to: 'attachments#add_exist_file_to_courses', as: 'course_attach_relations' get 'attachments/renderTag/:attchmentId', :to => 'attachments#renderTag', :attchmentId => /\d+/ From 89e060298326a809b37e306eed133d656b654061 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 1 Apr 2015 11:12:55 +0800 Subject: [PATCH 11/23] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81?= =?UTF-8?q?=E5=8E=BB=E9=99=A4=20observer,=20=E4=B8=80=E5=8F=A5=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=9A=84=E5=8A=9F=E8=83=BD=E9=9A=90=E8=97=8F=E5=9C=A8?= =?UTF-8?q?=E5=88=AB=E7=9A=84=E6=96=87=E4=BB=B6=E9=87=8C=EF=BC=8C=E5=BE=88?= =?UTF-8?q?=E9=9A=BE=E6=B3=A8=E6=84=8F=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/comment.rb | 7 +++++++ app/models/comment_observer.rb | 24 ------------------------ app/models/document.rb | 5 +++++ app/models/document_observer.rb | 22 ---------------------- app/models/forum.rb | 2 +- app/models/forum_observer.rb | 8 -------- app/models/memo.rb | 4 ++-- app/models/memo_observer.rb | 6 ------ app/models/message.rb | 8 +++++--- app/models/message_observer.rb | 22 ---------------------- app/models/news.rb | 11 ++++++----- app/models/news_observer.rb | 22 ---------------------- 12 files changed, 26 insertions(+), 115 deletions(-) delete mode 100644 app/models/comment_observer.rb delete mode 100644 app/models/document_observer.rb delete mode 100644 app/models/forum_observer.rb delete mode 100644 app/models/memo_observer.rb delete mode 100644 app/models/message_observer.rb delete mode 100644 app/models/news_observer.rb diff --git a/app/models/comment.rb b/app/models/comment.rb index 539c62e85..68ce73432 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -21,4 +21,11 @@ class Comment < ActiveRecord::Base belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' validates_presence_of :commented, :author, :comments safe_attributes 'comments' + after_create :send_mail + + def send_mail + if self.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added') + Mailer.run.news_comment_added(self) + end + end end diff --git a/app/models/comment_observer.rb b/app/models/comment_observer.rb deleted file mode 100644 index ff5b31446..000000000 --- a/app/models/comment_observer.rb +++ /dev/null @@ -1,24 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2013 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -class CommentObserver < ActiveRecord::Observer - def after_create(comment) - if comment.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added') - Mailer.run.news_comment_added(comment) - end - end -end diff --git a/app/models/document.rb b/app/models/document.rb index 33ffdaa2f..c8e5f8a24 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -24,6 +24,7 @@ class Document < ActiveRecord::Base after_save :be_user_score # user_score after_destroy :down_user_score acts_as_attachable :delete_permission => :delete_documents + after_create :send_mail # 被ForgeActivity虚拟关联 has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy # end @@ -87,4 +88,8 @@ class Document < ActiveRecord::Base :project_id => self.project_id) end + def send_mail + Mailer.run.document_added(self) if Setting.notified_events.include?('document_added') + end + end diff --git a/app/models/document_observer.rb b/app/models/document_observer.rb deleted file mode 100644 index 72516916c..000000000 --- a/app/models/document_observer.rb +++ /dev/null @@ -1,22 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2013 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -class DocumentObserver < ActiveRecord::Observer - def after_create(document) - Mailer.run.document_added(document) if Setting.notified_events.include?('document_added') - end -end diff --git a/app/models/forum.rb b/app/models/forum.rb index 0e664fded..15d78ab24 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -20,7 +20,7 @@ class Forum < ActiveRecord::Base after_destroy :delete_kindeditor_assets acts_as_taggable scope :by_join_date, order("created_at DESC") - #after_create :send_email + after_create :send_email def reset_counters! self.class.reset_counters!(id) end diff --git a/app/models/forum_observer.rb b/app/models/forum_observer.rb deleted file mode 100644 index 6afcac824..000000000 --- a/app/models/forum_observer.rb +++ /dev/null @@ -1,8 +0,0 @@ -class ForumObserver < ActiveRecord::Observer - # def after_create(forum) - # Thread.start do - # Mailer.forum_add(forum).deliver if Setting.notified_events.include?('forum_add') - # end - # - # end -end diff --git a/app/models/memo.rb b/app/models/memo.rb index e3e66d251..456736f2e 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -44,7 +44,7 @@ class Memo < ActiveRecord::Base "parent_id", "replies_count" - after_create :add_author_as_watcher, :reset_counters!, :sendmail + after_create :add_author_as_watcher, :reset_counters!, :send_mail # after_update :update_memos_forum after_destroy :reset_counters!,:delete_kindeditor_assets#,:down_user_score -- 公共区发帖暂不计入得分 # after_create :send_notification @@ -55,7 +55,7 @@ class Memo < ActiveRecord::Base # includes(:forum => ).where() # } - def sendmail + def send_mail Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added') end diff --git a/app/models/memo_observer.rb b/app/models/memo_observer.rb deleted file mode 100644 index 621dcf3d8..000000000 --- a/app/models/memo_observer.rb +++ /dev/null @@ -1,6 +0,0 @@ -class MemoObserver < ActiveRecord::Observer - def after_create(memo) - - Mailer.run.forum_message_added(memo) if Setting.notified_events.include?('forum_message_added') - end -end diff --git a/app/models/message.rb b/app/models/message.rb index 85a87132d..5d0da8fc3 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -64,10 +64,8 @@ class Message < ActiveRecord::Base after_update :update_messages_board after_destroy :reset_counters!,:down_user_score - # fq - after_create :act_as_activity,:be_user_score,:act_as_forge_activity + after_create :act_as_activity,:be_user_score,:act_as_forge_activity, :send_mail #before_save :be_user_score - # end scope :visible, lambda {|*args| includes(:board => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_messages, *args)) @@ -208,5 +206,9 @@ class Message < ActiveRecord::Base end end + def send_mail + Mailer.run.message_posted(self) if Setting.notified_events.include?('message_posted') + end + end diff --git a/app/models/message_observer.rb b/app/models/message_observer.rb deleted file mode 100644 index 1f438f77a..000000000 --- a/app/models/message_observer.rb +++ /dev/null @@ -1,22 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2013 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -class MessageObserver < ActiveRecord::Observer - def after_create(message) - Mailer.run.message_posted(message) if Setting.notified_events.include?('message_posted') - end -end diff --git a/app/models/news.rb b/app/models/news.rb index d2547fc02..9b88209c4 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -45,11 +45,8 @@ class News < ActiveRecord::Base :author_key => :author_id acts_as_watchable - after_create :add_author_as_watcher - # fq - after_create :act_as_activity,:act_as_forge_activity - # end - + after_create :act_as_activity,:act_as_forge_activity,:add_author_as_watcher, :send_mail + scope :visible, lambda {|*args| includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args)) } @@ -105,4 +102,8 @@ class News < ActiveRecord::Base end end + def send_mail + Mailer.run.news_added(news) if Setting.notified_events.include?('news_added') + end + end diff --git a/app/models/news_observer.rb b/app/models/news_observer.rb deleted file mode 100644 index 12258e7ca..000000000 --- a/app/models/news_observer.rb +++ /dev/null @@ -1,22 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2013 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -class NewsObserver < ActiveRecord::Observer - def after_create(news) - Mailer.run.news_added(news) if Setting.notified_events.include?('news_added') - end -end From b23892e29e734d7d9d1f161d5371605cd96e3331 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 1 Apr 2015 11:19:49 +0800 Subject: [PATCH 12/23] =?UTF-8?q?=E5=9C=A8application=E4=B8=AD=E5=8E=BB?= =?UTF-8?q?=E9=99=A4observer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/application.rb b/config/application.rb index 3b36d7cb7..05160d03e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -37,8 +37,7 @@ module RedmineApp # config.plugins = [ :exception_notification, :ssl_requirement, :all ] # Activate observers that should always be running. - config.active_record.observers = :journals_for_message_observer, :message_observer, :issue_observer, :journal_observer, :news_observer, - :document_observer, :wiki_content_observer, :comment_observer, :forum_observer, :memo_observer + config.active_record.observers = :journals_for_message_observer, :issue_observer, :journal_observer, :wiki_content_observer config.active_record.store_full_sti_class = true config.active_record.default_timezone = :local From 3ea33aa84758ea65719467cf8a4b0c56605914e1 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 1 Apr 2015 13:14:15 +0800 Subject: [PATCH 13/23] =?UTF-8?q?=E6=96=B0=E5=BB=BAnews=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/forum.rb | 5 +++-- app/models/news.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/forum.rb b/app/models/forum.rb index 15d78ab24..199f4353d 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -20,7 +20,7 @@ class Forum < ActiveRecord::Base after_destroy :delete_kindeditor_assets acts_as_taggable scope :by_join_date, order("created_at DESC") - after_create :send_email + after_create :send_mail def reset_counters! self.class.reset_counters!(id) end @@ -35,7 +35,8 @@ class Forum < ActiveRecord::Base self.creator == user || user.admin? end - def send_email + def send_mail + logger.debug "send mail for forum add." Mailer.run.forum_add(self) if Setting.notified_events.include?('forum_add') end # Updates topic_count, memo_count and last_memo_id attributes for +board_id+ diff --git a/app/models/news.rb b/app/models/news.rb index 9b88209c4..8e944a018 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -103,7 +103,7 @@ class News < ActiveRecord::Base end def send_mail - Mailer.run.news_added(news) if Setting.notified_events.include?('news_added') + Mailer.run.news_added(self) if Setting.notified_events.include?('news_added') end end From 243bac8fedc55c4b278be87b3fabc33e5e5e1086 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 1 Apr 2015 16:33:50 +0800 Subject: [PATCH 14/23] =?UTF-8?q?=E9=99=A4=E4=BA=86mail=5Fnotification=20?= =?UTF-8?q?=3D=3D=20all=20=E7=9A=84=EF=BC=8C=E5=85=B6=E4=BB=96=E9=83=BD?= =?UTF-8?q?=E4=B8=8D=E5=8D=B3=E6=97=B6=E5=8F=91=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 85 ++++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 23 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 919e5bb00..20f8aa4ac 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -165,7 +165,9 @@ class Mailer < ActionMailer::Base # cc = wiki_content.page.wiki.watcher_recipients - recipients @memo_url = url_for(forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))) - mail :to => recipients,:subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]" + mail :to => recipients, + :subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]", + :filter => true end # Builds a Mail::Message object used to email recipients of the added journals for message. @@ -222,20 +224,21 @@ class Mailer < ActionMailer::Base end end mail :to => @recipients, - :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} " + :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} ", + :filter => true elsif journals_for_message.jour.class.to_s.to_sym == :Bid if !journals_for_message.jour.author.notify_about? journals_for_message return -1 end - mail :to => recipients, :subject => @title + mail :to => recipients, :subject => @title,:filter => true elsif journals_for_message.jour.class.to_s.to_sym == :Contest if !journals_for_message.jour.author.notify_about? journals_for_message return -1 end - mail :to => recipients, :subject => @title + mail :to => recipients, :subject => @title,:filter => true else - mail :to => recipients1, :subject => @title + mail :to => recipients1, :subject => @title,:filter => true end @@ -270,9 +273,9 @@ class Mailer < ActionMailer::Base subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" - mail(:to => recipients, - - :subject => subject) + mail :to => recipients, + :subject => subject, + :filter => true end # issue.attachments.each do |attach| # attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}") @@ -318,9 +321,9 @@ class Mailer < ActionMailer::Base @issue = issue @journal = journal # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") - mail(:to => recipients, - - :subject => s) + mail :to => recipients, + :subject => s, + :filter => true end def self.deliver_mailer(to,cc, subject) @@ -406,7 +409,8 @@ class Mailer < ActionMailer::Base @issue_author_url = url_for(user_activities_url(@author)) @document_url = url_for(:controller => 'documents', :action => 'show', :id => document) mail :to => document.recipients, - :subject => "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}" + :subject => "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}", + :filter => true end # Builds a Mail::Message object used to email recipients of a project when an attachements are added. @@ -444,21 +448,24 @@ class Mailer < ActionMailer::Base @added_to = added_to @added_to_url = added_to_url mail :to => recipients, - :subject => "[#{container.name}] #{l(:label_attachment_new)}" + :subject => "[#{container.name}] #{l(:label_attachment_new)}", + :filter => true elsif container.class.name == 'Project' redmine_headers 'Project' => container.id @attachments = attachments @added_to = added_to @added_to_url = added_to_url mail :to => recipients, - :subject => "[#{container.name}] #{l(:label_attachment_new)}" + :subject => "[#{container.name}] #{l(:label_attachment_new)}", + :filter => true else redmine_headers 'Project' => container.project.identifier @attachments = attachments @added_to = added_to @added_to_url = added_to_url mail :to => recipients, - :subject => "[#{container.project.name}] #{l(:label_attachment_new)}" + :subject => "[#{container.project.name}] #{l(:label_attachment_new)}", + :filter => true end end @@ -477,7 +484,8 @@ class Mailer < ActionMailer::Base @news = news @news_url = url_for(:controller => 'news', :action => 'show', :id => news) mail :to => news.recipients, - :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}" + :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}", + :filter => true elsif news.course redmine_headers 'Course' => news.course.id @author = news.author @@ -487,7 +495,8 @@ class Mailer < ActionMailer::Base recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail } @news_url = url_for(:controller => 'news', :action => 'show', :id => news) mail :to => recipients, - :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}" + :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}", + :filter => true end end @@ -508,7 +517,8 @@ class Mailer < ActionMailer::Base @news_url = url_for(:controller => 'news', :action => 'show', :id => news) mail :to => news.recipients, :cc => news.watcher_recipients, - :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}" + :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}", + :filter => true elsif news.course redmine_headers 'Course' => news.course.id @author = comment.author @@ -520,7 +530,8 @@ class Mailer < ActionMailer::Base recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail } mail :to => recipients, - :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}" + :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}", + :filter => true end end @@ -543,7 +554,8 @@ class Mailer < ActionMailer::Base @message_url = url_for(message.event_url) mail :to => recipients, :cc => cc, - :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}" + :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}", + :filter => true elsif message.course redmine_headers 'Course' => message.course.id, 'Topic-Id' => (message.parent_id || message.id) @@ -557,7 +569,8 @@ class Mailer < ActionMailer::Base @message_url = url_for(message.event_url) mail :to => recipients, :cc => cc, - :subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}" + :subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}", + :filter => true end end @@ -579,7 +592,8 @@ class Mailer < ActionMailer::Base :id => wiki_content.page.title) mail :to => recipients, :cc => cc, - :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}" + :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}", + :filter => true end # Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was updated. @@ -603,7 +617,8 @@ class Mailer < ActionMailer::Base :version => wiki_content.version) mail :to => recipients, :cc => cc, - :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}" + :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}", + :filter => true end # Builds a Mail::Message object used to email the specified user their account information. @@ -754,6 +769,25 @@ class Mailer < ActionMailer::Base ActionMailer::Base.delivery_method = saved_method end + #过滤掉不是不合规则的收件人 + def filter(reps) + r_reps = [] + if reps.is_a? Array + reps.each do |r| + u = User.find_by_mail(r) + if u && u.mail_notification == 'all' + r_reps << r + end + end + elsif reps.is_a? User + u = User.find_by_mail(r) + if u && u.mail_notification == 'all' + r_reps << r + end + end + r_reps + end + def mail(headers={}) headers.merge! 'X-Mailer' => 'Redmine', 'X-Redmine-Host' => Setting.host_name, @@ -770,6 +804,11 @@ class Mailer < ActionMailer::Base headers[:cc].delete(@author.mail) if headers[:cc].is_a?(Array) end + if headers[:filter] + headers[:to] = filter(headers[:to]) + headers[:cc] = filter(headers[:cc]) + end + if @author && @author.logged? redmine_headers 'Sender' => @author.login end From 0099ab9f9a0390472fb42a61711c9075735d1d00 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 1 Apr 2015 16:44:40 +0800 Subject: [PATCH 15/23] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E4=BB=A5=E5=89=8D?= =?UTF-8?q?=E7=9A=84=E9=82=AE=E4=BB=B6=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 20f8aa4ac..ce47693ff 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -155,13 +155,9 @@ class Mailer < ActionMailer::Base @issue_author_url = url_for(user_activities_url(@author)) recipients ||= [] #将帖子创建者邮箱地址加入数组 - if @forum.creator.mail_notification != 'day' && @forum.creator.mail_notification != 'week' - recipients << @forum.creator.mail - end + recipients << @forum.creator.mail #回复人邮箱地址加入数组 - if @author.mail_notification != 'day' && @author.mail_notification != 'week' - recipients << @author.mail - end + recipients << @author.mail # cc = wiki_content.page.wiki.watcher_recipients - recipients @memo_url = url_for(forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))) @@ -202,12 +198,8 @@ class Mailer < ActionMailer::Base # 验证用户的收取邮件的方式 recipients ||= [] recipients1 ||= [] - if @mail.mail_notification != 'week' && @mail.mail_notification != 'day' - recipients1 = @mail.mail - end - if journals_for_message.jour.author.mail_notification != 'week' && journals_for_message.jour.author.mail_notification != 'day' - recipients = journals_for_message.jour.author.mail - end + recipients1 = @mail.mail + recipients = journals_for_message.jour.author.mail # modify by nwb #如果是直接留言并且留言对象是课程 @@ -219,9 +211,7 @@ class Mailer < ActionMailer::Base #收件人邮箱 @recipients ||= [] @members.each do |teacher| - if teacher.user.mail_notification != 'week' && teacher.user.mail_notification != 'day' - @recipients << teacher.user.mail - end + @recipients << teacher.user.mail end mail :to => @recipients, :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} ", @@ -779,7 +769,7 @@ class Mailer < ActionMailer::Base r_reps << r end end - elsif reps.is_a? User + elsif reps.is_a? String u = User.find_by_mail(r) if u && u.mail_notification == 'all' r_reps << r From 9cefb9f339761eddc006a9d6b81ffc142ac3b975 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 1 Apr 2015 17:47:04 +0800 Subject: [PATCH 16/23] =?UTF-8?q?=E6=AF=8F=E6=97=A5=E5=8F=91=E9=80=81?= =?UTF-8?q?=E5=8F=96=E6=97=A5=E6=9C=9F=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 13 +++++++++---- config/configuration.yml | 3 --- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index ce47693ff..df23813cd 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -63,6 +63,12 @@ class Mailer < ActionMailer::Base def send_for_user_activities(user, date_to, days) date_from = date_to - days.days + subject = "[ #{user.show_name} : #{l(:label_day_mail)}]" + @subject = " #{user.show_name} : #{date_to} #{l(:label_day_mail)}" + + date_from = "#{date_from} 23:59:59" + date_to = "#{date_to} 23:59:59" + # 生成token用于直接点击登录 @user = user token = Token.new(:user =>user , :action => 'autologin') @@ -77,10 +83,11 @@ class Mailer < ActionMailer::Base course_ids = courses.map {|course| course.id}.join(",") # 查询user的缺陷,包括发布的,跟踪的以及被指派的缺陷 - @issues = Issue.find_by_sql("select DISTINCT i.* from issues i, watchers w + sql = "select DISTINCT i.* from issues i, watchers w where (i.assigned_to_id = #{user.id} or i.author_id = #{user.id} or (w.watchable_type = 'Issue' and w.watchable_id = i.id and w.user_id = #{user.id})) - and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc") + and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc" + @issues = Issue.find_by_sql(sql) # @bids 查询课程作业,包括老师发布的作业,以及user提交作业 # @attachments查询课程课件更新 @@ -133,8 +140,6 @@ class Mailer < ActionMailer::Base @memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id})) and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc") - subject = "[ #{user.show_name} : #{l(:label_day_mail)}]" - @subject = " #{user.show_name} : #{date_to - 1.days} #{l(:label_day_mail)}" has_content = [@issues,@homeworks,@course_messages,@project_messages,@course_news,@project_news, @course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| diff --git a/config/configuration.yml b/config/configuration.yml index f17881485..adfaea456 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -84,9 +84,6 @@ default: email_delivery: delivery_method: :smtp smtp_settings: - - - address: smtp.126.com port: 25 domain: smtp.126.com From 552c27c51dffdf8c1c6e15da61d2e93435fe4381 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 2 Apr 2015 08:48:01 +0800 Subject: [PATCH 17/23] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=8F=90=E9=97=AE=E9=97=AE=E9=A2=98=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/homework_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index f9be6f79d..d22c62a5a 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -20,7 +20,7 @@ class HomeworkService many_times = course.homeworks.index(@bid) + 1 name = @bid.name homework_count = @bid.homeworks.count #已提交的作业数量 - student_questions_count = @bid.commit.nil? ? 0 : @bid.commit + student_questions_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count description = @bid.description #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 state = @bid.comment_status @@ -282,7 +282,7 @@ class HomeworkService many_times = course.homeworks.index(@bid) + 1 name = @bid.name homework_count = @bid.homeworks.count #已提交的作业数量 - student_questions_count = @bid.commit.nil? ? 0 : @bid.commit + student_questions_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count description = @bid.description #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 state = @bid.comment_status From 56df5ce9a7b25ae3533c65ed0d23570567471029 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 2 Apr 2015 17:20:52 +0800 Subject: [PATCH 18/23] =?UTF-8?q?=E4=BC=98=E5=8C=96zip=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=89=93=E5=8C=85=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 3 +- app/controllers/zipdown_controller.rb | 112 ++++++++++++------ app/models/zip_pack.rb | 18 +++ app/views/bids/_homework_list.html.erb | 4 +- config/initializers/30-redmine.rb | 1 + config/routes.rb | 10 +- db/migrate/20150402015402_create_zip_packs.rb | 14 +++ db/schema.rb | 14 ++- lib/trustie.rb | 1 + lib/trustie/utils.rb | 20 ++++ 10 files changed, 148 insertions(+), 49 deletions(-) create mode 100644 app/models/zip_pack.rb create mode 100644 db/migrate/20150402015402_create_zip_packs.rb create mode 100644 lib/trustie.rb create mode 100644 lib/trustie/utils.rb diff --git a/Gemfile b/Gemfile index 045642faf..98d81ca70 100644 --- a/Gemfile +++ b/Gemfile @@ -4,10 +4,9 @@ source 'http://ruby.taobao.org' unless RUBY_PLATFORM =~ /w32/ # unix-like only gem 'iconv' - gem 'rubyzip' - gem 'zip-zip' end +gem 'zipruby', '~> 0.3.6' #performance gem 'delayed_job_active_record'#, :group => :production gem 'daemons' gem 'grape', '~> 0.9.0' diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 9880a6382..80e7c1c06 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -1,4 +1,3 @@ -require 'zip' class ZipdownController < ApplicationController #查找项目(课程) before_filter :find_project_by_bid_id, :only => [:assort] @@ -56,9 +55,9 @@ class ZipdownController < ApplicationController if homework != nil unless homework.attachments.empty? zipfile = zip_homework_by_user homework - send_file zipfile, :filename => ((homework.user.user_extensions.nil? || homework.user.user_extensions.student_id.nil?) ? "" : homework.user.user_extensions.student_id) + + send_file zipfile.file_path, :filename => ((homework.user.user_extensions.nil? || homework.user.user_extensions.student_id.nil?) ? "" : homework.user.user_extensions.student_id) + "_" + (homework.user.lastname.nil? ? "" : homework.user.lastname) + (homework.user.firstname.nil? ? "" : homework.user.firstname) + - "_" + homework.name + ".zip", :type => detect_content_type(zipfile) if(zipfile) + "_" + homework.name + ".zip", :type => detect_content_type(zipfile.file_path) if(zipfile) else render file: 'public/no_file_found.html' end @@ -88,85 +87,120 @@ class ZipdownController < ApplicationController def zip_bid(bid) # Todo: User Access Controll bid_homework_path = [] + digests = [] bid.homeworks.each do |homeattach| unless homeattach.attachments.empty? - bid_homework_path << zip_homework_by_user(homeattach) + out_file = zip_homework_by_user(homeattach) + bid_homework_path << out_file.file_path + digests << out_file.file_digest end end - zips = split_pack_files(bid_homework_path, Setting.pack_attachment_max_size.to_i*1024) - x = 0 + homework_id = bid.id + user_id = bid.author_id - zips.each { |o| - x += 1 - file = zipping "#{Time.now.to_i}_#{bid.name}_#{x}.zip", o[:files], OUTPUT_FOLDER - o[:real_file] = file - o[:file] = File.basename(file) - o[:size] = (File.size(file) / 1024.0 / 1024.0).round(2) + out_file = find_or_pack(homework_id, user_id, digests.sort){ + zipping("#{Time.now.to_i}_#{bid.name}.zip", + bid_homework_path, OUTPUT_FOLDER) } + + # zips = split_pack_files(bid_homework_path, Setting.pack_attachment_max_size.to_i*1024) + # x = 0 + # + # + # zips.each { |o| + # x += 1 + # file = zipping "#{Time.now.to_i}_#{bid.name}_#{x}.zip", o[:files], OUTPUT_FOLDER + # o[:real_file] = file + # o[:file] = File.basename(file) + # o[:size] = (File.size(file) / 1024.0 / 1024.0).round(2) + # } + + [{files:[out_file.file_path], count: 1, index: 1, + real_file: out_file.file_path, file: File.basename(out_file.file_path), + size:(out_file.pack_size / 1024.0 / 1024.0).round(2) + }] end - def zip_homework_by_user(homeattach) + def zip_homework_by_user(homework_attach) homeworks_attach_path = [] not_exist_file = [] # 需要将所有homework.attachments遍历加入zip - # 并且返回zip路径 - homeattach.attachments.each do |attach| + + + digests = [] + homework_attach.attachments.each do |attach| if File.exist?(attach.diskfile) homeworks_attach_path << attach.diskfile + digests << attach.digest else not_exist_file << attach.filename + digests << 'not_exist_file' end end - zipping("#{homeattach.user.lastname}#{homeattach.user.firstname}_#{((homeattach.user.user_extensions.nil? || homeattach.user.user_extensions.student_id.nil?) ? "" : homeattach.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) + + out_file = find_or_pack(homework_attach.bid_id, homework_attach.user_id, digests.sort){ + zipping("#{homework_attach.user.lastname}#{homework_attach.user.firstname}_#{((homework_attach.user.user_extensions.nil? || homework_attach.user.user_extensions.student_id.nil?) ? "" : homework_attach.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", + homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) + } + end - def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[]) - # 输入待打包的文件列表,已经打包文件定位到ouput_path - ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE') + def find_or_pack(homework_id, user_id, digests) + raise "please given a pack block" unless block_given? - rename_zipfile = zip_name_refer ||= "#{Time.now.to_i.to_s}.zip" - zipfile_name = "#{output_path}/#{rename_zipfile}" + out_file = ZipPack.packed?(homework_id, user_id, digests.sort) - Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) + unless out_file && out_file.file_valid? + file = yield - unless is_attachment - #都是zip合并,没必要再费力压缩了 - Zip.default_compression = Zlib::NO_COMPRESSION + ZipPack.where(homework_id: homework_id, + user_id: user_id).delete_all + + out_file = ZipPack.create(homework_id: homework_id, + user_id: user_id, + file_digest: Trustie::Utils.digest(file), + file_path: file, + pack_size: File.size(file), + file_digests: digests.join(',') + ) else - Zip.default_compression = Zlib::DEFAULT_COMPRESSION + out_file.pack_times = out_file.pack_times + 1 + out_file.save end - Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| + out_file + end + + + def zipping(zip_name_refer, files_paths, output_path, is_attachment=false, not_exist_file=[]) + rename_zipfile = zip_name_refer ||= "#{Time.now.to_i.to_s}.zip" + zipfile_name = "#{output_path}/#{rename_zipfile}" + + Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) + Zip::Archive.open(zipfile_name, Zip::CREATE) do |zipfile| files_paths.each do |filename| flag = true index = 1 - rename_file = ic.iconv( (File.basename(filename)) ).to_s - rename_file = ic.iconv( filename_to_real( File.basename(filename))).to_s if is_attachment + rename_file = File.basename(filename) + rename_file = filename_to_real( File.basename(filename)) if is_attachment begin - zipfile.add(rename_file, filename) + zipfile.add_file(rename_file, filename) flag = false rescue Exception => e - zipfile.get_output_stream('FILE_NOTICE.txt') do |os| - os.write l(:label_file_exist) - end + zipfile.add_buffer('FILE_NOTICE.txt', l(:label_file_exist)) next end end unless not_exist_file.empty? - zipfile.get_output_stream('FILE_LOST.txt') do |os| - os.write l(:label_file_lost) + not_exist_file.join(',').to_s - end + zipfile.add_buffer('FILE_LOST.txt', l(:label_file_lost) + not_exist_file.join(',').to_s) end end zipfile_name - #rescue Errno => e - # logger.error "[zipdown#zipping] ===> #{e}" - # @error = e end # 合理分配文件打包 diff --git a/app/models/zip_pack.rb b/app/models/zip_pack.rb new file mode 100644 index 000000000..e2d03f363 --- /dev/null +++ b/app/models/zip_pack.rb @@ -0,0 +1,18 @@ +class ZipPack < ActiveRecord::Base + # attr_accessible :title, :body + + def self.packed?(bid_id, user_id, digests) + zip_pack = ZipPack.where(homework_id: bid_id, user_id: user_id).first + return false unless zip_pack && zip_pack.digests == digests + zip_pack + end + + def file_valid? + return false unless File.exist?(self.file_path) + Trustie::Utils.digest(self.file_path) == self.file_digest + end + + def digests + self.file_digests.split(',').sort + end +end diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index a59997a62..577cd280f 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -22,8 +22,8 @@ <%= link_to "留言", get_homework_jours_homework_attach_index_path(:bid_id => @bid.id), {:remote => true}%> (<%= @jours_count %>) -
  • - <%#= link_to "作品打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), class: "tb_all" unless @bid.homeworks.empty? %> +
  • <%= link_to "作品打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid, format: :json), + remote: true, class: "tb_all" unless @bid.homeworks.empty? %>
  • <% else %> diff --git a/config/initializers/30-redmine.rb b/config/initializers/30-redmine.rb index 1018ca18c..769039f4b 100644 --- a/config/initializers/30-redmine.rb +++ b/config/initializers/30-redmine.rb @@ -2,6 +2,7 @@ I18n.default_locale = 'en' I18n.backend = Redmine::I18n::Backend.new require 'redmine' +require 'trustie' # Load the secret token from the Redmine configuration file secret = Redmine::Configuration['secret_token'] diff --git a/config/routes.rb b/config/routes.rb index 6ca3edd67..d702ba24c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -102,11 +102,11 @@ RedmineApp::Application.routes.draw do mount SeemsRateable::Engine => '/rateable', :as => :rateable - # namespace :zipdown do - # match 'assort' - # match 'download_user_homework', :as => :download_user_homework - # match 'download' - # end + namespace :zipdown do + match 'assort' + match 'download_user_homework', :as => :download_user_homework + match 'download' + end namespace :test do match 'courselist' match 'zip' diff --git a/db/migrate/20150402015402_create_zip_packs.rb b/db/migrate/20150402015402_create_zip_packs.rb new file mode 100644 index 000000000..8ba268e24 --- /dev/null +++ b/db/migrate/20150402015402_create_zip_packs.rb @@ -0,0 +1,14 @@ +class CreateZipPacks < ActiveRecord::Migration + def change + create_table :zip_packs do |t| + t.integer :user_id + t.integer :homework_id + t.string :file_digest + t.string :file_path + t.integer :pack_times, default: 1 + t.integer :pack_size, default: 0 + t.string :file_digests + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 6f215e48f..a8ade8ed0 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 => 20150331032810) do +ActiveRecord::Schema.define(:version => 20150402015402) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1451,4 +1451,16 @@ ActiveRecord::Schema.define(:version => 20150331032810) do t.datetime "updated_at", :null => false end + create_table "zip_packs", :force => true do |t| + t.integer "user_id" + t.integer "homework_id" + t.string "file_digest" + t.string "file_path" + t.integer "pack_times", :default => 1 + t.integer "pack_size", :default => 0 + t.string "file_digests" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + end diff --git a/lib/trustie.rb b/lib/trustie.rb new file mode 100644 index 000000000..ff70d118c --- /dev/null +++ b/lib/trustie.rb @@ -0,0 +1 @@ +require 'trustie/utils' \ No newline at end of file diff --git a/lib/trustie/utils.rb b/lib/trustie/utils.rb new file mode 100644 index 000000000..a152a869a --- /dev/null +++ b/lib/trustie/utils.rb @@ -0,0 +1,20 @@ +#coding=utf-8 + +module Trustie + module Utils + def self.digest(diskfile) + md5 = Digest::MD5.new + File.open(diskfile, "rb") do |f| + buffer = "" + while (buffer = f.read(8192)) + md5.update(buffer) + end + end + md5.hexdigest + end + end +end + +if __FILE__ == $0 + puts Trustie::Utils.digest('/Users/guange/Downloads/QQ_V4.0.2.dmg') +end \ No newline at end of file From ceb6af7365619f40920cf4142c8a2634e0c8b0cc Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 3 Apr 2015 11:19:15 +0800 Subject: [PATCH 19/23] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=B7=BB=E5=8A=A0=E7=BC=96=E8=BE=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 2 +- app/controllers/comments_controller.rb | 5 +- app/controllers/forums_controller.rb | 4 +- app/controllers/messages_controller.rb | 6 ++ app/controllers/news_controller.rb | 3 + app/controllers/words_controller.rb | 4 +- app/helpers/application_helper.rb | 4 ++ app/models/bid.rb | 12 +++- app/models/comment.rb | 10 +++ app/models/forum.rb | 2 +- app/models/journals_for_message.rb | 11 +++- app/models/memo.rb | 2 +- app/models/message.rb | 11 +++- app/models/news.rb | 10 +++ app/views/bids/_new_homework_form.html.erb | 8 ++- app/views/bids/edit.html.erb | 3 +- app/views/boards/show.html.erb | 1 + app/views/courses/_courses_jours.html.erb | 11 ++-- app/views/courses/homework.html.erb | 2 +- app/views/courses/new_homework.html.erb | 3 +- app/views/messages/_course_show.html.erb | 66 ++++++++++--------- app/views/messages/_form_course.html.erb | 21 +++++- app/views/news/_course_form.html.erb | 17 +++-- app/views/news/_course_news.html.erb | 2 +- app/views/news/_course_show.html.erb | 14 ++-- .../lib/rails_kindeditor/active_record.rb | 12 +++- .../lib/rails_kindeditor/helper.rb | 6 +- public/assets/kindeditor/kindeditor.js | 12 ++-- public/javascripts/course.js | 41 +++++++++++- 29 files changed, 225 insertions(+), 80 deletions(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 8f7f0342f..3673d623c 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -41,7 +41,7 @@ module Mobile mount Apis::Comments #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) - #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? + add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 9f61306ab..0d1c39104 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -17,6 +17,7 @@ class CommentsController < ApplicationController default_search_scope :news + include ApplicationHelper model_object News before_filter :find_model_object before_filter :find_project_from_association @@ -26,9 +27,11 @@ class CommentsController < ApplicationController raise Unauthorized unless @news.commentable? @comment = Comment.new - @comment.safe_attributes = params[:comment] + @comment.comments = params[:comment] @comment.author = User.current if @news.comments << @comment + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT flash[:notice] = l(:label_comment_added) end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index c347ba6b8..f59704a62 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -64,7 +64,7 @@ class ForumsController < ApplicationController respond_to do |format| if @memo.save ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids ,@memo.id,1 + update_kindeditor_assets_owner ids ,@memo.id,OwnerTypeHelper::MEMO #end format.html { redirect_to (forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))), notice: "#{l :label_memo_create_succ}" } format.json { render json: @memo, status: :created, location: @memo } @@ -171,7 +171,7 @@ class ForumsController < ApplicationController # Description after save后需要进行资源记录的更新 # owner_type = 2 对应的是 forum ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids ,@forum.id,2 + update_kindeditor_assets_owner ids ,@forum.id,OwnerTypeHelper::FORUM #end respond_to do |format| diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index b50b2720f..2ad388f41 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -86,6 +86,10 @@ class MessagesController < ApplicationController if request.post? @message.save_attachments(params[:attachments]) if @message.save + # 更新kindeditor上传的图片资源所有者 + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE + call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) render_attachment_warning_if_needed(@message) redirect_to board_message_url(@board, @message) @@ -117,6 +121,8 @@ class MessagesController < ApplicationController @topic.children << @reply #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) attachments = Attachment.attach_files(@reply, params[:attachments]) render_attachment_warning_if_needed(@reply) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 617e56575..27c4aa37f 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -17,6 +17,7 @@ class NewsController < ApplicationController layout 'base_projects'# by young + include ApplicationHelper before_filter :authorize1, :only => [:show] default_search_scope :news model_object News @@ -136,6 +137,8 @@ class NewsController < ApplicationController @news.safe_attributes = params[:news] @news.save_attachments(params[:attachments]) if @news.save + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS render_attachment_warning_if_needed(@news) flash[:notice] = l(:notice_successful_create) redirect_to course_news_index_url(@course) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 2fc4fef9a..de2fbc732 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -1,7 +1,7 @@ # encoding: utf-8 #####leave message fq class WordsController < ApplicationController - + include ApplicationHelper before_filter :find_user, :only => [:new, :create, :destroy, :more, :back] def create if params[:new_form][:user_message].size>0 @@ -209,6 +209,8 @@ class WordsController < ApplicationController message = params[:new_form][:course_message] feedback = Course.add_new_jour(user, message, params[:id]) if(feedback.errors.empty?) + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE redirect_to course_feedback_url(params[:id]), notice: l(:label_feedback_success) else flash[:error] = feedback.errors.full_messages[0] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fd567c1fa..c94108dc1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -53,6 +53,10 @@ module ApplicationHelper # Author lizanle # Description after save后需要进行资源记录的更新 # owner_type = 1 对应的是 memo + # owner_type = 2 对应的是forum + # owner_type = 3 对应的是message + # owner_type = 4 对应的是news + # owner_type = 5 对应的是comment def update_kindeditor_assets_owner ids,owner_id,owner_type ids.each do |id| asset = Kindeditor::Asset.find(id.to_i) diff --git a/app/models/bid.rb b/app/models/bid.rb index 10476b4d3..ccd6198bb 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -17,7 +17,8 @@ class Bid < ActiveRecord::Base HomeworkProject = 2 attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password include Redmine::SafeAttributes - + include ApplicationHelper + has_many_kindeditor_assets :assets, :dependent => :destroy belongs_to :author, :class_name => 'User', :foreign_key => :author_id belongs_to :course has_many :biding_projects, :dependent => :destroy @@ -47,7 +48,7 @@ class Bid < ActiveRecord::Base validate :validate_user validate :validate_reward_type after_create :act_as_activity - + after_destroy :delete_kindeditor_assets scope :visible, lambda {|*args| nil } @@ -157,5 +158,10 @@ class Bid < ActiveRecord::Base end end - + # Time 2015-04-01 14:19:06 + # Author lizanle + # Description 删除对应课程通知的图片资源 + def delete_kindeditor_assets + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::BID + end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 539c62e85..880bf448c 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -17,8 +17,18 @@ class Comment < ActiveRecord::Base include Redmine::SafeAttributes + include ApplicationHelper + has_many_kindeditor_assets :assets, :dependent => :destroy belongs_to :commented, :polymorphic => true, :counter_cache => true belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' validates_presence_of :commented, :author, :comments safe_attributes 'comments' + after_destroy :delete_kindeditor_assets + + # Time 2015-03-31 09:15:06 + # Author lizanle + # Description 删除对应评论的图片资源 + def delete_kindeditor_assets + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::COMMENT + end end diff --git a/app/models/forum.rb b/app/models/forum.rb index 6843ab678..52417f25e 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -53,7 +53,7 @@ class Forum < ActiveRecord::Base # Author lizanle # Description 删除论坛后删除对应的资源 def delete_kindeditor_assets - delete_kindeditor_assets_from_disk self.id,2 + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::FORUM end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 23d9c7753..6875e6f4a 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -4,6 +4,8 @@ class JournalsForMessage < ActiveRecord::Base include Redmine::SafeAttributes include UserScoreHelper + include ApplicationHelper + has_many_kindeditor_assets :assets, :dependent => :destroy safe_attributes "jour_type", # 留言所属类型 "jour_id", # 留言所属类型的id "notes", # 留言内容 @@ -16,7 +18,7 @@ class JournalsForMessage < ActiveRecord::Base "m_reply_id" # 回复某留言的留言id(a留言回复了b留言,这是b留言的id) "is_comprehensive_evaluation" # 1 教师评论、2 匿评、3 留言 acts_as_tree :foreign_key => 'm_parent_id', :counter_cache => :m_reply_count, :order => "#{JournalsForMessage.table_name}.created_on ASC" - + after_destroy :delete_kindeditor_assets belongs_to :project, :foreign_key => 'jour_id', :conditions => "#{self.table_name}.jour_type = 'Project' " @@ -163,5 +165,10 @@ class JournalsForMessage < ActiveRecord::Base end end - + # Time 2015-04-01 14:15:06 + # Author lizanle + # Description 删除对应课程留言的图片资源 + def delete_kindeditor_assets + delete_kindeditor_assets_from_disk self.id,7 + end end diff --git a/app/models/memo.rb b/app/models/memo.rb index eb0c86855..182ea314e 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -176,6 +176,6 @@ class Memo < ActiveRecord::Base # Author lizanle # Description 从硬盘上删除资源 def delete_kindeditor_assets - delete_kindeditor_assets_from_disk self.id,1 + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MEMO end end diff --git a/app/models/message.rb b/app/models/message.rb index 85a87132d..dd1dcf92e 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -18,6 +18,8 @@ class Message < ActiveRecord::Base include Redmine::SafeAttributes include UserScoreHelper + include ApplicationHelper + has_many_kindeditor_assets :assets, :dependent => :destroy belongs_to :board belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' has_many :praise_tread, as: :praise_tread_object, dependent: :destroy @@ -62,7 +64,7 @@ class Message < ActiveRecord::Base after_create :add_author_as_watcher, :reset_counters! after_update :update_messages_board - after_destroy :reset_counters!,:down_user_score + after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets # fq after_create :act_as_activity,:be_user_score,:act_as_forge_activity @@ -208,5 +210,10 @@ class Message < ActiveRecord::Base end end - + # Time 2015-03-31 09:15:06 + # Author lizanle + # Description 删除对应消息的图片资源 + def delete_kindeditor_assets + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE + end end diff --git a/app/models/news.rb b/app/models/news.rb index d2547fc02..116353cf7 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -18,6 +18,8 @@ class News < ActiveRecord::Base include Redmine::SafeAttributes belongs_to :project + include ApplicationHelper + has_many_kindeditor_assets :assets, :dependent => :destroy #added by nwb belongs_to :course belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' @@ -49,6 +51,7 @@ class News < ActiveRecord::Base # fq after_create :act_as_activity,:act_as_forge_activity # end + after_destroy :delete_kindeditor_assets scope :visible, lambda {|*args| includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args)) @@ -105,4 +108,11 @@ class News < ActiveRecord::Base end end + # Time 2015-03-31 13:50:54 + # Author lizanle + # Description 删除news后删除对应的资源 + def delete_kindeditor_assets + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::NEWS + end + end diff --git a/app/views/bids/_new_homework_form.html.erb b/app/views/bids/_new_homework_form.html.erb index 9f3bf30c7..505fc88a8 100644 --- a/app/views/bids/_new_homework_form.html.erb +++ b/app/views/bids/_new_homework_form.html.erb @@ -13,7 +13,13 @@
  • - + + <% if edit_mode %> + <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:owner_id => bid.id,:owner_type =>OwnerTypeHelper::BID %> + <% else %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor' %> + <% end %>
  • diff --git a/app/views/bids/edit.html.erb b/app/views/bids/edit.html.erb index 80a023ac1..4133a24b2 100644 --- a/app/views/bids/edit.html.erb +++ b/app/views/bids/edit.html.erb @@ -1,3 +1,4 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> <%= labelled_form_for @bid do |f| %> - <%= render :partial => 'new_homework_form', :locals => { :bid => @bid, :bid_id => "edit_bid_#{@bid.id}"} %> + <%= render :partial => 'new_homework_form', :locals => { :bid => @bid, :bid_id => "edit_bid_#{@bid.id}",:f=>f,:edit_mode => true} %> <% end %> \ No newline at end of file diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 6e5888363..81d1288fd 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -1,3 +1,4 @@ + <% if @project %> <%= render :partial => 'project_show', locals: {project: @project} %> <% elsif @course %> diff --git a/app/views/courses/_courses_jours.html.erb b/app/views/courses/_courses_jours.html.erb index 5f2a67ebb..e79dac59b 100644 --- a/app/views/courses/_courses_jours.html.erb +++ b/app/views/courses/_courses_jours.html.erb @@ -1,4 +1,4 @@ - +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
    <%# reply_allow = JournalsForMessage.create_by_user? User.current %>

    <%= l(:label_leave_message) %>

    @@ -11,11 +11,12 @@
    <% else %> <%= form_for('new_form', :method => :post, - :url => {:controller => 'words', :action => 'leave_course_message'}) do |f|%> - <%= f.text_area 'course_message',:id => "leave_meassge",:style => "resize: none;", - :placeholder => "#{l(:label_welcome_my_respond)}",:maxlength => 250%> + :url => {:controller => 'words', :action => 'leave_course_message'},:html => {:id=>'leave_message_form'}) do |f|%> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= f.kindeditor 'course_message',:editor_id => 'leave_message_editor',:input_html=>{:id => "leave_meassge",:style => "resize: none;", + :placeholder => "#{l(:label_welcome_my_respond)}",:maxlength => 250}%> 取  消 - <%= l(:button_leave_meassge)%> + <%= l(:button_leave_meassge)%> <% end %> <% end %>
  • diff --git a/app/views/courses/homework.html.erb b/app/views/courses/homework.html.erb index 9317027e2..98440abab 100644 --- a/app/views/courses/homework.html.erb +++ b/app/views/courses/homework.html.erb @@ -32,7 +32,7 @@
    - <%= textilizable bid, :description %> + <%= textAreailizable bid, :description %>
    @@ -87,7 +118,7 @@ @@ -97,32 +128,3 @@ <% html_title @topic.subject %> - \ No newline at end of file diff --git a/app/views/messages/_form_course.html.erb b/app/views/messages/_form_course.html.erb index 8f806ac97..dc350bcb3 100644 --- a/app/views/messages/_form_course.html.erb +++ b/app/views/messages/_form_course.html.erb @@ -1,3 +1,4 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> <%= error_messages_for 'message' %> <% replying ||= false %> <% extra_option = replying ? { readonly: true} : { maxlength: 200 } %> @@ -28,7 +29,25 @@
    <%= text_area :quote,:quote,:style => 'display:none' %> - <%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <% if replying %> + <%= f.kindeditor :content, :editor_id => 'message_content_editor', + :width => '89%', + :height => 300, + :input_html => { :id => 'message_content', + :class => 'talk_text fl', + :maxlength => 5000 }%> + <% else %> + <%= f.kindeditor :content, :editor_id => 'message_content_editor', + :owner_id => @message.nil? ? 0: @message.id, + :owner_type => OwnerTypeHelper::MESSAGE, + :width => '91%', + :height => 300, + :class => 'talk_text fl', + :input_html => { :id => 'message_content', + :class => 'talk_text fl', + :maxlength => 5000 }%> + <% end %>

    diff --git a/app/views/news/_course_form.html.erb b/app/views/news/_course_form.html.erb index b32401d7c..5c0fc8274 100644 --- a/app/views/news/_course_form.html.erb +++ b/app/views/news/_course_form.html.erb @@ -1,12 +1,21 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
  • - - -

    + <% if is_new %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + + <%= f.kindeditor :description,:width=>'91%',:editor_id=>'news_description_editor' %> +

    + <% else %> + + <%= f.kindeditor :description,:width=>'91%',:editor_id=>'news_description_editor',:owner_id => @news.id,:owner_type => OwnerTypeHelper::NEWS %> +

    + <% end %> +
  • @@ -19,7 +28,7 @@ <%= link_to l(:button_create), "#", :onclick => 'submitNews();', :onmouseover => 'submitFocus(this);', :class => 'blue_btn fl c_white' %> <%= link_to l(:button_cancel), course_news_index_path(@course), :onclick => '$("#add-news").hide()', :class => 'blue_btn grey_btn fl c_white' %> <% else %> - <%= link_to l(:button_save), "#", :onclick => 'submitNews();',:onmouseover => 'this.focus()',:class => 'blue_btn fl c_white' %> + <%= link_to l(:button_save), "#", :onclick => "submitNews();",:onmouseover => 'this.focus()',:class => 'blue_btn fl c_white' %> <%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;',:class => 'blue_btn grey_btn fl c_white' %> <% end %>
    diff --git a/app/views/news/_course_news.html.erb b/app/views/news/_course_news.html.erb index a9af6551c..c6940ce10 100644 --- a/app/views/news/_course_news.html.erb +++ b/app/views/news/_course_news.html.erb @@ -51,7 +51,7 @@ <%= link_to_user_header(news.author,false,{:class=> 'problem_name c_orange fl'}) if news.respond_to?(:author) %> <%= l(:label_release_news) %>:<%= link_to h(news.title), news_path(news),:class => 'problem_tit fl fb c_dblue' %>
    -

    <%= news.description %>
    <%= l(:label_create_time) %> :<%= format_time(news.created_on) %>

    +

    <%= textAreailizable news.description %>
    <%= l(:label_create_time) %> :<%= format_time(news.created_on) %>

  • diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index ed6011e29..3334f7c6a 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -44,6 +44,7 @@ function submitNews() { + news_description_editor.sync(); if(regexTitle() && regexDescription()) { $("#news-form").submit(); @@ -51,6 +52,7 @@ } function submitComment() { + comment_editor.sync(); $("#add_comment_form").submit(); } function clearMessage() @@ -58,7 +60,7 @@ $("#comment_comments").val(""); } - +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>

    <%= l(:label_course_news) %>

    @@ -84,7 +86,7 @@ :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @course) %> <%= delete_link(news_path(@news),:class => 'talk_edit fr') if User.current.allowed_to?(:manage_news, @course) %>
    -
    <%= textilizable(@news, :description) %>
    <%= l(:label_create_time) %> : <%= format_time(@news.created_on) %>
    +
    <%= textAreailizable(@news, :description) %>
    <%= l(:label_create_time) %> : <%= format_time(@news.created_on) %>
    <%= link_to_attachments_course @news %>
    @@ -95,8 +97,9 @@

    <%= l(:label_comment_add) %>

    <%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form") do %> -
    - <%= text_area 'comment', 'comments', :placeholder=>"最多250个字"%> +
    + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= kindeditor_tag :comment, '',:height=>'100',:editor_id =>'comment_editor', :placeholder=>"最多250个字"%>

    <%= l(:label_cancel_with_space) %> @@ -106,6 +109,7 @@ <% end %>

    <% end %> + <% comments = @comments.reverse %> <% comments.each do |comment| %> <% next if comment.new_record? %> @@ -115,7 +119,7 @@
    <%= link_to_user_header(comment.author,false,:class => 'c_blue fb fl mb10 ') if comment.respond_to?(:author) %><%= format_time(comment.created_on) %>
    -

    <%= textilizable(comment.comments) %>

    +

    <%= textAreailizable(comment.comments) %>

    <%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %> diff --git a/lib/rails_kindeditor/lib/rails_kindeditor/active_record.rb b/lib/rails_kindeditor/lib/rails_kindeditor/active_record.rb index 5120acf0a..18e1d57ec 100644 --- a/lib/rails_kindeditor/lib/rails_kindeditor/active_record.rb +++ b/lib/rails_kindeditor/lib/rails_kindeditor/active_record.rb @@ -3,9 +3,17 @@ if defined?(ActiveRecord) def self.has_many_kindeditor_assets(*args) options = args.extract_options! asset_name = args[0] ? args[0].to_s : 'assets' - has_many asset_name.to_sym, :class_name => 'Kindeditor::Asset', :foreign_key => 'owner_id', :dependent => options[:dependent] - class_name = self.name + # Time 2015-04-01 14:20:32 + # Author lizanle + # Description 对象类型对应的数值,kindeditor_assets表里owner_type的值 + + has_many asset_name.to_sym, + :class_name => 'Kindeditor::Asset', + :conditions => "owner_type = #{('OwnerTypeHelper::'+class_name.upcase).constantize}", + :foreign_key => 'owner_id', :dependent => options[:dependent] + + Kindeditor::Asset.class_eval do belongs_to :owner, :class_name => class_name, :foreign_key => 'owner_id' end diff --git a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb index db2be85fb..8db3a637e 100644 --- a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb +++ b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb @@ -20,7 +20,11 @@ module RailsKindeditor def kindeditor_upload_json_path(*args) options = args.extract_options! owner_id_query_string = options[:owner_id] ? "?owner_id=#{options[:owner_id]}" : '' - owner_type_query_string = options[:owner_type] ? owner_id_query_string + "&owner_type=#{options[:owner_type]}" : owner_id_query_string + if owner_id_query_string.blank? + owner_type_query_string = options[:owner_type] ? "?owner_type=#{options[:owner_type]}" : "" + else + owner_type_query_string = options[:owner_type] ? owner_id_query_string + "&owner_type=#{options[:owner_type]}" : owner_id_query_string + end "#{main_app_root_url}kindeditor/upload#{owner_type_query_string}" end diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index e39c6e19e..680899eee 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -257,14 +257,10 @@ K.options = { minHeight : 100, minChangeSize : 50, zIndex : 811213, - items : [ - 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', - 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', - 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', - 'superscript', 'quickformat', 'fullscreen','|', '/', - 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', - 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', - 'anchor', 'link', '|' + items : ['emoticons', + 'source','plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', '|', + 'formatblock', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', + 'italic', 'underline', 'removeformat', '|', 'image', 'table', 'link', '|', 'fullscreen' ], noDisableItems : ['source', 'fullscreen'], colorTable : [ diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 4ca2c3403..3536478a8 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -129,7 +129,7 @@ function regexSubject() } function regexContent() { - var content = $.trim($("#message_content").val()); + var content = message_content_editor.html(); if(content.length ==0) { $("#message_content_span").text("描述不能为空"); @@ -146,6 +146,7 @@ function regexContent() } function submitCoursesBoard() { + message_content_editor.sync(); if(regexSubject()&®exContent()){$("#message-form").submit();} } /////////////////////////////////////////////////////////////// @@ -177,7 +178,7 @@ function regexTitle() function regexDescription() { - var name = $("#news_description").val(); + var name = news_description_editor.html(); if(name.length ==0) { $("#description_notice_span").text("描述不能为空"); @@ -185,6 +186,12 @@ function regexDescription() $("#description_notice_span").focus(); return false; } + else if(name.length >=6000){ + $("#description_notice_span").text("描述最多3000个汉字(或6000个英文字符)"); + $("#description_notice_span").css('color','#ff0000'); + $("#description_notice_span").focus(); + return false; + } else { $("#description_notice_span").text("填写正确"); @@ -193,10 +200,12 @@ function regexDescription() } } -function submitNews() +function submitNews(is_new) { + alert(is_new) if(regexTitle() && regexDescription()) { + news_description_editor.sync(); $("#news-form").submit(); } } @@ -205,6 +214,31 @@ function submitFocus(obj) { $(obj).focus(); } + +/////////////////////////////////////////////////课程讨论区 +function course_board_submit_message_replay() +{ + if(MessageReplayVevify()) + { + message_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值 + $("#message_form").submit(); + } +} +function MessageReplayVevify() { + var content = message_content_editor.html();//$.trim($("#message_content").val()); + if (content.length == 0) { + $("#message_content_span").text("<%= l(:label_reply_empty) %>"); + $("#message_content_span").css('color', '#ff0000'); + return false; + } + else { + $("#message_content_span").text("<%= l(:label_field_correct) %>"); + $("#message_content_span").css('color', '#008000'); + return true; + } +} +////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// //验证搜索时输入名字 @@ -336,6 +370,7 @@ function submit_new_bid(id) { if(regex_bid_name()&®ex_evaluation_num()) { + bid_description_editor.sync(); $("#"+id).submit(); } } From 893f6af85638b9316f3688faac3d5b4dd8f18cf1 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 3 Apr 2015 11:29:37 +0800 Subject: [PATCH 20/23] =?UTF-8?q?=E7=94=A8=E5=9B=9Erubyzip,=20zipruby?= =?UTF-8?q?=E6=9C=89bug.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- app/controllers/zipdown_controller.rb | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 98d81ca70..679e0a5b2 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end -gem 'zipruby', '~> 0.3.6' #performance +gem 'rubyzip' gem 'delayed_job_active_record'#, :group => :production gem 'daemons' gem 'grape', '~> 0.9.0' diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 80e7c1c06..a3bee3c95 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -1,10 +1,11 @@ +require 'zip' class ZipdownController < ApplicationController #查找项目(课程) before_filter :find_project_by_bid_id, :only => [:assort] #检查权限 #勿删 before_filter :authorize, :only => [:assort,:download_user_homework] SAVE_FOLDER = "#{Rails.root}/files" - OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip" + OUTPUT_FOLDER = "#{Rails.root}/files/archiveZip" #统一下载功能 def download @@ -181,23 +182,19 @@ class ZipdownController < ApplicationController zipfile_name = "#{output_path}/#{rename_zipfile}" Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) - Zip::Archive.open(zipfile_name, Zip::CREATE) do |zipfile| + Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| files_paths.each do |filename| - flag = true - index = 1 rename_file = File.basename(filename) rename_file = filename_to_real( File.basename(filename)) if is_attachment - begin - zipfile.add_file(rename_file, filename) - flag = false + zipfile.add(rename_file, filename) rescue Exception => e - zipfile.add_buffer('FILE_NOTICE.txt', l(:label_file_exist)) + zipfile.get_output_stream('FILE_NOTICE.txt'){|os| os.write l(:label_file_exist)} next end end unless not_exist_file.empty? - zipfile.add_buffer('FILE_LOST.txt', l(:label_file_lost) + not_exist_file.join(',').to_s) + zipfile.get_output_stream('FILE_LOST.txt'){|os| os.write l(:label_file_lost) + not_exist_file.join(',').to_s} end end zipfile_name From aa64b47d74b50b6122c095f8ad58e8e2d100c383 Mon Sep 17 00:00:00 2001 From: whimlex Date: Fri, 3 Apr 2015 11:30:48 +0800 Subject: [PATCH 21/23] =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=8C=89=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=80=92=E5=BA=8F=E6=98=BE=E7=A4=BA=EF=BC=9B=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E8=AF=BE=E7=A8=8B=E8=AE=BE=E7=BD=AE=E5=85=AC=E5=BC=80?= =?UTF-8?q?=E7=A7=81=E6=9C=89=E5=B1=9E=E6=80=A7=EF=BC=9B=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8A=A8=E6=80=81=EF=BC=88=E5=8A=A8=E6=80=81=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=B8=BB=E8=A6=81=E5=9C=A8=E4=BD=9C=E4=B8=9A=E5=92=8C=E4=BD=9C?= =?UTF-8?q?=E5=93=81=E4=B8=8A=E5=AD=98=E5=9C=A8=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=98=BE=E7=A4=BA=E5=9C=A8=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=92=8C=E7=95=99=E8=A8=80=E4=B8=AD=E5=AD=98=E5=9C=A8=E6=9D=83?= =?UTF-8?q?=E9=99=90=E9=97=AE=E9=A2=98=EF=BC=89=EF=BC=9B=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=A0=BC=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 58 ++++++++++++++++++------- app/helpers/activities_helper.rb | 12 +++++ app/helpers/courses_helper.rb | 23 +++++++++- app/services/courses_service.rb | 2 + app/views/courses/new.html.erb | 18 +++++++- app/views/courses/show.html.erb | 9 ++-- app/views/files/_course_list.html.erb | 6 ++- app/views/layouts/base_courses.html.erb | 2 +- config/locales/commons/en.yml | 5 +++ config/locales/commons/zh.yml | 3 +- config/locales/contacts/en.yml | 2 +- config/locales/courses/en.yml | 11 +++-- config/locales/courses/zh.yml | 1 + config/locales/en.yml | 6 +-- config/locales/my/en.yml | 2 +- config/locales/zh.yml | 4 +- 16 files changed, 126 insertions(+), 38 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 581005bf7..a243018ba 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1,6 +1,7 @@ class CoursesController < ApplicationController layout 'base_courses' include CoursesHelper + include ActivitiesHelper helper :activities helper :members helper :words @@ -680,26 +681,49 @@ class CoursesController < ApplicationController "show_course_files" => true, "show_course_news" => true, "show_course_messages" => true, - "show_bids" => true, "show_course_journals_for_messages" => true, + "show_bids" => true, "show_homeworks" => true } @date_to ||= Date.today + 1 @date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) - @author ||= @course.teacher - # 决定显示所用用户或单个用户活动 - @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, - :with_subprojects => false, - :author => @author) - @activity.scope_select {|t| has["show_#{t}"]} - # modify by nwb - # 添加私密性判断 - if User.current.member_of_course?(@course)|| User.current.admin? - events = @activity.events(@days, @course.created_at) + if @author.nil? + # 显示老师和助教的活动 + # @authors = searchTeacherAndAssistant(@course) + @authors = course_all_member(@course) + events = [] + @authors.each do |author| + @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, + :with_subprojects => false, + :author => author.user) + + @activity.scope_select {|t| has["show_#{t}"]} + # modify by nwb + # 添加私密性判断 + if User.current.member_of_course?(@course)|| User.current.admin? + events += @activity.events(@days, @course.created_at) + else + events += @activity.events(@days, @course.created_at, :is_public => 1) + end + + end else - events = @activity.events(@days, @course.created_at, :is_public => 1) + # @author = @course.teacher + @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, + :with_subprojects => false, + :author => @author) + + @activity.scope_select {|t| has["show_#{t}"]} + # modify by nwb + # 添加私密性判断 + if User.current.member_of_course?(@course)|| User.current.admin? + events = @activity.events(@days, @course.created_at) + else + events = @activity.events(@days, @course.created_at, :is_public => 1) + end end + # 无新动态时,显示老动态 if events.count == 0 if User.current.member_of_course?(@course)|| User.current.admin? @@ -708,13 +732,17 @@ class CoursesController < ApplicationController events = @activity.events(:is_public => 1) end end - events = paginateHelper events,10 - @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} - # documents @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id))) @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id) end + + sorted_events = sort_activity_events_course(events); + events = paginateHelper sorted_events,10 + @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} + # documents + + respond_to do |format| format.html{render :layout => 'base_courses'} format.api diff --git a/app/helpers/activities_helper.rb b/app/helpers/activities_helper.rb index c15d89e0c..2f48ba87f 100644 --- a/app/helpers/activities_helper.rb +++ b/app/helpers/activities_helper.rb @@ -30,4 +30,16 @@ module ActivitiesHelper end sorted_events end + def sort_activity_events_course(events) + events_by_group = events.group_by(&:event_group) + sorted_events = [] + events.sort {|x, y| y.event_datetime <=> x.event_datetime}.each do |event| + if group_events = events_by_group.delete(event.event_group) + group_events.sort {|x, y| y.event_datetime <=> x.event_datetime}.each_with_index do |e, i| + sorted_events << e unless e.event_description.nil? + end + end + end + sorted_events + end end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index f4ba5040e..3adcdb09e 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -632,7 +632,7 @@ module CoursesHelper #获取课程动态 def get_course_activity courses, activities @course_ids=activities.keys() - + @bid_ids = [] days = Setting.activity_days_default.to_i date_to ||= Date.today + 1 date_from = date_to - days-1.years @@ -653,8 +653,27 @@ module CoursesHelper activities[news.course_id]+=1 end + #feedbackc_count + JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess| + activities[jourformess.jour_id]+=1 + end + + #homework_count + #HomeworkForCourse.where(course_id: @course_ids).each do |homework| + # @bid_ids<?",date_from).count + + #end + + #@bid_ids.each do |bid_id| + # activities[] +=Bid.where(id: bid_id ).where("created_on>?",date_from).count + + #end + + + # 动态数 + 1 ( 某某创建了该课程 ) - activities.each_pair { |key, value| activities[key] = value + 1 } + # activities.each_pair { |key, value| activities[key] = value + 1 } return activities end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 7c816ec19..7c1f14104 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -194,6 +194,8 @@ class CoursesService @course.setup_time = params[:setup_time] @course.endup_time = params[:endup_time] @course.class_period = params[:class_period] + params[:course][:is_public] ? @course.is_public = 1 : @course.is_public = 0 + params[:course][:open_student] ? @course.open_student = 1 : @course.open_student = 0 end @issue_custom_fields = IssueCustomField.sorted.all diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index 3057285a7..68a326fb2 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -1,3 +1,16 @@ + + +

    <%= l(:permission_new_course)%>

    @@ -24,7 +37,8 @@
  • - + + 显示明码
    学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。
  • @@ -35,7 +49,7 @@
  • - + (打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。)
  • diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index c0b2f1eb6..698bf3cea 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -12,12 +12,13 @@
    <%= link_to_user_header(e.event_author,false,:class => 'problem_name c_orange fl') if e.respond_to?(:event_author) %> <%= link_to_user_header("(#{e.event_author})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName && e.respond_to?(:event_author) %> +   <%= l(:label_new_activity) %>: - <%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url,:class => "problem_tit c_dblue fl fb"%> + <%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url,:class => "problem_tit c_dblue fl fb"%>

    <%= e.event_description %>
    - <%= l :label_activity_time %> : <%= format_activity_day(day) %><%= format_time(e.event_datetime, false) %> + <%= l :label_activity_time %> : <%= format_activity_day(day) %> <%= format_time(e.event_datetime, false) %>

    @@ -25,7 +26,7 @@ <% end%> <% end%> <% end%> - +<% if @obj_pages.next_page.nil? %>
    - +<% end%>
      <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
    diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index de2a5a82c..7fc079bcb 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -15,7 +15,8 @@
    -<% curse_attachments.each do |file| %> +<% curse_attachments.sort.reverse.each do |file| %> + <% if file.is_public? || User.current.member_of_course?(course) %>
    <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> @@ -50,6 +51,9 @@
    + <% else %> +
    <%= file.filename %>是私有资源
    + <% end %> <% end %>
      diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 25b08ce7d..9fed77faf 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -48,7 +48,7 @@