Paul: Check-in [5a83c6619c]

Online event coordination and survey application

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Begin to support answer
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:5a83c6619c33b14e6434d45199c7fd45a20fbc85e2c134729460c4fd68cb138a
User & Date: milouse 2018-10-28 18:42:31
Context
2018-11-01
17:19
Add a new logger mechanism check-in: ea94e475cb user: milouse tags: trunk
2018-10-28
18:42
Begin to support answer check-in: 5a83c6619c user: milouse tags: trunk
18:19
Add .rubocop.yml file check-in: 0d9a885156 user: milouse tags: trunk
Changes

Changes to lib/notification.rb.

33
34
35
36
37
38
39

40



41
42
43
44
45
46
47
      to dest
      subject subject_line
      body content
    end
    m.from = @from
    m.header['User-agent'] = 'Paul Survey System'
    m.header['X-Mailer'] = 'Ruby Mail'

    m.deliver!



  end

  private

  def load_settings
    conf = File.join 'config', 'config.yml'
    return YAML.load_file(conf).freeze if File.exist? conf







>
|
>
>
>







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
      to dest
      subject subject_line
      body content
    end
    m.from = @from
    m.header['User-agent'] = 'Paul Survey System'
    m.header['X-Mailer'] = 'Ruby Mail'
    begin
      m.deliver!
    rescue Errno::ECONNREFUSED => e
      $stderr.puts e.class.name
    end
  end

  private

  def load_settings
    conf = File.join 'config', 'config.yml'
    return YAML.load_file(conf).freeze if File.exist? conf

Changes to lib/survey.rb.

70
71
72
73
74
75
76
77

78
79

80
81

82
83
84
85
86

87
88
89
90
    @data[:maybe] = opts['maybe'].to_s.to_bool if opts.has_key? 'maybe'
    return unless opts.has_key? 'proposals'
    extract_proposals(opts)
  end

  def extract_proposals(opts)
    @data[:proposals] ||= []
    opts['proposals'].each do |prop|

      if prop.is_a? String
        @data[:proposals] << prop

      elsif prop.has_key?('label')
        @data[:proposals] << prop['label']

      elsif prop.has_key?('date')
        loc_time = '00:00'
        loc_time = prop['time'] if prop['time'] && prop['time'] != ''
        @data[:proposals] << [prop['date'], loc_time].join(' ')
      end

    end
    @data
  end
end







|
>

<
>

<
>



|

>




70
71
72
73
74
75
76
77
78
79

80
81

82
83
84
85
86
87
88
89
90
91
92
    @data[:maybe] = opts['maybe'].to_s.to_bool if opts.has_key? 'maybe'
    return unless opts.has_key? 'proposals'
    extract_proposals(opts)
  end

  def extract_proposals(opts)
    @data[:proposals] ||= []
    opts['proposals'].each_with_index do |prop, idx|
      new_prop = { id: idx + 1 }
      if prop.is_a? String

        new_prop[:label] = prop
      elsif prop.has_key?('label')

        new_prop[:label] = prop['label']
      elsif prop.has_key?('date')
        loc_time = '00:00'
        loc_time = prop['time'] if prop['time'] && prop['time'] != ''
        new_prop[:label] = [prop['date'], loc_time].join(' ')
      end
      @data[:proposals] << new_prop
    end
    @data
  end
end

Changes to views/poll.slim.

1
2
3
4
5
6
7
8
9

10













p
  by #{@poll.data[:author]}

p
  input.share_url type='text' readonly=true value=share_url(@poll)

table
  tr
    - for prop in @poll.data[:proposals]

      th = prop



















|
<
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
p
  by #{@poll.data[:author]}

p
  input.share_url type='text' readonly=true value=share_url(@poll)

form action='/answer' method='post'

  - for prop in @poll.data[:proposals]
    fieldset.prop
      legend = prop[:label]
      label
        input type='radio' value='yes' name="answer#{prop[:label]}"
        | yes
      - if @poll.data[:maybe]
        label
          input type='radio' value='maybe' name="answer#{prop[:label]}"
          | maybe
      label
        input type='radio' value='no' name="answer#{prop[:label]}"
        | no

  fieldset
    input type='submit' value='Answer'