From 4cdebdb63f399abcfa7fd2c7abd4133ea7b6ff84 Mon Sep 17 00:00:00 2001 From: KRobertK13 Date: Thu, 14 Apr 2022 20:10:57 +0200 Subject: [PATCH] csapatmegszuntetes --- Gemfile | 2 +- Gemfile.lock | 19 +++++++++++-------- app/controllers/events_controller.rb | 1 + app/controllers/teams_controller.rb | 2 +- app/models/team.rb | 6 ++++++ app/views/events/show.html.erb | 12 ++++++------ config/database.yml | 4 ++-- 7 files changed, 28 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index efe33e4..e4544cf 100644 --- a/Gemfile +++ b/Gemfile @@ -35,7 +35,7 @@ gem 'dotenv-rails' gem 'jquery-rails' # gem 'less-rails-semantic_ui', '~> 2.3.1' gem 'autoprefixer-rails', '8.6.5' -gem 'therubyracer' +#gem 'therubyracer' gem 'carrierwave', '~> 1.0' diff --git a/Gemfile.lock b/Gemfile.lock index b8c1cd7..d5419a4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -126,6 +126,7 @@ GEM ruby2_keywords (>= 0.0.4) faraday-net_http (2.0.1) ffi (1.15.5) + ffi (1.15.5-x64-mingw32) globalid (1.0.0) activesupport (>= 5.0) hashie (5.0.0) @@ -141,7 +142,6 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) jwt (2.3.0) - libv8 (3.16.14.19) listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -160,7 +160,7 @@ GEM mini_mime (1.1.2) mini_portile2 (2.8.0) minitest (5.15.0) - msgpack (1.4.5) + msgpack (1.5.1) multi_json (1.15.0) multi_xml (0.6.0) net-imap (0.2.3) @@ -182,6 +182,8 @@ GEM nokogiri (1.13.3) mini_portile2 (~> 2.8.0) racc (~> 1.4) + nokogiri (1.13.3-x64-mingw32) + racc (~> 1.4) oauth2 (1.4.9) faraday (>= 0.17.3, < 3.0) jwt (>= 1.0, < 3.0) @@ -200,6 +202,7 @@ GEM omniauth (~> 2.0) orm_adapter (0.5.0) pg (1.3.4) + pg (1.3.4-x64-mingw32) public_suffix (4.0.6) puma (4.3.11) nio4r (~> 2.0) @@ -239,7 +242,6 @@ GEM rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - ref (2.0.0) regexp_parser (2.2.1) responders (3.0.1) actionpack (>= 5.0) @@ -249,6 +251,8 @@ GEM rubyzip (2.3.2) sassc (2.4.0) ffi (~> 1.9) + sassc (2.4.0-x64-mingw32) + ffi (~> 1.9) sassc-rails (2.1.2) railties (>= 4.0.0) sassc (>= 2.0) @@ -277,9 +281,6 @@ GEM sprockets (>= 3.0.0) ssrf_filter (1.0.7) strscan (3.0.1) - therubyracer (0.12.3) - libv8 (~> 3.16.14.15) - ref thor (1.2.1) tilt (2.0.10) timeout (0.2.0) @@ -290,6 +291,8 @@ GEM turbolinks-source (5.2.0) tzinfo (2.0.4) concurrent-ruby (~> 1.0) + tzinfo-data (1.2022.1) + tzinfo (>= 1.0.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) warden (1.2.9) @@ -308,6 +311,7 @@ GEM PLATFORMS ruby + x64-mingw32 DEPENDENCIES autoprefixer-rails (= 8.6.5) @@ -335,7 +339,6 @@ DEPENDENCIES shrine spring spring-watcher-listen (~> 2.0.0) - therubyracer trix-rails turbolinks (~> 5) tzinfo-data @@ -346,4 +349,4 @@ RUBY VERSION ruby 3.0.3p157 BUNDLED WITH - 2.3.4 + 2.3.10 diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index bf212fd..6f36aec 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -8,6 +8,7 @@ def index def show @entry = Entry.new + @teams = Team.where(id:@event.entry.map(&:team_id)) end def new diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index f726afe..9f7f92a 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -4,7 +4,7 @@ class TeamsController < ApplicationController def index @page = Page.find_by(name: 'teams') - @teams = Team.order(score: :desc).reject { |team| team.number_of_memberships.zero? } + @teams = Team.order(score: :desc) end def show diff --git a/app/models/team.rb b/app/models/team.rb index 0a3765a..fa84294 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -1,4 +1,7 @@ class Team < ApplicationRecord + + default_scope { ids = Membership.select("team_id, count(*) as member_count").group("team_id").having("count(*) > 0").map(&:team_id) + Team.where(id:ids)} has_many :memberships mount_uploader :image, ImageUploader @@ -43,4 +46,7 @@ def delete_memberships! membership.decline! end end + def entry_for(event) + Entry.find_by(team:self, event: event) + end end diff --git a/app/views/events/show.html.erb b/app/views/events/show.html.erb index 8f50844..25ce634 100644 --- a/app/views/events/show.html.erb +++ b/app/views/events/show.html.erb @@ -19,23 +19,23 @@

Nevezett csapatok

- <% @event.entry.each do |entry| %> - + <% @teams.each do |team| %> + <%entry = team.entry_for(@event) %>
- <% if entry.team.image? %> - <%= image_tag(entry.team.image.url(:square_thumb), alt: 'Image') %> + <% if team.image? %> + <%= image_tag(team.image.url(:square_thumb), alt: 'Image') %> <% else %> <%= image_tag('team-placeholder.png', alt: 'Image') %> <% end %>
- <%= link_to entry.team.name, team_path(entry.team), class: 'item team-name-item' %> + <%= link_to team.name, team_path(team), class: 'item team-name-item' %>
<% if admin? %>
- <%= entry.comment %> +
<% end %> <% if @event.can_entry? && entry.revocable_by?(current_user) %> diff --git a/config/database.yml b/config/database.yml index fc95499..c25acf6 100644 --- a/config/database.yml +++ b/config/database.yml @@ -6,8 +6,8 @@ default: &default development: <<: *default database: schorpong_development - username: schorpong - password: schorpong + username: postgres + password: Yxcvbnm13xy host: localhost port: 5432