diff --git a/app/controllers/dotations_controller.rb b/app/controllers/dotations_controller.rb
index 7dcf272..0122087 100644
--- a/app/controllers/dotations_controller.rb
+++ b/app/controllers/dotations_controller.rb
@@ -108,6 +108,7 @@ class DotationsController < ApplicationController
:date_of_recruitment, :min_amount_curr_id,
:max_amount_curr_id, :min_dot_ammount, :max_dot_ammount,
:min_dot_amount_curr_id, :max_dot_amount_curr_id,
+ :start_date_quarter, :end_date_quarter, :ann_date_quarter,
project_ids: [], tag_ids: [], company_activity_ids: [],
company_size_ids: [], expense_ids: [])
end
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index 3647060..f394a2b 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -6,7 +6,10 @@ class HomeController < ApplicationController
before_action :check_status
def check_status
- redirect_to '/construction.html'
+ if defined?(current_user) && user_signed_in?
+ else
+ redirect_to '/construction.html'
+ end
end
def index
diff --git a/app/models/dotation.rb b/app/models/dotation.rb
index 042ce41..3e72351 100644
--- a/app/models/dotation.rb
+++ b/app/models/dotation.rb
@@ -38,8 +38,8 @@ class Dotation < ApplicationRecord
has_and_belongs_to_many :tags
has_and_belongs_to_many :company_activities
# == Validations ==========================================================
- validates :name, presence: true
- validates :formal_name, presence: true
+ validates :name, presence: true, length: { maximum: 255 }
+ validates :formal_name, presence: true, length: { maximum: 255 }
# == Scopes ===============================================================
scope :search, (lambda do |search_value|
where('name LIKE :value OR formal_name LIKE :value',
@@ -98,8 +98,44 @@ class Dotation < ApplicationRecord
ret = ret.by_projects(filters[:projects]) unless filters[:projects].blank?
ret
end
+
+ def self.display_as_quarter(date)
+ ret = case date.month
+ when 1, 2, 3 then 'I '
+ when 4, 5, 6 then 'II '
+ when 7, 8, 9 then 'III '
+ when 10, 11, 12 then 'IV '
+ end
+ ret += "kwartał #{date.year}"
+ ret
+ end
+
# == Instance Methods =====================================================
+ def start_date_ret
+ if start_date_quarter.eql?(true)
+ Dotation.display_as_quarter(start_date)
+ else
+ start_date.strftime("%d-%m-%Y")
+ end
+ end
+
+ def end_date_ret
+ if end_date_quarter.eql?(true)
+ Dotation.display_as_quarter(end_date)
+ else
+ end_date.strftime("%d-%m-%Y")
+ end
+ end
+
+ def ann_date_ret
+ if ann_date_quarter.eql?(true)
+ Dotation.display_as_quarter(announcement_date)
+ else
+ announcement_date.strftime("%d-%m-%Y")
+ end
+ end
+
def safe_id
friendly_id
end
diff --git a/app/views/dotations/_form.html.erb b/app/views/dotations/_form.html.erb
index 868b95a..19450db 100644
--- a/app/views/dotations/_form.html.erb
+++ b/app/views/dotations/_form.html.erb
@@ -64,9 +64,29 @@
+
+
+
+ <%= form.check_box(:start_date_quarter, { class: 'form-check-input' }) %>
+ <%= form.label :start_date_quarter %>
+
+
+
+
+ <%= form.check_box(:end_date_quarter, { class: 'form-check-input' }) %>
+ <%= form.label :end_date_quarter %>
+
+
+
+
+ <%= form.check_box(:ann_date_quarter, { class: 'form-check-input' }) %>
+ <%= form.label :ann_date_quarter %>
+
+
- <%= form.label :localization %>
- <%= form.text_field :localization, class: 'form-control', placeholder: 'Wprowadź region' %>
+ <%= form.label :localization %>
+ <%= form.text_field :localization, class: 'form-control', placeholder: 'Wprowadź region' %>
+
diff --git a/app/views/home/404.html b/app/views/home/404.html
new file mode 100644
index 0000000..cf252b5
--- /dev/null
+++ b/app/views/home/404.html
@@ -0,0 +1,67 @@
+
+
+
+
+
Strona ktorej szukasz nie istnieje (404)
+
+
+
+
+
+
+
+
+
Strona której szukasz nie istnieje.
+
Możliwe, że adres został wpisany niepoprawnie lub strona została przeniesiona.
+
+
+
+
diff --git a/app/views/home/_dotation_card.html.erb b/app/views/home/_dotation_card.html.erb
index 1af13a5..8dbcfcb 100644
--- a/app/views/home/_dotation_card.html.erb
+++ b/app/views/home/_dotation_card.html.erb
@@ -19,7 +19,7 @@
Składanie wniosków
-
od <%= dotation.start_date.strftime("%d-%m-%Y") %> do <%= dotation.end_date.strftime("%d-%m-%Y") %>
+ od <%= dotation.start_date_ret %>
do <%= dotation.end_date_ret %>
diff --git a/app/views/home/_dotation_card.pdf.erb b/app/views/home/_dotation_card.pdf.erb
index 040bd3b..c86aa97 100644
--- a/app/views/home/_dotation_card.pdf.erb
+++ b/app/views/home/_dotation_card.pdf.erb
@@ -9,7 +9,7 @@
| Składanie wniosków |
- od <%= dotation.start_date.strftime("%d-%m-%Y") %> do <%= dotation.end_date.strftime("%d-%m-%Y") %> |
+ od <%= dotation.start_date_ret %> do <%= dotation.end_date_ret %> |
| Lokalizacja: |
diff --git a/app/views/home/_show.html.erb b/app/views/home/_show.html.erb
index 7ac8ba0..fb6abf9 100644
--- a/app/views/home/_show.html.erb
+++ b/app/views/home/_show.html.erb
@@ -54,19 +54,19 @@
Ogłoszenie aktualnego/najbliższego naboru
|
- <%= @dotation.announcement_date.strftime("%Y-%m-%d") unless @dotation.announcement_date.blank? %> |
+ <%= @dotation.ann_date_ret unless @dotation.announcement_date.blank? %> |
|
Rozpoczęcie aktualnego/najbliższego naboru
|
- <%= @dotation.start_date.strftime("%Y-%m-%d") unless @dotation.start_date.blank? %> |
+ <%= @dotation.start_date_ret unless @dotation.start_date.blank? %> |
|
Zakończenie aktualnego/najbliższego naboru
|
- <%= @dotation.end_date.strftime("%Y-%m-%d") unless @dotation.end_date.blank? %> |
+ <%= @dotation.end_date_ret unless @dotation.end_date.blank? %> |
|
diff --git a/app/views/home/_show.pdf.erb b/app/views/home/_show.pdf.erb
index 13e2ce1..1ad1117 100644
--- a/app/views/home/_show.pdf.erb
+++ b/app/views/home/_show.pdf.erb
@@ -51,19 +51,19 @@
|
Ogłoszenie aktualnego/najbliższego naboru
|
- <%= dotation.announcement_date.strftime("%Y-%m-%d") unless dotation.announcement_date.blank? %> |
+ <%= dotation.ann_date_ret unless dotation.announcement_date.blank? %> |
|
Rozpoczęcie aktualnego/najbliższego naboru
|
- <%= dotation.start_date.strftime("%Y-%m-%d") unless dotation.start_date.blank? %> |
+ <%= dotation.start_date_ret unless dotation.start_date.blank? %> |
|
Zakończenie aktualnego/najbliższego naboru
|
- <%= dotation.end_date.strftime("%Y-%m-%d") unless dotation.end_date.blank? %> |
+ <%= dotation.end_date_ret unless dotation.end_date.blank? %> |
|
diff --git a/config/locales/pl/models/dotation.yml b/config/locales/pl/models/dotation.yml
index 7b1345e..5fcbd31 100644
--- a/config/locales/pl/models/dotation.yml
+++ b/config/locales/pl/models/dotation.yml
@@ -30,6 +30,9 @@ pl:
start_date: Data najbliższego naboru
end_date: Data końca naboru
announcement_date: Data ogłoszenia naboru
+ start_date_quarter: Wyświetl jako kwartał
+ end_date_quarter: Wyświetl jako kwartał
+ ann_date_quarter: Wyświetl jako kwartał
tags: Tagi
full_descr: Pełny opis dotacji
positioning_text: Tekst pozycjonujący
@@ -39,7 +42,9 @@ pl:
attributes:
name:
blank: nie może być pusta
+ too_long: jest za długa (max 255 znaków)
formal_name:
blank: nie może być pusta
+ too_long: jest za długa (max 255 znaków)
partner:
required: jest wymagany
diff --git a/db/migrate/20220429113929_add_quarter_to_dotations.rb b/db/migrate/20220429113929_add_quarter_to_dotations.rb
new file mode 100644
index 0000000..5e554a7
--- /dev/null
+++ b/db/migrate/20220429113929_add_quarter_to_dotations.rb
@@ -0,0 +1,7 @@
+class AddQuarterToDotations < ActiveRecord::Migration[5.2]
+ def change
+ add_column :dotations, :start_date_quarter, :boolean, default: false
+ add_column :dotations, :end_date_quarter, :boolean, default: false
+ add_column :dotations, :ann_date_quarter, :boolean, default: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index cecb962..f23520c 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2022_04_04_150629) do
+ActiveRecord::Schema.define(version: 2022_04_29_113929) do
create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "name", null: false
@@ -112,6 +112,9 @@ ActiveRecord::Schema.define(version: 2022_04_04_150629) do
t.integer "min_dot_amount_curr_id", default: 1
t.bigint "max_dot_ammount"
t.integer "max_dot_amount_curr_id", default: 1
+ t.boolean "start_date_quarter"
+ t.boolean "end_date_quarter"
+ t.boolean "ann_date_quarter"
t.index ["active"], name: "index_dotations_on_active"
t.index ["announcement_date"], name: "index_dotations_on_announcement_date"
t.index ["arch"], name: "index_dotations_on_arch"
|