34 lines
1.8 KiB
Ruby
34 lines
1.8 KiB
Ruby
module HomeworkAttachHelper
|
|
#判断是否具有删除的权限
|
|
def attach_delete(project)
|
|
if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
|
|
true
|
|
else
|
|
false
|
|
end
|
|
end
|
|
#作业添加、编辑界面的tab页
|
|
def homework_settings_tabs f
|
|
@project = Project.find 205
|
|
@f = f
|
|
tabs = [{:name => 'info', :action => :edit_homework, :partial => 'homework_attach/edit_homework', :label => :label_information_plural},
|
|
{:name => 'members', :action => :homework_member, :partial => 'homework_attach/homework_member', :label => :label_member_plural}
|
|
]
|
|
#tabs.select {|tab| User.current.allowed_to?(tab[:action], @homework)}
|
|
end
|
|
|
|
def render_principals_for_new_members(project)
|
|
scope = Principal.active.sorted.not_member_of(project).like(params[:q])
|
|
principal_count = scope.count
|
|
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page'] #by young
|
|
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
|
|
|
|
s = content_tag('div', principals_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals')
|
|
|
|
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
|
|
link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
|
|
}
|
|
|
|
s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
|
end
|
|
end |