Gentoo Archives: gentoo-commits

From: Alex Legler <a3li@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/glsamaker:master commit in: app/models/, app/views/glsa/, app/controllers/
Date: Sat, 26 Feb 2011 10:55:28
Message-Id: 62941528b5651c7020117804b266af1cf6c25100.a3li@gentoo
1 commit: 62941528b5651c7020117804b266af1cf6c25100
2 Author: Alex Legler <alex <AT> a3li <DOT> li>
3 AuthorDate: Sat Feb 26 10:54:30 2011 +0000
4 Commit: Alex Legler <a3li <AT> gentoo <DOT> org>
5 CommitDate: Sat Feb 26 10:54:30 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/glsamaker.git;a=commit;h=62941528
7
8 Allow to import references at creation of the draft
9
10 ---
11 app/controllers/glsa_controller.rb | 2 +-
12 app/models/glsa.rb | 11 ++++++++++-
13 app/views/glsa/new-request.html.erb | 8 ++++++++
14 3 files changed, 19 insertions(+), 2 deletions(-)
15
16 diff --git a/app/controllers/glsa_controller.rb b/app/controllers/glsa_controller.rb
17 index dcddebc..f5d3e11 100644
18 --- a/app/controllers/glsa_controller.rb
19 +++ b/app/controllers/glsa_controller.rb
20 @@ -52,7 +52,7 @@ class GlsaController < ApplicationController
21 def create
22 if params[:what] == "request"
23 begin
24 - glsa = Glsa.new_request(params[:title], params[:bugs], params[:comment], params[:access], current_user)
25 + glsa = Glsa.new_request(params[:title], params[:bugs], params[:comment], params[:access], (params[:import_references].to_i == 1), current_user)
26
27 Glsamaker::Mail.request_notification(glsa, current_user)
28
29
30 diff --git a/app/models/glsa.rb b/app/models/glsa.rb
31 index 814a1e3..764ef72 100644
32 --- a/app/models/glsa.rb
33 +++ b/app/models/glsa.rb
34 @@ -136,7 +136,7 @@ class Glsa < ActiveRecord::Base
35 end
36
37 # Files a new GLSA request
38 - def self.new_request(title, bugs, comment, access, user)
39 + def self.new_request(title, bugs, comment, access, import_references, user)
40 glsa = Glsa.new
41 glsa.requester = user
42 glsa.glsa_id = Digest::MD5.hexdigest(title + Time.now.to_s)[0...9]
43 @@ -184,6 +184,15 @@ class Glsa < ActiveRecord::Base
44 end
45 end
46
47 + if import_references
48 + logger.debug { "importing references" }
49 + refs = []
50 + glsa.related_cves.each do |cve|
51 + refs << {:title => cve.cve_id, :url => cve.url}
52 + end
53 + glsa.add_references refs
54 + end
55 +
56 glsa
57 end
58
59
60 diff --git a/app/views/glsa/new-request.html.erb b/app/views/glsa/new-request.html.erb
61 index 4f1062f..bd6df24 100644
62 --- a/app/views/glsa/new-request.html.erb
63 +++ b/app/views/glsa/new-request.html.erb
64 @@ -31,6 +31,14 @@
65 <p><textarea name="comment" id="comment" class="nice" rows="4"><%= h params[:comment] %></textarea></p>
66 </div>
67 <br />
68 +<div class="box w40em">
69 + <h2 style="margin-top: 0;"><img src="/images/icons/reference.png" alt="reference" /> References</h2>
70 + <p>
71 + <input type="checkbox" name="import_references" id="import_references" value="1" checked="checked" />
72 + <label for="import_references">Import all references from linked bugs</label>
73 + </p>
74 +</div>
75 +<br />
76 <%- if current_user.access >= 1 -%>
77 <div class="box w40em">
78 <h2 style="margin-top: 0;"><img src="/images/icons/permission.png" alt="permission" /> Permissions</h2>