添加参赛应用的删除和修改功能以及添加相应的删除和修改权限
This commit is contained in:
parent
cc5b55ec9c
commit
bc068eb12b
|
@ -75,7 +75,7 @@ GEM
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
rdoc (~> 3.4)
|
rdoc (~> 3.4)
|
||||||
thor (>= 0.14.6, < 2.0)
|
thor (>= 0.14.6, < 2.0)
|
||||||
rake (10.1.0)
|
rake (10.0.4)
|
||||||
rdoc (3.12.2)
|
rdoc (3.12.2)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
ruby-openid (2.1.8)
|
ruby-openid (2.1.8)
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
class SoftapplicationsController < ApplicationController
|
class SoftapplicationsController < ApplicationController
|
||||||
|
before_filter :find_softapplication, only: [:edit, :update, :destroy]
|
||||||
|
before_filter :editable, only: [:edit, :update]
|
||||||
|
before_filter :destroyable, only: :destroy
|
||||||
|
|
||||||
# GET /softapplications
|
# GET /softapplications
|
||||||
# GET /softapplications.json
|
# GET /softapplications.json
|
||||||
def index
|
def index
|
||||||
|
@ -71,7 +75,7 @@ class SoftapplicationsController < ApplicationController
|
||||||
# PUT /softapplications/1
|
# PUT /softapplications/1
|
||||||
# PUT /softapplications/1.json
|
# PUT /softapplications/1.json
|
||||||
def update
|
def update
|
||||||
@softapplication = Softapplication.find(params[:id])
|
# @softapplication = Softapplication.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @softapplication.update_attributes(params[:softapplication])
|
if @softapplication.update_attributes(params[:softapplication])
|
||||||
|
@ -92,11 +96,11 @@ class SoftapplicationsController < ApplicationController
|
||||||
# DELETE /softapplications/1
|
# DELETE /softapplications/1
|
||||||
# DELETE /softapplications/1.json
|
# DELETE /softapplications/1.json
|
||||||
def destroy
|
def destroy
|
||||||
@softapplication = Softapplication.find(params[:id])
|
# @softapplication = Softapplication.find(params[:id])
|
||||||
@softapplication.destroy
|
@softapplication.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to softapplications_url }
|
format.html { redirect_to :back }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -192,4 +196,24 @@ class SoftapplicationsController < ApplicationController
|
||||||
#format.api { render_api_ok }
|
#format.api { render_api_ok }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_softapplication
|
||||||
|
@softapplication = Softapplication.find_by_id(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def editable
|
||||||
|
unless @softapplication.editable_by? User.current
|
||||||
|
render_403
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroyable
|
||||||
|
unless @softapplication.destroyable_by? User.current
|
||||||
|
render_403
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -181,7 +181,7 @@ class Attachment < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def pack?
|
def pack?
|
||||||
!!(self.filename =~ /\.(zip|rar|tar|gz)$/i)
|
!!(self.filename =~ /\.(zip|rar|tar|gz|exe)$/i)
|
||||||
end
|
end
|
||||||
|
|
||||||
def thumbnailable?
|
def thumbnailable?
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Softapplication < ActiveRecord::Base
|
||||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||||
has_many :contesting_softapplications, :dependent => :destroy
|
has_many :contesting_softapplications, :dependent => :destroy
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :contest
|
has_many :contests, :through => :contesting_softapplications
|
||||||
|
|
||||||
def add_jour(user, notes, reference_user_id = 0, options = {})
|
def add_jour(user, notes, reference_user_id = 0, options = {})
|
||||||
if options.count == 0
|
if options.count == 0
|
||||||
|
@ -21,6 +21,13 @@ class Softapplication < ActiveRecord::Base
|
||||||
def set_commit(commit)
|
def set_commit(commit)
|
||||||
self.update_attribute(:commit, commit)
|
self.update_attribute(:commit, commit)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def editable_by? usr
|
||||||
|
usr.admin? || self.user == usr
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroyable_by? usr
|
||||||
|
self.user == usr || usr.admin?
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<td>
|
<td>
|
||||||
<%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication)) %>
|
<%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication)) %>
|
||||||
</td>
|
</td>
|
||||||
|
<td><%= link_to '删除', c_softapplication.softapplication, method: :delete, data: { confirm: '您确定要删除吗?' } %></td>
|
||||||
</tr></br>
|
</tr></br>
|
||||||
</div>
|
</div>
|
||||||
<div style="padding-left: 68px">
|
<div style="padding-left: 68px">
|
||||||
|
|
|
@ -1,28 +1,43 @@
|
||||||
<!--add by huang-->
|
<!--add by huang-->
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
<div id="footer" style="margin-left:-5px;padding-top: 50px;clear: both;font-size: 12px;">
|
<div id="footer" style="margin-left:-5px;padding-top: 50px;clear: both;font-size: 12px;">
|
||||||
<div style="border-top:solid 1px #C6E9F1;width:940px;margin-left:auto;margin-right:auto;margin-bottom: 5px;margin-top: -50px;"></div>
|
<div style="border-top:solid 1px #C6E9F1;width:940px;margin-left:auto;margin-right:auto;margin-bottom: 5px;margin-top: -50px;">
|
||||||
<div class="base_footer">
|
</div>
|
||||||
<div align="center">
|
<div class="base_footer">
|
||||||
|
<div align="center">
|
||||||
<!--gcm-->
|
|
||||||
<p>
|
<!--gcm-->
|
||||||
<span>主办单位:</span>
|
<p>
|
||||||
<span class="footer_text_link"><%= link_to "国防科学技术大学并行与分布处理国家重点实验室","http://www.nudt.edu.cn/ArticleShow.asp?ID=47",:target=>"_blank"%></span>
|
<span>主办单位:</span>
|
||||||
<span id="copyright">版权@2007~2014</span>
|
<span class="footer_text_link"><%= link_to "国防科学技术大学并行与分布处理国家重点实验室","http://www.nudt.edu.cn/ArticleShow.asp?ID=47",:target=>"_blank"%></span>
|
||||||
<span id="contact_us" class="footer_text_link"><%= link_to "联系我们","http://forge.trustie.net/projects/2/member",:target=>"_blank"%></span>
|
<span id="copyright">版权@2007~2014</span>
|
||||||
<span id="record"class="footer_text_link"><%= link_to "湘ICP备09019772","http://www.miibeian.gov.cn/"%></span>
|
<span id="contact_us" class="footer_text_link"><%= link_to "联系我们","http://forge.trustie.net/projects/2/member",:target=>"_blank"%></span>
|
||||||
|
<span id="record"class="footer_text_link"><%= link_to "湘ICP备09019772","http://www.miibeian.gov.cn/"%></span>
|
||||||
</p>
|
|
||||||
<div id="logo_link">
|
</p>
|
||||||
<span class="footer_logo_link"><%= link_to image_tag('/images/footer_logo/nudt.png',:size=>'100x30',:alt=>"国防科学技术大学计算机学院"),"http://www.nudt.edu.cn/special.asp?classid=12"%></span>
|
<div id="logo_link">
|
||||||
<span class="footer_logo_link"><%= link_to image_tag('/images/footer_logo/peking_eecs.png',:size=>'100x30',:alt=>"北京大学信息科学技术学院软件研究所"), "http://eecs.pku.edu.cn"%></span>
|
<span class="footer_logo_link"><%= link_to image_tag('/images/footer_logo/nudt.png',:size=>'100x30',:alt=>"国防科学技术大学计算机学院"),"http://www.nudt.edu.cn/special.asp?classid=12"%></span>
|
||||||
<span class="footer_logo_link"><%= link_to image_tag('/images/footer_logo/buaa_scse.png',:size=>'100x30',:alt=>"北京航空航天大学计算机学院"), "http://scse.buaa.edu.cn/"%></span>
|
<span class="footer_logo_link"><%= link_to image_tag('/images/footer_logo/peking_eecs.png',:size=>'100x30',:alt=>"北京大学信息科学技术学院软件研究所"), "http://eecs.pku.edu.cn"%></span>
|
||||||
<span class="footer_logo_link"><%= link_to image_tag('/images/footer_logo/iscas.png',:size=>'100x30',:alt=>"中国科学院软件研究所"), "http://www.iscas.ac.cn"%></span>
|
<span class="footer_logo_link"><%= link_to image_tag('/images/footer_logo/buaa_scse.png',:size=>'100x30',:alt=>"北京航空航天大学计算机学院"), "http://scse.buaa.edu.cn/"%></span>
|
||||||
<span class="footer_logo_link"><%= link_to image_tag('/images/footer_logo/inforbus.png',:size=>'100x30',:alt=>"山东中创软件商用中间件股份有限公司"), "http://www.inforbus.com"%></span>
|
<span class="footer_logo_link"><%= link_to image_tag('/images/footer_logo/iscas.png',:size=>'100x30',:alt=>"中国科学院软件研究所"), "http://www.iscas.ac.cn"%></span>
|
||||||
</div>
|
<span class="footer_logo_link"><%= link_to image_tag('/images/footer_logo/inforbus.png',:size=>'100x30',:alt=>"山东中创软件商用中间件股份有限公司"), "http://www.inforbus.com"%></span>
|
||||||
<!--gcm-->
|
</div>
|
||||||
|
<!--gcm-->
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="debug">
|
||||||
|
<%= debug(params) if Rails.env.development? %>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||||
|
|
||||||
|
ga('create', 'UA-46523987-1', 'trustie.net');
|
||||||
|
ga('send', 'pageview');
|
||||||
|
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<h1>Listing softapplications</h1>
|
<h1>参赛应用</h1>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue