diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index f632dc0..4c52b43 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -64,8 +64,11 @@ class HomeController < ApplicationController SendContactEmailJob.perform_later(@consultation_email.id) end - def arrange_consultation + def arrange_consultation; end + def monitor + prepare_filters + cookies[:filter] = JSON.generate(build_filter_hash) end def show @@ -113,9 +116,15 @@ class HomeController < ApplicationController def emailfilter require 'json' + prepare_filters + filters = if params[:from_monit].blank? + JSON.parse(cookies[:filter]) + else + JSON.parse(JSON.generate(build_filter_hash)) + end @emailfilter = FilterForEmail.new( email: params[:email_filter_inp], - filters: JSON.parse(cookies[:filter]) + filters: filters ) @emailfilter.save SendNotifyEmailJob.perform_later(@emailfilter.id, 1) diff --git a/app/views/home/monitor.html.erb b/app/views/home/monitor.html.erb new file mode 100644 index 0000000..1f4986f --- /dev/null +++ b/app/views/home/monitor.html.erb @@ -0,0 +1,70 @@ +
+
+
+
+
+
+

Monitoring

+
+
+
+
+
+
+ +
+
+
+
+
+ <%= form_tag(home_emailfilter_path, method: :post, remote: true, id: 'email_filter_form') do %> +
+
+

Powiadomienie o nowych dotacjach

+
+
+
+
+
+ + +
+ <%= hidden_field_tag 'filter', @filter_hash %> + <%= hidden_field_tag 'from_monit', 1 %> +
+
Ważne informacje
+

Podając adres e-mail wyrażasz zgodę na otrzymywanie wiadomości o wynikach wyszukiwania spełniających wybrane przez Ciebie kryteria

+
+
+
+
+
+
+ + <% @locations.each do |location| %> +
+ <%= check_box_tag("location[]", location.id, @location_chk.include?(location.id.to_s) , class: 'form-check-input', onchange: "formSubmit()") %> + +
+ <% end %> +
+
+
+ +
+
+ <% end %> + +
+
+
+
+
+ diff --git a/config/routes.rb b/config/routes.rb index bfe4e2d..9afc258 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,7 @@ Rails.application.routes.draw do get 'email_filter/unsubscribe' get 'kontakt' => 'home#contact' get 'regulamin' => 'home#statute' + get 'monitoring' => 'home#monitor' get 'umow_konsultacje' => 'home#arrange_consultation' get 'dotacja/:id' => 'home#show' get 'zestawienie_dotacji/plik' => 'home#prepare_pdf'