Conflicts:
	db/schema.rb
This commit is contained in:
sw 2014-07-28 15:09:14 +08:00
commit a39672dd14
20 changed files with 113 additions and 164 deletions

View File

@ -153,6 +153,7 @@ class AdminController < ApplicationController
@first_page.image_width = params[:image_width] @first_page.image_width = params[:image_width]
@first_page.image_height = params[:image_height] @first_page.image_height = params[:image_height]
@first_page.sort_type = params[:sort_type] @first_page.sort_type = params[:sort_type]
@first_page.show_course = params[:show_course]
if @first_page.save if @first_page.save
respond_to do |format| respond_to do |format|
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)

View File

@ -174,7 +174,9 @@ class AttachmentsController < ApplicationController
respond_to do |format| respond_to do |format|
# modify by nwb # modify by nwb
if !@attachment.container.nil? && (@attachment.container.is_a?(Course) || @attachment.container.course) if !@attachment.container.nil? && (@attachment.container.is_a?(Course) || @attachment.container.course)
if @course.nil? if @attachment.container.is_a?(News)
format.html { redirect_to_referer_or news_path(@attachment.container) }
elsif @course.nil?
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
else else
format.html { redirect_to_referer_or course_path(@course) } format.html { redirect_to_referer_or course_path(@course) }

View File

@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class ProjectsController < ApplicationController class ProjectsController < ApplicationController
layout :select_project_layout layout :select_project_layout
menu_item :overview menu_item :overview
menu_item :roadmap, :only => :roadmap menu_item :roadmap, :only => :roadmap
menu_item :settings, :only => :settings menu_item :settings, :only => :settings
@ -459,24 +460,10 @@ class ProjectsController < ApplicationController
end end
def new def new
@project_type = params[:project_type] ||= params[:course]
@issue_custom_fields = IssueCustomField.sorted.all @issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all @trackers = Tracker.sorted.all
@project = Project.new
case @project_type @project.safe_attributes = params[:project]
when '0' # Project
@project = Project.new
@project.safe_attributes = params[:project]
when '1' # Course
@project = Project.new
@project.safe_attributes = params[:project]
@course_tag = params[:course]
@course = Course.new
@course.safe_attributes = params[:course]
else # default Project
@project = Project.new
@project.safe_attributes = params[:project]
end
render :layout => 'base' render :layout => 'base'
end end
@ -490,128 +477,43 @@ class ProjectsController < ApplicationController
end end
def create def create
@course_tag = params[:project][:project_type]
if(@course_tag=="1")
if User.current.user_extensions.identity#.include?(UserExtensions::TEACHER,UserExtensions::DEVELOPER)
@course = Course.new
@course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
@course.safe_attributes = params[:project][:course]
@course.tea_id = User.current.id
# added by bai
@course.term = params[:term]
@course.time = params[:time]
#@course.school_id = params[:occupation]
@course.school_id = User.current.user_extensions.school_id
@course.setup_time = params[:setup_time]
@course.endup_time = params[:endup_time]
@course.class_period = params[:class_period]
end
end
@issue_custom_fields = IssueCustomField.sorted.all @issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all @trackers = Tracker.sorted.all
@project = Project.new @project = Project.new
@project.user_id = User.current.id
@project.dts_test = params[:project][:dts_test]
@project.safe_attributes = params[:project] @project.safe_attributes = params[:project]
if @course_tag == '1' if validate_parent_id && @project.save
@project.identifier = @course.extra @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
end # Add current user as a project member if he is not admin
if @course_tag == '1' #unless User.current.admin?
if User.current.user_extensions.identity == 0 r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
if@course.save m = Member.new(:user => User.current, :roles => [r])
if validate_parent_id && @project.save project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
# Add current user as a project member if he is not admin Rails.logger.debug "UserGrade created: #{user_grades.to_json}"
unless User.current.admin? if params[:project][:is_public] == '1'
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type)
m = Member.new(:user => User.current, :roles => [r]) Rails.logger.debug "ProjectStatus created: #{project_status.to_json}"
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) end
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id) @project.members << m
if params[:project][:is_public] == '1' @project.project_infos << project_info
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :project_type => @course_tag) #end
end respond_to do |format|
@project.members << m format.html {
@project.project_infos << project flash[:notice] = l(:notice_successful_create)
end if params[:continue]
respond_to do |format| attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
format.html { redirect_to new_project_path(attrs, :course => '0')
flash[:notice] = l(:notice_successful_create)
if params[:continue]
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
redirect_to new_project_path(attrs, :course => '0')
#Added by young
elsif params[:course_continue]
redirect_to new_project_path(:course => '1')
#Ended by young
else
redirect_to settings_project_path(@project,:project_type => 1)
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
end
else else
@course.destroy redirect_to settings_project_path(@project)
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
end end
else }
if validate_parent_id && @project.save format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
@project.delete
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
else
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
end
end
end end
else else
#@project.memberships.create respond_to do |format|
if validate_parent_id && @project.save format.html { render :action => 'new', :layout => 'base'}#Added by young
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') format.api { render_validation_errors(@project) }
# Add current user as a project member if he is not admin end
#unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
if params[:project][:is_public] == '1' || @course_tag=="1"
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type)
end
@project.members << m
@project.project_infos << project
#end
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_create)
if params[:continue]
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
redirect_to new_project_path(attrs, :course => '0')
#Added by young
elsif params[:course_continue]
redirect_to new_project_path(:course => '1')
#Ended by young
else
redirect_to settings_project_path(@project)
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
end
else
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
end
end end
end end

