diff --git a/Gemfile b/Gemfile index 4d690b4..de74b49 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,7 @@ gem 'jquery-ui-rails' # Use Sass to process CSS gem "sassc-rails" - +gem "redis" # Use Redis adapter to run Action Cable in production # gem "redis", ">= 4.0.1" diff --git a/Gemfile.lock b/Gemfile.lock index 69755e0..28dc594 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -254,6 +254,10 @@ GEM erb psych (>= 4.0.0) tsort + redis (5.4.1) + redis-client (>= 0.22.0) + redis-client (0.29.0) + connection_pool reline (0.6.2) io-console (~> 0.5) responders (3.2.0) @@ -331,6 +335,7 @@ DEPENDENCIES pghero puma (>= 5.0) rails (~> 7.1.5, >= 7.1.5.2) + redis rufus-scheduler sassc-rails sprockets-rails diff --git a/app/models/entry.rb b/app/models/entry.rb index 14b2f62..5fc8dcd 100644 --- a/app/models/entry.rb +++ b/app/models/entry.rb @@ -10,7 +10,7 @@ class Entry < ApplicationRecord before_save :normalize_time - PRAKTIKUMSTYPEN = %w[propädeutikum fachspezifikum] + PRAKTIKUMSTYPEN = %w[propädeutikum fachspezifikum mediation] ENTRY_ARTEN = [ "Praktikum", "Selbsterfahrung", diff --git a/app/models/user.rb b/app/models/user.rb index c6dbd3d..0973680 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,7 +6,7 @@ class User < ApplicationRecord has_many :entries, dependent: :destroy - PRAKTIKUMSTYPEN = %w[propädeutikum fachspezifikum] + PRAKTIKUMSTYPEN = %w[propädeutikum fachspezifikum mediation] ENTRY_ARTEN = [ "Praktikum", "Selbsterfahrung", diff --git a/app/views/entries/index.html.erb b/app/views/entries/index.html.erb index ac50f97..4277b3d 100644 --- a/app/views/entries/index.html.erb +++ b/app/views/entries/index.html.erb @@ -321,11 +321,19 @@ + <% if entry.praktikums_typ != 'mediation' %> <%= ["Fortbildung", "Semesterkosten"].include?(entry.entry_art) ? entry.entry_art : entry.praktikums_typ.capitalize %> + <% else %> + <%= entry.praktikums_typ&.capitalize%> + <% end %> - <%= ["Fortbildung", "Semesterkosten"].include?(entry.entry_art) ? entry.beschreibung : entry.entry_art.capitalize %> + <% if entry.praktikums_typ != 'mediation' %> + <%= ["Fortbildung", "Semesterkosten"].include?(entry.entry_art) ? entry.entry_art : entry.praktikums_typ.capitalize %> + <% else %> + <%= entry.praktikums_typ&.capitalize %> + <% end %> @@ -351,7 +359,13 @@
<%= link_to 'Bearbeiten', edit_entry_path(entry), class: 'btn btn-sm btn-outline-primary' %> - <%= link_to 'Löschen', entry_path(entry), class: 'btn btn-sm btn-outline-danger open-delete-modal' %> +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f18d1a3..1624949 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -23,36 +23,29 @@ diff --git a/config/environments/development.rb b/config/environments/development.rb index e5f5d33..0e45e80 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -22,8 +22,12 @@ Rails.application.configure do if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true - - config.cache_store = :memory_store + + config.cache_store = :redis_cache_store, { + url: ENV.fetch("REDIS_URL", "redis://localhost:6379/0"), + namespace: "myapp:dev:cache", + expires_in: 1.hour + } config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } diff --git a/config/environments/production.rb b/config/environments/production.rb index 85de75a..415df9d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -65,7 +65,9 @@ Rails.application.configure do config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") # Use a different cache store in production. - # config.cache_store = :mem_cache_store + config.cache_store = :redis_cache_store, { + url: ENV.fetch("REDIS_URL", "redis://redis:6379/0") + } # Use a real queuing backend for Active Job (and separate queues per environment). # config.active_job.queue_adapter = :resque diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml new file mode 100644 index 0000000..e07f06b --- /dev/null +++ b/docker-compose-dev.yml @@ -0,0 +1,38 @@ + +version: "3.3" +services: + db: + image: postgres:17 + restart: unless-stopped + environment: + POSTGRES_PASSWORD: password + POSTGRES_USER: praktikum + volumes: + - pgdata:/var/lib/postgresql/data + ports: + - '35432:35432' + healthcheck: + test: [ "CMD", "pg_isready", "-q" ] + timeout: 45s + interval: 10s + retries: 10 + command: -p 35432 + networks: + - praktikum-network + redis: + image: 'redis' + command: redis-server + volumes: + - 'redis:/data' + networks: + - praktikum-network + environment: + - ALLOW_EMPTY_PASSWORD=yes + ports: + - '6379:6379' +volumes: + pgdata: + redis: +networks: + praktikum-network: + driver: bridge \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 5d0db29..0473a8d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,17 @@ services: command: -p 35432 networks: - praktikum-network + redis: + image: 'redis' + command: redis-server + volumes: + - 'redis:/data' + networks: + - praktikum-network + environment: + - ALLOW_EMPTY_PASSWORD=yes + ports: + - '6379:6379' web: build: . restart: unless-stopped @@ -38,6 +49,7 @@ services: - praktikum-network volumes: pgdata: + redis: networks: praktikum-network: driver: bridge \ No newline at end of file