Merge branch 'dev_shcool' into rep_quality

Conflicts:
	db/schema.rb
This commit is contained in:
huang 2016-07-28 10:19:37 +08:00
commit c6bc5c9cb8
23 changed files with 337 additions and 14 deletions

View File

@ -598,6 +598,66 @@ class AdminController < ApplicationController
format.html
end
end
# 获取申请的高校列表
# status: 0 未审批; 1 已批阅;
def applied_schools
@name = params[:name]
@apply_status = ApplyAddSchools.where(:status => 0).order('created_at desc')
@apply_count = @apply_status.count
@apply_pages = Paginator.new @apply_count, 30, params['page'] || 1
@apply_status = paginateHelper @apply_status, 30
@page = (params['page'] || 1).to_i - 1
respond_to do |format|
format.html
end
end
def has_applied_schools
@name = params[:name]
@has_apply_status = ApplyAddSchools.where(:status => 1).order('created_at desc')
@has_apply_count = @has_apply_status.count
@has_apply_pages = Paginator.new @has_apply_count, 30, params['page'] || 1
@has_apply_status = paginateHelper @has_apply_status, 30
@page = (params['page'] || 1).to_i - 1
respond_to do |format|
format.html
end
end
# 批准未审批的高校
# 消息发送,发送对象为申请人
# status: 0表示未批准 status1表示已批准 status 2表示已拒绝
def approve_applied_schools
applied_school = ApplyAddSchools.find params[:id]
applied_school.update_column('status', 1) unless applied_school.nil?
AppliedMessage.create(:user_id => applied_school.user_id, :status => true, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools")
respond_to do |format|
format.html{ redirect_to unapplied_schools_url }
end
end
# 更改申请的高校名称
# REDO: 修改该字段
# REDO: 同步修改使用了改名称的用户单位
def edit_applied_schools
@applied_schools = ApplyAddSchools.find params[:id]
@applied_schools.update_column('name', params[:name])
end
# 删除申请的高校
# REDO: destroy关联删除
# REDO: 删除确认提示,是否删除
# REDO: 给申请人发送消息
def delete_applied_schools
@applied_schools = ApplyAddSchools.find params[:id]
@applied_schools.destroy
end
#移动端版本管理
def mobile_version
@versions = PhoneAppVersion.reorder('created_at desc')

View File

@ -180,7 +180,7 @@ class SchoolController < ApplicationController
applyschool.city = params[:city]
applyschool.address = params[:address]
applyschool.remarks = params[:remarks]
applyschool.user_id = User.current.id
if applyschool.save
data[:school_id] = school.id
else

View File

@ -381,6 +381,7 @@ class StudentWorkController < ApplicationController
@is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评
@show_all = false
# 0表示没有分组的学生-1表示所有分组的学生
if @group
if @group == "0"
none_group_students = @course.members.select{ |member| member.course_group_id == 0 }
@ -389,6 +390,13 @@ class StudentWorkController < ApplicationController
else
student_in_group = '(' + none_group_students.map{ |member| member.user_id }.join(',') + ')'
end
elsif @group == "-1"
all_group_students = @course.members.select{ |member| member.course_group_id }
if all_group_students.empty?
student_in_group = '(0)'
else
student_in_group = '(' + all_group_students.map{ |member| member.user_id }.join(',') + ')'
end
else
course_group = CourseGroup.find_by_id(@group)
group_students = course_group.users

View File

@ -88,7 +88,7 @@ class SyllabusesController < ApplicationController
end
def destroy
if @syllabus && @syllabus.courses.empty?
if @syllabus && @syllabus.courses.not_deleted.empty?
@syllabus.destroy
redirect_to user_courselist_user_path(User.current.id)
end

View File

@ -595,19 +595,19 @@ module CoursesHelper
def get_acts_list_type type
case type
when "homework"
">" + l(:label_homework_acts)
l(:label_homework_acts)
when "news"
">" + l(:label_news_acts)
l(:label_news_acts)
when "attachment"
">" + l(:label_attachment_acts)
l(:label_attachment_acts)
when "message"
">" + l(:label_message_acts)
l(:label_message_acts)
when "journalsForMessage"
">" + l(:label_journalsForMessage_acts)
l(:label_journalsForMessage_acts)
when "poll"
">" + l(:label_poll_acts)
l(:label_poll_acts)
else
">" + l(:label_all_cats)
l(:label_all_cats)
end
end

View File

@ -0,0 +1,21 @@
class AppliedMessage < ActiveRecord::Base
# status: 0表示未批准 status1表示已批准 status 2表示已拒绝
attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed
belongs_to :applied ,:polymorphic => true
belongs_to :apply_add_schools
belongs_to :user
has_many :message_alls, :class_name => 'MessageAll', :as =>:message, :dependent => :destroy
validates :user_id,presence: true
validates :applied_id,presence: true
validates :applied_type, presence: true
after_create :add_user_message
# 因为要排序所以需要写入总表
def add_user_message
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
self.message_alls << MessageAll.new(:user_id => self.user_id, :viewed => false)
end
end
end

View File

@ -1,4 +1,16 @@
class ApplyAddSchools < ActiveRecord::Base
# status0 未审批 1 已批阅
attr_accessible :address, :city, :name, :province, :remarks, :school_id, :status
has_many :applied_messages, :class_name =>'AppliedMessage', :as => :applied, :dependent => :destroy
belongs_to :school
after_create :send_massage
#给系统所有管理发送消息
def send_massage
users = User.where(:admin => 1)
users.each do |user|
self.applied_messages << AppliedMessage.new(:user_id => user.id, :viewed => false, :status => false)
end
end
end

View File

@ -0,0 +1,6 @@
<div class="tabs">
<ul>
<li><%= link_to '未审批', {:action => 'applied_schools'}, class: "#{current_page?(unapplied_schools_path)? 'selected' : nil }" %></li>
<li><%= link_to '已审批', {:action => 'has_applied_schools'}, class: "#{current_page?(applied_schools_path)? 'selected' : nil }" %></li>
</ul>
</div>

View File

@ -0,0 +1,78 @@
<h3>
<%=l(:label_applied_shcools)%>
</h3>
<%= render 'tab_has_applied_applied' %>
<%= form_tag({}, :method => :get) do %>
<fieldset>
<label for='name'>
单位名称:
</label>
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '输入单位名称进行搜索' %>
<%= submit_tag l(:button_apply ), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'applied_shcools'}, :class => 'icon icon-reload' %>
</fieldset>
<% end %>
&nbsp;
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 20px;">
序号
</th>
<th style="width: 85px;">
单位名称
</th>
<th style="width: 75px;">
地区
</th>
<th style="width: 75px;">
详细地址
</th>
<th style="width: 20px;">
用户
</th>
<th style="width: 60px;">
创建时间
</th>
<th style="width: 75px;">
操作
</th>
</tr>
</thead>
<tbody>
<% @apply_status.each do |apply| %>
<% if apply.status == 0 %>
<tr class="odd">
<td style="text-align: center;">
<%= apply.id %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=apply.name%>' id="schools_title_<%= apply.id %>">
<%= apply.name %>
</td>
<td class="center">
<%= apply.province + apply.city %>
</td>
<td align="left" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%= apply.address %>
</td>
<td class="center">
<%= apply.user_id %>
</td>
<td class="center">
<%= format_date(apply.created_at) %>
</td>
<td class="center">
<%= link_to( l(:label_approve), { :controller => 'admin', :action => 'approve_applied_schools', :id => apply.id }, :class => 'icon-del') %>
<%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id }, :class => 'icon-del') %>
<%= link_to( l(:button_change), { :controller => 'admin', :action => 'edit_applied_schools', :id => apply.id, :name => apply.name }, :class => 'icon-del') %>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>

View File

@ -0,0 +1,77 @@
<h3>
<%=l(:label_applied_shcools)%>
</h3>
<%= render 'tab_has_applied_applied' %>
<%= form_tag({}, :method => :get) do %>
<fieldset>
<label for='name'>
单位名称:
</label>
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '输入单位名称进行搜索' %>
<%= submit_tag l(:button_apply ), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'applied_shcools'}, :class => 'icon icon-reload' %>
</fieldset>
<% end %>
&nbsp;
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 20px;">
序号
</th>
<th style="width: 85px;">
单位名称
</th>
<th style="width: 75px;">
地区
</th>
<th style="width: 75px;">
详细地址
</th>
<th style="width: 20px;">
用户
</th>
<th style="width: 60px;">
创建时间
</th>
<th style="width: 75px;">
操作
</th>
</tr>
</thead>
<tbody>
<% @has_apply_status.each do |apply| %>
<% if apply.status == 1 %>
<tr class="odd">
<td style="text-align: center;">
<%= apply.id %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=apply.name%>' id="schools_title_<%= apply.id %>">
<%= apply.name %>
</td>
<td class="center">
<%= apply.province + apply.city %>
</td>
<td align="left" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%= apply.address %>
</td>
<td class="center">
<%= apply.user_id %>
</td>
<td class="center">
<%= format_date(apply.created_at) %>
</td>
<td class="center">
<%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id }, :class => 'icon-del') %>
<%= link_to( l(:button_change), { :controller => 'admin', :action => 'edit_applied_schools', :id => apply.id, :name => apply.name }, :class => 'icon-del') %>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>

View File

