This commit is contained in:
nwb 2014-07-28 17:14:20 +08:00
commit 9da116c0e3
11 changed files with 244 additions and 149 deletions

View File

@ -263,9 +263,6 @@ class UsersController < ApplicationController
sort_init 'login', 'asc' sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on) sort_update %w(login firstname lastname mail admin created_on last_login_on)
# Deprecation
@project_type = params[:project_type]
case params[:format] case params[:format]
when 'xml', 'json' when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15}) @offset, @limit = api_offset_and_limit({:limit => 15})
@ -274,16 +271,9 @@ class UsersController < ApplicationController
end end
# retrieve all users # retrieve all users
scope = UserStatus.visible # 先内连一下statuses 保证排序之后数量一致
scope = User.visible.
# if role has something, change scope. joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id")
case params[:role]
when 'teacher'
scope = UserStatus.teacher
when 'student'
scope = UserStatus.student
else
end
# unknow # unknow
scope = scope.in_group(params[:group_id]) if params[:group_id].present? scope = scope.in_group(params[:group_id]) if params[:group_id].present?
@ -295,25 +285,32 @@ class UsersController < ApplicationController
# users classify # users classify
case params[:user_sort_type] case params[:user_sort_type]
when '0' when '0'
# 创建时间排序
@s_type = 0 @s_type = 0
@us_ordered = scope. @users = scope.reorder('users.created_on DESC')
joins("LEFT JOIN users ON user_statuses.user_id = users.id").
reorder('users.created_on DESC')
when '1' when '1'
# 活跃度排序, 就是所谓的得分情况
@s_type = 1 @s_type = 1
@us_ordered = scope.reorder('user_statuses.grade DESC') @users = scope.
joins("LEFT JOIN user_scores ON users.id = user_scores.user_id").
reorder('user_scores.active DESC')
when '2' when '2'
# 粉丝数排序
@s_type = 2 @s_type = 2
@us_ordered = scope.reorder('user_statuses.watchers_count DESC') @users = scope.
#joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id").
reorder('user_statuses.watchers_count DESC')
else else
# 默认活跃度排序
@s_type = 1 @s_type = 1
@us_ordered = scope.reorder('user_statuses.grade DESC') @users = scope.
joins("LEFT JOIN user_scores ON users.id = user_scores.user_id").
reorder('user_scores.active DESC')
end end
# limit and offset # limit and offset
@users_statuses = @us_ordered.offset(@user_pages.offset).limit(@user_pages.per_page) @users = @users.limit(@user_pages.per_page).offset(@user_pages.offset)
# get users ActiveRecord
@users = @users_statuses.includes(:user).map(&:user)
@user_base_tag = params[:id] ? 'base_users':'users_base' @user_base_tag = params[:id] ? 'base_users':'users_base'
respond_to do |format| respond_to do |format|

View File

@ -827,9 +827,12 @@ module ApplicationHelper
def select_option_helper option def select_option_helper option
tmp = Hash.new tmp = Hash.new
tmp={"" => ""} tmp={"" => ""}
if option.nil?
else
option.each do |project| option.each do |project|
tmp[project.name] = project.id tmp[project.name] = project.id
end end
end
tmp tmp
end end
# Redmine links # Redmine links
@ -1172,6 +1175,7 @@ module ApplicationHelper
objects = objects.first objects = objects.first
end end
# end # end
if objects != nil
objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact
errors = objects.map {|o| o.errors.full_messages}.flatten errors = objects.map {|o| o.errors.full_messages}.flatten
if errors.any? if errors.any?
@ -1192,6 +1196,7 @@ module ApplicationHelper
###xianbo ###xianbo
html << "</ul></div>\n" html << "</ul></div>\n"
end end
end
html.html_safe html.html_safe
end end

View File

