diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e12d4886a..7d26b2eca 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -615,6 +615,10 @@ class CoursesController < ApplicationController end def show + #更新创建课程消息状态 + create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0) + create_course_messages.update_all(:viewed => true) + course_activities = @course.course_activities @canShowRealName = User.current.member_of_course? @course @page = params[:page] ? params[:page].to_i + 1 : 0 diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 6271a6832..6bb61e6a1 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -81,8 +81,12 @@ class MembersController < ApplicationController user_ids.each do |user_id| members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id) user_grades << UserGrade.new(:user_id => user_id, :project_id => @project.id) - ## added by nie + #给新成员发送加入项目的消息,发送者id放在ForgeMessage的forge_message_id字段中, + #forge_message_type设置为JoinProject + forge_join = ForgeMessage.new(:user_id =>user_id, :forge_message_id=>User.current.id,:project_id => @project.id,:forge_message_type=>"JoinProject", :viewed => false) + forge_join.save + ## added by nie if (params[:membership][:role_ids]) role = Role.find(params[:membership][:role_ids][0]) project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id) if role.allowed_to?(:is_manager) @@ -301,6 +305,7 @@ class MembersController < ApplicationController grade.destroy end end + ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id) end respond_to do |format| format.html { redirect_to_settings_in_projects } diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 90974b376..d26e465ba 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -534,6 +534,14 @@ class ProjectsController < ApplicationController project_invite_messages.each do |project_invite_message| project_invite_message.update_attribute(:viewed, true) end + #更新被加入项目消息的viewed字段 + join_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "JoinProject") + join_project_messages.each do |join_project| + join_project.update_attribute(:viewed, true) + end + #更新被移出项目消息的viewed字段 + remove_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "RemoveFromProject") + remove_project_messages.update_all(:viewed => true) end def message_invite(message_id, key) diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 062b0fa34..85bd6a784 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -5,14 +5,18 @@ class SchoolController < ApplicationController def upload uploaded_io = params[:logo] school_id ||= params[:id] + s1 = School.find(school_id) unless uploaded_io.nil? File.open(Rails.root.join('public', 'images', 'school', school_id.to_s+'.png'), 'wb') do |file| file.write(uploaded_io.read) end - s1 = School.find(school_id) + s1.logo_link = '/images/school/'+school_id.to_s+'.png' - s1.save + end + s1.name = params[:name] unless params[:name].blank? + s1.province = params[:province] unless params[:province].blank? + s1.save redirect_to admin_schools_url(:school_name => params[:school_name]) end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 85c01bcbd..9393339a8 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -62,6 +62,9 @@ class StudentWorkController < ApplicationController journals_for_teacher.each do |journal_for_teacher| journal_for_teacher.update_attributes(:viewed => true) end + #不能参与作业匿评消息状态更新 + no_evaluation = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "NoEvaluation", 0) + no_evaluation.update_all(:viewed => true) # 作品留言 # 消息end #设置作业对应的forge_messages表的viewed字段 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d25dd6fd2..ef3210719 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -128,12 +128,12 @@ class UsersController < ApplicationController #课程相关消息 when 'homework' - @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage') and user_id =?", @user).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','NoEvaluation') and user_id =?", @user).order("created_at desc") when 'course_message' @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") when 'course_news' # 课程通知包含发布的通知和回复的通知 - @message_alls = CourseMessage.where("course_message_type =? or course_message_type =?", "News", "Comment").where("user_id =?", @user).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type in (?, ? ,?)", "News", "Comment", "Course").where("user_id =?", @user).order("created_at desc") when 'poll' @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") @@ -145,7 +145,7 @@ class UsersController < ApplicationController when 'forge_news' @message_alls = ForgeMessage.where("forge_message_type in (?,?) and user_id =?", "News", "Comment", @user).order("created_at desc") when 'apply' - @message_alls = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'AppliedProject') and user_id =?", @user).order("created_at desc") + @message_alls = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'AppliedProject', 'JoinProject', 'RemoveFromProject') and user_id =?", @user).order("created_at desc") #贴吧消息 when 'forum' diff --git a/app/models/attachment.rb b/app/models/attachment.rb index f7fb9b1aa..0f728fc00 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -442,7 +442,12 @@ class Attachment < ActiveRecord::Base def self.attach_filesex(obj, attachments,attachment_type) - result = obj.save_attachmentsex(attachments, User.current,attachment_type) + if obj.is_public? + public_status = true + else + public_status = false + end + result = obj.save_attachmentsex(attachments, User.current,attachment_type, public_status) obj.attach_saved_attachments result end diff --git a/app/models/course.rb b/app/models/course.rb index 501d958e4..46599dbfc 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -50,7 +50,7 @@ class Course < ActiveRecord::Base validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/ validates_length_of :description, :maximum => 10000 before_save :self_validate - after_create :create_board_sync, :act_as_course_activity + after_create :create_board_sync, :act_as_course_activity, :act_as_course_message before_destroy :delete_all_members safe_attributes 'extra', @@ -321,6 +321,10 @@ class Course < ActiveRecord::Base self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id) end + #创建课程后,给该用户发送消息 + def act_as_course_message + self.course_messages << CourseMessage.new(:user_id => self.tea_id, :course_id => self.id, :viewed => false) + end #项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题 #def name # read_attribute('name') || Project.find_by_identifier(self.extra).try(:name) diff --git a/app/models/student_work.rb b/app/models/student_work.rb index cd4d81a32..700613792 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -12,6 +12,7 @@ class StudentWork < ActiveRecord::Base before_destroy :delete_praise before_save :set_program_score, :set_src + after_create :act_as_message acts_as_attachable def delete_praise @@ -136,4 +137,11 @@ class StudentWork < ActiveRecord::Base end end end + + def act_as_message + if self.created_at > self.homework_common.end_time + 1 + CourseMessage.create(:user_id => self.user_id, :course_id => self.homework_common.course_id, + :course_message_id => self.id, :course_message_type => 'NoEvaluation',:viewed => false) + end + end end diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb index 8e1e1c421..01e04dcfd 100644 --- a/app/views/courses/_join_private_course.html.erb +++ b/app/views/courses/_join_private_course.html.erb @@ -71,7 +71,7 @@ 密      码: -
  • +
  • 身      份: <%= image_tag(@school.logo_link, id: "avatar_image", :class=>"school_avatar")%> - 上传图片 + 上传图片 <%= file_field_tag 'logo',:style => "display:none;", :id => "file", :onchange => "showPreview(this)"%>
    +
    学校名称:
    +
    学校省份: + +
    - <%= submit_tag('上传') %> - <%= submit_tag('取消') %> + + + <%#= submit_tag('提交',:class=>'mr5') %> + <%#= submit_tag('取消') %>
    <% end %> + diff --git a/app/views/users/_selector_for_messages.html.erb b/app/views/users/_selector_for_messages.html.erb index e7884fc60..66f9ec7a3 100644 --- a/app/views/users/_selector_for_messages.html.erb +++ b/app/views/users/_selector_for_messages.html.erb @@ -19,7 +19,7 @@
  • <%= link_to "项目任务", user_message_path(User.current, :type => 'issue'), :class => "homepageTypePTask postTypeGrey" %>
  • <%= link_to "项目讨论", user_message_path(User.current, :type => 'forge_message'), :class => "homepagePostTypeForum postTypeGrey" %>
  • <%= link_to "项目新闻", user_message_path(User.current, :type => 'forge_news'), :class => "homepageTypePNews postTypeGrey" %>
  • -
  • <%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "homepageTypeUApply postTypeGrey" %>
  • +
  • <%= link_to "加入项目", user_message_path(User.current, :type => 'apply'), :class => "homepageTypeUApply postTypeGrey" %>
  • @@ -27,9 +27,9 @@
  • diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index d4b61e966..7f535f2ec 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -37,7 +37,7 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil? %> + <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil? && !ma.course_message.nil? %> <% end %> <% end %> + + <% if ma.course_message_type == "NoEvaluation" %> + + <% end %> + + <% if ma.course_message_type == "Course" %> + + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb index b93122bd2..9a9bec10d 100644 --- a/app/views/users/_user_message_forge.html.erb +++ b/app/views/users/_user_message_forge.html.erb @@ -20,6 +20,72 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> + + <% if ma.forge_message_type == "JoinProject" %> + + <% end %> + + <% if ma.forge_message_type == "RemoveFromProject" %> + + <% end %> <% if ma.forge_message_type == "ProjectInvite" %> <% inviter = User.find(ma.forge_message_id) %> @@ -29,7 +95,7 @@
  • <%=link_to inviter, user_path(inviter), :class => "newsBlue homepageNewsPublisher" %> - '>邀请你加入项目 + '>邀请你加入项目:
  • <% if ma.user.member_of?(ma.project) %>
  • diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index 377f2b112..9378013f9 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -93,13 +93,13 @@ module Redmine end end - def save_attachmentsex(attachments, author=User.current,attachment_type) + def save_attachmentsex(attachments, author=User.current,attachment_type, public_status) @curattachment_type = attachment_type - result = save_attachments(attachments,author) + result = save_attachments(attachments,author, public_status) result end - def save_attachments(attachments, author=User.current) + def save_attachments(attachments, author=User.current,public_status) # 清除临时文件 if attachments tempAttach = attachments[:dummy] @@ -140,11 +140,16 @@ module Redmine end end end - if a && !attachment['is_public_checkbox'] + if public_status + if a && !attachment['is_public_checkbox'] + a.is_public = false + elsif a && attachment['is_public_checkbox'] + a.is_public = true + end + else a.is_public = false - elsif a && attachment['is_public_checkbox'] - a.is_public = true end + set_attachment_public(a) if a next unless a a.description = attachment['description'].to_s.strip diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index a08c7760b..6c6227ed4 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -8,6 +8,14 @@ h3, .wiki h2 {font-size: 15px; padding-left: 5px} h4, .wiki h3 {font-size: 13px;} h4 {border-bottom: 1px dotted #bbb;} li{list-style-type:none;} + +/*Tim 151019*/ +.schoolName {border:1px solid #dddddd; outline: none; width: 180px; height: 22px;} +.provinceSelect {border: 1px solid #dddddd; outline: none; color: #888888;} +.submit_btn {background-color: #269ac9; color: #ffffff; padding: 2px 5px; border: none; border-radius: 3px; cursor: pointer;} +.submit_btn:hover {background-color:#297fb8;} +.cancel_btn {background-color: #c1c1c1; color: #ffffff; padding: 2px 5px; border: none; border-radius: 3px; cursor: pointer;} +.cancel_btn:hover {background-color:#656565; } /*huang*/ .hwork_input_news{ border:1px solid #64bdd9; height:22px; width:594px; background:#fff; margin-bottom:10px; padding:5px;} @@ -2805,7 +2813,7 @@ img,embed{max-width: 100%;} img.school_avatar { background: rgb(245, 245, 245); padding: 4px; - border: 1px solid #e5dfc7; + border: 1px solid #eaeaea; float: left; display: block; width: 100px; diff --git a/public/stylesheets/images/post_image_list.png b/public/stylesheets/images/post_image_list.png index 07636288d..001fd5df0 100644 Binary files a/public/stylesheets/images/post_image_list.png and b/public/stylesheets/images/post_image_list.png differ diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index 5a9ea3830..05c9ca244 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -1874,9 +1874,9 @@ div.tableline{ font-size: 12px; color: #fff; padding: 3px 9px; - background: #15bccf; + background: #269ac9; border-radius: 4px; - border: 1px solid #15bccf; + border: 1px solid #269ac9; box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.2), 0px 0px 2px rgb(255, 255, 255) inset; text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2), 0px 1px 0px rgb(255, 255, 255); cursor: pointer;