View File

@ -24,6 +24,7 @@ class WelcomeController < ApplicationController
def index def index
@first_page = FirstPage.where("page_type = 'project'").first @first_page = FirstPage.where("page_type = 'project'").first
@show_course = @first_page.show_course
if @first_page.nil? || @first_page.sort_type.nil? if @first_page.nil? || @first_page.sort_type.nil?
@projects = find_miracle_project(10, 3,"grade desc") @projects = find_miracle_project(10, 3,"grade desc")
else else

View File

@ -68,6 +68,10 @@ module ApplicationHelper
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action]) link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
end end
def link_to_if_authorized_course(name, options = {}, html_options = nil, *parameters_for_method_reference)
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_course(options[:controller] || params[:controller], options[:action])
end
def link_to_if_authorized_contest(name, options = {}, html_options = nil, *parameters_for_method_reference) def link_to_if_authorized_contest(name, options = {}, html_options = nil, *parameters_for_method_reference)
link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_contest(options[:controller] || params[:controller], options[:action]) link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_contest(options[:controller] || params[:controller], options[:action])
end end

View File

@ -68,6 +68,7 @@ class JournalsForMessage < ActiveRecord::Base
return true return true
end end
end end
def self.remove_by_user? user def self.remove_by_user? user
if( self.user == user || if( self.user == user ||
@ -87,6 +88,15 @@ class JournalsForMessage < ActiveRecord::Base
def reference_user def reference_user
User.find(reply_id) User.find(reply_id)
end end
def delete_by_user?user
# 用户可删除自己的留言
if self.user.id == user.id || user.admin?
return true
else
return false
end
end
def self.reference_message(user_id) def self.reference_message(user_id)
@user = User.find(user_id) @user = User.find(user_id)

View File

@ -758,6 +758,7 @@ class Project < ActiveRecord::Base
'tracker_ids', 'tracker_ids',
'issue_custom_field_ids', 'issue_custom_field_ids',
'project_type', 'project_type',
'dts_test',
'attachmenttype' 'attachmenttype'

View File

@ -27,24 +27,28 @@
<label for='image_height' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_imgae_height)%>:</label> <label for='image_height' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_imgae_height)%>:</label>
<%= text_field_tag 'image_height', params[:label_imgae_height], :value => @first_page.image_height,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> <%= text_field_tag 'image_height', params[:label_imgae_height], :value => @first_page.image_height,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p> </p>
<!-- <p style="margin-left:60px;padding-right: 20px;"> <p style="margin-left:60px;padding-right: 20px;">
<label for='title'>&nbsp;&nbsp;&nbsp;<#%= l(:label_site_title) %>:</label> <label for='title'>&nbsp;&nbsp;&nbsp;<%= l(:label_show_course) %>:</label>
<#%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> <select name="show_course" id="show_course" style="font-size:small;width:497px;margin-left:10px;display: inline">
</p> --> <option value="1" <%= "selected=selected" if @first_page.show_course == 1 %>><%= l(:general_text_yes) %></option>
<option value="2" <%= "selected=selected" if @first_page.show_course == 2 %>><%= l(:general_text_no) %></option>
</select>
</p>
<p style="margin-left:60px;padding-right: 20px;">
<label for='sort_type' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_sort_type)%>:</label>
<select name="sort_type" id="sort_type" style="font-size:small;width:497px;margin-left:80px;">
<option value="1" <%= "selected=selected" if @first_page.sort_type == 1 %>><%= l(:label_sort_by_active) %></option>
<option value="2" <%= "selected=selected" if @first_page.sort_type == 2 %>><%= l(:label_sort_by_influence) %></option>
<option value="0" <%= "selected=selected" if @first_page.sort_type == 0 %>><%= l(:label_sort_by_time) %></option>
</select>
</p>
<p style="margin-left:60px;padding-right: 20px;"> <p style="margin-left:60px;padding-right: 20px;">
<label for='description' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_site_description)%>:</label> <label for='description' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_site_description)%>:</label>
<!-- <#%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> --> <!-- <#%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> -->
<%= text_area 'first_page', 'description', :value => @first_page.description,:cols => 80, :rows => 15, :class => 'wiki-edit' %> <%= text_area 'first_page', 'description', :value => @first_page.description,:cols => 80, :rows => 15, :class => 'wiki-edit' %>
<%= wikitoolbar_for 'first_page_description' %> <%= wikitoolbar_for 'first_page_description' %>
</p> </p>
<p style="margin-left:60px;padding-right: 20px;">
<label for='sort_type' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_sort_type)%>:</label>
<select name="sort_type" id="sort_type" style="font-size:small;width:496px;margin-left:80px;">
<option value="1" <%= "selected=selected" if @first_page.sort_type == 1 %>><%= l(:label_sort_by_active) %></option>
<option value="2" <%= "selected=selected" if @first_page.sort_type == 2 %>><%= l(:label_sort_by_influence) %></option>
<option value="0" <%= "selected=selected" if @first_page.sort_type == 0 %>><%= l(:label_sort_by_time) %></option>
</select>
</p>
<%= submit_tag l(:button_save), :class => "small", :name => nil %> <%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %> <% end %>

