Skip to content

Commit 29b6269

Browse files
committed
Merge branch 'main' of github.com:better-together-solutions/community-engine-rails
2 parents ffbff20 + 7bed2e4 commit 29b6269

File tree

54 files changed

+944
-74
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+944
-74
lines changed
102 KB
Loading
102 KB
Loading
102 KB
Loading

app/assets/stylesheets/better_together/cards.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22
aspect-ratio: 3 / 2;
33
overflow: hidden;
44
object-fit: cover;
5+
}
6+
7+
.card {
8+
&.active {
9+
background-color: var(--bs-primary-bg-subtle);
10+
}
511
}

app/controllers/better_together/conversations_controller.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ class ConversationsController < ApplicationController
99

1010
helper_method :available_participants
1111

12-
def index; end
12+
def index
13+
authorize @conversations
14+
end
1315

1416
def new
1517
@conversation = Conversation.new
18+
authorize @conversation
1619
end
1720

18-
def create
21+
def create # rubocop:todo Metrics/MethodLength
1922
@conversation = Conversation.new(conversation_params.merge(creator: helpers.current_person))
23+
24+
authorize @conversation
25+
2026
if @conversation.save
2127
@conversation.participants << helpers.current_person
2228

@@ -30,6 +36,8 @@ def create
3036
end
3137

3238
def show # rubocop:todo Metrics/MethodLength
39+
authorize @conversation
40+
3341
@messages = @conversation.messages.with_all_rich_text.includes(sender: [:string_translations]).order(:created_at)
3442
@message = @conversation.messages.build
3543

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
module BetterTogether
4+
# CRUD for BetterTogether::Event
5+
class EventsController < FriendlyResourceController
6+
def index
7+
@draft_events = @events.draft
8+
@upcoming_events = @events.upcoming
9+
@past_events = @events.past
10+
end
11+
12+
protected
13+
14+
def resource_class
15+
::BetterTogether::Event
16+
end
17+
end
18+
end

app/controllers/better_together/resource_controller.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ def update
4444
end
4545
end
4646

47+
def destroy
48+
authorize_resource
49+
50+
resource_string = resource_instance.to_s
51+
52+
if resource_instance.destroy
53+
redirect_to url_for(resource_class),
54+
notice: "#{resource_class.model_name.human} #{resource_string} was successfully removed."
55+
else
56+
render :show, status: :unprocessable_entity
57+
end
58+
end
59+
4760
protected
4861

4962
def authorize_resource
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
module BetterTogether
4+
# View helpers for events
5+
module EventsHelper
6+
end
7+
end

app/helpers/better_together/image_helper.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ module ImageHelper # rubocop:todo Metrics/ModuleLength
77
# rubocop:todo Metrics/CyclomaticComplexity
88
# rubocop:todo Metrics/AbcSize
99
def cover_image_tag(entity, options = {}) # rubocop:todo Metrics/MethodLength, Metrics/AbcSize
10-
image_classes = "cover-image rounded-top #{options[:class]}"
10+
image_classes = "cover-image #{options[:class]}"
1111
image_style = options[:style].to_s
1212
image_width = options[:width] || 2400
1313
image_height = options[:height] || 600
1414
image_format = options[:format] || 'jpg'
15-
image_alt = options[:alt] || 'Cover Image'
16-
image_title = options[:title] || 'Cover Image'
15+
image_alt = options[:alt] || entity
16+
image_title = options[:title] || entity
1717
image_tag_attributes = {
1818
class: image_classes,
1919
style: image_style,
@@ -43,8 +43,8 @@ def card_image_tag(entity, options = {}) # rubocop:todo Metrics/MethodLength, Me
4343
image_width = options[:width] || 1200
4444
image_height = options[:height] || 800
4545
image_format = options[:format] || 'jpg'
46-
image_alt = options[:alt] || 'Card Image'
47-
image_title = options[:title] || 'Card Image'
46+
image_alt = options[:alt] || entity
47+
image_title = options[:title] || entity
4848
image_tag_attributes = {
4949
class: image_classes,
5050
style: image_style,
@@ -53,7 +53,7 @@ def card_image_tag(entity, options = {}) # rubocop:todo Metrics/MethodLength, Me
5353
}
5454

5555
# Determine if entity has a card image
56-
if entity.respond_to?(:card_image) && entity.card_image.attached?
56+
if entity.respond_to?(:card_image) && entity.card_image&.attached?
5757
attachment = if entity.respond_to?(:optimized_card_image)
5858
entity.optimized_card_image
5959
else

app/helpers/better_together/platforms_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module BetterTogether
44
module PlatformsHelper # rubocop:todo Style/Documentation
55
def invitation_token_expires_at
6-
session[:platform_invitation_expires_at].to_datetime.to_i
6+
session[:platform_invitation_expires_at]&.to_datetime&.to_i
77
end
88
end
99
end

0 commit comments

Comments
 (0)