This commit is contained in:
huang 2015-05-18 11:37:06 +08:00
commit 3c810a0cee
50 changed files with 1958 additions and 1590 deletions

View File

@ -274,6 +274,13 @@ module Mobile
get ":course_id/members" do
cs = CoursesService.new
count = cs.course_members params
# 我如果在学生当中,那么我将放在第一位
count.each do |m|
if m.user.id == current_user.id
count.delete m
count.unshift m
end
end
present :data, count, with: Mobile::Entities::Member
present :status, 0
end
@ -290,6 +297,20 @@ module Mobile
present :data,homeworkscore,with: Mobile::Entities::Homeworkscore
present :status,0
end
desc '发布课程通知'
params do
requires :token,type:String
requires :course_id,type:Integer,desc:'课程id'
requires :title,type:String,desc:'通知标题'
requires :desc,type:String,desc:'通知描述'
end
post ':course_id/create_course_notice' do
cs = CoursesService.new
news = cs.create_course_notice params,current_user
present :data,news,with:Mobile::Entities::News
present :status,0
end
end
end
end

View File

@ -85,6 +85,7 @@ module Mobile
requires :search_by, type: String,desc: '搜索依据0 昵称1 用户名2 邮箱,3 昵称和姓名'
optional :is_search_assitant,type:Integer,desc:'是否搜索注册用户来作为助教'
optional :course_id,type:Integer,desc: '课程id搜索注册用户不为该课程教师的其他用户'
optional :user_id,type:Integer,desc:'用户id'
end
get 'search/search_user' do
us = UsersService.new

View File

@ -315,7 +315,7 @@ class AccountController < ApplicationController
#根据home_url生产正则表达式
eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/")
if (code=~params[:back_url] || params[:back_url].to_s.include?('lost_password')) && last_login_on != ''
redirect_to user_activities_path(user,host: Setting.user_domain)
redirect_to user_activities_path(user,host: Setting.host_user)
else
if last_login_on == ''
redirect_to my_account_url
@ -333,7 +333,7 @@ class AccountController < ApplicationController
token = Token.get_or_create_permanent_login_token(user)
cookie_options = {
:value => token.value,
:expires => 7.days.from_now,
:expires => 1.month.from_now,
:path => (Redmine::Configuration['autologin_cookie_path'] || '/'),
:secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false),
:httponly => true

View File

@ -852,7 +852,7 @@ class CoursesController < ApplicationController
#验证是否显示课程
def can_show_course
@first_page = FirstPage.find_by_page_type('project')
if @first_page.show_course == 2
if @first_page.try(:show_course) == 2
render_404
end
end

View File

@ -118,11 +118,11 @@ module ApplicationHelper
end
#if user.active? || (User.current.admin? && user.logged?)
# link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes
# link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => user.css_classes
#else
# name
#end
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => user.css_classes
else
h(user.to_s)
end
@ -131,7 +131,7 @@ module ApplicationHelper
def link_to_isuue_user(user, options={})
if user.is_a?(User)
name = h(user.name(options[:format]))
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => "pro_info_p"
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => "pro_info_p"
else
h(user.to_s)
end
@ -140,7 +140,7 @@ module ApplicationHelper
def link_to_settings_user(user, options={})
if user.is_a?(User)
name = h(user.name(options[:format]))
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => "w90 c_orange fl"
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => "w90 c_orange fl"
else
h(user.to_s)
end
@ -155,7 +155,7 @@ module ApplicationHelper
else
name = user.login
end
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => options[:class]
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.host_user}, :class => options[:class]
else
h(user.to_s)
end
@ -2086,21 +2086,21 @@ module ApplicationHelper
hidden_non_project = Setting.find_by_name("hidden_non_project")
visiable = !(hidden_non_project && hidden_non_project.value == "0")
main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.course_domain}
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain}
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain}
main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.host_course}
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.host_name}
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.host_contest}
# course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'}
course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain}
course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.host_course}
# courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'}
#users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain}
#users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.host_user}
# contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'}
bids_link = link_to l(:label_requirement_enterprise), {:controller => 'bids', :action => 'index'}
forum_link = link_to l(:label_forum_all), {:controller => "forums", :action => "index"}
stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'}
school_all_school_link = link_to l(:label_school_all), {:controller => 'school', :action => 'index'}
project_new_link = link_to l(:label_project_new), {:controller => 'projects', :action => 'new', :host => Setting.project_domain}
# project_mine_link = link_to l(:label_my_project), {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain}
project_new_link = link_to l(:label_project_new), {:controller => 'projects', :action => 'new', :host => Setting.host_name}
# project_mine_link = link_to l(:label_my_project), {:controller => 'users', :action => 'user_projects', :host => Setting.host_name}
#@nav_dispaly_project_label
nav_list = Array.new

View File

@ -11,7 +11,7 @@ module GitlabHelper
PROJECT_PATH_CUT = 40
# gitlab版本库所在服务器
# 注意REPO_IP_ADDRESS必须以http://开头暂时只支持HTTP协议未支持SSH
#REPO_IP_ADDRESS = "http://" + Setting.repository_domain
#REPO_IP_ADDRESS = "http://" + Setting.host_repository
REPO_IP_ADDRESS = "http://192.168.137.100"
GITLAB_API = "/api/v3"

View File

