From 7ea0fac7741aa7bd154b5abad1014d5d2c7527f4 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 14 Aug 2015 15:48:23 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=82=E5=8F=91=E5=B8=83=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92=202=E3=80=81=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E9=97=AE=E5=8D=B7=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92?= =?UTF-8?q?=203=E3=80=81=E6=B6=88=E6=81=AF=E7=95=8C=E9=9D=A2=EF=BC=88?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E6=88=90=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/models/homework_common.rb | 15 +- app/models/poll.rb | 16 +- app/views/users/user_messages.html.erb | 182 +++++++----------- .../stylesheets/images/resource_icon_list.png | Bin 0 -> 2476 bytes public/stylesheets/public_new.css | 151 +++++++++++++++ spec/models/course_message_spec.rb | 5 + 7 files changed, 256 insertions(+), 115 deletions(-) create mode 100644 public/stylesheets/images/resource_icon_list.png create mode 100644 spec/models/course_message_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f2b5b1af0..1579a23c4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -98,7 +98,7 @@ class UsersController < ApplicationController # 用户消息 def user_messages - #@user_messges = User.current.forge_messages + @user_messges = @user.forge_messages respond_to do |format| format.html{render :layout=>'base_users_new'} format.api diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 5fe01db96..217c7d770 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -15,12 +15,14 @@ class HomeworkCommon < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动 # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy + # 课程消息 + has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy acts_as_attachable acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" }, :description => :description, :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} - after_create :act_as_activity, :send_mail, :act_as_course_activity + after_create :act_as_activity, :send_mail, :act_as_course_activity, :act_as_course_message after_destroy :delete_kindeditor_assets def act_as_activity @@ -34,6 +36,17 @@ class HomeworkCommon < ActiveRecord::Base end end + #课程作业消息记录 + def act_as_course_message + if self.course + self.course.members.each do |m| + if m.user_id != self.user_id + self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) + end + end + end + end + #删除对应的图片 def delete_kindeditor_assets delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON diff --git a/app/models/poll.rb b/app/models/poll.rb index 34a381246..c5a6a294d 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -10,7 +10,9 @@ class Poll < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy - after_create :act_as_activity, :act_as_course_activity + # 课程消息 + has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy + after_create :act_as_activity, :act_as_course_activity, :act_as_course_message acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" }, :description => :polls_description, @@ -35,4 +37,16 @@ class Poll < ActiveRecord::Base self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id) end end + + # 发布问卷,出了发布者外,其他人都能收到消息通知 + def act_as_course_message + if self.polls_type == "Course" + Course.find(self.polls_group_id).members.each do |m| + if m.user_id != self.user_id + self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.polls_group_id, :viewed => false) + end + end + end + end + end diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 463381db8..e7fcb790a 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -1,117 +1,75 @@ -
- - - 新建课程 - -
- - -
- diff --git a/public/stylesheets/images/resource_icon_list.png b/public/stylesheets/images/resource_icon_list.png new file mode 100644 index 0000000000000000000000000000000000000000..1b5bc6f58c73e58545a57fc4e29463d4ef7a0e9b GIT binary patch literal 2476 zcmaJ@eLR!>8sFo!6rNP_QkqFh*=%gt3}Iv~WT|;gv)vfBd$zIBybtNcOG3~2WX@BL zULGu+h+~m@Bzoc$oxCM_ColUDAy4PrD|(*K`5fo|T=)I^UBA!w`d-)XdtHCr*$2J$ zX=@p2!C)|LvImI@t=`a^yGjH4HVkB9pv6$&<|jA=h6#jp9sqM@f}sGM%%+C}RDjNm zk7)ylFqkTW`FS3MyMjCbjz!v7F|5&OI1YzI+hTDz^lmuD8jV3&Lx!_L+Y+!i0%i|< z=|Mo*c+4;YmE^vZ3-TNg5ds01fIu^ zW2|l6&{zz9kLz+Q31q~w0ghlfmib4l-HNfwQDAeS%p`!viUXMLJdh3ldSwD@S z@-4+OSFQ!OVk`RgqJ zIcgIryJ8*OHKtML-Wtnx^NEmA=Ueeqm3;;S-2FaqbClK=_ugx4OnZ&x7|LUIX2y+` ziN5%BN4w4G(GS+wuHS6=$D>_=hp*7zm=W(nc4<|v!jg8_zT?B>q|=6CyrM;MRbe-0 zKW8P1J#?t+tzN0kdy~>rvujnI6eD#N8Qwec*bW0)22L63vU06v?5i6-&A)5NQaaN+ zC9Wm3jv)d8KR10EroDcYiW1L7uGF@haFaJ--Lae?H>%{kI+UlUg&p-#2? zoy@!xc3Xd({KF^M{sDcte63@~E2918b-xFNeo2+a30mR|GWs5+P-b=5)7zT^_djqV z%R*?;S*D+oI#>Tpe&6kNX=Bngk4`ZW`R+ZN=0*#2`m5<;a{n3ahEjFA=`|?@kqg_1 zS{?0kx-8*`ifz{Fj`#BP48knbU@F`y7k?d;%R9xX=`YN2*5!HeqD@Jxpp}lW|Y zY>dA!dlaMgT~BTADO`wZ#r)XKLOVI7JOcL5SFiJjADQ(%7R_jiWsRk0Hp)%Y8ux~6 zSD+oirmGHf#rc)BgR?9Hg3-~D1Jgm|%QnUe0>b$0LTTTnEf03j?JMo296xtC+<7Fv z!~*R#6qg(q?#-Z7YlX`Xv$jQ z@mnAF9=mc{Ui|)Jn2LOFtE+0HM3z3;T@|Ep9<{!tvbGAS2ow$>_UGV=JX)Ve9%!`r47QmY$I58QOnvUUxcANK6Vjk_>h zpCa(Xn2n7-6w^0`*G}Z5Po~Ih<65p#tbQ3U*eI>oLR6c?nTZcvJxh^FytZ27q^P06 z^sSO&qXw_*p8b1Sy2T&-@~EPnE%V<@55Gv9 zDu21kTR)*(fBr&uY_GrKV)dH0RsmYUXR^)YtIa>&y|JpXy}tOUu-s5y`?)fEp;7-G z$}2aMcIPucqo(XmNTpOg{DS=R(6eEd&mv`L;?a$u7zZ7TlSF~Zg&FaLx5)k6@HkRs zLcOl`S51^+UhLgHRBv&+b<>sSPm0>`m4#k?QHos)0UA&E;`<3R9f|zzzsSqN!}2DF z3dj6eGiBqkLnRSohCMEQ#%~5|ZC+1~=3wM4gl1hzr@P@G?Y=blxsgKX5qrC}r=-04 z li > a { + display: block; + padding: 3px 20px; + clear: both; + font-weight: normal; + line-height: 1.5; + color:#616060; + white-space: nowrap; +} +.dropdown-menu > li > a:hover{ + color: #ffffff; + text-decoration: none; + background-color: #64bdd9; + outline:none; +} + +/*发送资源弹窗*/ +/*.resourceShareContainer {width:100%; height:100%; background:#666; filter:alpha(opacity=50); opacity:0.5; -moz-opacity:0.5; position:absolute; left:0; top:0; z-index:-999;}*/ +.resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;} +.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;} +.resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;} +.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;} +.resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;} +.searchResourcePopup {border:none; outline:none; background-color:#ffffff; width:184px; height:25px; padding-left:10px; display:inline-block; float:left;} +.searchIconPopup{width:31px; height:25px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -18px no-repeat; display:inline-block; float:left;} +.courseSend {width:260px; height:15px; line-height:15px; margin-bottom:10px;} +.courseSendCheckbox {padding:0px; margin:0px; width:12px; height:12px; margin-right:10px; display:inline-block; margin-top:2px;} +.sendCourseName {font-size:12px; color:#5f6060;} +.courseSendSubmit {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#64bdd9; margin-right:25px; float:left;} +.courseSendCancel {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#c1c1c1; float:left} +a.sendSourceText {font-size:14px; color:#ffffff;} + +/*上传资源弹窗*/ +.resourceUploadPopup {width:400px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} +.uploadText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;} +.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative;} +.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#64bdd9; border-radius:3px; float:left; margin-right:12px;} +a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;} +.chooseFile {color:#ffffff; display:block; margin-left:32px;} +.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;} +.uploadResourceName {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444; margin-bottom:2px;} +.uploadResourceIntr2 {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444;} +.uploadType {margin:10px 0; border:1px solid #e6e6e6; width:100px; height:30px; outline:none; font-size:12px; color:#888888;} +.uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;} + + +/*新个人主页框架css*/ +.navContainer {width:100%; margin:0 auto; background-color:#15bccf;} +.homepageContentContainer {width:100%; margin:0 auto; background-color:#eaebed;} +.homepageContent {width:1000px; background-color:#eaebed; margin:0 auto;} +.navHomepage {width:1000px; height:54px; background-color:#15bccf; margin:0 auto;} +.navHomepageLogo {width:60px; height:54px; line-height:54px; vertical-align:middle; margin-left:2px; margin-right:40px;} +.navHomepageMenu {margin-right:40px;display:inline-block;height:54px; line-height:54px; vertical-align:middle;} +.navHomepageSearchBox {width:380px; border:none; outline:none; height:32px; margin-top:11px; background-color:#ffffff;} +.navHomepageSearchInput {width:345px; height:32px; outline:none; border:none; float:left; padding-left:5px;; margin:0;} +.homepageSearchIcon {width:30px; height:32px; background:url(../images/nav_icon.png) -8px 3px no-repeat; float:left;} +a.homepageSearchIcon:hover {background:url(../images/nav_icon.png) -49px 3px no-repeat;} +.navHomepageNews {width:30px; display:block; float:right; margin-top:12px; position:relative;} +.homepageNewsIcon {background:url(../images/nav_icon.png) -5px -85px no-repeat; width:30px; height:29px; display:block;} +.newsActive {width:10px; height:10px; border-radius:50%; border:2px solid #ffffff; background-color:#ff0000; position:absolute; left:17px; top:5px;} +.navHomepageProfile {width:65px; display:block; float:right; margin-top:8px; margin-left:33px;} +.homepageProfileMenuIcon {background:url(../images/nav_icon.png) -8px -175px no-repeat; width:20px; height:25px; float:left; margin-top:15px;} +a.homepageProfileMenuIcon:hover {background:url(../images/nav_icon.png) -8px -175px no-repeat; width:12px; height:12px; float:left;} +.homepageLeft {width:240px; float:left; margin-right:10px;} +.homepageRight {width:750px; float:left;} +.homepagePortraitContainer {width:238px; height:348px; border:1px solid #dddddd; background-color:#ffffff; margin-top:15px;} +.homepagePortraitImage {width:208px; height:208px; margin:15px 16px 14px 16px;} +.homepageFollow {} +.homepageEditProfile {} +.homepageImageName {font-size:16px; color:#484848; margin-left:15px; display:inline-block; margin-right:8px;} +.homepageImageSex {float:left; top:116px; left:5px; width:14px; height:14px; display:inline-block;} +.homepageSignature {font-size:12px; color:#888888; margin-left:15px; margin-top:5px; margin-bottom:15px;} +.homepageImageBlock {margin:0 26px; float:left; text-align:center; display:inline-block;} +.homepageImageNumber {font-size:12px; color:#484848;} +.homepageImageText {width:26px; font-size:12px; color:#888888;} +.homepageVerDiv {height:28px; vertical-align:middle; width:1px; float:left; display:inline-block; background-color:#d1d1d1; margin-top:3px;} +.homepageLeftMenuContainer {width:238px; border:1px solid #dddddd; border-bottom:none; background-color:#ffffff; margin-top:10px;} +.homepageLeftMenuBlock {border-bottom:1px solid #dddddd; height:50px; line-height:50px; vertical-align:middle;} +a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} +.homepageLeftLabelContainer {width:238px; border:1px solid #dddddd; background-color:#ffffff; margin-top:10px;} +.homepageRightBanner {} +.newsType {width:60px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-40px; font-size:12px; color:#888888; display:none; line-height:2;} +.homepageRightBlock {} +.homepageNewsList {width:710px; height:39px; line-height:39px; vertical-align:middle; border-bottom:1px dashed #eaeaea; margin:0 auto;} +.homepageNewsPublisher {width:95px; font-size:12px; color:#15bccf; display:block;} +.homepageNewsType {width:95px; font-size:12px; color:#888888; display:block;} +.homepageNewsContent {width:445px; font-size:12px; color:#4b4b4b; display:block;} +.homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;} +a.homepageWhite {color:#ffffff;} +a.homepageWhite:hover {color:#a1ebff} +a.newsGrey {color:#4b4b4b;} +a.newsGrey:hover {color:#000000;} +a.newsBlue {color:#15bccf;} +a.newsBlue:hover {color:#0781b4;} \ No newline at end of file diff --git a/spec/models/course_message_spec.rb b/spec/models/course_message_spec.rb new file mode 100644 index 000000000..cddcdc0a1 --- /dev/null +++ b/spec/models/course_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CourseMessage, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end