添加功能:管理员界面发送系统消息
This commit is contained in:
parent
146d877254
commit
66251c8d30
|
@ -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
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
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
|
||||
@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 system_messages_url(@project)}
|
||||
flash[:notice] = l(:notice_successful_message)
|
||||
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
|
|
@ -0,0 +1,2 @@
|
|||
module SystemMessagesHelper
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
class SystemMessage < ActiveRecord::Base
|
||||
attr_accessible :content, :id, :user_id
|
||||
belongs_to :user
|
||||
end
|
|
@ -133,6 +133,7 @@ class User < Principal
|
|||
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"
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<h3 style="float: left">
|
||||
<%=l(:label_system_message)%>
|
||||
</h3><br/>
|
||||
<div style="padding-top: 20px; padding-left: 5px;">
|
||||
<%= form_for(@admin_messages) do |f| %>
|
||||
<div class="field">
|
||||
<%= f.text_area :content %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit l(:label_submit),:class => "small" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<% @system_messages.each do |sm| %>
|
||||
<ul><li><%= sm.content %></li></ul>
|
||||
<% end %>
|
|
@ -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,5 @@ zh:
|
|||
label_registration_manual_activation: 手动激活帐号
|
||||
label_registration_automatic_activation: 自动激活帐号
|
||||
|
||||
label_system_message: 系统消息
|
||||
|
||||
|
|
|
@ -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,16 @@ 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'
|
||||
get 'show', :as => 'show'
|
||||
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 +712,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,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
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20150906083453) do
|
||||
ActiveRecord::Schema.define(:version => 20150909062619) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1357,6 +1357,13 @@ ActiveRecord::Schema.define(:version => 20150906083453) do
|
|||
add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id"
|
||||
add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id"
|
||||
|
||||
create_table "system_messages", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.string "content"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "taggings", :force => true do |t|
|
||||
t.integer "tag_id"
|
||||
t.integer "taggable_id"
|
||||
|
|
|
@ -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,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SystemMessagesController, :type => :controller do
|
||||
|
||||
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 SystemMessage, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue