From cdc9d63c179bf2b62160b64b22ad1d8e64bcf859 Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Thu, 7 Apr 2022 10:49:34 +0200 Subject: [PATCH] dotations --- app/controllers/home_controller.rb | 14 +++++++++++--- app/models/dotation.rb | 1 + app/views/home/_dotations.html.erb | 4 ++-- app/views/home/_show.html.erb | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 4a2ad6d..b32e868 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -9,7 +9,10 @@ class HomeController < ApplicationController prepare_filters cookies[:filter] = JSON.generate(build_filter_hash) @dotations = Dotation.extra_search(params[:search]).public_dot - .point_desc.end_date_asc.page(params[:page]) + .point_desc.end_date_asc.page(params[:page]).per(2) + # count on all + @dotations_size = Dotation.extra_search(params[:search]).public_dot + .point_desc.end_date_asc.count end def search @@ -17,7 +20,10 @@ class HomeController < ApplicationController prepare_filters cookies[:filter] = JSON.generate(build_filter_hash) @dotations = Dotation.search_with_filters(build_filter_hash).public_dot - .point_desc.end_date_asc.page(params[:page]) + .point_desc.end_date_asc.page(params[:page]).per(2) + # count on all + @dotations_size = Dotation.search_with_filters(build_filter_hash).public_dot + .point_desc.end_date_asc.count end def contact @@ -33,7 +39,7 @@ class HomeController < ApplicationController def order_meeting @dotation = Dotation.friendly.find(params[:d]) - @consultation_email = ConsultationEmail.new() + @consultation_email = ConsultationEmail.new end def order_meeting_save @@ -47,6 +53,8 @@ class HomeController < ApplicationController def show @dotation = Dotation.friendly.find(params[:id]) + @intersting_dotations = Dotation.public_dot.point_desc + .where.not(id: @dotation.id).limit(4) @company_sizes = CompanySize.all respond_to do |format| format.html diff --git a/app/models/dotation.rb b/app/models/dotation.rb index 4b58d16..042ce41 100644 --- a/app/models/dotation.rb +++ b/app/models/dotation.rb @@ -72,6 +72,7 @@ class Dotation < ApplicationRecord scope :end_date_asc, -> { order(end_date: :asc) } scope :public_dot, -> { where(active: true) } scope :by_id, ->(val) { where(id: val) } + scope :open_recruitment, -> { where('dotations.dotation_start_date <= :dat AND dotations.dotation_end_date >= :dat', dat: Time.now) } # == Callbacks ============================================================ # == Class Methods ======================================================== diff --git a/app/views/home/_dotations.html.erb b/app/views/home/_dotations.html.erb index 84e4c65..e364a65 100644 --- a/app/views/home/_dotations.html.erb +++ b/app/views/home/_dotations.html.erb @@ -1,4 +1,3 @@ -
<%= render 'filter_form' %> @@ -25,7 +24,7 @@ <% else %>
-
Znalezionych dotacji: <%= @dotations.count %>
+
Znalezionych aktywnych dotacji: <%= @dotations_size %>
diff --git a/app/views/home/_show.html.erb b/app/views/home/_show.html.erb index 7588c2c..7ac8ba0 100644 --- a/app/views/home/_show.html.erb +++ b/app/views/home/_show.html.erb @@ -147,6 +147,20 @@
+
+
+

 

+

Inne dotacje, które mogą Ciebie zainteresować

+
+
+
+
+ <% @intersting_dotations.each do |interesting_dotation| %> + <%= render 'dotation_card', dotation: interesting_dotation %> + <% end %> +
+
+