@ -24,7 +24,7 @@ module RepositoriesHelper
ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/"
end
PROJECT_PATH_CUT = 40
REPO_IP_ADDRESS = Setting.repository_domain
REPO_IP_ADDRESS = Setting.host_repository
def format_revision(revision)
if revision.respond_to? :format_identifier

View File

@ -508,6 +508,12 @@ class CoursesService
end
end
def create_course_notice params ,current_user
n = News.new(:course_id =>params[:course_id], :author_id => current_user.id,:title =>params[:title],:description=> params[:desc])
n.save
{:id => n.id,:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count}
end
private
def searchmember_by_name members, name
#searchPeopleByRoles(project, StudentRoles)

View File

@ -125,9 +125,9 @@
:file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all)
} %>
<% if container.nil? %>
<span id="upload_file_count" :class="c_grey"><%= l(:label_no_file_uploaded)%></span>
<% end %>
<% if defined?(container) %>
<span id="upload_file_count" class="c_grey"><%= l(:label_no_file_uploaded)%></span>
<% end %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</span>

View File

@ -43,7 +43,7 @@
<div id="upload_progressbar" style="height:14px; margin-bottom: 10px;display: block"></div>
</div>
</span>
<%= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "btn_addPic", :style => "text-decoration:none;" %>
<%#= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "btn_addPic", :style => "text-decoration:none;" %>
<a href="javascript:void(0);" class="btn_addPic" style="text-decoration:none;">
<span><%= l(:button_upload_photo) %></span>
</a>

View File

@ -9,8 +9,8 @@
:size => "1",
:multiple => true,
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_file_size => Setting.upload_avatar_max_size,
:max_file_size_message => l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:file_type => Redmine::Configuration['pic_types'].to_s,
:type_support_message => l(:error_pic_type),

View File

@ -187,7 +187,7 @@
<!-- modified by longjun -->
<%= link_to l(:label_create_new_projects),
new_project_path(:course => 0, :project_type => 0, :host => Setting.project_domain),
new_project_path(:course => 0, :project_type => 0, :host => Setting.host_name),
:target => '_blank'
%>
<!-- end longjun -->

View File

@ -23,6 +23,7 @@
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;</label>
<input type="text" name="course[name]" id="course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name();" value="<%= @course.name%>">
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
<input type="password" style="top: -100000px;position: fixed;">
</li>
<div class="cl"></div>
<li class="ml45">

View File

@ -1,5 +1,4 @@
<!-- added by fq -->
<!--display the board-->
<script>$(function(){$("img").removeAttr("alt");});</script>
<div class="borad-topic-count">共有 <%=link_to @forum.memos.count %> 个贴子</div>
<div style="padding-top: 10px">
<% if memos.any? %>

View File

@ -31,5 +31,5 @@
</div>
<% end -%>
<ul class="wlist">
<%= pagination_links_full issue_pages, issue_count, :per_page_links => false, :remote => false, :flag => true %>
<%= pagination_links_full issue_pages, issue_count, :per_page_links => false, :remote => true, :flag => true %>
</ul>

View File

@ -55,7 +55,7 @@
<% end %>
<% end %>
<!-- more -->
<div class="subNav subNav_jiantou" onclick="$('#navContent').toggle(500);" id="expand_tools_expand"><%= l(:label_project_more) %></div>
<div class="subNav subNav_jiantou" id="expand_tools_expand" nhtype="toggle4cookie" data-id="expand_tool_more" data-target="#navContent" data-val="retract"><%= l(:label_project_more) %></div>
<ul class="navContent" id="navContent">
<%= render 'projects/tools_expand' %>
</ul>

View File

@ -169,15 +169,15 @@ function cookieget(n)
<div class="side_center">
<div class="custom_service">
<% get_memo %>
<% if @public_forum %>
<%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %>
<%= f.text_area :subject,:id=>"subject", :class => "opnionText", :placeholder => l(:label_feedback_tips) %>
<%= f.hidden_field :content,:id => 'hidden', :required => true , :value => l(:label_feedback_value) %>
<%#= f.submit :value => l(:label_memo_create), :class => "opnionButton", :id => "button1" %>
<label class="c_grey">您还能输入<span id="textCount" class="c_orange">50</span>个字符</label>
<a href="javascript:void(0);" class="opnionButton" style=" color:#fff;" id="" onclick="f_submit();"><%= l(:label_submit)%></a>
<% end %>
<% end %>
<% if @public_forum %>
<%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %>
<%= f.text_area :subject,:id=>"subject", :class => "opnionText", :placeholder => l(:label_feedback_tips) %>
<%= f.hidden_field :content,:id => 'hidden', :required => true , :value => l(:label_feedback_value) %>
<%#= f.submit :value => l(:label_memo_create), :class => "opnionButton", :id => "button1" %>
<label class="c_grey">您还能输入<span id="textCount" class="c_orange">50</span>个字符</label>
<a href="javascript:void(0);" class="opnionButton" style=" color:#fff;" id="" onclick="f_submit();"><%= l(:label_submit)%></a>
<% end %>
<% end %>
</div>
<div class="msgserver">
<a href="http://user.trustie.net/users/34/user_newfeedback" style="color: #15BCCF;"><%= l(:label_technical_support) %>白&nbsp;&nbsp;&nbsp;羽</a>

View File

