public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/glsamaker:master commit in: app/models/, app/views/glsa/, app/controllers/
@ 2011-02-26 10:55 Alex Legler
  0 siblings, 0 replies; only message in thread
From: Alex Legler @ 2011-02-26 10:55 UTC (permalink / raw
  To: gentoo-commits

commit:     62941528b5651c7020117804b266af1cf6c25100
Author:     Alex Legler <alex <AT> a3li <DOT> li>
AuthorDate: Sat Feb 26 10:54:30 2011 +0000
Commit:     Alex Legler <a3li <AT> gentoo <DOT> org>
CommitDate: Sat Feb 26 10:54:30 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/glsamaker.git;a=commit;h=62941528

Allow to import references at creation of the draft

---
 app/controllers/glsa_controller.rb  |    2 +-
 app/models/glsa.rb                  |   11 ++++++++++-
 app/views/glsa/new-request.html.erb |    8 ++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/app/controllers/glsa_controller.rb b/app/controllers/glsa_controller.rb
index dcddebc..f5d3e11 100644
--- a/app/controllers/glsa_controller.rb
+++ b/app/controllers/glsa_controller.rb
@@ -52,7 +52,7 @@ class GlsaController < ApplicationController
   def create
     if params[:what] == "request"
       begin
-        glsa = Glsa.new_request(params[:title], params[:bugs], params[:comment], params[:access], current_user)
+        glsa = Glsa.new_request(params[:title], params[:bugs], params[:comment], params[:access], (params[:import_references].to_i == 1), current_user)
         
         Glsamaker::Mail.request_notification(glsa, current_user)
         

diff --git a/app/models/glsa.rb b/app/models/glsa.rb
index 814a1e3..764ef72 100644
--- a/app/models/glsa.rb
+++ b/app/models/glsa.rb
@@ -136,7 +136,7 @@ class Glsa < ActiveRecord::Base
   end
 
   # Files a new GLSA request
-  def self.new_request(title, bugs, comment, access, user)
+  def self.new_request(title, bugs, comment, access, import_references, user)
     glsa = Glsa.new
     glsa.requester = user
     glsa.glsa_id = Digest::MD5.hexdigest(title + Time.now.to_s)[0...9]
@@ -184,6 +184,15 @@ class Glsa < ActiveRecord::Base
       end
     end
 
+    if import_references
+      logger.debug { "importing references" }
+      refs = []
+      glsa.related_cves.each do |cve|
+        refs << {:title => cve.cve_id, :url => cve.url}
+      end
+      glsa.add_references refs
+    end
+
     glsa
   end
 

diff --git a/app/views/glsa/new-request.html.erb b/app/views/glsa/new-request.html.erb
index 4f1062f..bd6df24 100644
--- a/app/views/glsa/new-request.html.erb
+++ b/app/views/glsa/new-request.html.erb
@@ -31,6 +31,14 @@
   <p><textarea name="comment" id="comment" class="nice" rows="4"><%= h params[:comment] %></textarea></p>
 </div>
 <br />
+<div class="box w40em">
+  <h2 style="margin-top: 0;"><img src="/images/icons/reference.png" alt="reference" /> References</h2>
+  <p>
+    <input type="checkbox" name="import_references" id="import_references" value="1" checked="checked" />
+    <label for="import_references">Import all references from linked bugs</label>
+  </p>
+</div>
+<br />
 <%- if current_user.access >= 1 -%>
 <div class="box w40em">
   <h2 style="margin-top: 0;"><img src="/images/icons/permission.png" alt="permission" /> Permissions</h2>



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-02-26 10:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-26 10:55 [gentoo-commits] proj/glsamaker:master commit in: app/models/, app/views/glsa/, app/controllers/ Alex Legler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox