New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/apply media design and links #4285
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
53487f0
working on media links
fd737ce
add media links for conferences
c11e111
Merge branch 'master' into feature/apply_media_design_and_links
4f6747f
add specs for decidim media and links
3bed6d9
add seeds media link
f5139bf
add changelog
b3e2177
Merge branch 'master' into feature/apply_media_design_and_links
9dccf16
i18n sanity locales
e08db93
upgrade with master
8b6f14b
rename MediLink to MediaLink
3900667
Merge branch 'master' into feature/apply_media_design_and_links
7d556e9
Merge branch 'master' into feature/apply_media_design_and_links
03f06ff
merge master and fix conflicts
cf8d8a9
fix permissions
5e71821
Merge branch 'master' into feature/apply_media_design_and_links
f235a71
apply cell photo and photos list on conferences and fix translations
8508ce4
Merge branch 'master' into feature/apply_media_design_and_links
25edbed
Merge branch 'master' into feature/apply_media_design_and_links
970117f
fix locales for photos
aea636e
Merge branch 'master' into feature/apply_media_design_and_links
f4a3bd1
apply requested changes add test on creation media link and test for …
e3d0a78
add pagination on media links
6fb37ee
Merge branch 'master' into feature/apply_media_design_and_links
09199de
solve conflicts
c09ba63
fix rubocop offenses
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
decidim-conferences/app/cells/decidim/conferences/media_link/show.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<li> | ||
<%= icon "external-link" %> | ||
<div> | ||
<%= link_to model.link, target: "_blank" do %> | ||
<strong><%= translated_attribute(model.title) %> </strong> | ||
<% end %> | ||
<div class="text-small"><%= l(model.date, format: :decidim_short_with_month_name_short) %> · <%= model.link %></small> | ||
</div> | ||
</li> |
14 changes: 14 additions & 0 deletions
14
decidim-conferences/app/cells/decidim/conferences/media_link_cell.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Conferences | ||
# This cell renders the media link card for an instance of a MediaLink | ||
class MediaLinkCell < Decidim::ViewModel | ||
include Decidim::LayoutHelper | ||
|
||
def show | ||
render | ||
end | ||
end | ||
end | ||
end |
28 changes: 28 additions & 0 deletions
28
decidim-conferences/app/cells/decidim/conferences/photo/show.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<div class="column"> | ||
<article class="card" data-open="media-picture-<%= index %>"> | ||
<div class="picture__content"> | ||
<%= image_thumb %> | ||
<h5 class="card__title"> | ||
<strong><%= title %></strong> | ||
</h5> | ||
<div class="text-small"> | ||
<%= short_description %> | ||
</div> | ||
</div> | ||
</article> | ||
<div id="media-picture-<%= index %>" class="reveal picture__modal" data-reveal> | ||
<div class="reveal__header"> | ||
<h3 class="reveal__title"><%= t("conferences.photo.show.photo", scope: "decidim") %></h3> | ||
</div> | ||
<%= image_big %> | ||
<h5> | ||
<strong><%= title %></strong> | ||
</h5> | ||
<div class="text-small"> | ||
<%= decidim_sanitize description %> | ||
</div> | ||
<button class="close-button" data-close aria-label="<%= t("conferences.photo.show.close_modal", scope: "decidim") %>" type="button"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
</div> |
41 changes: 41 additions & 0 deletions
41
decidim-conferences/app/cells/decidim/conferences/photo_cell.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Conferences | ||
# This cell renders the media link card for an instance of a MediaLink | ||
class PhotoCell < Decidim::ViewModel | ||
include Decidim::ApplicationHelper | ||
include Decidim::SanitizeHelper | ||
|
||
def show | ||
render | ||
end | ||
|
||
private | ||
|
||
def index | ||
@options[:index] | ||
end | ||
|
||
def image_thumb | ||
image_tag model.thumbnail_url | ||
end | ||
|
||
def image_big | ||
image_tag model.big_url | ||
end | ||
|
||
def title | ||
translated_attribute model.title | ||
end | ||
|
||
def short_description | ||
decidim_sanitize html_truncate(description, length: 100, separator: "...") | ||
end | ||
|
||
def description | ||
translated_attribute(model.description) | ||
end | ||
end | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
decidim-conferences/app/cells/decidim/conferences/photos_list/show.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="section images"> | ||
<h4 class="section-heading"><%= t("conferences.photos_list.show.related_photos", scope: "decidim") %></h4> | ||
<div class="row small-up-1 smallmedium-up-2 card-grid"> | ||
<% model.each_with_index do |photo, index| %> | ||
<%= cell "decidim/conferences/photo", photo, index: index %> | ||
<% end %> | ||
</div> | ||
</div> |
17 changes: 17 additions & 0 deletions
17
decidim-conferences/app/cells/decidim/conferences/photos_list_cell.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Conferences | ||
# This cell renders the photos list | ||
class PhotosListCell < Decidim::ViewModel | ||
include Cell::ViewModel::Partial | ||
include Decidim::ApplicationHelper | ||
include Decidim::SanitizeHelper | ||
|
||
def show | ||
return unless model.any? | ||
render | ||
end | ||
end | ||
end | ||
end |
66 changes: 66 additions & 0 deletions
66
decidim-conferences/app/commands/decidim/conferences/admin/create_media_link.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Conferences | ||
module Admin | ||
# A command with all the business logic when creating a new | ||
# media link for conference in the system. | ||
class CreateMediaLink < Rectify::Command | ||
# Public: Initializes the command. | ||
# | ||
# form - A form object with the params. | ||
# conference - The Conference that will hold the speaker | ||
def initialize(form, current_user, conference) | ||
@form = form | ||
@current_user = current_user | ||
@conference = conference | ||
end | ||
|
||
# Executes the command. Broadcasts these events: | ||
# | ||
# - :ok when everything is valid. | ||
# - :invalid if the form wasn't valid and we couldn't proceed. | ||
# | ||
# Returns nothing. | ||
def call | ||
return broadcast(:invalid) if form.invalid? | ||
|
||
transaction do | ||
create_media_link! | ||
end | ||
|
||
broadcast(:ok) | ||
end | ||
|
||
private | ||
|
||
attr_reader :form, :conference, :current_user | ||
|
||
def create_media_link! | ||
log_info = { | ||
resource: { | ||
title: form.title | ||
}, | ||
participatory_space: { | ||
title: conference.title | ||
} | ||
} | ||
|
||
@media_link = Decidim.traceability.create!( | ||
Decidim::Conferences::MediaLink, | ||
current_user, | ||
form.attributes.slice( | ||
:title, | ||
:link, | ||
:weight, | ||
:date | ||
).merge( | ||
conference: conference | ||
), | ||
log_info | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
56 changes: 56 additions & 0 deletions
56
decidim-conferences/app/commands/decidim/conferences/admin/destroy_media_link.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Conferences | ||
module Admin | ||
# A command with all the business logic when destroying a media link | ||
# in the system. | ||
class DestroyMediaLink < Rectify::Command | ||
# Public: Initializes the command. | ||
# | ||
# media_link - the MediaLink to destroy | ||
# current_user - the user performing this action | ||
def initialize(media_link, current_user) | ||
@media_link = media_link | ||
@current_user = current_user | ||
end | ||
|
||
# Executes the command. Broadcasts these events: | ||
# | ||
# - :ok when everything is valid. | ||
# - :invalid if the form wasn't valid and we couldn't proceed. | ||
# | ||
# Returns nothing. | ||
def call | ||
destroy_speaker! | ||
broadcast(:ok) | ||
end | ||
|
||
private | ||
|
||
attr_reader :media_link, :current_user | ||
|
||
def destroy_speaker! | ||
log_info = { | ||
resource: { | ||
title: media_link.title | ||
}, | ||
participatory_space: { | ||
title: media_link.conference.title | ||
} | ||
} | ||
|
||
Decidim.traceability.perform_action!( | ||
"delete", | ||
media_link, | ||
current_user, | ||
log_info | ||
) do | ||
media_link.destroy! | ||
media_link | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
64 changes: 64 additions & 0 deletions
64
decidim-conferences/app/commands/decidim/conferences/admin/update_media_link.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Conferences | ||
module Admin | ||
# A command with all the business logic when updating a conference | ||
# speaker in the system. | ||
class UpdateMediaLink < Rectify::Command | ||
# Public: Initializes the command. | ||
# | ||
# form - A form object with the params. | ||
# media_link - The ConferenceSpeaker to update | ||
def initialize(form, media_link) | ||
@form = form | ||
@media_link = media_link | ||
end | ||
|
||
# Executes the command. Broadcasts these events: | ||
# | ||
# - :ok when everything is valid. | ||
# - :invalid if the form wasn't valid and we couldn't proceed. | ||
# | ||
# Returns nothing. | ||
def call | ||
return broadcast(:invalid) if form.invalid? | ||
return broadcast(:invalid) unless media_link | ||
|
||
transaction do | ||
update_media_link! | ||
end | ||
|
||
broadcast(:ok) | ||
end | ||
|
||
private | ||
|
||
attr_reader :form, :media_link | ||
|
||
def update_media_link! | ||
log_info = { | ||
resource: { | ||
title: media_link.title | ||
}, | ||
participatory_space: { | ||
title: media_link.conference.title | ||
} | ||
} | ||
|
||
Decidim.traceability.update!( | ||
media_link, | ||
form.current_user, | ||
form.attributes.slice( | ||
:title, | ||
:link, | ||
:weight, | ||
:date | ||
), | ||
log_info | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
return unless models.any?
here and remove it from the views