From 29c720a8a4413bb0ed7cc8292174e22560eedfa6 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 30 Dec 2015 17:45:15 +0800 Subject: [PATCH 01/14] =?UTF-8?q?1.=E6=9D=83=E9=99=90=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 4 +++- app/views/messages/_show_org_subfields.html.erb | 2 +- app/views/organizations/_org_subfield_message.html.erb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index ae13b7e78..e91b3f0db 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -231,8 +231,10 @@ class MessagesController < ApplicationController @isReply = false if @project (render_403; return false) unless @message.editable_by?(User.current) - else + elsif @course (render_403; return false) unless @message.course_editable_by?(User.current) + else + (render_403; return false) unless @message.org_subfield_editable_by?(User.current) end @message.safe_attributes = params[:message] diff --git a/app/views/messages/_show_org_subfields.html.erb b/app/views/messages/_show_org_subfields.html.erb index cbd316ea4..fcdac063f 100644 --- a/app/views/messages/_show_org_subfields.html.erb +++ b/app/views/messages/_show_org_subfields.html.erb @@ -9,7 +9,7 @@ <% end %> <% else %> -
  • 暂无资源栏目
  • +
  • 暂无帖子栏目
  • <% end %> <% else %> 请在左侧选择组织 diff --git a/app/views/organizations/_org_subfield_message.html.erb b/app/views/organizations/_org_subfield_message.html.erb index 57c50486b..e6bee8000 100644 --- a/app/views/organizations/_org_subfield_message.html.erb +++ b/app/views/organizations/_org_subfield_message.html.erb @@ -11,7 +11,7 @@ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.board.org_subfield.name.to_s+" | 资源栏目讨论区",org_subfield_boards_path(activity.board.org_subfield), :class => "newsBlue ml15 mr5"%> + <%= link_to activity.board.org_subfield.name.to_s+" | 帖子栏目讨论区",org_subfield_boards_path(activity.board.org_subfield), :class => "newsBlue ml15 mr5"%>
    From c2578698f5551015704b08eca9658ee2bce0448f Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 30 Dec 2015 18:25:56 +0800 Subject: [PATCH 02/14] =?UTF-8?q?1.=E7=BB=84=E7=BB=87=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E6=9C=89=E6=9D=83=E9=99=90=E8=AE=BF=E9=97=AE=E5=B8=96?= =?UTF-8?q?=E5=AD=90=E8=B5=84=E6=BA=90=E6=A0=8F=E7=9B=AE=202.=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E7=BB=84=E7=BB=87=E9=A1=B5=E9=9D=A2=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=E5=B8=96=E5=AD=90=E6=A0=B7=E5=BC=8F=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/messages/_org_subfield_show.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/messages/_org_subfield_show.html.erb b/app/views/messages/_org_subfield_show.html.erb index 9eb082d33..304694b39 100644 --- a/app/views/messages/_org_subfield_show.html.erb +++ b/app/views/messages/_org_subfield_show.html.erb @@ -7,6 +7,7 @@ $(function(){ $("#RSide").removeAttr("id"); $("#Container").css("width","1000px"); + $(".postRightContainer").css("margin-left", "0px"); }); -
    +
    <%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_path(@document.creator_id) %> diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index bcb50cfed..b37a38da0 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -70,7 +70,7 @@ a.linkGrey8:hover {color:#585858;} .org_login_list{ border:1px solid #eaeaea; background:#fff; padding-left:10px; padding-bottom:10px; padding-top:8px; width:60px; left:-53px; position:absolute; z-index:9999; line-height:2; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); margin-top: 30px;} #orgUserName {max-width:50px; overflow:hidden; white-space: nowrap; text-overflow: ellipsis; display:inline-block;} -.org_login_list a {color:#269ac9;} +.org_login_list a {color:#269ac9;} .orgListStatus {width:55px; float:left;} .reCon{ margin:5px; width:710px;} @@ -102,4 +102,5 @@ ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; } .sectionContent li:hover {background-color:#cccccc; cursor:pointer;} .sectionContent span {width:175px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; display:inline-block; height:18px; vertical-align:middle;}.popbox_polls{width:300px;height:100px;position:fixed !important;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;} -.org_login_list a {color:#269ac9;} \ No newline at end of file +.org_login_list a {color:#269ac9;} +div.flash {margin-top :0px !important} \ No newline at end of file From ec631691e35b17a79c7eba3c85130e8d811a15a5 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 31 Dec 2015 11:12:09 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=92=8C=E8=AF=BE=E7=A8=8B=E9=85=8D=E7=BD=AE=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=93=E6=9D=9F=E5=AD=A6=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 2 + app/views/courses/new.html.erb | 120 ++++++++++-------- app/views/courses/settings.html.erb | 40 +++--- config/locales/courses/en.yml | 2 +- config/locales/courses/zh.yml | 2 +- .../20151231012634_add_last_term_to_course.rb | 17 +++ db/schema.rb | 9 +- public/javascripts/course.js | 42 +++++- 8 files changed, 159 insertions(+), 75 deletions(-) create mode 100644 db/migrate/20151231012634_add_last_term_to_course.rb diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 5d60238bf..aabe1a921 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -196,6 +196,8 @@ class CoursesService @course.tea_id = current_user.id @course.term = params[:term] @course.time = params[:time] + @course.end_term = params[:end_term] + @course.end_time = params[:end_time] #@course.school_id = params[:occupation] @course.school_id = current_user.user_extensions.school_id @course.setup_time = params[:setup_time] diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index f1b917816..9875ec9b7 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -4,64 +4,82 @@
      <%= labelled_form_for @course do |f| %> -
    • - - - - - -
    • -
      -
    • - - - -
    • -
      -
    • - - <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %> - <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %> -
    • -
      -
    • - - - - 显示明码 - +
    • + + + + + +
    • - 学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。 - -
    • - - +
    • + + + +
    • - -
    • - - - (打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。) +
    • + + <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %> + <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %> + +
    • - -
    • - - - (打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表) +
    • + + <%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {} %> + <%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{} %> + 仅针对跨越多个学期的班级,否则不用修改。 +
    • - -
    • +
    • + + + + 显示明码 + +
      + 学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。 +
    • +
    • + + +
      +
    • +
    • + + + (选中后课外用户可见该课程,否则仅对课内成员可见) +
      +
    • +
    • + + + (选中后课外用户可见学生列表,否则仅对课内成员可见) +
      +
    • +
    • id="course_publish_resource" name="course[publish_resource]" type="checkbox" /> - (打钩为"允许学生上传资源",不打钩为"不允许学生上传资源") + (选中后允许学生上传课程资源,否则不允许)
      -
    • -
    • - 提交 - <%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%> -
      -
    • + +
    • + 提交 + <%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%> +
      +
    • <% end%>
    -
    \ No newline at end of file +
    + \ No newline at end of file diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index ae6416c9d..23d0a2a3f 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -2,11 +2,11 @@

    <%= l(:label_course_modify_settings)%>

    @@ -50,6 +50,12 @@ <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"term_selected"} %>
    +
  • + + <%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"end_time_selected"} %> + <%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"end_term_selected"} %> +
  • +
  • @@ -123,15 +129,17 @@
  • diff --git a/config/locales/courses/en.yml b/config/locales/courses/en.yml index fd8ba2366..20d9d112c 100644 --- a/config/locales/courses/en.yml +++ b/config/locales/courses/en.yml @@ -15,7 +15,7 @@ en: label_homework: Task label_course_news: 课程通知 label_main_teacher: 主讲教师 - label_course_term: 开课学期 + label_course_term: 开始学期 label_join_course: 加入 label_exit_course: exit course diff --git a/config/locales/courses/zh.yml b/config/locales/courses/zh.yml index 16d49ea1f..19b979d97 100644 --- a/config/locales/courses/zh.yml +++ b/config/locales/courses/zh.yml @@ -19,7 +19,7 @@ zh: label_course_news: 课程通知 label_course_mail_news_reply: 课程通知回复 label_main_teacher: 主讲教师 - label_course_term: 开课学期 + label_course_term: 开始学期 label_isuue_mail_status: 更新了issue状态! label_join_course: 加入 diff --git a/db/migrate/20151231012634_add_last_term_to_course.rb b/db/migrate/20151231012634_add_last_term_to_course.rb new file mode 100644 index 000000000..1b342eaaf --- /dev/null +++ b/db/migrate/20151231012634_add_last_term_to_course.rb @@ -0,0 +1,17 @@ +class AddLastTermToCourse < ActiveRecord::Migration + def change + add_column :courses, :end_time, :integer + add_column :courses, :end_term, :string + + count = Course.all.count / 30 + 2 + transaction do + for i in 1 ... count do + Course.page(i).per(30).each do |course| + course.end_time = course.time + course.end_term = course.term + course.save + end + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 72ca3c649..ec783d251 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 => 20151229022049) do +ActiveRecord::Schema.define(:version => 20151231012634) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -198,6 +198,7 @@ ActiveRecord::Schema.define(:version => 20151229022049) do t.integer "last_message_id" t.integer "parent_id" t.integer "course_id" + t.integer "org_subfield_id" end add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" @@ -474,6 +475,8 @@ ActiveRecord::Schema.define(:version => 20151229022049) do t.integer "outline", :default => 0 t.integer "publish_resource", :default => 0 t.integer "is_delete", :default => 0 + t.integer "end_time" + t.string "end_term" end create_table "custom_fields", :force => true do |t| @@ -1643,10 +1646,6 @@ ActiveRecord::Schema.define(:version => 20151229022049) do t.string "extra" end - create_table "temp", :id => false, :force => true do |t| - t.integer "id", :default => 0, :null => false - end - create_table "time_entries", :force => true do |t| t.integer "project_id", :null => false t.integer "user_id", :null => false diff --git a/public/javascripts/course.js b/public/javascripts/course.js index a0bce3099..df04d857b 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -119,6 +119,46 @@ function regex_course_class_period() return false; } } +//验证开始学期和结束学期 +function regex_time_term(){ + var obj_time = document.getElementById("time"); + var obj_end_time = document.getElementById("end_time"); + var obj_term = document.getElementById("term"); + var obj_end_term = document.getElementById("end_term"); + var time = obj_time.options[obj_time.selectedIndex]; + var end_time = obj_end_time.options[obj_end_time.selectedIndex]; + var term = obj_term.options[obj_term.selectedIndex]; + var end_term = obj_end_term.options[obj_end_term.selectedIndex]; + if(time.value == end_time.value) { + if(set_term_val(term.value) > set_term_val(end_term.value)) { + $("#course_time_term_notice").html("开始学期不能晚于结束学期"); + $("#course_time_term_notice").show(); + return false; + } else { + $("#course_time_term_notice").html(""); + $("#course_time_term_notice").hide(); + return true; + } + } else if(time.value < end_time.value) { + $("#course_time_term_notice").html(""); + $("#course_time_term_notice").hide(); + return true; + } else { + $("#course_time_term_notice").html("开始学期不能晚于结束学期"); + $("#course_time_term_notice").show(); + return false; + } +} +//学期转换为数字 +function set_term_val(val) { + if(val == "春季学期"){ + return 1; + } else if(val == "夏季学期"){ + return 2; + } else if(val == "秋季学期"){ + return 3; + } +} //验证密码 function regex_course_password() { @@ -145,7 +185,7 @@ function regex_course_password() //提交新建课程 function submit_new_course() { - if(regex_course_name()&®ex_course_class_period()&®ex_course_password()) + if(regex_course_name()&®ex_course_class_period()&®ex_time_term()&®ex_course_password()) { $("#new_course").submit(); } From b380b515c6dfadf747bdcd5b724b62e7b1112e96 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 31 Dec 2015 11:18:06 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E7=BB=9F=E8=AE=A1?= 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 737a1ea69..2e796b2bb 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -273,7 +273,7 @@ class Mailer < ActionMailer::Base @subject = " #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}" mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" #有内容才发,没有不发 - mail :to => user.mail,:subject => subject if has_content + mail :to => user.mail,:subject => @subject if has_content end # 作业截止时间邮件提醒 From 2c5a4f8a13573ba4a40d9df9f56c72323727df01 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 31 Dec 2015 11:36:21 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=92=8C=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E4=BD=9C=E4=B8=9A=E6=97=B6=E7=9A=84=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E5=8C=BF=E8=AF=84=E6=94=B9=E4=B8=BA=E7=A6=81=E7=94=A8=E5=8C=BF?= =?UTF-8?q?=E8=AF=84=EF=BC=8C=E9=BB=98=E8=AE=A4=E4=B8=8D=E9=80=89=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/views/users/_user_homework_form.html.erb | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 46362c2d3..d345fba5f 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -63,7 +63,7 @@ class HomeworkCommonController < ApplicationController end @homework.end_time = params[:homework_common][:end_time] || Time.now @homework.course_id = params[:course_id] - @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 1 + @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0 homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 78d8e2b46..85d42e189 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -522,7 +522,7 @@ class UsersController < ApplicationController else homework.publish_time = params[:homework_common][:publish_time] end - homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 1 + homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0 homework.homework_type = params[:homework_type].to_i || 1 homework.late_penalty = 10 homework.teacher_priority = 1 diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 29be69a23..d145dab90 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -5,9 +5,9 @@ @@ -53,8 +53,8 @@
    <% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %>
    - - 启用匿评 + + 禁用匿评
    <% end %>
    From 63b7330cd874ba2f4125473b2f1e99083665cc9a Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 31 Dec 2015 11:39:00 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E4=B8=AD=E7=BB=9F=E8=AE=A1=E6=95=B0?= 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 2e796b2bb..318de2942 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -155,7 +155,6 @@ 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)}]" date_from = "#{date_from} 17:59:59" date_to = "#{date_to} 17:59:59" # 生成token用于直接点击登录 @@ -270,6 +269,7 @@ class Mailer < ActionMailer::Base total_count = @issues.count + @issues_journals.count + @course_messages.count + @project_messages.count + @course_news.count + @course_news_comments.count + @project_news.count + @project_news_comments.count + @project_attachments.count + @course_journal_messages.count + @user_journal_messages.count + @project_journal_messages.count + @forums.count + @memos.count + @attachments.count + @bids.count + @wiki_contents.count + subject = "[ #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}]" @subject = " #{user.show_name}#{l(:label_day_mail_first)}#{total_count}#{l(:label_day_mail_last)}" mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" #有内容才发,没有不发 From 806e4caf5a368026afe9db8bc8610ca95604bdab Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 31 Dec 2015 13:26:28 +0800 Subject: [PATCH 09/14] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=A0=8F=E7=9B=AE=E5=8A=9F=E8=83=BD=EF=BC=9B?= =?UTF-8?q?2.=E6=9C=AA=E7=99=BB=E5=BD=95=E6=83=85=E5=86=B5=EF=BC=8C?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E9=83=A8=E5=88=86=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 10 ++ app/helpers/organizations_helper.rb | 11 ++- app/views/layouts/base_org.html.erb | 28 +++--- .../_org_left_subfield_list.html.erb | 57 ++++++----- .../organizations/_show_home_page.html.erb | 8 +- .../organizations/_subfield_list.html.erb | 95 +++++++++++-------- .../organizations/hide_org_subfield.js.erb | 2 + app/views/organizations/setting.html.erb | 3 +- app/views/organizations/show.html.erb | 2 +- .../organizations/show_org_subfield.js.erb | 2 + config/routes.rb | 2 + ...0151231023235_add_hide_to_org_subfields.rb | 5 + ...1231023610_add_records_to_org_subfields.rb | 9 ++ db/schema.rb | 8 +- 14 files changed, 153 insertions(+), 89 deletions(-) create mode 100644 app/views/organizations/hide_org_subfield.js.erb create mode 100644 app/views/organizations/show_org_subfield.js.erb create mode 100644 db/migrate/20151231023235_add_hide_to_org_subfields.rb create mode 100644 db/migrate/20151231023610_add_records_to_org_subfields.rb diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 466fbd8e3..dabf45da8 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -281,4 +281,14 @@ class OrganizationsController < ApplicationController format.js end end + + def hide_org_subfield + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @org_subfield.update_attribute(:hide, 1) + end + + def show_org_subfield + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @org_subfield.update_attribute(:hide, 0) + end end diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 607d2af5c..69c355313 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -17,6 +17,15 @@ module OrganizationsHelper s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" ) end - + def get_default_name field + case field.name + when 'activity' then + return '动态' + when 'course' then + return '课程' + when 'project' then + return '项目' + end + end end diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index 83bcb4dc9..8599ad750 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -120,19 +120,21 @@
    -
    - <%= link_to '文章', organization_org_document_comments_path(@organization) %>  - <% if User.current.logged? %> - ( - <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> - ) - <% end %> -  |  - <%= link_to '成员', members_organization_path(@organization.id) %>  - <% if User.current.logged? %> - (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>) - <% end %> -
    + <% if User.current.logged? %> +
    + <%= link_to '文章', organization_org_document_comments_path(@organization) %>  + <% if User.current.logged? %> + ( + <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> + ) + <% end %> +  |  + <%= link_to '成员', members_organization_path(@organization.id) %>  + <% if User.current.logged? %> + (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>) + <% end %> +
    + <% end %>
    <%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %> diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index d11919927..42ebd240a 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -1,31 +1,38 @@ -
    +<% org_activity_field = organization.org_subfields.where('field_type="default" and name="activity" and field_type="default"').first %> +<% org_course_field = organization.org_subfields.where('field_type="default" and name="course" and field_type="default"').first %> +<% org_project_field = organization.org_subfields.where('field_type="default" and name="project" and field_type="default"').first %> +
    <%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %>
    -
    - 项目 - <% if User.current.logged? and User.current.admin_of_org?(organization) %> - <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> - <% end %> -
    -
    -
      - - <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> -
    -
    -
    - 课程 - <% if User.current.logged? and User.current.admin_of_org?(organization) %> - <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> - <% end %> -
    -
    -
      - <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> -
    -
    -<% organization.org_subfields.each do |field| %> +
    + 项目 + <% if User.current.logged? and User.current.admin_of_org?(organization) %> + <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> + <% end %> +
    +
    +
      + + <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> +
    +
    +
    +
    +
    + 课程 + <% if User.current.logged? and User.current.admin_of_org?(organization) %> + <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> + <% end %> +
    +
    +
      + <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> +
    +
    +
    +<% organization.org_subfields.where("field_type != 'default'").each do |field| %> +
    <% if field.field_type == "Post" %> <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %> <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%> diff --git a/app/views/organizations/_show_home_page.html.erb b/app/views/organizations/_show_home_page.html.erb index 76ee84e69..c80c52b2f 100644 --- a/app/views/organizations/_show_home_page.html.erb +++ b/app/views/organizations/_show_home_page.html.erb @@ -1,16 +1,16 @@ -
    +
    - + <% if User.current.logged? %>
    <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>
    - + <% end %> <% unless document.content.blank? %>
    <%= document.content.html_safe %>
    <% end %> - <% if params[:show_homepage].nil? %> + <% if params[:show_homepage].nil? and User.current.logged? %>
    发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
    diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index 642a5ffd0..8a092f7e2 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -1,47 +1,47 @@ +
      +
    • 已有栏目
    • +
    • 状态
    • +
    • 类型
    • +
      +
    -
      -
    • 已有栏目
    • -
    • 状态
    • -
    • 类型
    • -
      -
    -
      -
    • 动态
    • -
    • 默认
    • -
    • 默认
    • -
      -
    -
      -
    • 项目
    • -
    • 默认
    • -
    • 默认
    • -
      -
    -
      -
    • 课程
    • -
    • 默认
    • -
    • 默认
    • -
      -
    - <% subfields.each do |field| %> +<% default_fields.each do |field| %> + <% name = get_default_name(field) %>
      -
    • <%= field.name %>
    • -
    • 新增
    • -
    • <%= field.field_type == "Post" ? "帖子":"资源" %>
    • - <%= link_to "删除",org_subfield_path(field), :method => 'delete',:remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr5" %> - 编辑 -
      +
    • <%= name %>
    • +
    • 默认
    • +
    • 默认
    • + <%= field.hide==0?"设为隐藏":"设为显示" %> +
    - <% end %> +<% end %> - \ No newline at end of file + } + + function hide(content, id){ + if (content.text() == '设为隐藏') + $.ajax({ + url: "/organizations/hide_org_subfield?org_subfield_id=" + id, + type: "post" + }); + else + $.ajax({ + url: "/organizations/show_org_subfield?org_subfield_id=" + id, + type: "post" + }); + } + \ No newline at end of file diff --git a/app/views/organizations/hide_org_subfield.js.erb b/app/views/organizations/hide_org_subfield.js.erb new file mode 100644 index 000000000..09ed3c280 --- /dev/null +++ b/app/views/organizations/hide_org_subfield.js.erb @@ -0,0 +1,2 @@ +$("#hide_<%= @org_subfield.id %>").text("设为显示"); +$("#org_subfield_<%= @org_subfield.id %>").css("display", "none"); \ No newline at end of file diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 4fc20653a..3058d03a8 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -107,7 +107,8 @@
    - <%= render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields } %> + <%= render :partial => 'organizations/subfield_list', :locals => {:default_fields => @organization.org_subfields.where("field_type='default'"), + :subfields => @organization.org_subfields.where("field_type != 'default'") } %>
    diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index a79271add..78fb12279 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -16,7 +16,7 @@ .homepagePostReplyInputContainer .ke-inline-block {display: none;} .homepagePostReplyInputContainer .ke-container {float: left;} -<% if params[:show_homepage].nil? %> +<% if params[:show_homepage].nil? and User.current.logged? %>
    <%= @org_subfield.nil? ? "最新动态":"#{@org_subfield.name}" %>
    <% if params[:org_subfield_id].nil? %> diff --git a/app/views/organizations/show_org_subfield.js.erb b/app/views/organizations/show_org_subfield.js.erb new file mode 100644 index 000000000..165b07afd --- /dev/null +++ b/app/views/organizations/show_org_subfield.js.erb @@ -0,0 +1,2 @@ +$("#hide_<%= @org_subfield.id %>").text("设为隐藏"); +$("#org_subfield_<%= @org_subfield.id %>").css("display", "block"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 9326ac61e..2d195f0d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -51,6 +51,8 @@ RedmineApp::Application.routes.draw do collection do get 'check_uniq' get 'autocomplete_search' + post 'hide_org_subfield' + post 'show_org_subfield' end resources :org_document_comments do member do diff --git a/db/migrate/20151231023235_add_hide_to_org_subfields.rb b/db/migrate/20151231023235_add_hide_to_org_subfields.rb new file mode 100644 index 000000000..57dd5cb68 --- /dev/null +++ b/db/migrate/20151231023235_add_hide_to_org_subfields.rb @@ -0,0 +1,5 @@ +class AddHideToOrgSubfields < ActiveRecord::Migration + def change + add_column :org_subfields, :hide, :integer, :default => 0 + end +end diff --git a/db/migrate/20151231023610_add_records_to_org_subfields.rb b/db/migrate/20151231023610_add_records_to_org_subfields.rb new file mode 100644 index 000000000..61fb760da --- /dev/null +++ b/db/migrate/20151231023610_add_records_to_org_subfields.rb @@ -0,0 +1,9 @@ +class AddRecordsToOrgSubfields < ActiveRecord::Migration + def change + Organization.all.each do |org| + OrgSubfield.create(:organization_id => org.id, :name => 'activity', :field_type => 'default') + OrgSubfield.create(:organization_id => org.id, :name => 'course', :field_type => 'default') + OrgSubfield.create(:organization_id => org.id, :name => 'project', :field_type => 'default') + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 72ca3c649..6e3a62182 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 => 20151229022049) do +ActiveRecord::Schema.define(:version => 20151231023610) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -198,6 +198,7 @@ ActiveRecord::Schema.define(:version => 20151229022049) do t.integer "last_message_id" t.integer "parent_id" t.integer "course_id" + t.integer "org_subfield_id" end add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" @@ -1209,9 +1210,10 @@ ActiveRecord::Schema.define(:version => 20151229022049) do t.integer "organization_id" t.integer "priority" t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "field_type" + t.integer "hide", :default => 0 end create_table "organizations", :force => true do |t| From 22be66f85ca7f016a4bb31497d0348ada31fe7cf Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 31 Dec 2015 14:00:33 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E8=AF=BE=E7=A8=8B/=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=B8=96=E5=AD=90=E4=B8=AD=EF=BC=8C=E7=94=A8=E6=88=B7=E5=9C=A8?= =?UTF-8?q?=E7=99=BB=E9=99=86=E6=83=85=E5=86=B5=E4=B8=8B=E5=8D=B3=E5=8F=AF?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=B8=96=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/messages/_course_show.html.erb | 38 ++++++++++++----------- app/views/messages/_project_show.html.erb | 22 +++++++------ 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 294f9b7d4..c3278a209 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -37,28 +37,30 @@ <%= link_to image_tag(url_to_avatar(@topic.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@topic.author) %>
    - <% if @topic.author.id == User.current.id%> + <% if User.current.logged? %>
    - <% if @topic.author.id == User.current.id%> + <% if User.current.logged? %>