@ -132,12 +132,12 @@
<div id="topic_editor" style="display: none;">
<%if User.current.member_of_course?(course) %>
<div class="mt10">
<% if User.current.admin? %>
<% if User.current.id == course.tea_id %>
<%= f.check_box :sticky, :value => topic.sticky %>
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
<% end %>
<%= f.check_box :locked, :value => topic.locked %>
<%= label_tag 'message_locked', l(:label_board_locked) %>
<% end %>
<div class="cl"></div>
</div>
<% end %>

View File

@ -9,7 +9,7 @@
<input type="hidden" value="<%= @type%>" name="type" id="user_activities_type">
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName">班级动态
<div class="NewsBannerName">
<%= get_acts_list_type @type %></div>
<ul class="resourcesSelect">
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>

View File

@ -1,6 +1,6 @@
<br>
<div style='width:470px;text-align:center;font-family: "微软雅黑","宋体"' class="f14">
<% if @syllabus.courses.empty? || @syllabus.courses.not_deleted.empty? %>
<% if @syllabus.courses.not_deleted.empty? %>
确认删除该课程吗?
<% else %>
该课程下已经存在班级,不能删除。
@ -8,7 +8,7 @@
</div>
</br>
<div style='width:164px; margin:0 auto; text-align:center; font-family: "微软雅黑","宋体"'>
<% if @syllabus.courses.empty?|| @syllabus.courses.not_deleted.empty? %>
<% if @syllabus.courses.not_deleted.empty? %>
<%=link_to '确认', syllabus_path(@syllabus), :class => 'Blue-btn fl', :method => 'delete'%>
<a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>关闭</a>
<% else %>

View File

@ -0,0 +1,18 @@
<% if ma.class == AppliedMessage %>
<!--申请加入项目-->
<% if ma.applied_type == "ApplyAddSchools" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"><%= link_to image_tag(url_to_avatar(ma.user), :width => "30", :height => "30"), user_path(ma.user), :target => '_blank' %></a>
</li>
<li class="homepageNewsPubType fl">
<%=link_to ma.user, user_path(ma.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">批准你加入项目:</span>
</li>
<li class="homepageNewsContent fl">
<a class ="#{ma.viewed == 0 ? 'newsBlack' : 'newsGrey'}" target = '_blank'><%= ma.applied.name %></a>
</li>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% end %>

View File

@ -34,6 +34,8 @@
<%= render :partial => 'users/user_message_org', :locals => {:ma => ma} %>
<%# 申请类消息 %>
<%= render :partial => 'users/user_message_applied', :locals => {:ma => ma} %>
<% 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%>

View File

@ -388,6 +388,7 @@ zh:
label_organization_name: 组织名称
label_organization_list: 组织列表
label_school_plural: 学校列表
label_applied_shcools: 单位名称列表
label_organization_new: 新建组织
label_edit_organization: 编辑组织
label_organization_edit: 修改组织
@ -909,6 +910,7 @@ zh:
button_test: 测试
button_edit: 编辑
button_delete: 删除
button_approve: 批准
button_set_homepage: 设为首页
button_cancel_homepage: 取消首页
button_edit_homepage: 编辑首页

View File

@ -1070,6 +1070,10 @@ RedmineApp::Application.routes.draw do
match 'admin/default_configuration', :via => :post
get 'admin/organization'
get 'admin/schools'
get 'admin/applied_schools', as: :unapplied_schools
get 'admin/has_applied_schools', as: :applied_schools
get 'admin/approve_applied_schools'
get 'admin/leave_messages'
match 'admin/messages_list', as: :messages_list
match 'admin/project_messages', as: :project_messages

View File

@ -0,0 +1,5 @@
class AddStudentIdToApplyAddSchool < ActiveRecord::Migration
def change
add_column :apply_add_schools, :user_id, :integer
end
end

View File

@ -0,0 +1,13 @@
class CreateAppliedMessages < ActiveRecord::Migration
def change
create_table :applied_messages do |t|
t.integer :user_id
t.integer :applied_id
t.string :applied_type
t.integer :viewed, :default => false
t.integer :status, :default => false
t.timestamps
end
end
end

View File

@ -371,6 +371,7 @@ Redmine::MenuManager.map :admin_menu do |menu|
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 :applied_schools, {:controller => 'admin', :action => 'applied_schools'}, :caption => :label_applied_shcools
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
menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural

View File

@ -1,5 +1,6 @@
#coding=utf-8
#
require 'uglifier'
def compress(srcs, outfile)
wechat_path = File.join(Rails.root, "public", "javascripts", "wechat")

View File

@ -0,0 +1,10 @@
FactoryGirl.define do
factory :applied_message do
user_id 1
applied_id 1
applied_type "MyString"
viewed 1
status 1
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe AppliedMessage, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end