Skip to content
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 25 commits into from Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
53487f0
working on media links
Oct 15, 2018
fd737ce
add media links for conferences
Oct 15, 2018
c11e111
Merge branch 'master' into feature/apply_media_design_and_links
Oct 16, 2018
4f6747f
add specs for decidim media and links
Oct 16, 2018
3bed6d9
add seeds media link
Oct 16, 2018
f5139bf
add changelog
Oct 16, 2018
b3e2177
Merge branch 'master' into feature/apply_media_design_and_links
Oct 16, 2018
9dccf16
i18n sanity locales
Oct 17, 2018
e08db93
upgrade with master
Oct 17, 2018
8b6f14b
rename MediLink to MediaLink
Oct 17, 2018
3900667
Merge branch 'master' into feature/apply_media_design_and_links
Oct 17, 2018
7d556e9
Merge branch 'master' into feature/apply_media_design_and_links
Oct 18, 2018
03f06ff
merge master and fix conflicts
Oct 19, 2018
cf8d8a9
fix permissions
Oct 19, 2018
5e71821
Merge branch 'master' into feature/apply_media_design_and_links
Oct 23, 2018
f235a71
apply cell photo and photos list on conferences and fix translations
Oct 23, 2018
8508ce4
Merge branch 'master' into feature/apply_media_design_and_links
Oct 23, 2018
25edbed
Merge branch 'master' into feature/apply_media_design_and_links
Oct 23, 2018
970117f
fix locales for photos
Oct 23, 2018
aea636e
Merge branch 'master' into feature/apply_media_design_and_links
Oct 24, 2018
f4a3bd1
apply requested changes add test on creation media link and test for …
Oct 24, 2018
e3d0a78
add pagination on media links
Oct 24, 2018
6fb37ee
Merge branch 'master' into feature/apply_media_design_and_links
Oct 24, 2018
09199de
solve conflicts
Oct 25, 2018
c09ba63
fix rubocop offenses
Oct 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@ Decidim::User.where(**search for old subscribed users**).update(newsletter_notif

**Added**:

- **decidim-conferences**: Add the new design of Uploaded Attachments to a Conference, and add the MediaLinks entity. [\#4285](https://github.com/decidim/decidim/pull/4285)
- **decidim-proposals**: When Participatory Texts are published, the admin has the chance to update the contents of each Proposal. [#4326](https://github.com/decidim/decidim/pull/4326)
- **decidim-conferences**: Add the relationship with other spaces. Each Conference-page should potentially be related to participatory processes, consultations and assemblies. [\#4339](https://github.com/decidim/decidim/pull/4339)
- **decidim-conferences**: Apply new design for Conference Program [#4271](https://github.com/decidim/decidim/pull/4271)
Expand Down
@@ -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>
@@ -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 decidim-conferences/app/cells/decidim/conferences/photo/show.erb
@@ -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">&times;</span>
</button>
</div>
</div>
41 changes: 41 additions & 0 deletions decidim-conferences/app/cells/decidim/conferences/photo_cell.rb
@@ -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
@@ -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>
@@ -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
Copy link
Contributor

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

return unless model.any?
render
end
end
end
end
@@ -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
@@ -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
@@ -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