View File

@ -15,7 +15,7 @@
:method => :delete, :method => :delete,
:class => 'delete', :class => 'delete',
:title => l(:button_delete) %> :title => l(:button_delete) %>
<% else %> <% else %>
<%= link_to image_tag('delete.png'), attachment_path(attachment), <%= link_to image_tag('delete.png'), attachment_path(attachment),
:data => {:confirm => l(:text_are_you_sure)}, :data => {:confirm => l(:text_are_you_sure)},
:method => :delete, :method => :delete,

View File

@ -1,6 +1,6 @@
<%= raw @issues.map {|issue| { <%= raw @issues.map {|issue| {
'id' => issue.id, 'id' => issue.id,
'label' => "#{issue.tracker} ##{issue.id}: #{truncate issue.subject.to_s, :length => 60}", 'label' => "#{issue.tracker} ##{issue.project_index}: #{truncate issue.subject.to_s, :length => 60}",
'value' => issue.id 'value' => issue.id
} }
}.to_json }.to_json

View File

@ -78,6 +78,9 @@ function checkMaxLength() {
'#{l(:label_reply_plural)} #{journal.user.name}: '); '#{l(:label_reply_plural)} #{journal.user.name}: ');
return false;"} %> return false;"} %>
<% end %> <% end %>
<% if journal.delete_by_user?(User.current) %>
<%= link_to(l(:button_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => journal.user}, :method => :delete,:remote => true)%>
<% end %>
</span> </span>
</span> </span>
<div style="clear: both;"></div> <div style="clear: both;"></div>

View File

@ -40,8 +40,10 @@
<li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;" class="loggedas_li"> <li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;" class="loggedas_li">
<%=link_to_user(User.current)%> <%=link_to_user(User.current)%>
<ul class="sub_menu"> <ul class="sub_menu">
<% if @show_course.nil? || @show_course != 2 %>
<% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%> <% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
<% hasCourse=true%> <% hasCourse=true%>
<li id="course_loggedas_li"><%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %> <li id="course_loggedas_li"><%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %>
<ul class="course_sub_menu"> <ul class="course_sub_menu">
<% User.current.courses.each do |course| %> <% User.current.courses.each do |course| %>
@ -51,7 +53,9 @@
<% end %> <% end %>
</ul> </ul>
</li> </li>
<% end -%> <% end -%>
<% end %>
<li id="project_loggedas_li"><%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %> <li id="project_loggedas_li"><%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
<% if hasCourse %> <% if hasCourse %>

View File

@ -75,7 +75,7 @@
</tr> </tr>
<tr> <tr>
<td align="left"><span class="font_lighter"> <%= format_time(comment.created_on) %></span></td> <td align="left"><span class="font_lighter"> <%= format_time(comment.created_on) %></span></td>
<td width="200" align="right" class="a"><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, <td width="200" align="right" class="a"><%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment},
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td> :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td>
</tr> </tr>
</table></td> </table></td>