@ -27,13 +27,13 @@
<% end %>
<%= render :partial => 'layouts/user_project_list', :locals => {:hasCourse => hasCourse} %>
<li style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.host_user}%>
</li>
</ul>
</li>
<li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;">
<%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')',
{ :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.user_domain },
{ :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user },
{:class => 'my-message'} if User.current.logged?%>
</li>
</ul>

View File

@ -67,17 +67,17 @@ end
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><%=User.current%> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')', { :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.user_domain }, {:class => 'my-message'} if User.current.logged? -%>
<%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')', { :controller => 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user }, {:class => 'my-message'} if User.current.logged? -%>
</li>
<li>
<%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %>
<%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.host_course} %>
</li>
<li>
<%=link_to l(:label_my_projects),{:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
<%=link_to l(:label_my_projects),{:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name} %>
</li>
<li class="divider"></li>
<li>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.host_user}%>
</li>
</ul>
</li>

View File

@ -18,15 +18,15 @@
<% if User.current.logged? -%>
<li id="current_user_li">
<%= link_to "#{User.current.login}<span class='pic_triangle'></span>".html_safe, {:controller=> 'users', :action => 'show', id: User.current.id, host: Setting.user_domain}, :class => "uses_name"%>
<%= link_to "#{User.current.login}<span class='pic_triangle'></span>".html_safe, {:controller=> 'users', :action => 'show', id: User.current.id, host: Setting.host_user}, :class => "uses_name"%>
<ul id="user_sub_menu" style="right: 0px;display: none;">
<% unless User.current.projects.empty? %>
<li id="my_projects_li">
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain}, :class => "parent" %>
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name}, :class => "parent" %>
<ul id="my_projects_ul">
<% User.current.projects.each do |project| %>
<li title="<%=project.name%>">
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.project_domain } %>
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.host_name } %>
</li>
<% end %>
</ul>
@ -49,7 +49,7 @@
<% end %>
<% end %>
<li>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%>
<%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.host_user}%>
</li>
</ul>
</li>

View File

@ -1,10 +1,10 @@
<% if User.current.projects.count>0 %>
<li id="project_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name} %>
<ul class="project_sub_menu" style="top:<%= hasCourse ? 35 : 0 %>px;">
<% User.current.projects.each do |project| %>
<li style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" title="<%=project.name%>">
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.project_domain } %>
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.host_name } %>
</li>
<% end %>
</ul>

View File

@ -52,7 +52,7 @@
<a href="javascript:void(0)" onclick="submitSerch('<%= l(:label_search_conditions_not_null) %>');" class="search_btn fl f14 c_white" >
<%= l(:label_search)%>
</a>
<br />
<div class="cl"></div>
<span id="project_name_span" style="float: left"></span>
<% end %>
</div>

View File

@ -157,7 +157,7 @@
<!--邀请加入-->
<div class="subNavBox">
<% if User.current.member_of?(@project) %>
<div class="subNav currentDd currentDt subNav_jiantou" id="expand_tools_expand_invit" onclick="$('#navContent_invit').toggle(500);"><%= l(:label_invite)%></div>
<div class="subNav currentDd currentDt subNav_jiantou" id="expand_tools_expand_invit" nhtype="toggle4cookie" data-id="expand_invit" data-target="#navContent_invit"><%= l(:label_invite)%></div>
<ul class="navContent " style="display:block" id="navContent_invit">
<li><%= link_to l(:label_invite_new_user), :controller=>"projects", :action=>"invite_members_by_mail", :id => @project %></li>
<% if User.current.allowed_to?(:manage_members, @project) %>

View File

@ -68,7 +68,7 @@
</tr>
<tr>
<td>
<%=link_to l(:field_homepage), home_path %> >
<%=link_to l(:field_homepage), home_path %> >
<span>
<%=link_to @user.name, user_path %>
</span>
@ -122,7 +122,7 @@
<strong class="font_small_watch">
<%= link_to l(:label_user_watcher)+"("+User.watched_by(@user.id).count.to_s+")" ,:controller=>"users", :action=>"user_watchlist"%>
</strong> &nbsp;
<strong class="font_small_watch">
<%= link_to l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)+"("+@user.watcher_users.count.to_s+")", :controller=>"users", :action=>"user_fanslist" %>
</strong>&nbsp;&nbsp;
@ -190,16 +190,16 @@
<% unless @user.user_extensions.nil? %>
<% if @user.user_extensions.identity == 0 || @user.user_extensions.identity == 1 %>
<tr>
<% unless @user.user_extensions.school.nil? %>
<td style=" float: right" width="70px">
<span style="float: right"><%= l(:field_occupation) %></span>
</td>
<td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
<% unless @user.user_extensions.school.nil? %>
<a href="http://course.trustie.net/?school_id=<%= @user.user_extensions.school.id%>"><%= @user.user_extensions.school.name %></a>
<% end %>
</td>
<% end %>
</tr>
<% elsif @user.user_extensions.identity == 3 %>
<% elsif @user.user_extensions.identity == 3 && @user.user_extensions.occupation.empty? %>
<tr>
<td style=" float: right" width="70px">
<span style="float: right"> <%= l(:field_occupation) %></span>

View File

@ -18,9 +18,6 @@
}
})
});
</script>
<script type="text/javascript">
function get_school(value){
var prefix = '';
if(location.href.indexOf('ros') >= 0)
@ -36,14 +33,9 @@
}
})
}
</script>
<script type="text/javascript">
function test(id){
location.href = encodeURI('http://<%= Setting.host_course %>/?school_id='+id);
}
</script>
<script type="text/javascript">
function ssearch(){
//alert($("#key_word").val());
var value = $("#key_word").val();

View File

@ -34,7 +34,7 @@
<% memberships = user.memberships.all(:conditions => cond) %>
<%= l(:label_x_contribute_to, :count => memberships.count) %>
<% for member in memberships %>
<%= link_to member.project.name, {:controller => 'projects', :action => 'show',id: member.project.id, host: Setting.project_domain } %><%= (memberships.last == member) ? '' : '' %>
<%= link_to member.project.name, {:controller => 'projects', :action => 'show',id: member.project.id, host: Setting.host_name } %><%= (memberships.last == member) ? '' : '' %>
<% end %>
<p>
<%# unless user.memberships.empty? %>
@ -45,7 +45,7 @@
<%= "" unless user_courses.empty? %>
<% for course in user_courses %>
<%# if course.name != nil %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : '' %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.host_course} %><%= (user_courses.last == course) ? '' : '' %>
<%# end %>
<% end %>
<%# end %>

View File

@ -32,7 +32,7 @@
<%= l(:label_x_course_contribute_to, :count => user_courses.count) %>
<%= "" unless user_courses.empty? %>
<% for course in user_courses %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : '' %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.host_course} %><%= (user_courses.last == course) ? '' : '' %>
<% end %>
</p>
</td>

View File

@ -38,7 +38,7 @@
<%= "" unless user_courses.empty? %>
<% for course in user_courses %>
<%# if course.name != nil %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : '' %>
<%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.host_course} %><%= (user_courses.last == course) ? '' : '' %>
<%# end %>
<% end %>
<%# end %>

View File

@ -1520,3 +1520,5 @@ en:
label_no_courses: You do not participate in any course, please search the curriculum, course, or create a course!
label_commit_failed: commit failed
#api end
error_upload_avatar_to_large: "too big (%{max_size})"

View File

@ -1983,3 +1983,4 @@ zh:
label_media: 媒体
label_code: 代码
error_upload_avatar_to_large: "超过大小限制 (%{max_size})"

View File

@ -60,7 +60,9 @@ per_page_options:
default: '25,50,100'
mail_from:
default: trustieforge@gmail.com
upload_avatar_max_size:
format: int
default: 5242880
### delayjob for send email.
delayjob_enabled:
default: 1
@ -254,16 +256,6 @@ tags_max_length:
tags_show_search_results:
format: int
default: 5
user_domain:
default: user.trustie.net
project_domain:
default: forge.trustie.net
contest_domain:
default: contest.trustie.net
course_domain:
default: course.trustie.net
repository_domain:
default: repository.trustie.net
please_chose:
default: 请选择
hidden_non_project:

View File

@ -0,0 +1,8 @@
class AddHostConfigToSettings < ActiveRecord::Migration
def change
Setting.create(name: 'host_course', value: 'course.trustie.net')
Setting.create(name: 'host_contest', value: 'contest.trustie.net')
Setting.create(name: 'host_user', value: 'user.trustie.net')
Setting.create(name: 'host_repository', value: 'repository.trustie.net')
end
end

File diff suppressed because it is too large Load Diff

View File

@ -267,7 +267,7 @@ Redmine::AccessControl.map do |map|
end
#by young
Redmine::MenuManager.map :top_menu do |menu|
menu.push :home, {:host => Setting.user_domain}
menu.push :home, {:host => Setting.host_user}
menu.push :course_practice, {:controller => 'projects', :action => 'course', :project_type => 1}
menu.push :project_deposit, { :controller => 'projects', :action => 'index', :project_type => 0}, :caption => :label_project_deposit
menu.push :software_user, {:controller => 'users', :action => 'index'}
@ -336,7 +336,7 @@ end
########fq
Redmine::MenuManager.map :bid_menu do |menu|
menu.push :respond, { :controller => 'bids', :action => 'show' }, :caption => :label_user_response
menu.push :project, { :controller => 'bids', :action => 'show_project', :host => Setting.project_domain }, :caption => :label_bidding_project
menu.push :project, { :controller => 'bids', :action => 'show_project', :host => Setting.host_name }, :caption => :label_bidding_project
# menu.push :result, { :controller => 'bids', :action => 'show_results' },
# :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p }
end
@ -422,7 +422,7 @@ Redmine::MenuManager.map :course_menu do |menu|
end
Redmine::MenuManager.map :user_menu do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain }
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.host_user }
menu.push :user_course, {:controller => 'users', :action => 'user_courses'},
:if => Proc.new {|u| if User.current == u || User.current.admin?
membership = u.coursememberships.all
@ -432,7 +432,7 @@ Redmine::MenuManager.map :user_menu do |menu|
FirstPage.find_by_page_type('project').show_course != 2 && membership && membership.count > 0
}
#menu.push :user_homework, {:controller => 'users', :action => 'user_homeworks'} by huang
menu.push :user_project, {:controller => 'users', :action => 'user_projects_index', :host => Setting.project_domain},
menu.push :user_project, {:controller => 'users', :action => 'user_projects_index', :host => Setting.host_name},
:if => Proc.new {|u| if User.current.admin?
memberships = u.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first
else
@ -443,24 +443,24 @@ Redmine::MenuManager.map :user_menu do |menu|
memberships || watch_projects
}
# menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} by huang
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user}
end
Redmine::MenuManager.map :user_enterprise_menu do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain }
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.host_user }
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain}
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.host_name}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.user_domain}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user}
end
Redmine::MenuManager.map :user_menu_self do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.project_domain }
menu.push :user_information, {:controller => 'users', :action => 'info', :host => Setting.user_domain}
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.user_domain}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.user_domain}
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.host_name }
menu.push :user_information, {:controller => 'users', :action => 'info', :host => Setting.host_user}
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.host_name}
menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user}
menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user}
end
#end

View File

@ -0,0 +1,122 @@
/*
* jQuery File Upload Validation Plugin 1.1.3
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2013, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/* global define, require, window */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'./jquery.fileupload-process'
], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS:
factory(require('jquery'));
} else {
// Browser globals:
factory(
window.jQuery
);
}
}(function ($) {
'use strict';
// Append to the default processQueue:
$.blueimp.fileupload.prototype.options.processQueue.push(
{
action: 'validate',
// Always trigger this action,
// even if the previous action was rejected:
always: true,
// Options taken from the global options map:
acceptFileTypes: '@',
maxFileSize: '@',
minFileSize: '@',
maxNumberOfFiles: '@',
disabled: '@disableValidation'
}
);
// The File Upload Validation plugin extends the fileupload widget
// with file validation functionality:
$.widget('blueimp.fileupload', $.blueimp.fileupload, {
options: {
/*
// The regular expression for allowed file types, matches
// against either file type or file name:
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
// The maximum allowed file size in bytes:
maxFileSize: 10000000, // 10 MB
// The minimum allowed file size in bytes:
minFileSize: undefined, // No minimal file size
// The limit of files to be uploaded:
maxNumberOfFiles: 10,
*/
// Function returning the current number of files,
// has to be overriden for maxNumberOfFiles validation:
getNumberOfFiles: $.noop,
// Error and info messages:
messages: {
maxNumberOfFiles: 'Maximum number of files exceeded',
acceptFileTypes: 'File type not allowed',
maxFileSize: 'File is too large',
minFileSize: 'File is too small'
}
},
processActions: {
validate: function (data, options) {
if (options.disabled) {
return data;
}
var dfd = $.Deferred(),
settings = this.options,
file = data.files[data.index],
fileSize;
if (options.minFileSize || options.maxFileSize) {
fileSize = file.size;
}
if ($.type(options.maxNumberOfFiles) === 'number' &&
(settings.getNumberOfFiles() || 0) + data.files.length >
options.maxNumberOfFiles) {
file.error = settings.i18n('maxNumberOfFiles');
} else if (options.acceptFileTypes &&
!(options.acceptFileTypes.test(file.type) ||
options.acceptFileTypes.test(file.name))) {
file.error = settings.i18n('acceptFileTypes');
} else if (fileSize > options.maxFileSize) {
file.error = settings.i18n('maxFileSize');
} else if ($.type(fileSize) === 'number' &&
fileSize < options.minFileSize) {
file.error = settings.i18n('minFileSize');
} else {
delete file.error;
}
if (file.error || data.files.error) {
data.files.error = true;
dfd.rejectWith(this, [data]);
} else {
dfd.resolveWith(this, [data]);
}
return dfd.promise();
}
}
});
}));

View File