@ -0,0 +1,96 @@
<%#= error_messages_for 'softapplication' %>
<%= form_for Softapplication.new, :url => softapplications_path do |f| %>
<fieldset class="contes-new-box" style="padding-left: 36px; line-height: 8px; margin-left: 1px" >
<%= hidden_field_tag 'contest_id', @contest.id %>
<tr style="width:700px; margin-left: -10px;">
<span><%= l(:label_work_name) %></span>
<span class="contest-star"> * </span>:
<td><%= f.text_field :name, :required => true, :size => 60, :style => "width:350px;" %></td>
<!--span style="font-size: 10px">(<%#= l(:label_workname_lengthlimit) %>)</span-->
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_running_platform) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px"><%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:350px;" %></td>
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_work_type) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px">
<span>
<%#= select_tag 'app_type_name', work_type_opttion, {:name => 'app_type_name',:style => "width:358px;"} %>
</span>
<%= f.select :app_type_name,work_type_opttion, {},{:style => "width:358px;",:onchange => "selectChange(this)"} %>
<%#= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %>
</td>
<span style="font-size: 10px;display: none" id="other_span">
<%#= f.text_field :other_input, :required => true, :size => 60, :style => "width:100px;" %>
<input type="text" style="width: 100px;" id="other_input" name = "other_input"/>
</span>
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_work_description) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:350px;" %></td>
<!--span style="font-size: 10px">(<%#= l(:label_workdescription_lengthlimit) %>)</span-->
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_softapplication_developers) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px"><%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:350px;" %></td>
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_work_deposit_project) %></span>
<span style="padding-left: 4px"><%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:358px;" %></span>
<span><%= link_to l(:label_create_new_projects),{:controller => 'projects',:action => 'new',course: 0, project_type: 0,host: Setting.project_domain}, :target => '_blank' %></span><!-- new_project_path(course: 0, project_type: 0) -->
</tr>
<br/>
<br/>
<br/>
<fieldset style="width: 500px; padding-top: 10px">
<legend>
<%= l(:label_upload_softworkpacket_photo) %>
</legend>
<%#= render_flash_messages %>
<p id="put-bid-form-partial">
<%= render :partial => 'attachments/form' %>
</p>
<p style="font-size: 11px">
1、<%= l(:label_upload_softapplication_packets_mustpacketed) %> <br/>
<br>
2、<%= l(:label_upload_softapplication_photo_condition) %>
</p>
</fieldset>
</fieldset></br>
<div class="align-center" style="padding-top: -3px; padding-bottom: 8px">
<%= submit_tag l(:button_create) %>
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();",
:type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'",
:onmouseover => "this.style.backgroundPosition = 'left -30px'" %>
</div>
<% end %>

View File

@ -88,7 +88,7 @@
<div style="padding-bottom: 10px; line-height: 15px"> <div style="padding-bottom: 10px; line-height: 15px">
<div style="padding-left: 82px; font-size: 14px"> <div style="padding-left: 82px; font-size: 14px">
<span><strong><%= l(:label_attending_contest) %></strong></span> <span><strong><%= l(:label_attending_contest) %></strong></span>
<span><%= link_to l(:label_new_attendingcontest_work), "javascript:void(0);", onclick: "$('#put-project-form').toggle();" %></span> <span><%= link_to l(:label_new_attendingcontest_work), "javascript:void(0);", onclick: "$('#put-project-form').slideToggle();" %></span>
</div> </div>
</div> </div>
<% else %> <% else %>
@ -99,102 +99,8 @@
<% end %> <% end %>
<!--点击新建参赛作品弹出框新建参赛作品并关联到竞赛中--> <!--点击新建参赛作品弹出框新建参赛作品并关联到竞赛中-->
<div id="put-project-form" style="display: none; padding-left: 83px; width: 88%"> <div id="put-project-form" style=" padding-left: 83px; width: 88%">
<%= form_for Softapplication.new, :url => softapplications_path do |f| %> <%= render "new_softapplication" %>
<fieldset class="contes-new-box" style="padding-left: 36px; line-height: 8px; margin-left: 1px" >
<%= hidden_field_tag 'contest_id', @contest.id %>
<tr style="width:700px; margin-left: -10px;">
<span><%= l(:label_work_name) %></span>
<span class="contest-star"> * </span>:
<td><%= f.text_field :name, :required => true, :size => 60, :style => "width:350px;" %></td>
<span style="font-size: 10px">(<%= l(:label_workname_lengthlimit) %>)</span>
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_running_platform) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px"><%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:350px;" %></td>
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_work_type) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px">
<span>
<%#= select_tag 'app_type_name', work_type_opttion, {:name => 'app_type_name',:style => "width:358px;"} %>
</span>
<%= f.select :app_type_name,work_type_opttion, {},{:style => "width:358px;",:onchange => "selectChange(this)"} %>
<%#= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %>
</td>
<span style="font-size: 10px;display: none" id="other_span">
<%#= f.text_field :other_input, :required => true, :size => 60, :style => "width:100px;" %>
<input type="text" style="width: 100px;" id="other_input" name = "other_input"/>
</span>
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_work_description) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:350px;" %></td>
<span style="font-size: 10px">(<%= l(:label_workdescription_lengthlimit) %>)</span>
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_softapplication_developers) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px"><%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:350px;" %></td>
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_work_deposit_project) %></span>
<span style="padding-left: 4px"><%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:358px;" %></span>
<span><%= link_to l(:label_create_new_projects),{:controller => 'projects',:action => 'new',course: 0, project_type: 0,host: Setting.project_domain}, :target => '_blank' %></span><!-- new_project_path(course: 0, project_type: 0) -->
</tr>
<br/>
<br/>
<br/>
<fieldset style="width: 500px; padding-top: 10px">
<legend>
<%= l(:label_upload_softworkpacket_photo) %>
</legend>
<%#= render_flash_messages %>
<p id="put-bid-form-partial">
<%= render :partial => 'attachments/form' %>
</p>
<p style="font-size: 11px">
1、<%= l(:label_upload_softapplication_packets_mustpacketed) %> <br/>
<br>
2、<%= l(:label_upload_softapplication_photo_condition) %>
</p>
</fieldset>
</fieldset></br>
<div class="align-center" style="padding-top: -3px; padding-bottom: 8px">
<%= submit_tag l(:button_create) %>
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();",
:type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'",
:onmouseover => "this.style.backgroundPosition = 'left -30px'" %>
</div>
<% end %>
</div> </div>

View File

@ -25,6 +25,11 @@
<%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %> <%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %>
<div class="activity_description info-break" style="font-size: 13px;"> <div class="activity_description info-break" style="font-size: 13px;">
<div class="issue-list-description">
<div class="wiki">
<%#= textilizable e.event_url,:description %>
</div>
</div>
<%= h(truncate(strip_tags(e.event_description).gsub(/&nbsp;/, ' '), length: 30, omission: '...')) %> <%= h(truncate(strip_tags(e.event_description).gsub(/&nbsp;/, ' '), length: 30, omission: '...')) %>
</div> </div>
<div class="activity_status" style="position:relative; padding-top: 3px;"> <div class="activity_status" style="position:relative; padding-top: 3px;">

View File

@ -257,17 +257,35 @@
<tr> <tr>
<% if e.user == User.current %> <% if e.user == User.current %>
<td colspan="2" valign="top"> <td colspan="2" valign="top">
<strong><%= link_to("#{l(:label_i)}", user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_i_new_activity) %></span>&nbsp;<%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %> <strong>
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %>
</strong>&nbsp;
<span class="font_lighter">
<%= l(:label_i_new_activity) %>
</span>&nbsp;
<%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %>
</td> </td>
<% else %> <% else %>
<td colspan="2" valign="top"> <td colspan="2" valign="top">
<strong><%= link_to(h(e.user), user_path(e.user_id)) %></strong>&nbsp;<span class="font_lighter"><%= l(:label_new_activity) %></span>&nbsp;<%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %> <strong>
<%= link_to(h(e.user), user_path(e.user_id)) %>
</strong>&nbsp;
<span class="font_lighter">
<%= l(:label_new_activity) %>
</span>&nbsp;
<%= link_to format_activity_title("#{act.source_from} (#{act.status}): #{act.tracker.name} #{act.subject}"), {:controller => 'issues', :action => 'show', :id => act.id} %>
</td> </td>
<% end %> <% end %>
</tr> </tr>
<tr> <tr>
<td colspan="2" width="580"> <td colspan="2" width="580">
<p class="font_description"> <%= textilizable(act.description) %> </p></td> <div class="issue-list-description">
<div class="wiki">
<%= textilizable act, :description %>
</div>
</div>
<!-- <p class="font_description"> <%#= textilizable(act.description) %> </p> -->
</td>
</tr> </tr>
<tr> <tr>
<td> <td>

View File

@ -166,10 +166,10 @@
<%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %> <%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %>
</span> </span>
<span class="memo_author"> <span class="memo_author">
楼主: <%= link_to_user(topic.author) %> 楼主: <%= link_to topic.author.login.truncate(10, omission: '...'),user_path(topic.author),title: topic.author.login %>
</span> </span>
<span class="memo_last_person"> <span class="memo_last_person">
最后回复:<%=link_to_user topic.last_reply.try(:author) %> 最后回复:<% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %><%=link_to topic.last_reply.author.login.truncate(10, omission: '...'),user_path(topic.last_reply.author),title: topic.last_reply.author.login%><% end %>
</span> </span>
<span class="memo_reply"> <span class="memo_reply">
回复(<%= link_to topic.try(:replies_count), topic.event_url %>) 回复(<%= link_to topic.try(:replies_count), topic.event_url %>)

View File

@ -2048,6 +2048,7 @@ zh:
notice_account_updated: 帐号更新成功 notice_account_updated: 帐号更新成功
notice_attendingcontest_work_successfully_created: 恭喜您,参赛作品创建成功! notice_attendingcontest_work_successfully_created: 恭喜您,参赛作品创建成功!
notice_softapplication_was_successfully_updated: 恭喜您,参赛作品更新成功! notice_softapplication_was_successfully_updated: 恭喜您,参赛作品更新成功!
notice_attendingcontest_work_failed_created: 参赛产品创建失败
label_attendingcontestwork_belongs_contest: 所属竞赛 label_attendingcontestwork_belongs_contest: 所属竞赛
label_attendingcontestwork_belongs_type: 所属类别 label_attendingcontestwork_belongs_type: 所属类别

View File

@ -1,11 +1,12 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one: one:
act_id: id: 1
act_type: MyString act_id: 1
user_id: act_type: JournalsForMessage
user_id: 5
two: two:
act_id: act_id: 2
act_type: MyString act_type: JournalsForMessage
user_id: user_id: 5

View File

@ -1,4 +1,34 @@
jfm_001: jfm_001:
id: 1
jour_id: 5
jour_type: Principal
user_id: 2
notes:
status: 0
reply_id: 0
created_on: 2014-07-16 15:27:2
updated_on: 2014-07-16 15:27:2
m_parent_id:
is_readed:
m_reply_count:
m_reply_id:
is_comprehensive_evaluation:
jfm_002:
id: 2
jour_id: 5
jour_type: Principal
user_id: 2
notes: 我觉得这个系统挺实用界面挺简洁美观1
status:
reply_id: 0
created_on: 2014-07-16 15:27:2
updated_on: 2014-07-16 15:27:2
m_parent_id:
is_readed:
m_reply_count:
m_reply_id:
is_comprehensive_evaluation:
jfm_045:
id: 45 id: 45
jour_id: 2 jour_id: 2
jour_type: Project jour_type: Project
@ -64,7 +94,7 @@ jfm_060:
jour_id: 2 jour_id: 2
jour_type: Project jour_type: Project
user_id: 2 user_id: 2
notes: something very nice notes:
status: status:
reply_id: 0 reply_id: 0
created_on: 2013-08-21 07:04:43 created_on: 2013-08-21 07:04:43
@ -119,4 +149,3 @@ jfm_088:
m_reply_count: m_reply_count:
m_reply_id: m_reply_id:
is_comprehensive_evaluation: is_comprehensive_evaluation:

View File

@ -0,0 +1,37 @@
require File.expand_path('../../test_helper', __FILE__)
class UsersControllerTest < ActionController::TestCase
fixtures :users, :projects, :members, :member_roles, :roles,
:custom_fields, :custom_values, :groups_users,
:auth_sources,
:activities,
:journals_for_messages
def setup
User.current = nil
@request.session[:user_id] = 1
@request.session[:ctime] = Time.now
@request.session[:atime] = Time.now
end
test '#index by non-member' do
@request.session[:user_id] = nil
get :index
assert_response :success
assert_template 'index'
end
test '#show by non-member' do
@request.session[:user_id] = 8
get :show, {id: 5}
assert_response :success
assert_template 'show'
end
test '#user_newfeedback by non-member' do
@request.session[:user_id] = nil
get :user_newfeedback, {id: 5}
assert_response :success
assert_template 'user_newfeedback'
end
end