Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
3a80a80841
4
Gemfile
4
Gemfile
|
@ -19,6 +19,10 @@ gem 'acts-as-taggable-on'
|
|||
group :development do
|
||||
gem 'better_errors', path: 'lib/better_errors'
|
||||
gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler'
|
||||
if ENV['PRY']
|
||||
gem 'pry'
|
||||
gem 'pry-nav'
|
||||
end
|
||||
end
|
||||
|
||||
# Gems used only for assets and not required
|
||||
|
|
27
ReadMe.txt
27
ReadMe.txt
|
@ -1,11 +1,18 @@
|
|||
patch:
|
||||
用户姓名的部分,根据issues#655。
|
||||
为了修改方便
|
||||
alias:
|
||||
方法 之前显示 调整之后
|
||||
用户姓名的部分,根据issues#655。
|
||||
为了修改方便
|
||||
alias:
|
||||
方法 之前显示 调整之后
|
||||
name firstname+lastname login
|
||||
nickname xxx login
|
||||
realname xxx firstname+lastname
|
||||
|
||||
User model经过修改,已经完全集成了user_extensions的功能
|
||||
例如
|
||||
user.gender=1
|
||||
user.save
|
||||
user_extensions字段会自动保存
|
||||
不必要每次user.user_extensions.xxx以及判断是否为空
|
||||
================================================================================
|
||||
app/models/setting.rb :165
|
||||
# fixed domain url in development. tantantan's bug
|
||||
|
@ -14,22 +21,22 @@ app/models/setting.rb :165
|
|||
define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/
|
||||
end
|
||||
end
|
||||
程序部分链接中制定了subdomain参数,使链接在二级域名中来回跳转。
|
||||
为了开发方便,使之功能在development模式下失效。
|
||||
程序部分链接中制定了subdomain参数,使链接在二级域名中来回跳转。
|
||||
为了开发方便,使之功能在development模式下失效。
|
||||
# => nyan
|
||||
================================================================================
|
||||
app/controller/projects_controller.rb ===> projects#fake
|
||||
fake filter: 修改了传到页面中的Count后缀的数量
|
||||
改为正确的数量,删掉fake过滤器即可
|
||||
fake filter: 修改了传到页面中的Count后缀的数量
|
||||
改为正确的数量,删掉fake过滤器即可
|
||||
================================================================================
|
||||
#导航栏匹配域名显示和改变
|
||||
#导航栏匹配域名显示和改变
|
||||
app\helper\application_helper.rb
|
||||
# rewrite navigation
|
||||
|
||||
app\views\layouts\_base_header.html.erb
|
||||
# reset navigation by domain name and url through regular match
|
||||
================================================================================
|
||||
#首页根据域名匹配进入不同的页面
|
||||
#首页根据域名匹配进入不同的页面
|
||||
app\controller\welcome_controller.rb
|
||||
def entry_select_user
|
||||
if request.original_url.match(/user\.trustie\.net/)
|
||||
|
|
|
@ -881,6 +881,7 @@ class BidsController < ApplicationController
|
|||
|
||||
def memberAccess
|
||||
# 是课程,则判断当前用户是否参加了课程
|
||||
return true if current_user.admin?
|
||||
return 0 if @bid.courses.first.project_type == Project::ProjectType_project
|
||||
currentUser = User.current
|
||||
render_403 unless currentUser.member_of?(@bid.courses.first)
|
||||
|
|
|
@ -21,13 +21,7 @@ class WelcomeController < ApplicationController
|
|||
before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index]
|
||||
|
||||
def index
|
||||
projectActive = Project.project_entities.active
|
||||
@projectCount = projectActive.count
|
||||
@projectPublicCount = projectActive.all_public.count
|
||||
@projectHidenCount = @projectCount - @projectPublicCount
|
||||
|
||||
@developerCount = User.developer.count
|
||||
@allUsercount = User.count
|
||||
end
|
||||
|
||||
def robots
|
||||
|
@ -36,10 +30,7 @@ class WelcomeController < ApplicationController
|
|||
end
|
||||
|
||||
def course
|
||||
@courseCount = Project.course_entities.count
|
||||
@teacherCount = User.teacher.count
|
||||
@studentCount = User.student.count
|
||||
@logoLink = logolink()
|
||||
@logoLink ||= logolink()
|
||||
end
|
||||
|
||||
|
||||
|
@ -121,25 +112,25 @@ class WelcomeController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def render(*args)
|
||||
_fake if @fake_filter
|
||||
super
|
||||
end
|
||||
# def render(*args)
|
||||
# _fake if @fake_filter
|
||||
# super
|
||||
# end
|
||||
|
||||
private
|
||||
# private
|
||||
|
||||
def fake
|
||||
@fake_filter = true
|
||||
end
|
||||
# def fake
|
||||
# @fake_filter = true
|
||||
# end
|
||||
|
||||
# 骗子方法
|
||||
def _fake
|
||||
instance_variables.map { |variable|
|
||||
if variable.to_s =~ /Count$/
|
||||
self.instance_variable_set(variable.to_sym,
|
||||
("1" + (self.instance_variable_get(variable.to_sym).to_s)).to_i)
|
||||
end
|
||||
}
|
||||
end
|
||||
# # 骗子方法
|
||||
# def _fake
|
||||
# instance_variables.map { |variable|
|
||||
# if variable.to_s =~ /Count$/
|
||||
# self.instance_variable_set(variable.to_sym,
|
||||
# ("1" + (self.instance_variable_get(variable.to_sym).to_s)).to_i)
|
||||
# end
|
||||
# }
|
||||
# end
|
||||
|
||||
end
|
||||
|
|
|
@ -199,6 +199,53 @@ class User < Principal
|
|||
end
|
||||
}
|
||||
|
||||
|
||||
# ======================================================================
|
||||
# 集中处理 User 扩展表为空的问题
|
||||
validate :valid_user_extensions
|
||||
before_save :save_user_extensions
|
||||
|
||||
def extensions
|
||||
self.user_extensions ||= self.create_user_extensions
|
||||
end
|
||||
|
||||
def respond_to?(m, include_private = false)
|
||||
flag = extensions.respond_to? m.to_sym
|
||||
if flag
|
||||
flag
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def method_missing m, *args, &block
|
||||
if extensions.respond_to? m.to_sym
|
||||
self.class.send :define_method, m.to_sym, *args do
|
||||
self.extensions.__send__ m.to_sym, *args
|
||||
end
|
||||
__send__ m.to_sym, *args, &block
|
||||
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def valid_user_extensions
|
||||
if !self.extensions.valid?
|
||||
self.extensions.errors.messages.each do |key, values|
|
||||
values.each do |value|
|
||||
self.errors.add key, value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def save_user_extensions
|
||||
self.extensions.save
|
||||
end
|
||||
# 集中处理 User 扩展表为空的问题 < end
|
||||
# ======================================================================
|
||||
|
||||
#选择项目成员时显示的用户信息文字
|
||||
def userInfo
|
||||
info=self.nickname + ' (' + self.realname + ')';
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
<h3 style="padding-left: 10px;"><%= l(:label_my_account) %></h3>
|
||||
<%= error_messages_for 'user' %>
|
||||
<%= error_messages_for 'se' %>
|
||||
|
||||
<fieldset class="box" style="margin:10px;">
|
||||
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
|
||||
|
|
|
@ -1,125 +1,88 @@
|
|||
<%= error_messages_for 'member' %>
|
||||
<% roles = Role.find_all_givable
|
||||
members = @project.member_principals.includes(:roles, :principal).all.sort %>
|
||||
<%
|
||||
roles = Role.givable.all
|
||||
if @project.project_type == Project::ProjectType_course
|
||||
roles = roles[3..5]
|
||||
else
|
||||
roles = roles[0..2]
|
||||
end
|
||||
members = @project.member_principals.includes(:roles, :principal).all.sort
|
||||
%>
|
||||
|
||||
<div class="splitcontentleft">
|
||||
<% if members.any? %>
|
||||
<table class="list members">
|
||||
<thead><tr>
|
||||
<th><%= l(:label_user) %></th>
|
||||
<th><%= l(:label_role_plural) %></th>
|
||||
<th style="width:15%"></th>
|
||||
<% if members.any? %>
|
||||
<table class="list members">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= l(:label_user) %></th>
|
||||
<th><%= l(:label_role_plural) %></th>
|
||||
<th style="width:15%"></th>
|
||||
<%= call_hook(:view_projects_settings_members_table_header, :project => @project) %>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% members.each do |member| %>
|
||||
<% next if member.new_record? %>
|
||||
<tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %> member">
|
||||
<td class="<%= member.principal.class.name.downcase %>"><%= link_to_user member.principal %></td>
|
||||
<td class="roles">
|
||||
<span id="member-<%= member.id %>-roles"><!-- <%=h member.roles.sort.collect(&:to_s).join(', ') %> -->
|
||||
<!--modified by huang for: -->
|
||||
<% if @project.project_type == 1 %>
|
||||
<% if member.roles.sort.collect(&:to_s).join(', ') =='Manager' %>
|
||||
老师
|
||||
<% else %>
|
||||
<%=h member.roles.sort.collect(&:to_s).join(', ') %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%=h member.roles.sort.collect(&:to_s).join(', ') %>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% members.each do |member| %>
|
||||
<% next if member.new_record? %>
|
||||
<tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %> member">
|
||||
<td class="<%= member.principal.class.name.downcase %>"><%= link_to_user member.principal %></td>
|
||||
<td class="roles">
|
||||
<span id="member-<%= member.id %>-roles">
|
||||
<%= h member.roles.sort.collect(&:to_s).join(', ') %>
|
||||
</span>
|
||||
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
|
||||
:method => :put,
|
||||
:html => { :id => "member-#{member.id}-roles-form", :class => 'hol' }}
|
||||
) do |f| %>
|
||||
<!--added by huang for: filer the roles-->
|
||||
<%= error_messages_for 'member' %>
|
||||
<% if @project.project_type == 1 %>
|
||||
<% r = [] %>
|
||||
<% for i in 3..5 %>
|
||||
<% roles = Role.givable.all[i]
|
||||
members = @project.member_principals.includes(:roles, :principal).all.sort %>
|
||||
<% r << roles %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% r = [] %>
|
||||
<% for i in 0..2 %>
|
||||
<% roles = Role.givable.all[i]
|
||||
members = @project.member_principals.includes(:roles, :principal).all.sort %>
|
||||
<% r << roles %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<!--end-->
|
||||
<p><% r.each do |role| %>
|
||||
<label><%= check_box_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
|
||||
:disabled => member.member_roles.detect {|mr| mr.role_id == role.id && !mr.inherited_from.nil?} %> <%=h role %></label><br />
|
||||
<% end %></p>
|
||||
<%= hidden_field_tag 'membership[role_ids][]', '' %>
|
||||
<p><%= submit_tag l(:button_change), :class => "small" %>
|
||||
<%= link_to_function l(:button_cancel),
|
||||
"$('#member-#{member.id}-roles').show(); $('#member-#{member.id}-roles-form').hide(); return false;"
|
||||
%></p>
|
||||
<% end %>
|
||||
</td>
|
||||
<!--modified by huang for: if the user'roles is Manager that he will can't modified himself-->
|
||||
<%= error_messages_for 'member' %>
|
||||
<% roles = Role.find_all_givable
|
||||
members = @project.member_principals.includes(:roles, :principal).all.sort %>
|
||||
<% if @project.project_type == 1 %>
|
||||
<%if member.roles.first.to_s == "Manager" %>
|
||||
<td class="buttons"></td>
|
||||
<% else %>
|
||||
<td class="buttons">
|
||||
<%= link_to_function l(:button_edit),
|
||||
"$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;",
|
||||
:class => 'icon icon-edit' %>
|
||||
<%= delete_link membership_path(member),
|
||||
:remote => true,
|
||||
:data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %>
|
||||
</td>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<td class="buttons">
|
||||
<%= link_to_function l(:button_edit),
|
||||
"$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;",
|
||||
:class => 'icon icon-edit' %>
|
||||
<%= delete_link membership_path(member),
|
||||
:remote => true,
|
||||
:data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %>
|
||||
</td>
|
||||
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
|
||||
:method => :put,
|
||||
:html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}}
|
||||
) do |f| %>
|
||||
|
||||
<p>
|
||||
<% roles.each do |role| %>
|
||||
<label><%= check_box_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
|
||||
:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %> <%= h role %></label><br/>
|
||||
<% end %></p>
|
||||
<%= hidden_field_tag 'membership[role_ids][]', '' %>
|
||||
<p><%= submit_tag l(:button_change), :class => "small" %>
|
||||
<%= link_to_function l(:button_cancel),
|
||||
"$('#member-#{member.id}-roles').show(); $('#member-#{member.id}-roles-form').hide(); return false;"
|
||||
%></p>
|
||||
<% end %>
|
||||
</td>
|
||||
<!--modified by huang for: if the user'roles is Manager that he will can't modified himself-->
|
||||
<% if @project.project_type == 1 %>
|
||||
<% if member.roles.first.to_s == "Manager" %>
|
||||
<td class="buttons"></td>
|
||||
<% else %>
|
||||
<td class="buttons">
|
||||
<%= link_to_function l(:button_edit),
|
||||
"$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;",
|
||||
:class => 'icon icon-edit' %>
|
||||
<%= delete_link membership_path(member),
|
||||
:remote => true,
|
||||
:data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %>
|
||||
</td>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<td class="buttons">
|
||||
<%= link_to_function l(:button_edit),
|
||||
"$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;",
|
||||
:class => 'icon icon-edit' %>
|
||||
<%= delete_link membership_path(member),
|
||||
:remote => true,
|
||||
:data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %>
|
||||
</td>
|
||||
<% end %>
|
||||
<!--end-->
|
||||
<%= call_hook(:view_projects_settings_members_table_row, {:project => @project, :member => member}) %>
|
||||
</tr>
|
||||
<% end; reset_cycle %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
<!--end-->
|
||||
<%= call_hook(:view_projects_settings_members_table_row, { :project => @project, :member => member}) %>
|
||||
</tr>
|
||||
<% end; reset_cycle %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!--added by huang for: filer the roles-->
|
||||
<%= error_messages_for 'member' %>
|
||||
<% if @project.project_type == 1 %>
|
||||
<% r = [] %>
|
||||
<% for i in 3..5 %>
|
||||
<% roles = Role.givable.all[i]
|
||||
members = @project.member_principals.includes(:roles, :principal).all.sort %>
|
||||
<% r << roles %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% r = [] %>
|
||||
<% for i in 0..2 %>
|
||||
<% roles = Role.givable.all[i]
|
||||
members = @project.member_principals.includes(:roles, :principal).all.sort %>
|
||||
<% r << roles %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<!--end-->
|
||||
|
||||
<div class="splitcontentright">
|
||||
<% if r.any? %>
|
||||
<% if roles.any? %>
|
||||
<% if @project.applied_projects.any? %>
|
||||
<div id="applied_project_block">
|
||||
<%= form_for(@applied_members, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
|
||||
|
@ -131,7 +94,7 @@
|
|||
</div>
|
||||
<!--show the roles which will select-->
|
||||
<p style="padding-top: 5px"><%= l(:label_role_plural) %>:
|
||||
<% r.each do |role| %>
|
||||
<% roles.each do |role| %>
|
||||
|
||||
<label><%= check_box_tag 'membership[role_ids][]', role.id %> <%= h role %></label>
|
||||
<% end %></p>
|
||||
|
@ -144,24 +107,25 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
|
||||
<fieldset><legend><%=l(:label_member_new)%></legend>
|
||||
<%= form_for(@member, {:as => :membership, :url => project_memberships_path(@project), :remote => true, :method => :post}) do |f| %>
|
||||
<fieldset>
|
||||
<legend><%= l(:label_member_new) %></legend>
|
||||
|
||||
<p><%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %></p>
|
||||
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_project_memberships_path(@project, :format => 'js') }')" %>
|
||||
<p><%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %></p>
|
||||
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_project_memberships_path(@project, :format => 'js') }')" %>
|
||||
|
||||
<div id="principals_for_new_member">
|
||||
<%= render_principals_for_new_members(@project) %>
|
||||
</div>
|
||||
<!--show the roles which will select-->
|
||||
<p style="padding-top: 5px"><%= l(:label_role_plural) %>:
|
||||
<% r.each do |role| %>
|
||||
|
||||
<label><%= check_box_tag 'membership[role_ids][]', role.id %> <%=h role %></label>
|
||||
<% end %></p>
|
||||
<div id="principals_for_new_member">
|
||||
<%= render_principals_for_new_members(@project) %>
|
||||
</div>
|
||||
<!--show the roles which will select-->
|
||||
<p style="padding-top: 5px"><%= l(:label_role_plural) %>:
|
||||
<% roles.each do |role| %>
|
||||
|
||||
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>
|
||||
</fieldset>
|
||||
<label><%= check_box_tag 'membership[role_ids][]', role.id %> <%= h role %></label>
|
||||
<% end %></p>
|
||||
|
||||
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -51,14 +51,14 @@
|
|||
|
||||
<% when '2' %>
|
||||
|
||||
<% if (ProjectInfo.find_by_project_id(obj.id)).user_id == User.current.id %>
|
||||
<% if (ProjectInfo.find_by_project_id(obj.id)).try(:user_id) == User.current.id %>
|
||||
<span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag,
|
||||
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
|
||||
<% end %>
|
||||
|
||||
<% when '3' %>
|
||||
|
||||
<% if (ProjectInfo.find_by_project_id(obj.project_id)).user_id == User.current.id %>
|
||||
<% if (ProjectInfo.find_by_project_id(obj.project_id)).try(:user_id) == User.current.id %>
|
||||
<span class='del'> <%= link_to 'x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag,
|
||||
:taggable_id => obj.id, :taggable_type => object_flag %> </span>
|
||||
<% end %>
|
||||
|
|
|
@ -259,17 +259,4 @@
|
|||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<div class="hidden" style="width:100%;">
|
||||
<div style="width:600px;margin:0px auto;margin-top:80px;">
|
||||
<table style="width:600px;font-size:15px; color: #e8770d;">
|
||||
<tr>
|
||||
<td><strong>当前网站状态</strong></td>
|
||||
<td>活跃课程: <%=@courseCount%></td>
|
||||
<td>高校: 2个</td>
|
||||
<td>教师: <%=@teacherCount%> 名</td>
|
||||
<td>学生: <%=@studentCount%> 名<td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<%= render partial: 'link_to_another' %>
|
|
@ -137,16 +137,4 @@
|
|||
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<div class="hidden" style="width:100%;">
|
||||
<div style="width:600px;margin:0px auto;margin-top:180px;">
|
||||
<table style="width:600px;font-size:15px; color: gray;">
|
||||
<tr>
|
||||
<td><strong>当前网站状态</strong></td>
|
||||
<td>活跃项目:<%=@projectCount%>个</td>
|
||||
<td>私有项目: <%=@projectHidenCount%>个</td>
|
||||
<td>开发者:<%=@allUsercount%>个 </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<%= render partial: 'link_to_another' %>
|
Loading…
Reference in New Issue