Merge branch 'dev_hjq' into szzh
This commit is contained in:
commit
b75247177c
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the SystemMessages controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -79,6 +79,11 @@ class AdminController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 系统消息
|
||||
def messages
|
||||
@admin_messages = SystemMessage.new
|
||||
end
|
||||
|
||||
def plugins
|
||||
@plugins = Redmine::Plugin.all
|
||||
end
|
||||
|
|
|
@ -114,8 +114,10 @@ class IssuesController < ApplicationController
|
|||
def show
|
||||
# 当前用户查看指派给他的缺陷消息,则设置消息为已读
|
||||
query = @issue.forge_messages
|
||||
if User.current.id == @issue.assigned_to_id
|
||||
query.update_all(:viewed => true)
|
||||
query.each do |m|
|
||||
if m.user_id == User.current.id
|
||||
m.update_attribute(:viewed, true)
|
||||
end
|
||||
end
|
||||
# 缺陷状态更新
|
||||
query_journals = @issue.journals
|
||||
|
|
|
@ -322,6 +322,12 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def settings
|
||||
# 修改查看消息状态
|
||||
applied_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =? and viewed =?", User.current.id, @project, "AppliedProject", 0)
|
||||
applied_messages.each do |applied_message|
|
||||
applied_message.update_attributes(:viewed => true)
|
||||
end
|
||||
# end
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@issue_category ||= IssueCategory.new
|
||||
@member ||= @project.members.new
|
||||
|
@ -342,7 +348,7 @@ class ProjectsController < ApplicationController
|
|||
if params[:repository] == "pswd_is_null"
|
||||
html << l(:label_password_not_null)
|
||||
end
|
||||
flash[:error] = html if !html.to_s.blank?
|
||||
flash.now[:error] = html if !html.to_s.blank?
|
||||
end
|
||||
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
|
||||
@repository = Repository.factory(scm)
|
||||
|
|
|
@ -47,13 +47,23 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
def index
|
||||
# 消息状态更新
|
||||
# 作业消息状态更新
|
||||
@homework.course_messages.each do |homework_message|
|
||||
if User.current.id == homework_message.user_id
|
||||
homework_message.update_attributes(:viewed => true)
|
||||
if User.current.id == homework_message.user_id && homework_message.viewed == 0
|
||||
homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0
|
||||
end
|
||||
end
|
||||
|
||||
# 作品打分消息状态更新
|
||||
studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0)
|
||||
studentworks_scores.each do |studentworks_score|
|
||||
studentworks_score.update_attributes(:viewed => true) if studentworks_score.viewed == 0
|
||||
end
|
||||
# 作品评论消息状态更新
|
||||
journals_for_teacher = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "JournalsForMessage", 0)
|
||||
journals_for_teacher.each do |journal_for_teacher|
|
||||
journal_for_teacher.update_attributes(:viewed => true)
|
||||
end
|
||||
# 作品留言
|
||||
# 消息end
|
||||
#设置作业对应的forge_messages表的viewed字段
|
||||
query_student_work = @homework.course_messages
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
class SystemMessagesController < ApplicationController
|
||||
# before_filter :message_author, :only => [:show]
|
||||
#
|
||||
# def message_author
|
||||
# if(!User.current.logged? && !token.nil?)
|
||||
#
|
||||
# User.current =try_to_autologin1
|
||||
# end
|
||||
# if @system_messages
|
||||
# render_403 :message => :notice_not_authorized_message
|
||||
# else
|
||||
# deny_access
|
||||
# end
|
||||
# end
|
||||
|
||||
def index
|
||||
@system_messages = SystemMessage.all
|
||||
end
|
||||
|
||||
# def show
|
||||
# @system_messages = SystemMessage.find(params[:id])
|
||||
# end
|
||||
|
||||
# GET /products/new
|
||||
# def new
|
||||
# @product = Product.new
|
||||
# end
|
||||
|
||||
# GET /products/1/edit
|
||||
# def edit
|
||||
# end
|
||||
|
||||
# POST /products
|
||||
# POST /products.json
|
||||
def create
|
||||
unless User.current.admin?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
@system_messages = SystemMessage.new
|
||||
@system_messages.content = params[:system_message][:content]
|
||||
@system_messages.user_id = User.current.id
|
||||
respond_to do |format|
|
||||
if @system_messages.save
|
||||
format.html {redirect_to user_message_path(User.current, :type => "system_messages")}
|
||||
flash[:notice] = l(:notice_successful_message)
|
||||
else
|
||||
if params[:system_message][:content].empty?
|
||||
flash[:error] = l(:label_content_blank_fail)
|
||||
else
|
||||
flash[:error] = l(:label_admin_message_fail)
|
||||
end
|
||||
format.html {redirect_to admin_messages_path}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /products/1
|
||||
# PATCH/PUT /products/1.json
|
||||
# def update
|
||||
# respond_to do |format|
|
||||
# if @product.update(product_params)
|
||||
# format.html { redirect_to @product, notice: 'Product was successfully updated.' }
|
||||
# format.json { render :show, status: :ok, location: @product }
|
||||
# else
|
||||
# format.html { render :edit }
|
||||
# format.json { render json: @product.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# DELETE /products/1
|
||||
# DELETE /products/1.json
|
||||
# def destroy
|
||||
# @system_messages.destroy
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
# end
|
||||
|
||||
# private
|
||||
# # Use callbacks to share common setup or constraints between actions.
|
||||
# def set_product
|
||||
# @product = Product.find(params[:id])
|
||||
# end
|
||||
#
|
||||
# # Never trust parameters from the scary internet, only allow the white list through.
|
||||
# def message_params
|
||||
# params.require(:admin_system_messages).permit(:content)
|
||||
# end
|
||||
|
||||
|
||||
end
|
|
@ -105,6 +105,19 @@ class UsersController < ApplicationController
|
|||
redirect_to signin_url
|
||||
return
|
||||
end
|
||||
# 记录当前点击按钮的时间
|
||||
# 考虑到用户未退出刷新消息页面
|
||||
if OnclickTime.where("user_id =?", User.current).first.nil?
|
||||
message_new_time = OnclickTime.new
|
||||
message_new_time.user_id = User.current.id
|
||||
message_new_time.onclick_time = Time.now
|
||||
message_new_time.save
|
||||
else
|
||||
message_new_time = OnclickTime.where("user_id =?", User.current).first
|
||||
message_last_time = message_new_time.onclick_time
|
||||
message_new_time.update_attributes(:onclick_time => Time.now)
|
||||
end
|
||||
@user_system_messages = SystemMessage.where("created_at >?", message_last_time).order("created_at desc")
|
||||
# 当前用户查看消息,则设置消息为已读
|
||||
if params[:viewed] == "all"
|
||||
course_querys = @user.course_messages
|
||||
|
@ -122,10 +135,23 @@ class UsersController < ApplicationController
|
|||
case params[:type]
|
||||
when nil
|
||||
@message_alls = []
|
||||
messages = MessageAll.where("user_id =?",@user).order("created_at desc")
|
||||
messages = MessageAll.where("user_id =?" ,@user).order("created_at desc")
|
||||
messages.each do |message_all|
|
||||
@message_alls << message_all.message
|
||||
end
|
||||
when 'unviewed'
|
||||
@message_alls = []
|
||||
messages = MessageAll.where("user_id =?", @user).order("created_at desc")
|
||||
messages.each do |message_all|
|
||||
# 在点击或者刷新消息列表后未读的消息存放在数组
|
||||
if message_all.message.viewed == 0
|
||||
@message_alls << message_all.message
|
||||
end
|
||||
end
|
||||
when 'system_messages'
|
||||
@message_alls = SystemMessage.order("created_at desc").all
|
||||
when 'apply'
|
||||
@message_alls = ForgeMessage.where("forge_message_type =? and user_id =?" , "AppliedProject", @user).order("created_at desc")
|
||||
when 'homework'
|
||||
@message_alls = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc")
|
||||
when 'course_message'
|
||||
|
|
|
@ -264,7 +264,7 @@ class WikiController < ApplicationController
|
|||
end
|
||||
@page.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to project_wiki_index_url(@project) }
|
||||
format.html {redirect_to edit_project_wiki_page_url @project, @page.title}
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
module SystemMessagesHelper
|
||||
end
|
|
@ -52,6 +52,40 @@ module UsersHelper
|
|||
end
|
||||
end
|
||||
|
||||
def title_for_message type
|
||||
case type
|
||||
when nil
|
||||
'消息'
|
||||
when 'unviewed'
|
||||
'未读消息'
|
||||
when 'apply'
|
||||
'用户申请'
|
||||
when 'system_messages'
|
||||
'系统消息'
|
||||
when 'homework'
|
||||
'作业消息'
|
||||
when 'course_message'
|
||||
'课程讨论'
|
||||
when 'course_news'
|
||||
'课程通知'
|
||||
when 'issue'
|
||||
'项目任务'
|
||||
when 'forum'
|
||||
'贴吧帖子'
|
||||
when 'user_feedback'
|
||||
'用户留言'
|
||||
end
|
||||
end
|
||||
|
||||
# 统计未读消息数
|
||||
def unviewed_message(user)
|
||||
course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count
|
||||
forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count
|
||||
user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count
|
||||
user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count
|
||||
messages_count = course_count + forge_count + user_feedback_count + user_memo_count
|
||||
end
|
||||
|
||||
def user_mail_notification_options(user)
|
||||
user.valid_notification_options.collect {|o| [l(o.last), o.first]}
|
||||
end
|
||||
|
|
|
@ -1,8 +1,21 @@
|
|||
class AppliedProject < ActiveRecord::Base
|
||||
attr_accessible :project_id, :user_id
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
belongs_to :project
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
|
||||
|
||||
after_create :send_appliled_message
|
||||
|
||||
def send_appliled_message
|
||||
# if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
|
||||
self.project.members.each do |m|
|
||||
if m.roles.first.to_s.include?("Manager")
|
||||
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
#删除用户申请
|
||||
def self.deleteappiled(userid, projectid)
|
||||
|
@ -11,5 +24,4 @@ class AppliedProject < ActiveRecord::Base
|
|||
applied.destroy
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -147,6 +147,13 @@ class Issue < ActiveRecord::Base
|
|||
unless self.author_id == self.assigned_to_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false)
|
||||
end
|
||||
if self.tracker_id == 5
|
||||
self.project.members.each do |m|
|
||||
if m.roles.first.to_s.include?("Manager") && m.user_id != self.author_id && m.user_id != self.assigned_to_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 更新缺陷
|
||||
|
@ -1009,7 +1016,7 @@ class Issue < ActiveRecord::Base
|
|||
if leaf.start_date
|
||||
# Only move subtask if it starts at the same date as the parent
|
||||
# or if it starts before the given date
|
||||
if start_date == leaf.start_date || date > leaf.start_date
|
||||
if start_date == leaf.start_date || date > leaf.start_date
|
||||
leaf.reschedule_on!(date)
|
||||
end
|
||||
else
|
||||
|
|
|
@ -34,8 +34,10 @@ class Mailer < ActionMailer::Base
|
|||
end
|
||||
def method_missing(name, *args, &block)
|
||||
if Setting.delayjob_enabled? && Object.const_defined?('Delayed')
|
||||
# with delayed_job
|
||||
@target.delay.send(name, *args, &block)
|
||||
else
|
||||
# without delayed_job
|
||||
@target.send(name, *args, &block).deliver
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class OnclickTime < ActiveRecord::Base
|
||||
attr_accessible :onclick_time, :user_id
|
||||
|
||||
belongs_to :user
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
class SystemMessage < ActiveRecord::Base
|
||||
attr_accessible :content, :id, :user_id
|
||||
belongs_to :user
|
||||
|
||||
validates :content, presence: true
|
||||
validates_length_of :content, maximum: 255
|
||||
end
|
|
@ -132,6 +132,8 @@ class User < Principal
|
|||
has_many :course_messages
|
||||
has_many :memo_messages
|
||||
has_many :user_feedback_messages
|
||||
has_one :onclick_time
|
||||
has_many :system_messages
|
||||
|
||||
# 虚拟转换
|
||||
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
|
||||
|
@ -209,7 +211,7 @@ class User < Principal
|
|||
before_save :update_hashed_password
|
||||
before_destroy :remove_references_before_destroy
|
||||
# added by fq
|
||||
after_create :act_as_activity
|
||||
after_create :act_as_activity, :add_onclick_time
|
||||
# end
|
||||
|
||||
scope :in_group, lambda {|group|
|
||||
|
@ -257,11 +259,18 @@ class User < Principal
|
|||
|
||||
# 新消息统计
|
||||
def count_new_message
|
||||
course_count = CourseMessage.where("user_id =? and viewed =?", User.current.id, 0).count
|
||||
forge_count = ForgeMessage.where("user_id =? and viewed =?", User.current.id, 0).count
|
||||
user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", User.current.id, 0).count
|
||||
user_memo_count = MemoMessage.where("user_id =? and viewed =?", User.current.id, 0).count
|
||||
messages_count = course_count + forge_count + user_feedback_count + user_memo_count
|
||||
if OnclickTime.where("user_id =?", User.current).first.nil?
|
||||
message_new_time = OnclickTime.new
|
||||
message_new_time.user_id = User.current.id
|
||||
message_new_time.onclick_time = User.current.last_login_on.nil? ? Time.now : User.current.last_login_on
|
||||
message_new_time.save
|
||||
end
|
||||
course_count = CourseMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count
|
||||
forge_count = ForgeMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count
|
||||
user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count
|
||||
user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count
|
||||
system_messages_count = SystemMessage.where("created_at >?", User.current.onclick_time.onclick_time).count
|
||||
messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count
|
||||
end
|
||||
|
||||
# 查询指派给我的缺陷记录
|
||||
|
@ -994,6 +1003,13 @@ class User < Principal
|
|||
self.acts << Activity.new(:user_id => self.id)
|
||||
end
|
||||
|
||||
# 注册用户的时候消息默认点击时间为用户创建时间
|
||||
def add_onclick_time
|
||||
if OnclickTime.where("user_id =?" , self.id).first.nil?
|
||||
OnclickTime.create(:user_id => self.id, :onclick_time => self.created_on)
|
||||
end
|
||||
end
|
||||
|
||||
# Removes references that are not handled by associations
|
||||
# Things that are not deleted are reassociated with the anonymous user
|
||||
def remove_references_before_destroy
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
|
||||
<h3 style="float: left">
|
||||
<%=l(:label_system_message)%>
|
||||
</h3><br/>
|
||||
<div style="padding-top: 20px; padding-left: 5px;">
|
||||
<%= form_for(@admin_messages, :html => {:id =>'system_message-form'}) do |f| %>
|
||||
<div class="field">
|
||||
<%= f.kindeditor :content,:width=>'87%',:editor_id=>'system_message_editor' %>
|
||||
<p id="content_notice_span" class="ml55"></p>
|
||||
</div>
|
||||
<div>
|
||||
<p id="content_notice_span" class="ml55"></p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= link_to l(:label_submit), "javascript:void(0)",:class => "small", :onclick => "system_message_editor.sync();submit_message();" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<script>
|
||||
function system_message_length() {
|
||||
var obj = system_message_editor.html();
|
||||
if (obj.length == 0) {
|
||||
$("#content_notice_span").text("内容不能为空");
|
||||
$("#content_notice_span").css('color', '#ff0000');
|
||||
$("#content_notice_span").focus();
|
||||
return false;
|
||||
}
|
||||
else if (obj.length > 255) {
|
||||
$("#content_notice_span").text("内容过长,超过255个字符");
|
||||
$("#content_notice_span").css('color', '#ff0000');
|
||||
$("#content_notice_span").focus();
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$("#content_notice_span").text("填写正确");
|
||||
$("#content_notice_span").css('color', '#008000');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function submit_message() {
|
||||
|
||||
if (system_message_length()) {
|
||||
$("#system_message-form").submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -49,16 +49,6 @@
|
|||
<%= link_to l(:field_homepage), home_path %> > <a href="http://<%= Setting.host_name %>"><%=l(:label_project_hosting_platform) %> </a>><%= link_to @project.name, project_path(@project.id) %>
|
||||
</p>
|
||||
</div>
|
||||
<!--<div class="search fl">-->
|
||||
<!--<%#= form_tag(projects_search_path, :method => :get, :id => "project_search_form", :class => "search_form") do %>-->
|
||||
<!--<%#= text_field_tag 'name', params[:name], :placeholder => "项目名称", :class => "search_text fl", :onkeyup => "regexName('#{l(:label_search_conditions_not_null)}');" %>-->
|
||||
<!--<a href="#" onclick="submitSerch('<%#= l(:label_search_conditions_not_null) %>');" class="search_btn fl f14 c_white" >-->
|
||||
<!--<%#= l(:label_search)%>-->
|
||||
<!--</a>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--<span id="project_name_span" class="fl"></span>-->
|
||||
<!--<%# end %>-->
|
||||
<!--</div>-->
|
||||
</div><!--TopBar end-->
|
||||
|
||||
<div id="content">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
|
||||
<li>
|
||||
<label><span class="c_red">*</span> <%= l(:field_title) %> :</label>
|
||||
<input type="text" name="news[title]" class="hwork_input_news" id="news_title" width="576px" onkeyup="regexTitle();" maxlength="60" placeholder="60个字符以内" value="<%= is_new ? '' : @news.title %>">
|
||||
<input type="text" name="news[title]" class="hwork_input_news" id="news_title" width="576px" onblur="regexTitle();" maxlength="60" placeholder="60个字符以内" value="<%= is_new ? '' : @news.title %>">
|
||||
<p id="title_notice_span" class="ml55"></p>
|
||||
</li>
|
||||
<li class="mb10">
|
||||
|
|
|
@ -12,14 +12,6 @@
|
|||
<p style="padding-right: 20px;">
|
||||
<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:0px;" %>
|
||||
</p><!--by young-->
|
||||
<p>
|
||||
<%#= f.text_field :enterprise_name, :size => 60, :style => "width:490px;" %>
|
||||
<label for="project_description">
|
||||
<%= l(:field_enterprise_name)%>
|
||||
<span class="required"> </span>
|
||||
</label>
|
||||
<%= select_tag :organization_id,options_for_select(project_organizations_id_option,@project.organization_id),{} %>
|
||||
</p>
|
||||
<p style="display: none" >
|
||||
<%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH,
|
||||
value:"#{User.current.id.to_s + '_' +Time.now.to_s.gsub(' ','_').gsub(':','').gsub('+','')}" %>
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
$(function(){
|
||||
<%if @select_tab%>
|
||||
<%if @select_tab == "modules"%>
|
||||
project_setting(2);
|
||||
project_setting(2);
|
||||
<% elsif @select_tab == "members"%>
|
||||
project_setting(3);
|
||||
<% elsif @select_tab == "versions"%>
|
||||
project_setting(4);
|
||||
$("#pro_st_edit_ban").toggle();
|
||||
project_setting(4);
|
||||
$("#pro_st_edit_ban").toggle();
|
||||
<% elsif @select_tab == "repositories" %>
|
||||
project_setting(6);
|
||||
$("#pro_st_edit_ku").toggle();
|
||||
project_setting(6);
|
||||
$("#pro_st_edit_ku").toggle();
|
||||
<%else%>
|
||||
<% end%>
|
||||
<% end%>
|
||||
|
|
|
@ -19,11 +19,6 @@
|
|||
<textarea class="w543" id="project_description" name="project[description]" rows="8" placeholder="最多3000个汉字(或6000个英文字符)"><%= @project.description%></textarea>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li >
|
||||
<label class="label02"> 组织 :</label>
|
||||
<%= select_tag :organization_id,options_for_select(project_organizations_id_option,@project.organization_id),{} %>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li >
|
||||
<label class="label02">公开 :</label>
|
||||
<input id="project_is_public" name="project[is_public]" type="checkbox" <%= @project.is_public ? "checked" : ""%>>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<% @system_messages.each do |sm| %>
|
||||
<ul><li><%= sm.content %></li></ul>
|
||||
<% end %>
|
|
@ -1,9 +1,11 @@
|
|||
<div class="homepageRightBanner">
|
||||
<div class="NewsBannerName">消息</div>
|
||||
<div class="NewsBannerName"><%= title_for_message(params[:type]) %></div>
|
||||
<ul class="resourcesSelect">
|
||||
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
|
||||
<ul class="newsType">
|
||||
<li><%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %></li>
|
||||
<li><%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %></li>
|
||||
<li><%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %></li>
|
||||
<%# 课程相关消息 %>
|
||||
<li><%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %></li>
|
||||
<li><%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %></li>
|
||||
|
@ -22,19 +24,51 @@
|
|||
<li><%= link_to "贴吧帖子", user_message_path(User.current, :type => 'forum'), :class => "resourcesGrey" %></li>
|
||||
<%# 系统贴吧 %>
|
||||
<li><%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "resourcesGrey" %></li>
|
||||
|
||||
<%# 系统消息 %>
|
||||
<li><%= link_to "系统消息", user_message_path(User.current, :type => 'system_messages'), :class => "resourcesGrey" %></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="resources mt10" id="users_setting">
|
||||
<div>
|
||||
<% if params[:type].nil? %>
|
||||
<div class="newsReadSetting">
|
||||
有 <span class="c_red"><%= User.current.count_new_message %></span> 条未读<a href="javascript:void(0);" class="ml15"><%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %></a>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @message_alls.count >0 %>
|
||||
<% if params[:type].nil? || params[:type] == "unviewed" %>
|
||||
<div class="newsReadSetting">
|
||||
有 <span class="c_red"><%= unviewed_message(@user) %></span> 条未读
|
||||
<% unless (unviewed_message(@user) == 0 || User.current != @user) %>
|
||||
<a href="javascript:void(0);" class="ml15"><%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%# 系统消息 %>
|
||||
<% if params[:type] != 'system_messages' %>
|
||||
<% @user_system_messages.each do |usm| %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<a href="javascript:void(0);">
|
||||
<div class="navHomepageLogo fl">
|
||||
<%= image_tag("/images/logo.png", width: "30px", height: "30px", class: "mt3") %>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<span class="newsBlue homepageNewsPublisher">Trustie平台</span><span class="homepageNewsType fl">发布新消息:</span>
|
||||
</li>
|
||||
<li class="homepageNewsContent fl">
|
||||
<%= link_to usm.content.html_safe, user_message_path(User.current, :type => "system_messages"),
|
||||
:class => "newsRed",
|
||||
:onmouseover => "message_titile_show($(this),event);",
|
||||
:onmouseout => "message_titile_hide($(this));"
|
||||
%>
|
||||
</li>
|
||||
<div style="display:none;" class="message_title_red">
|
||||
<%= usm.content.html_safe %>
|
||||
</div>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(usm.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%# 课程消息 %>
|
||||
<% unless @message_alls.nil? %>
|
||||
<% @message_alls.each do |ma| %>
|
||||
|
@ -74,6 +108,23 @@
|
|||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ma.course_message_type == "HomeworkCommon" && ma.status == 1 %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a></li>
|
||||
<li class="homepageNewsPubType fl"><%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %><span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布的作业:</span></li>
|
||||
<% if ma.viewed == 0 %>
|
||||
<li class="homepageHomeworkContent fl">
|
||||
<%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :title => "#{ma.course_message.name}" %>
|
||||
</li>
|
||||
<li class="homepageHomeworkContentWarn fl"> 截止时间快到了!</li>
|
||||
<% else %>
|
||||
<li class="homepageNewsContent fl">
|
||||
<%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :title => "#{ma.course_message.name}" %>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ma.course_message_type == "Poll" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a></li>
|
||||
|
@ -131,6 +182,21 @@
|
|||
<% end %>
|
||||
<!--项目消息-->
|
||||
<% if ma.class == ForgeMessage %>
|
||||
<% if ma.forge_message_type == "AppliedProject" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.forge_message.user), :width => "30", :height => "30"), user_path(ma.forge_message.user) %></a>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%=link_to ma.forge_message.user, user_path(ma.forge_message.user), :class => "newsBlue homepageNewsPublisher" %>
|
||||
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">申请加入项目:</span>
|
||||
</li>
|
||||
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
|
||||
<%= link_to ma.project, settings_project_path(:id => ma.project, :tab => "members"), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",:title => "#{ma.project}" %></a>
|
||||
</li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ma.forge_message_type == "Issue" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
|
@ -272,6 +338,30 @@
|
|||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%# 系统消息 %>
|
||||
<% if ma.class == SystemMessage %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<a href="javascript:void(0);">
|
||||
<div class="navHomepageLogo fl">
|
||||
<%=image_tag("/images/logo.png",width:"30px", height: "30px",class: "mt3")%>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl"><span class="newsBlue homepageNewsPublisher" >Trustie平台</span><span class="homepageNewsType fl">发布新消息:</span></li>
|
||||
<li class="homepageNewsContent fl">
|
||||
<%= link_to ma.content.html_safe, user_message_path(User.current, :type => "system_messages"),
|
||||
:class => "#{params[:type]=="unviewed" ? "newsBlack" : "newsRed"}",
|
||||
:onmouseover =>"message_titile_show($(this),event);",
|
||||
:onmouseout => "message_titile_hide($(this));"
|
||||
%>
|
||||
</li>
|
||||
<div style="display:none;" class="message_title_red">
|
||||
<%= ma.content.html_safe%>
|
||||
</div>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<ul class="wlist" style=" border:none; padding-top: 15px;">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
|
||||
|
|
|
@ -11,3 +11,5 @@ en:
|
|||
label_registration_activation_by_email: account activation by email
|
||||
label_registration_manual_activation: manual account activation
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
|
||||
label_system_message: system messages
|
||||
|
|
|
@ -14,3 +14,7 @@ zh:
|
|||
label_registration_manual_activation: 手动激活帐号
|
||||
label_registration_automatic_activation: 自动激活帐号
|
||||
|
||||
label_system_message: 系统消息
|
||||
label_admin_message_fail: 消息内容过长!
|
||||
label_content_blank_fail: 消息内容不能为空!
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ zh:
|
|||
notice_create_failed: 创建失败,请先完善个人信息
|
||||
notice_failed_create: 创建失败
|
||||
notice_successful_update: 更新成功
|
||||
notice_successful_message: 消息创建成功!
|
||||
notice_successful_edit: 修改成功
|
||||
notice_failed_edit: 修改失败
|
||||
notice_successful_delete: 删除成功
|
||||
|
@ -49,6 +50,7 @@ zh:
|
|||
notice_not_contest_setting_authorized: 对不起,您无权配置此竞赛。
|
||||
notice_not_contest_delete_authorized: 对不起,您无权删除此竞赛。
|
||||
notice_not_authorized_archived_project: 要访问的项目已经归档。
|
||||
notice_not_authorized_message: 您访问的消息不存在!
|
||||
notice_email_sent: "邮件已发送至 %{value}"
|
||||
notice_email_error: "发送邮件时发生错误 (%{value})"
|
||||
notice_feeds_access_key_reseted: 您的RSS存取键已被重置。
|
||||
|
|
|
@ -260,6 +260,15 @@ RedmineApp::Application.routes.draw do
|
|||
match '/users/search', :via => [:get, :post]
|
||||
#end
|
||||
|
||||
# 消息相关路由
|
||||
resources :system_messages do
|
||||
collection do
|
||||
post 'create', :as => 'system_messages'
|
||||
get 'index', :as => 'index'
|
||||
end
|
||||
end
|
||||
# match 'system_messages/index', to: 'system_messages#index', :via => :get, :as => 'system_messages'
|
||||
|
||||
match 'account/heartbeat', to: 'account#heartbeat', :via => :get
|
||||
match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post]
|
||||
match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post]
|
||||
|
@ -702,6 +711,7 @@ RedmineApp::Application.routes.draw do
|
|||
match 'admin/projects', :via => :get
|
||||
get 'admin/courses'
|
||||
match 'admin/users', :via => :get
|
||||
match 'admin/messages', :via => :get
|
||||
match 'admin/first_page_made', as: :first_page_made
|
||||
match 'admin/course_page_made', as: :course_page_made
|
||||
match 'admin/contest_page_made', as: :contest_page_made
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
class CreateOnclickTimes < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :onclick_times do |t|
|
||||
t.integer :user_id
|
||||
t.datetime :onclick_time
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
class CreateSystemMessages < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :system_messages do |t|
|
||||
t.integer :id
|
||||
t.integer :user_id
|
||||
t.string :content
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
3396
db/schema.rb
3396
db/schema.rb
File diff suppressed because it is too large
Load Diff
|
@ -369,6 +369,7 @@ Redmine::MenuManager.map :admin_menu do |menu|
|
|||
menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
|
||||
menu.push :courses, {:controller => 'admin', :action => 'courses'}, :caption => :label_course_all
|
||||
menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural
|
||||
menu.push :messages, {:controller => 'admin', :action => 'messages'}, :caption => :label_system_message
|
||||
menu.push :schools, {:controller => 'admin', :action => 'schools'}, :caption => :label_school_plural
|
||||
menu.push :first_page_made, {:controller => 'admin',:action => 'first_page_made'},:caption => :label_first_page_made
|
||||
menu.push :mobile_version, {:controller => 'admin',:action => 'mobile_version'},:caption => :label_mobile_version
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#coding=utf-8
|
||||
|
||||
namespace :homework_endtime do
|
||||
desc "send a message for Job deadline"
|
||||
task :message => :environment do
|
||||
current_day = Date.today.day
|
||||
homework_commons = HomeworkCommon.where("end_time >=?",Date.today)
|
||||
homework_commons.each do |homework_common|
|
||||
if CourseMessage.where("course_message_type =? and course_message_id =? and status =?", "HomeworkCommon", homework_common.id, 1).first.nil?
|
||||
if homework_common.end_time.day - Date.today.day < 2 && homework_common.end_time.year == Date.today.year
|
||||
homework_common.course.student.each do |s|
|
||||
homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :status => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1833,7 +1833,7 @@ input#time_entry_comments { width: 90%;}
|
|||
|
||||
.tabular.settings p{ padding-left: 300px; }
|
||||
.tabular.settings label{ margin-left: -300px; width: 295px; }
|
||||
.tabular.settings textarea { width: 99%; }
|
||||
.tabular.settings textarea { width: 96%; }
|
||||
|
||||
.settings.enabled_scm table {width:100%}
|
||||
.settings.enabled_scm td.scm_name{ font-weight: bold; }
|
||||
|
@ -2807,4 +2807,6 @@ img.school_avatar {
|
|||
width: 100px;
|
||||
height: 100px;
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
.admin_message_warn{font-size: 12px;color: red;}
|
|
@ -515,11 +515,16 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;}
|
|||
.homepageNewsType {width:110px; padding-left: 5px; font-size:12px; color:#888888; display:block;}
|
||||
.homepageNewsPubType {width:220px; font-size:12px; color:#888888; display: block;}
|
||||
.homepageNewsContent {width:365px; max-width:365px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; }
|
||||
.homepageHomeworkContentWarn {width:110px; max-width:365px; margin-right:10px; font-size:12px; color:red; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; }
|
||||
.homepageHomeworkContent {width:245px; max-width:365px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; }
|
||||
|
||||
.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.newsRed {color:red;}
|
||||
a.newsRed:hovor {color:#888888;}
|
||||
a.replyGrey {color:#888888; display:inline-block;}
|
||||
a.replyGrey:hover {color:#4b4b4b;}
|
||||
a.replyGrey1 {color:#888888;}
|
||||
|
@ -979,6 +984,8 @@ img.ui-datepicker-trigger {
|
|||
margin-bottom: 3px;
|
||||
}
|
||||
.message_title{border: 1px solid #D4D4D4;padding: 0.6em;margin-left: 1.4em;margin-right: 0.4em;border-radius: 4px;font-family: "Microsoft YaHei";background-size: 100% 100%;margin-bottom: 5px;background-color: #E8E8E8;}
|
||||
.message_title_red{border: 1px solid #D4D4D4;padding: 0.6em;margin-left: 1.4em;margin-right: 0.4em;border-radius: 4px;font-family: "Microsoft YaHei";background-size: 100% 100%;margin-bottom: 5px;background-color: #E8E8E8;color: red}
|
||||
|
||||
.description{display: none !important;}
|
||||
.ispublic-label{display: none !important;}
|
||||
.is_public_checkbox{display: none !important;}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SystemMessagesController, :type => :controller do
|
||||
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
FactoryGirl.define do
|
||||
factory :onclick_time do
|
||||
user_id 1
|
||||
onclick_time "2015-09-06 14:57:02"
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
FactoryGirl.define do
|
||||
factory :system_message do
|
||||
id 1
|
||||
user_id 1
|
||||
content "MyString"
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe OnclickTime, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SystemMessage, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue