1.#1249 未登录和非本人进入用户课程界面时隐藏课程不显示

解决方案:判断当前用户和所查看的用户是否一致,不一致取消隐藏课程的显示
2.国际化代码以及页面代码调整
This commit is contained in:
sw 2014-10-10 09:21:10 +08:00
parent 7f08652cd1
commit 8cd3dd0287
4 changed files with 64 additions and 65 deletions

View File

@ -226,7 +226,14 @@ class UsersController < ApplicationController
end
end
membership = @user.coursememberships.all#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
if User.current == @user || User.current.admin?
membership = @user.coursememberships.all
else
membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current))
end
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
@memberships = []
membership.collect { |e|
@ -235,9 +242,9 @@ class UsersController < ApplicationController
## 判断课程是否过期 [需封装]
@memberships_doing = []
@memberships_done = []
now_time = Time.now.year
#now_time = Time.now.year
@memberships.map { |e|
end_time = e.course.get_time.year
#end_time = e.course.get_time.year
isDone = course_endTime_timeout?(e.course)
if isDone
@memberships_done.push e

View File

@ -12,8 +12,6 @@
);
</script>
<script type="text/javascript">
function get_options(value) {
$.ajax({
@ -21,17 +19,12 @@
url: '/school/get_options/' + encodeURIComponent(value),
data: 'text',
success: function (data) {
$("#province").val(value)
$("#schoollist").html(data);
}
});
}
</script>
<div class="contextual" style="padding-right: 10px;">
<%= link_to(l(:button_change_password), {:action => 'password'}, :class => 'icon icon-passwd') if @user.change_password_allowed? %>
<%= call_hook(:view_my_account_contextual, :user => @user) %>
@ -39,9 +32,7 @@
<h3 style="padding-left: 10px;"><%= l(:label_my_account) %></h3>
<%= error_messages_for 'user' %>
<fieldset class="box" style="margin:10px;">
<%= labelled_form_for :user, @user,
:url => {:action => "account"},
:html => {:id => 'my_account_form',
@ -70,7 +61,6 @@
<div>
<span id='name' style='display:none'>
<p style="width:530px;padding-left: 26px;">
<%= f.text_field :lastname, :required => true %>
<span class='font_lighter'><%= l(:field_lastname_eg) %></span>
@ -82,7 +72,8 @@
</span>
<span id='enterprise' style='display:none'>
<p style="width:400px;padding-left: 26px;"><%= l(:label_company_name)%><%= text_field_tag :enterprise_name, @user.firstname %>
<p style="width:400px;padding-left: 26px;">
<%= l(:label_company_name)%><%= text_field_tag :enterprise_name, @user.firstname %>
</p>
</span>
@ -95,10 +86,10 @@
</p>
<% else %>
<% if @user.user_extensions.gender == 0 %><!-- label_gender_male -->
<p style="width:400px;padding-left: 26px;">
<%= l(:label_gender) %>&nbsp;&nbsp;
<%= select_tag 'gender', "<option value = '0'>#{l(:label_gender_male)}</option><option value = '1'>#{l(:label_gender_female)}</option>".html_safe, :class => 'gender' %>
</p>
<p style="width:400px;padding-left: 26px;">
<%= l(:label_gender) %>&nbsp;&nbsp;
<%= select_tag 'gender', "<option value = '0'>#{l(:label_gender_male)}</option><option value = '1'>#{l(:label_gender_female)}</option>".html_safe, :class => 'gender' %>
</p>
<% else %>
<p style="width:400px;padding-left: 26px;">
<%= l(:label_gender) %>&nbsp;&nbsp;
@ -107,12 +98,11 @@
<% end %>
<% end %>
</span>
<!-- added by Wen -->
<p style="padding-left: 26px;">
<% if User.current.user_extensions.school.nil? %>
<%= l(:field_occupation) %>&nbsp;<span class="required">*</span>
<%= l(:field_occupation) %>&nbsp;
<span class="required">*</span>
<input id="province" name="province" type="text" value="请单击选择省份及学校" readonly>
<input id="occupation" name="occupation" type="hidden"/>
<input id="occupation_name" type="text" readonly/>
@ -126,8 +116,7 @@
<div id="WOpenWindow">
<a class="modal_close" href="#"></a>
<h2>学校列表</h2>
<h2><%= l(:lable_school_list)%></h2>
&nbsp;&nbsp;
<div class="pcontent">
<ul id="provincelist" class="school_list">
@ -234,39 +223,40 @@
<% unless @user.user_extensions.identity == 2 %>
<p style="width:400px;padding-left: 26px;">
<%= l(:label_identity) %>
<select onchange="showtechnical_title(this.value, document.getElementById('userTechnical_title'));" name="identity" id="userIdentity" class="location">
<option value=""><%= l(:label_account_identity_choose) %></option>
<option value="0"><%= l(:label_account_identity_teacher) %></option>
<option value="1"><%= l(:label_account_identity_student) %></option>
<option value="3"><%= l(:label_account_identity_developer) %></option>
<p style="width:400px;padding-left: 26px;">
<%= l(:label_identity) %>
<select onchange="showtechnical_title(this.value, document.getElementById('userTechnical_title'));" name="identity" id="userIdentity" class="location">
<option value=""><%= l(:label_account_identity_choose) %></option>
<option value="0"><%= l(:label_account_identity_teacher) %></option>
<option value="1"><%= l(:label_account_identity_student) %></option>
<option value="3"><%= l(:label_account_identity_developer) %></option>
</select>
<span id='technical_title' style='display:none'>
<select name="technical_title" id="userTechnical_title"></select>
</span>
<span id='no' style='display:none'>
<!-- modified by fq -->
<% unless User.current.user_extensions.student_id.nil? %>
<%= text_field_tag :no, User.current.user_extensions.student_id, :placeholder => "请输入学号" %>
<% else %>
<%= text_field_tag :no, nil, :placeholder => "请输入学号" %></span>
<% end %>
<!-- end -->
</span>
<% else %>
<span style="display:none">
<select onchange="showtechnical_title(this.value, document.getElementById('userTechnical_title'));" name="identity" id="userIdentity" class="location">
<option value=""><%= l(:label_account_identity_choose) %></option>
<option value="0"><%= l(:label_account_identity_teacher) %></option>
<option value="1"><%= l(:label_account_identity_student) %></option>
<option value="2"><%= l(:label_account_identity_enterprise) %></option>
<option value="3"><%= l(:label_account_identity_developer) %></option>
</select>
</span>
</p>
</select>
<span id='technical_title' style='display:none'>
<select name="technical_title" id="userTechnical_title"></select>
</span>
<span id='no' style='display:none'>
<!-- modified by fq -->
<% unless User.current.user_extensions.student_id.nil? %>
<%= text_field_tag :no, User.current.user_extensions.student_id, :placeholder => "请输入学号" %>
<% else %>
<%= text_field_tag :no, nil, :placeholder => "请输入学号" %></span>
<% end %>
<!-- end -->
</span>
</p>
<% else %>
<p>
<span style="display:none">
<select onchange="showtechnical_title(this.value, document.getElementById('userTechnical_title'));" name="identity" id="userIdentity" class="location">
<option value=""><%= l(:label_account_identity_choose) %></option>
<option value="0"><%= l(:label_account_identity_teacher) %></option>
<option value="1"><%= l(:label_account_identity_student) %></option>
<option value="2"><%= l(:label_account_identity_enterprise) %></option>
<option value="3"><%= l(:label_account_identity_developer) %></option>
</select>
</span>
</p>
<% end %>
</div>

View File

@ -39,19 +39,20 @@
</div>
<div class="course welcome_left" id="welcome_left">
<span class="font_welcome_school"> <% if @school_id.nil? and (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) %>
<span class="font_welcome_school">
<% if @school_id.nil? and (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) %>
<% else %>
<% if @school_id == "0" %>
<% else %>
<% if @school_id.nil? %>
<%= link_to School.find(User.current.user_extensions.school.id).name, options={:action => 'course', :school_id => User.current.user_extensions.school.id}, html_options={:class => 'font_welcome_school', :method => 'get'} %>
<br/>
<% else %>
<%= link_to School.find(@school_id).name, options={:action => 'course', :school_id => @school_id}, html_options={:class => 'font_welcome_school', :method => 'get'} %>
<br/>
<% end %>
<% if @school_id == "0" %>
<% else %>
<% if @school_id.nil? %>
<%= link_to School.find(User.current.user_extensions.school.id).name, options={:action => 'course', :school_id => User.current.user_extensions.school.id}, html_options={:class => 'font_welcome_school', :method => 'get'} %>
<br/>
<% else %>
<%= link_to School.find(@school_id).name, options={:action => 'course', :school_id => @school_id}, html_options={:class => 'font_welcome_school', :method => 'get'} %>
<br/>
<% end %>
<% end %>
<% end %>
</span>
<% unless @course_page.nil? %>
<span class="font_welcome_trustie"><%= @course_page.title %> </span>

View File

@ -2145,3 +2145,4 @@ zh:
lable_sure_exit_project: 是否确认退出该项目
lable_input_class: 在此输入课时
lable_input_class_vilidate: 学时只能为整数
lable_school_list: 学校列表