From 72f084062a049e2ca07f376399a16c479c51efd1 Mon Sep 17 00:00:00 2001 From: Christoph Marzell Date: Sun, 9 Nov 2025 06:52:18 +0100 Subject: [PATCH] add ausbildung --- Dockerfile | 7 ++- app/controllers/entries_controller.rb | 7 ++- app/controllers/static_pages_controller.rb | 4 ++ app/models/entry.rb | 10 ++++- app/views/entries/_form.html.erb | 34 ++++++++++++++- app/views/entries/index.html.erb | 14 +++++- app/views/layouts/application.html.erb | 33 +++++++++++++- app/views/static_pages/impressum.html.erb | 43 +++++++++++++++++++ bin/docker-entrypoint | 31 ++++++++++--- config/routes.rb | 6 ++- ...51109044107_add_beschreibung_to_entries.rb | 5 +++ .../20251109044216_add_kosten_to_entries.rb | 5 +++ db/schema.rb | 4 +- 13 files changed, 185 insertions(+), 18 deletions(-) create mode 100644 app/controllers/static_pages_controller.rb create mode 100644 app/views/static_pages/impressum.html.erb create mode 100644 db/migrate/20251109044107_add_beschreibung_to_entries.rb create mode 100644 db/migrate/20251109044216_add_kosten_to_entries.rb diff --git a/Dockerfile b/Dockerfile index 46505c7..bd0f1b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,9 @@ USER rails:rails # Entrypoint prepares the database. ENTRYPOINT ["/rails/bin/docker-entrypoint"] +HEALTHCHECK --interval=5m --timeout=3s \ + CMD curl -f http://localhost:3000 || exit 1 + # Start the server by default, this can be overwritten at runtime -EXPOSE 3000 -CMD ["./bin/rails", "server"] +#EXPOSE 3000 +#CMD ["./bin/rails", "server"] diff --git a/app/controllers/entries_controller.rb b/app/controllers/entries_controller.rb index 6625cc7..d584962 100644 --- a/app/controllers/entries_controller.rb +++ b/app/controllers/entries_controller.rb @@ -36,6 +36,9 @@ class EntriesController < ApplicationController entries.sum(&:kilometer_pauschale) end + @fortbildungskosten_by_year = Entry.total_fortbildungskosten_by_year(current_user) + + # Voraussichtliches Ende je Kombination basierend auf weekly_target_matrix @estimated_end_by_typ_art = {} @remaining_minutes_matrix.each do |typ, arts| @@ -106,7 +109,9 @@ class EntriesController < ApplicationController :minutes, :praktikums_typ, :entry_art, - :distance_km + :distance_km, + :beschreibung, + :kosten ) end diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb new file mode 100644 index 0000000..d6bad98 --- /dev/null +++ b/app/controllers/static_pages_controller.rb @@ -0,0 +1,4 @@ +class StaticPagesController < ApplicationController + def impressum + end +end diff --git a/app/models/entry.rb b/app/models/entry.rb index 25798af..f8bfb6c 100644 --- a/app/models/entry.rb +++ b/app/models/entry.rb @@ -12,7 +12,7 @@ class Entry < ApplicationRecord before_save :normalize_time PRAKTIKUMSTYPEN = %w[propädeutikum fachspezifikum] - ENTRY_ARTEN = %w[Praktikum Selbsterfahrung Supervision] + ENTRY_ARTEN = %w[Praktikum Selbsterfahrung Supervision Fortbildung] validates :praktikums_typ, inclusion: { in: PRAKTIKUMSTYPEN } validates :entry_art, inclusion: { in: ENTRY_ARTEN } @@ -23,6 +23,12 @@ class Entry < ApplicationRecord distance_km * 0.42 end + def self.total_fortbildungskosten_by_year(user) + where(user: user, entry_art: 'Fortbildung') + .group_by { |e| e.date.year } + .transform_values { |entries| entries.sum { |e| e.kosten.to_f } } + end + def jahr date.year end @@ -42,6 +48,8 @@ class Entry < ApplicationRecord entry.praktikums_typ, entry.entry_art, entry.distance_km, + entry.beschreibung, + entry.kosten, entry.user.email ] end diff --git a/app/views/entries/_form.html.erb b/app/views/entries/_form.html.erb index 7c71b10..3bbcf4a 100644 --- a/app/views/entries/_form.html.erb +++ b/app/views/entries/_form.html.erb @@ -11,7 +11,7 @@ <% end %> -
+
<%= form.label :date, 'Datum', class: 'form-label' %> <%= form.text_field :date, @@ -46,7 +46,7 @@
<%= form.label :entry_art, 'Art', class: 'form-label' %> - <%= form.select :entry_art, Entry::ENTRY_ARTEN, {}, class: 'form-select' %> + <%= form.select :entry_art, Entry::ENTRY_ARTEN, {}, class: 'form-select', id: 'entry_art_select' %>
@@ -56,6 +56,20 @@ min: 0, value: form.object.distance_km || 0 %>
+ +
"> +
+ <%= form.label :beschreibung, 'Beschreibung', class: 'form-label' %> + <%= form.text_field :beschreibung, class: 'form-control' %> +
+ +
+ <%= form.label :kosten, 'Kosten (z. B. Teilnahmegebühr)', class: 'form-label' %> + <%= form.number_field :kosten, class: 'form-control', min: 0, step: 0.01 %> +
+
+ +
@@ -64,3 +78,19 @@ <%= link_to 'Zurück', entries_path, class: 'btn btn-secondary ms-2' %>
<% end %> + diff --git a/app/views/entries/index.html.erb b/app/views/entries/index.html.erb index d1a7c2e..b800caf 100644 --- a/app/views/entries/index.html.erb +++ b/app/views/entries/index.html.erb @@ -13,6 +13,12 @@

<% end %> +
💶 Fortbildungskosten
+ <% @fortbildungskosten_by_year.each do |year, sum| %> +

<%= year %>: <%= number_to_currency(sum, unit: "€", separator: ",", delimiter: ".", precision: 2) %>

+ <% end %> + +

Gesamtzeit: <%= @total_minutes / 60 %> h <%= @total_minutes % 60 %> min

@@ -84,8 +90,12 @@ <%= entry.date.strftime('%d.%m.%Y') %> <%= entry.hours.to_i %>h <%= entry.minutes.to_i %>min - <%= entry.praktikums_typ.capitalize %> - <%= entry.entry_art.capitalize %> + + <%= entry.entry_art == "Fortbildung" ? "Fortbildung" : entry.praktikums_typ.capitalize %> + + + <%= entry.entry_art == "Fortbildung" ? entry.beschreibung : entry.entry_art.capitalize %> + <%= entry.distance_km.to_f %> km <%= number_to_currency(entry.kilometer_pauschale, unit: "€", separator: ",", delimiter: ".") %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 90a58e3..e6b4528 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,11 +11,36 @@ <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> - + + + + + + + <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> + + +