diff --git a/app/assets/images/logo_kd.png b/app/assets/images/logo_kd.png new file mode 100644 index 0000000..10bb2a2 Binary files /dev/null and b/app/assets/images/logo_kd.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e0afb62..80fcaba 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -13,3 +13,13 @@ //= require rails-ujs //= require activestorage //= require turbolinks +function reloadFunctionsOnAjax() { + $(".tooltip").tooltip("hide"); + //$('.popover').popover('hide'); + + // Reload tootltips + $('[data-toggle="tooltip"]').tooltip({ trigger : 'hover' }) + + // Reload popovers + //$('[data-toggle="popover"]').popover() +} diff --git a/app/assets/javascripts/home.js b/app/assets/javascripts/home.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/home.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3a0a730..aaa3eb3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,10 +2,13 @@ # App class ApplicationController < ActionController::Base - before_action :authenticate_user! layout :layout_by_resource def layout_by_resource devise_controller? ? 'devise' : 'application' end + + def after_sign_in_path_for(resource) + dotations_path # your path + end end diff --git a/app/controllers/company_activities_controller.rb b/app/controllers/company_activities_controller.rb index a29c451..83b5b73 100644 --- a/app/controllers/company_activities_controller.rb +++ b/app/controllers/company_activities_controller.rb @@ -1,4 +1,5 @@ class CompanyActivitiesController < ApplicationController + before_action :authenticate_user! include ApplicationHelper before_action :check_access before_action :set_company_activity, only: %i[show edit update destroy] diff --git a/app/controllers/company_sizes_controller.rb b/app/controllers/company_sizes_controller.rb index df2fbb9..4105f43 100644 --- a/app/controllers/company_sizes_controller.rb +++ b/app/controllers/company_sizes_controller.rb @@ -1,4 +1,5 @@ class CompanySizesController < ApplicationController + before_action :authenticate_user! include ApplicationHelper before_action :check_access before_action :set_company_size, only: %i[show edit update destroy] diff --git a/app/controllers/dotations_controller.rb b/app/controllers/dotations_controller.rb index 9e61575..7be3372 100644 --- a/app/controllers/dotations_controller.rb +++ b/app/controllers/dotations_controller.rb @@ -1,4 +1,5 @@ class DotationsController < ApplicationController + before_action :authenticate_user! include ApplicationHelper before_action :check_access before_action :set_dotation, only: %i[show edit update destroy activate] @@ -104,6 +105,6 @@ class DotationsController < ApplicationController :announcement_date, :full_descr, :positioning_text, :points, :date_of_recruitment, :min_amount_curr_id, :max_amount_curr_id, project_ids: [], tag_ids: [], company_activity_ids: [], - company_size_ids: []) + company_size_ids: [], expense_ids: []) end end diff --git a/app/controllers/expenses_controller.rb b/app/controllers/expenses_controller.rb index 4da248a..001cb90 100644 --- a/app/controllers/expenses_controller.rb +++ b/app/controllers/expenses_controller.rb @@ -1,6 +1,7 @@ class ExpensesController < ApplicationController + before_action :authenticate_user! include ApplicationHelper - before_action :check_access + before_action :check_access before_action :set_expense, only: %i[show edit update destroy] def check_access diff --git a/app/controllers/experts_controller.rb b/app/controllers/experts_controller.rb index ba4b6fb..a36251f 100644 --- a/app/controllers/experts_controller.rb +++ b/app/controllers/experts_controller.rb @@ -1,4 +1,5 @@ class ExpertsController < ApplicationController + before_action :authenticate_user! include ApplicationHelper before_action :check_access before_action :set_expert, only: %i[show edit update destroy] diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..d0d340f --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +# Home +class HomeController < ApplicationController + layout 'home_layout' + + def index + prepare_filters + @dotations = Dotation.extra_search(params[:search]).public_dot + .point_desc.end_date_asc.page(params[:page]) + end + + def contact; end + + def show + @dotation = Dotation.find(params[:id]) + @company_sizes = CompanySize.all + end + + private + + def prepare_filters + @company_sizes = CompanySize.all + @company_activities = CompanyActivity.all + @projects = Project.all + end +end diff --git a/app/controllers/partners_controller.rb b/app/controllers/partners_controller.rb index 18bcfb1..851cc7b 100644 --- a/app/controllers/partners_controller.rb +++ b/app/controllers/partners_controller.rb @@ -1,4 +1,5 @@ class PartnersController < ApplicationController + before_action :authenticate_user! include ApplicationHelper before_action :check_access before_action :set_partner, only: %i[show edit update destroy] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 93c4089..b0d2a5f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,4 +1,5 @@ class ProjectsController < ApplicationController + before_action :authenticate_user! include ApplicationHelper before_action :check_access before_action :set_project, only: %i[show edit update destroy] diff --git a/app/controllers/settings/users_controller.rb b/app/controllers/settings/users_controller.rb index ea4a96d..651f9a1 100644 --- a/app/controllers/settings/users_controller.rb +++ b/app/controllers/settings/users_controller.rb @@ -4,6 +4,7 @@ module Settings # Users class UsersController < ApplicationController + before_action :authenticate_user! before_action :set_user, only: %i[show edit update destroy] # GET /users or /users.json diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index fcfbce0..ecad231 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,4 +1,5 @@ class TagsController < ApplicationController + before_action :authenticate_user! include ApplicationHelper before_action :check_access before_action :set_tag, only: %i[show edit update destroy] diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index f9b859b..9c916c8 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -1,4 +1,5 @@ class WelcomeController < ApplicationController + before_action :authenticate_user! def index end end diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb new file mode 100644 index 0000000..fbc9ba4 --- /dev/null +++ b/app/helpers/home_helper.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# helper for home +module HomeHelper + def change_ammount(ammount) + ret = if ammount >= 1_000_000 + "#{ammount / 1_000_000} mln" + else + "#{ammount / 1_000} tyś" + end + ret + end +end diff --git a/app/models/dotation.rb b/app/models/dotation.rb index d044e82..3cd7bf0 100644 --- a/app/models/dotation.rb +++ b/app/models/dotation.rb @@ -28,6 +28,13 @@ class Dotation < ApplicationRecord where('name LIKE :value OR formal_name LIKE :value', value: "%#{search_value}%") end) + scope :extra_search, (lambda do |search_value| + where('name LIKE :value OR formal_name LIKE :value', + value: "%#{search_value}%") + end) + scope :point_desc, -> { order(points: :desc) } + scope :end_date_asc, -> { order(end_date: :asc) } + scope :public_dot, -> { where(active: true) } # == Callbacks ============================================================ # == Class Methods ======================================================== diff --git a/app/models/expense.rb b/app/models/expense.rb index a991346..2a80366 100644 --- a/app/models/expense.rb +++ b/app/models/expense.rb @@ -2,6 +2,7 @@ # Expanse class Expense < ApplicationRecord + default_scope { order(name: :asc) } # == Constants ============================================================ # == Attributes =========================================================== diff --git a/app/views/dotations/_form.html.erb b/app/views/dotations/_form.html.erb index 8349110..31ca9ad 100644 --- a/app/views/dotations/_form.html.erb +++ b/app/views/dotations/_form.html.erb @@ -118,6 +118,10 @@ <%= form.label :projects %> <%= form.select(:project_ids, @projects.collect {|p| [ p.name, p.id ] }, { include_blank: false }, { class: 'form-control duallistbox', multiple: true } ) %> +
+ <%= form.label :expenses %> + <%= form.select(:expense_ids, @expenses.collect {|p| [ p.name, p.id ] }, { include_blank: false }, { class: 'form-control duallistbox', multiple: true } ) %> +
diff --git a/app/views/dotations/_list.html.erb b/app/views/dotations/_list.html.erb index 7f5f9eb..8e41791 100644 --- a/app/views/dotations/_list.html.erb +++ b/app/views/dotations/_list.html.erb @@ -14,6 +14,7 @@ Nazwa Nazwa formalna + Punkty Data od Data do Publiczne @@ -26,6 +27,7 @@ <%= link_to dotation.name, dotation %> <%= dotation.formal_name %> + <%= dotation.points %> <%= dotation.date_from %> <%= dotation.date_to %> diff --git a/app/views/dotations/_show.html.erb b/app/views/dotations/_show.html.erb index cf2536c..eb3002c 100644 --- a/app/views/dotations/_show.html.erb +++ b/app/views/dotations/_show.html.erb @@ -79,8 +79,8 @@
    - <% @dotation.projects.each do |project| %> -
  • <%= project.name %>
  • + <% @dotation.expenses.each do |expense| %> +
  • <%= expense.name %>
  • <% end %>
diff --git a/app/views/home/_dotation_card.html.erb b/app/views/home/_dotation_card.html.erb new file mode 100644 index 0000000..bb0c280 --- /dev/null +++ b/app/views/home/_dotation_card.html.erb @@ -0,0 +1,73 @@ +
+
+

<%= dotation.name %>

+
+
+
+
+
+
+

<%= dotation.formal_name %>

+
+
+
+
+

Składanie wniosków

+
+
+

od <%= dotation.start_date.strftime("%d-%m-%Y") %> do <%= dotation.end_date.strftime("%d-%m-%Y") %>

+
+
+
+
+
+
+

<%= dotation.localization %>

+
+
+ + <% unless dotation.max_amount.blank? %> +
+
+
Wartość projektu
+
+
+
do <%= change_ammount(dotation.max_amount) %> <%= dotation.max_amount_curr.name %>
+
+
+ <% end %> + <% unless dotation.max_amount.blank? %> +
+
+
Poziom dofinansowania
+
+
+
do <%= dotation.max_percent %>% dotacji
+
+
+ <% end %> +
+
+
+
+ <% unless dotation.expenses.blank? %> + Co można dofinansować? + <% max_expense = dotation.expenses.count %> + <% dotation.expenses.limit(5).each_with_index do |expense, index| %> + <%= expense.name %> + <% if index < max_expense - 1 && index < 4 %> + <%= ', ' -%> + <% elsif max_expense > 5 %> + <%= '...' -%> + <% end %> + <% end %> + <% end %> +
+
+
+ + + +
diff --git a/app/views/home/_dotations.html.erb b/app/views/home/_dotations.html.erb new file mode 100644 index 0000000..5590818 --- /dev/null +++ b/app/views/home/_dotations.html.erb @@ -0,0 +1,31 @@ +<% if @dotations.blank? %> +
+
+

Uwagi

+
+
+
+ +
Informacja
+ Brak danych do wyświetlenia +
+
+ +
+ +<% else %> +
+
+ <%= render 'filter_form' %> +
+
+ <% @dotations.each do |dotation| %> + <%= render 'dotation_card', dotation: dotation %> + <% end %> +
+
+ +
+
+ +<% end %> diff --git a/app/views/home/_filter_form.html.erb b/app/views/home/_filter_form.html.erb new file mode 100644 index 0000000..7e99311 --- /dev/null +++ b/app/views/home/_filter_form.html.erb @@ -0,0 +1,121 @@ +<% if params[:search] %> + + +
+
+

Filtry

+
+
+
+
+
+
+

Wyszukiwana fraza:
+ <%= params[:search] %>

+
+
+
+
+
+
+ +
+
+
+ <% @company_sizes.each do |company_size| %> +
+ + +
+ <% end %> +
+
+
+
+
+ +
+
+
+ <% @company_activities.each do |company_activity| %> +
+ + +
+ <% end %> +
+
+
+
+
+ +
+
+
+ <% @projects.each do |project| %> +
+ + +
+ <% end %> +
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +<% end %> diff --git a/app/views/home/_show.html.erb b/app/views/home/_show.html.erb new file mode 100644 index 0000000..15402b6 --- /dev/null +++ b/app/views/home/_show.html.erb @@ -0,0 +1,139 @@ +
+
+

<%= @dotation.formal_name %>

+
+
+
+
+
+
+
+<% if !@dotation.expert_id.blank? && !@dotation.expert_info.blank? %> +
+
+ + + + + + + + + + +
Subiektywna opinia eksperta
+ <%= render '/experts/expert_show', expert: @dotation.expert %> + <%= raw @dotation.expert_info %>
+
+
+<% end %> +
+
+
+

Wielkość przedsiębiorstwa

+
+
+
+
+ <% @company_sizes.each do |company_size| %> + <% if @dotation.company_sizes.include?(company_size) %> + <%= company_size.name %> + <% else %> + <%= company_size.name %> + <% end %> +    + <% end %> +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Ogłoszenie aktualnego/najbliższego naboru + <%= @dotation.announcement_date.strftime("%Y-%m-%d") unless @dotation.announcement_date.blank? %>
+ Rozpoczęcie aktualnego/najbliższego naboru + <%= @dotation.start_date.strftime("%Y-%m-%d") unless @dotation.start_date.blank? %>
+ Zakończenie aktualnego/najbliższego naboru + <%= @dotation.end_date.strftime("%Y-%m-%d") unless @dotation.end_date.blank? %>
+ Co można dofinansować? + +
    + <% @dotation.expenses.each do |expense| %> +
  • <%= expense.name %>
  • + <% end %> +
+
+ Miejsce realizacji projektu + <%= @dotation.localization %>
+ Minimalna wartość projektu (wydatków) + <%= change_ammount(@dotation.min_amount) %> <%= @dotation.min_amount_curr.name %>
+ Maksymalna wartość projektu (wydatków) + <%= change_ammount(@dotation.max_amount) %> <%= @dotation.max_amount_curr.name %>
+
+
+
+
+
+

Szczegółowy opis dotacji

+
+
+
+
+ <%= raw @dotation.full_descr %> +
+
+
+
+
+ <%= raw @dotation.positioning_text %> +
+
+
+
+
+

Pomoc w opracowaniu wniosku – komu można zlecić opracowanie dokumentów do tego konkursu

+
+
+
+
+ <%= render '/partners/partner_show', partner: @dotation.partner %> +
+
+
+
+ <% @dotation.tags.each do |tag| %> + <%= tag.name %> + <% end %> +
+
diff --git a/app/views/home/contact.html.erb b/app/views/home/contact.html.erb new file mode 100644 index 0000000..b95d5ed --- /dev/null +++ b/app/views/home/contact.html.erb @@ -0,0 +1,46 @@ +
+
+
+
+
+
+

Kontakt

+
+
+
+
+
+
+ +
+
+
+
+
+
+
+

Kontakt

+
+ + +
+
+
+ Kontakt +
+ + + +
+ +
+
+
+
+
diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 0000000..0d8bb48 --- /dev/null +++ b/app/views/home/index.html.erb @@ -0,0 +1,37 @@ +
+
+

Kalendarz Dotacji

+
+
+
+
+
+
+

Tutaj jakieś informacje co znajduje się na tej stronie czego można się spodziewać itd, może jakieś zdjęcie? coś do przemyślenia

+
+
+
+
+
+ +
+
+
+ <%= form_tag(home_index_path, method: :get, remote: true) do %> +
+ <%= text_field_tag(:search, params[:search], class: 'form-control form-control-lg', placeholder: 'Wpisz wyszukiwaną frazę') %> +
+ +
+
+ <% end %> +
+
+
+
+ <%= render 'dotations' %> +
+
+
diff --git a/app/views/home/index.js.erb b/app/views/home/index.js.erb new file mode 100644 index 0000000..9f2e024 --- /dev/null +++ b/app/views/home/index.js.erb @@ -0,0 +1,2 @@ +$('#search_result').html("<%= escape_javascript(render partial: 'dotations') %>"); +reloadFunctionsOnAjax(); diff --git a/app/views/home/show.html.erb b/app/views/home/show.html.erb new file mode 100644 index 0000000..61b1884 --- /dev/null +++ b/app/views/home/show.html.erb @@ -0,0 +1,33 @@ + +
+
+
+
+ <%= link_to 'Powrót do strony wyszukiwania', :back, class: 'btn btn-info' %> +
+ +
+ +
+ +
+ +
+ +
+
+
+
+
+
+

<%= @dotation.name %>

+
+ +
+ <%= render 'show' %> +
+
+
+
+
+
diff --git a/app/views/home/test.html.erb b/app/views/home/test.html.erb new file mode 100644 index 0000000..faac4e0 --- /dev/null +++ b/app/views/home/test.html.erb @@ -0,0 +1,50 @@ +
+
+ +
+
+ Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a + bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, + raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. +
+
+
+
+ +
+
+ Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a + bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, + raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. +
+
+
+
+ +
+
+ Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a + bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, + raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. +
+
+
+
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 06d8a30..953d3ee 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -46,7 +46,7 @@