noodall-form-builder 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- noodall-form-builder (0.0.2)
4
+ noodall-form-builder (0.0.3)
5
5
  fastercsv
6
6
 
7
7
  GEM
@@ -1,20 +1,22 @@
1
+ require 'fastercsv'
2
+
1
3
  module Noodall
2
4
  class Admin::FormResponsesController < Noodall::Admin::BaseController
3
5
  include SortableTable::App::Controllers::ApplicationController
4
6
  before_filter :find_form,:set_title
5
-
7
+
6
8
  def index
7
9
  if @form.nil?
8
10
  @responses = Noodall::FormResponse.all
9
11
  else
10
12
  @responses = @form.responses
11
13
  end
12
-
14
+
13
15
  respond_to do |format|
14
16
  format.html # index.html.erb
15
17
  format.xml { render :xml => @responses }
16
-
17
-
18
+
19
+
18
20
  format.csv do
19
21
  csv_string = FasterCSV.generate do |csv|
20
22
  header_row = @form.fields.map do |field|
@@ -22,7 +24,7 @@ module Noodall
22
24
  end
23
25
  header_row += ['Date', 'IP', 'Form Location']
24
26
  csv << header_row
25
-
27
+
26
28
  for response in @responses
27
29
  response_row = @form.fields.map do |field|
28
30
  begin
@@ -35,34 +37,34 @@ module Noodall
35
37
  csv << response_row
36
38
  end
37
39
  end
38
- send_data csv_string, :filename => "#{@form.title} responses - #{Time.now.to_formatted_s(:db)}.csv",
39
- :type => 'text/csv',
40
+ send_data csv_string, :filename => "#{@form.title} responses - #{Time.now.to_formatted_s(:db)}.csv",
41
+ :type => 'text/csv',
40
42
  :disposition => 'attachment'
41
43
  end
42
-
44
+
43
45
  end
44
46
  end
45
-
47
+
46
48
  def destroy
47
49
  @form.responses = @form.responses.reject{|r| r.id.to_s == params[:id]}
48
-
50
+
49
51
  @form.save
50
52
  flash[:notice] = "Response was successfully deleted."
51
-
53
+
52
54
  respond_to do |format|
53
55
  format.html { redirect_to(noodall_admin_form_form_responses_url(@form)) }
54
56
  format.xml { head :ok }
55
57
  end
56
58
  end
57
-
59
+
58
60
  def mark_as_spam
59
61
  @response = @form.responses.find(params[:id])
60
-
62
+
61
63
  @response.mark_as_spam!
62
-
64
+
63
65
  redirect_to(noodall_admin_form_form_responses_url(@form))
64
66
  end
65
-
67
+
66
68
  private
67
69
  def set_title
68
70
  @page_title = "#{@form.title} Responses"
@@ -70,6 +72,6 @@ module Noodall
70
72
  def find_form
71
73
  @form = Noodall::Form.find(params[:form_id]) unless params[:form_id].blank?
72
74
  end
73
-
75
+
74
76
  end
75
- end
77
+ end
@@ -4,7 +4,7 @@ module Noodall
4
4
  initializer "set menu" do |app|
5
5
  Noodall::UI.menu_items['Forms'] = :noodall_admin_forms_path
6
6
  end
7
-
7
+
8
8
  initializer "static assets" do |app|
9
9
  app.middleware.use ::ActionDispatch::Static, "#{root}/public"
10
10
  end
@@ -1,5 +1,5 @@
1
1
  module Noodall
2
2
  module FormBuilder
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noodall-form-builder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors: []
13
13