@ -1,15 +1,44 @@
$(function() {
var $upload_file = $('.upload_file');
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
var validateImage = function(file) {
var types = $upload_file.attr('data-file-type').split(",");
var check = false;
$.each(types, function(n, e) {
if (endsWith(file.name, e)) {
check = true;
}
});
if (!check) {
alert($upload_file.attr("data-type-support-message") + $upload_file.attr("data-file-type"));
return false;
}
if (file.size && file.size > parseInt($upload_file.attr('data-max-file-size'))) {
alert($upload_file.attr("data-max-file-size-message"));
return false;
}
return true;
};
$('.upload_file').fileupload({
url: '/upload_avatar.json?source_type=' + $('.upload_file').attr('data-source-type') +
'&source_id=' + $('.upload_file').attr('data-source-id'),
add: function(e, data) {
if (!validateImage(data.files[0])) {
return false;
}
data.submit();
},
formData: function(form) {
var data = form.serializeArray();
var auth = null;
for(var key in data){
if(data[key].name == "authenticity_token"){
auth = data[key];break;
}
for (var key in data) {
if (data[key].name == "authenticity_token") {
auth = data[key];
break;
}
}
return [auth];
},

View File

@ -384,4 +384,45 @@ function submitProjectBoard()
{
$("#message-form").submit();
}
}
}
//cookie记忆html区块 显示/隐藏 的代码 start
$(function(){
var personalized_expand_key = "personalized_expand";
function personalized_init(){
var personalized_map = cookieget(personalized_expand_key);
if(personalized_map!=false){
personalized_map = JSON.parse(personalized_map);
$("*[nhtype='toggle4cookie']").each(function(){
var personalized_id=$(this).data('id');
var val = personalized_map[personalized_id];
if(val!=undefined && val!=$(this).data('val')){
personalized_click($(this),0);
}
});
}
}
function personalized_click(obj,timeout){
var target = $(obj.data('target'));
var oldval = obj.data('val');
var val='';
if(oldval=='expand'){val='retract';}else{val='expand';}
obj.data('val',val);
var personalized_map = cookieget(personalized_expand_key);
if(personalized_map == false){
personalized_map={};
}else{
personalized_map = JSON.parse(personalized_map);
}
var personalized_id=obj.data('id');
personalized_map[personalized_id]=val;
cookiesave(personalized_expand_key,JSON.stringify(personalized_map));
target.toggle(timeout);
}
$("*[nhtype='toggle4cookie']").click(function(){
personalized_click($(this),500);
});
personalized_init();
});
//cookie记忆html区块 显示/隐藏 的代码 end

View File

@ -7,6 +7,7 @@ h2, .wiki h1 {font-size: 20px;}
h3, .wiki h2 {font-size: 15px; padding-left: 5px}
h4, .wiki h3 {font-size: 13px;}
h4 {border-bottom: 1px dotted #bbb;}
li{list-style-type:none;}
/*huang*/
/*current position*/
.contest_count{
@ -1597,7 +1598,8 @@ blockquote {
margin-right: 0.4em;
border-radius: 4px;
font-family: "Microsoft YaHei";
background: url('../images/requirements/reference.jpg')
background: url('../images/requirements/reference.jpg');
background-size: 100% 100%;
}
blockquote blockquote { margin-left: 0;}
@ -2779,4 +2781,4 @@ div.repos_explain{
padding-top: 20px;
padding-bottom: 20px;
}
.upload_img img{max-width: 580px;}
.upload_img img{max-width: 100%;}

View File

@ -487,6 +487,7 @@ blockquote {
border-radius: 4px;
font-family: "Microsoft YaHei";
background: url('../images/requirements/reference.jpg');
background-size: 100% 100%;
}
a.member_search_edit {width: 43px;background: #15bccf;color: #fff;text-align: center;text-decoration: none;padding: 2px;}
.min_search_edit {width: 150px;height: 20px;border: 1px solid #d0d0d0 !important;color: #666;}

View File

@ -388,6 +388,7 @@ blockquote {
border-radius: 4px;
font-family: "Microsoft YaHei";
background: url(http://test.forge.trustie.net/images/requirements/xreference.jpg.pagespeed.ic.h4inUJNyH0.jpg);
background-size: 100% 100%;
}
/*上传项目图片*/
.upload_file{margin-left: -60px;margin-top: 40px;width: 50px;position: absolute;height: 24px;opacity: 0;cursor: pointer}

15
spec/factories/courses.rb Normal file
View File

@ -0,0 +1,15 @@
#coding=utf-8
#
FactoryGirl.define do
factory :course do
name 'name'
time '2015'
term 'term'
class_period 1
password '111'
description 'description'
is_public 1
open_student 1
association :teacher, factory: :user
end
end

View File

@ -1,9 +1,9 @@
FactoryGirl.define do
factory :user do
login "ExampleUser"
login "factoryuser"
mail "user@example.com"
password "foobar"
password_confirmation "foobar"
password "foobar111"
password_confirmation "foobar111"
end
end

5
spec/fixtures/hah.txt vendored Normal file
View File

@ -0,0 +1,5 @@

BIN
spec/fixtures/test.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -29,6 +29,10 @@ RSpec.configure do |config|
# instead of true.
config.use_transactional_fixtures = true
config.before(:suite) do
require_relative "seeds"
end
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.

View File

@ -1,6 +1,22 @@
require 'rails_helper'
require 'shared_account_spec'
RSpec.describe "Account request", :type => :request do
describe "注册用户" do
include_context "create user"
it "正常注册可以成功" do
shared_register
expect(response).to redirect_to(my_account_url)
end
it "修改用户资料" do
shared_register
shared_update_user
expect(response).to redirect_to(user_url(session[:user_id]))
end
end
describe "用户登录" do
let(:user){FactoryGirl.create(:user)}
@ -10,7 +26,7 @@ RSpec.describe "Account request", :type => :request do
end
context "正常登录" do
before{post signin_path, username: user.login, password: user.password}
before{ post signin_path, username: user.login, password: user.password }
it "登录成功,正常跳转" do
expect(response).to redirect_to(my_account_url)
end

View File

@ -0,0 +1,48 @@
require 'rails_helper'
require 'shared_account_spec'
RSpec.describe "课程", :type => :request do
let(:course){FactoryGirl.attributes_for(:course)}
describe "创建课程" do
include_context "create user"
before {
shared_register
shared_update_user
}
context "参数正确,成功创建课程" do
before{
# uu = current_user
# allow(User).to receive(:current).and_return(uu)
# allow(uu).to receive(:allowed_to?).and_return(123)
post courses_path,
"course[name]"=> course[:name],
"class_period"=> course[:class_period],
"time"=> course[:time],
"term"=> course[:term],
"course[password]"=>course[:password],
"course[description]"=> course[:description],
"course[is_public]"=> course[:is_public],
"course[open_student]"=> course[:open_student]
}
it{expect(assigns(:course)).to be_instance_of(Course)}
it{expect(response).to redirect_to(settings_course_url(assigns(:course), course_type: 1))}
end
end
describe "配置课程" do
let (:course) {FactoryGirl.create(:course)}
context "修改课程图片" do
include Rack::Test::Methods
let(:avatar) {Rack::Test::UploadedFile.new("#{Rails.root}/spec/fixtures/test.jpg",'image/jpg')}
context "正常图片上传成功" do
subject(:resp) {post upload_avatar_path(source_type: 'Course', source_id: course.id, format: :json),"avatar"=>{image: avatar}}
it{ expect(subject).to be_ok }
it{ expect(subject.body).not_to be_empty }
end
it "不是图片,上传失败"
end
end
end

View File

@ -0,0 +1,6 @@
require 'rails_helper'
RSpec.describe "作业打包下载", :type => :request do
describe "单独下载某学生作业" do
end
end

18
spec/seeds.rb Normal file
View File

@ -0,0 +1,18 @@
if Role.count <= 0
ActiveRecord::Base.connection.execute(
%Q{
INSERT INTO `roles` (`id`, `name`, `position`, `assignable`, `builtin`, `permissions`, `issues_visibility`)
VALUES
(1,'Non member',1,1,1,'---\n- :upload_attachments\n- :memos_attachments_download\n- :add_project\n- :projects_attachments_download\n- :add_course\n- :course_attachments_download\n- :view_course_files\n- :add_messages\n- :delete_own_messages\n- :view_calendar\n- :view_documents\n- :view_files\n- :view_gantt\n- :view_issues\n- :save_queries\n- :comment_news\n- :browse_repository\n- :view_changesets\n- :view_time_entries\n- :view_wiki_pages\n- :view_wiki_edits\n','default'),
(2,'Anonymous',2,1,2,'---\n- :memos_attachments_download\n- :view_course_files\n- :view_calendar\n- :view_documents\n- :view_files\n- :view_gantt\n- :view_issues\n- :browse_repository\n- :view_changesets\n- :view_time_entries\n- :view_wiki_pages\n- :view_wiki_edits\n','default'),
(3,'Manager',3,1,0,'---\n- :upload_attachments\n- :memos_attachments_download\n- :add_project\n- :edit_project\n- :close_project\n- :select_project_modules\n- :manage_members\n- :manage_versions\n- :add_subprojects\n- :is_manager\n- :projects_attachments_download\n- :as_teacher\n- :add_course\n- :edit_course\n- :close_course\n- :select_course_modules\n- :view_course_journals_for_messages\n- :course_attachments_download\n- :view_course_files\n- :view_homework_attaches\n- :quote_project\n- :manage_boards\n- :add_messages\n- :edit_messages\n- :edit_own_messages\n- :delete_messages\n- :delete_own_messages\n- :view_calendar\n- :view_code_review\n- :add_code_review\n- :edit_code_review\n- :delete_code_review\n- :assign_code_review\n- :code_review_setting\n- :add_documents\n- :edit_documents\n- :delete_documents\n- :view_documents\n- :manage_files\n- :view_files\n- :view_gantt\n- :manage_categories\n- :view_issues\n- :add_issues\n- :edit_issues\n- :manage_issue_relations\n- :manage_subtasks\n- :set_issues_private\n- :set_own_issues_private\n- :add_issue_notes\n- :edit_issue_notes\n- :edit_own_issue_notes\n- :view_private_notes\n- :set_notes_private\n- :move_issues\n- :delete_issues\n- :manage_public_queries\n- :save_queries\n- :view_issue_watchers\n- :add_issue_watchers\n- :delete_issue_watchers\n- :manage_news\n- :comment_news\n- :manage_repository\n- :browse_repository\n- :view_changesets\n- :commit_access\n- :manage_related_issues\n- :log_time\n- :view_time_entries\n- :edit_time_entries\n- :edit_own_time_entries\n- :manage_project_activities\n- :manage_wiki\n- :rename_wiki_pages\n- :delete_wiki_pages\n- :view_wiki_pages\n- :export_wiki_pages\n- :view_wiki_edits\n- :edit_wiki_pages\n- :delete_wiki_pages_attachments\n- :protect_wiki_pages\n','all'),
(4,'Developer',4,1,0,'---\n- :add_project\n- :manage_members\n- :manage_versions\n- :projects_attachments_download\n- :add_course\n- :edit_course\n- :close_course\n- :select_course_modules\n- :view_course_journals_for_messages\n- :course_attachments_download\n- :view_course_files\n- :view_homework_attaches\n- :paret_in_homework\n- :select_contest_modules\n- :quote_project\n- :contest_attachments_download\n- :manage_contestnotifications\n- :notificationcomment_contestnotifications\n- :manage_boards\n- :add_messages\n- :edit_own_messages\n- :delete_own_messages\n- :view_calendar\n- :view_documents\n- :do_dts\n- :manage_files\n- :view_files\n- :view_gantt\n- :manage_categories\n- :view_issues\n- :add_issues\n- :edit_issues\n- :manage_issue_relations\n- :manage_subtasks\n- :set_issues_private\n- :set_own_issues_private\n- :add_issue_notes\n- :edit_own_issue_notes\n- :view_private_notes\n- :set_notes_private\n- :move_issues\n- :manage_public_queries\n- :save_queries\n- :view_issue_watchers\n- :add_issue_watchers\n- :delete_issue_watchers\n- :manage_news\n- :comment_news\n- :manage_repository\n- :browse_repository\n- :view_changesets\n- :commit_access\n- :manage_related_issues\n- :log_time\n- :view_time_entries\n- :edit_own_time_entries\n- :view_wiki_pages\n- :export_wiki_pages\n- :view_wiki_edits\n- :protect_wiki_pages\n','default'),
(5,'Reporter',5,1,0,'---\n- :upload_attachments\n- :memos_attachments_download\n- :add_project\n- :projects_attachments_download\n- :add_course\n- :edit_course\n- :close_course\n- :select_course_modules\n- :view_course_journals_for_messages\n- :course_attachments_download\n- :view_course_files\n- :view_homework_attaches\n- :manage_boards\n- :add_messages\n- :edit_own_messages\n- :delete_own_messages\n- :view_calendar\n- :view_code_review\n- :add_documents\n- :view_documents\n- :view_files\n- :view_gantt\n- :view_issues\n- :add_issues\n- :add_issue_notes\n- :edit_own_issue_notes\n- :save_queries\n- :comment_news\n- :browse_repository\n- :view_changesets\n- :log_time\n- :view_time_entries\n- :view_wiki_pages\n- :export_wiki_pages\n- :view_wiki_edits\n- :edit_wiki_pages\n- :delete_wiki_pages_attachments\n','default'),
(7,'TeachingAsistant',6,1,0,'---\n- :add_project\n- :edit_project\n- :manage_members\n- :projects_attachments_download\n- :as_teacher\n- :add_course\n- :edit_course\n- :close_course\n- :select_course_modules\n- :view_course_journals_for_messages\n- :course_attachments_download\n- :view_course_files\n- :view_homework_attaches\n- :manage_boards\n- :add_messages\n- :delete_own_messages\n- :view_calendar\n- :view_documents\n- :manage_files\n- :view_files\n- :view_gantt\n- :view_issues\n- :add_issues\n- :add_issue_notes\n- :save_queries\n- :manage_news\n- :comment_news\n- :browse_repository\n- :view_changesets\n- :view_time_entries\n- :view_wiki_pages\n- :export_wiki_pages\n- :view_wiki_edits\n- :edit_wiki_pages\n- :delete_wiki_pages_attachments\n','default'),
(9,'Teacher',7,1,0,'---\n- :upload_attachments\n- :memos_attachments_download\n- :add_project\n- :edit_project\n- :close_project\n- :select_project_modules\n- :manage_members\n- :manage_versions\n- :add_subprojects\n- :projects_attachments_download\n- :as_teacher\n- :add_course\n- :edit_course\n- :close_course\n- :select_course_modules\n- :view_course_journals_for_messages\n- :course_attachments_download\n- :view_course_files\n- :view_homework_attaches\n- :manage_boards\n- :add_messages\n- :edit_messages\n- :edit_own_messages\n- :delete_messages\n- :delete_own_messages\n- :view_calendar\n- :add_documents\n- :edit_documents\n- :delete_documents\n- :view_documents\n- :manage_files\n- :view_files\n- :view_gantt\n- :manage_categories\n- :view_issues\n- :add_issues\n- :edit_issues\n- :manage_issue_relations\n- :manage_subtasks\n- :set_issues_private\n- :set_own_issues_private\n- :add_issue_notes\n- :edit_own_issue_notes\n- :view_private_notes\n- :set_notes_private\n- :move_issues\n- :delete_issues\n- :manage_public_queries\n- :save_queries\n- :view_issue_watchers\n- :add_issue_watchers\n- :delete_issue_watchers\n- :manage_news\n- :comment_news\n- :manage_repository\n- :browse_repository\n- :view_changesets\n- :commit_access\n- :manage_related_issues\n- :log_time\n- :view_time_entries\n- :edit_time_entries\n- :edit_own_time_entries\n- :manage_project_activities\n- :manage_wiki\n- :rename_wiki_pages\n- :delete_wiki_pages\n- :view_wiki_pages\n- :export_wiki_pages\n- :view_wiki_edits\n- :edit_wiki_pages\n- :delete_wiki_pages_attachments\n- :protect_wiki_pages\n','default'),
(10,'Student',8,1,0,'---\n- :upload_attachments\n- :memos_attachments_download\n- :add_project\n- :projects_attachments_download\n- :as_student\n- :add_course\n- :edit_course\n- :close_course\n- :select_course_modules\n- :view_course_journals_for_messages\n- :course_attachments_download\n- :view_course_files\n- :view_homework_attaches\n- :paret_in_homework\n- :manage_boards\n- :add_messages\n- :edit_own_messages\n- :delete_own_messages\n- :view_calendar\n- :view_documents\n- :view_files\n- :view_gantt\n- :view_issues\n- :add_issues\n- :add_issue_notes\n- :save_queries\n- :comment_news\n- :browse_repository\n- :view_changesets\n- :view_time_entries\n- :view_wiki_pages\n- :view_wiki_edits\n','default');
}
)
end

View File

@ -0,0 +1,42 @@
require 'rails_helper'
RSpec.shared_context "create user" do
let(:user) {FactoryGirl.attributes_for(:user)}
def shared_register
post register_path, user: user
end
def shared_update_user
post my_account_url,
login: user[:login],
identity: 0,
technical_title: "教授",
no: '',
"user[lastname]" => 'lastname',
"user[firstname]" => 'firstname',
enterprise_name: '',
gender: 1,
province: '',
occupation: "",
"user[mail]" => user[:mail],
"user[language]" => "zh",
province: '',
city: '',
"user[mail_notification]" => "all",
"user_extensions[birthday]" => '',
"user_extensions[gender]" => 1,
"user_extensions[brief_introduction]" => '',
"user_extensions[location]" => '',
"user_extensions[occupation]" => '',
"user_extensions[work_experience]" => '',
"user_extensions[zip_code]" => ''
end
def shared_login
post signin_path, username: user[:login], password: user[:password]
end
def current_user
User.find(session[:user_id])
end
end