View File

@ -12,7 +12,7 @@
</div> </div>
<div class="wiki-description"> <div class="wiki-description">
<p> <p>
<%= textilizable(project.short_description, :project => project) %> <%= textilizable(project.short_description.strip, :project => project) %>
</p> </p>
</div> </div>

View File

@ -137,7 +137,12 @@
<% end %> <% end %>
</tr> </tr>
<tr> <tr>
<td colspan="2" width="580"><p class="font_description"> <%= act.notes.html_safe %> </p> <% if act.notes.nil? %>
<% desStr = '' %>
<% else %>
<% desStr=act.notes.html_safe %>
<% end %>
<td colspan="2" width="580"><p class="font_description"> <%= desStr %> </p>
</td> </td>
</tr> </tr>
<tr> <tr>

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

@ -498,7 +498,7 @@ zh:
project_module_time_tracking: 时间跟踪 project_module_time_tracking: 时间跟踪
project_module_news: 新闻 project_module_news: 新闻
project_module_documents: 文档 project_module_documents: 文档
project_module_files: 资料下载 project_module_files: 作品下载
project_module_wiki: Wiki project_module_wiki: Wiki
project_module_repository: 版本库 project_module_repository: 版本库
project_module_boards: 讨论区 project_module_boards: 讨论区
@ -579,6 +579,7 @@ zh:
label_sort_type: 热门项目排序方式 label_sort_type: 热门项目排序方式
label_contest_notification_title: 竞赛通知标题 label_contest_notification_title: 竞赛通知标题
label_contest_notification_content: 竞赛通知内容 label_contest_notification_content: 竞赛通知内容
label_show_course: 显示课程
#by young #by young
label_requirement: 需求 label_requirement: 需求
label_new_course: 课程列表 label_new_course: 课程列表

View File

@ -0,0 +1,5 @@
class FirstPageAddColumn < ActiveRecord::Migration
def change
add_column("first_pages","show_course",:integer,default: 1)
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140725073357) do ActiveRecord::Schema.define(:version => 20140728014933) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -425,6 +425,7 @@ ActiveRecord::Schema.define(:version => 20140725073357) do
t.integer "sort_type" t.integer "sort_type"
t.integer "image_width", :default => 107 t.integer "image_width", :default => 107
t.integer "image_height", :default => 63 t.integer "image_height", :default => 63
t.integer "show_course", :default => 1
end end
create_table "forums", :force => true do |t| create_table "forums", :force => true do |t|
@ -845,18 +846,18 @@ ActiveRecord::Schema.define(:version => 20140725073357) do
create_table "relative_memos", :force => true do |t| create_table "relative_memos", :force => true do |t|
t.integer "osp_id" t.integer "osp_id"
t.integer "parent_id" t.integer "parent_id"
t.string "subject", :null => false t.string "subject", :null => false
t.text "content", :limit => 16777215, :null => false t.text "content", :null => false
t.integer "author_id" t.integer "author_id"
t.integer "replies_count", :default => 0 t.integer "replies_count", :default => 0
t.integer "last_reply_id" t.integer "last_reply_id"
t.boolean "lock", :default => false t.boolean "lock", :default => false
t.boolean "sticky", :default => false t.boolean "sticky", :default => false
t.boolean "is_quote", :default => false t.boolean "is_quote", :default => false
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "viewed_count_crawl", :default => 0 t.integer "viewed_count_crawl", :default => 0
t.integer "viewed_count_local", :default => 0 t.integer "viewed_count_local", :default => 0
t.string "url" t.string "url"
t.string "username" t.string "username"
t.string "userhomeurl" t.string "userhomeurl"

View File

@ -48,8 +48,13 @@ module Redmine
end end
def attachments_deletable?(user=User.current) def attachments_deletable?(user=User.current)
(respond_to?(:visible?) ? visible?(user) : true) && if (self.has_attribute?(:course) ||self.has_attribute?(:course_id)) && self.course
user.allowed_to?(self.class.attachable_options[:delete_permission], self.project) (respond_to?(:visible?) ? visible?(user) : true) &&
user.allowed_to?(self.class.attachable_options[:delete_permission], self.course)
else
(respond_to?(:visible?) ? visible?(user) : true) &&
user.allowed_to?(self.class.attachable_options[:delete_permission], self.project)
end
end end
def saved_attachments def saved_attachments