From 3217e6233c783abfcae40b924f4f6f2c3f7ba698 Mon Sep 17 00:00:00 2001 From: Carrick Rogers Date: Thu, 28 Jul 2016 13:17:26 -0400 Subject: [PATCH 1/6] add waffle badge remove plus sign --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f11d413d68..e1fdc4fae9 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ [![Build Status](https://travis-ci.org/avalonmediasystem/avalon.svg?branch=develop)](https://travis-ci.org/avalonmediasystem/avalon) +[![Stories in Ready](https://badge.waffle.io/avalonmediasystem/avalon.png?label=ready&title=Ready)](https://waffle.io/avalonmediasystem/avalon) + [![Coverage Status](https://coveralls.io/repos/avalonmediasystem/avalon/badge.svg?branch=master&service=github)](https://coveralls.io/github/avalonmediasystem/avalon?branch=master) For more information and regular project updates visit the [Avalon blog](http://www.avalonmediasystem.org/blog). From 9c4eafeee5eaefa686050d601408eb02a2eb8600 Mon Sep 17 00:00:00 2001 From: Brian Keese Date: Fri, 29 Jul 2016 11:52:36 -0400 Subject: [PATCH 2/6] Fix marker tooltips --- Gemfile.lock | 2 +- app/assets/javascripts/avalon_player.js.coffee | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index aed9a71467..5cf204639b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -87,7 +87,7 @@ GIT GIT remote: https://github.com/avalonmediasystem/media-element-add-to-playlist.git - revision: 05cfa851b556d5838f2404442172a9857b31b3d1 + revision: af3644c432e8c61dc6d31a0c72ab4bf28c6ecbdd branch: master specs: media_element_add_to_playlist (0.0.1) diff --git a/app/assets/javascripts/avalon_player.js.coffee b/app/assets/javascripts/avalon_player.js.coffee index f44643e5d8..38c993201f 100644 --- a/app/assets/javascripts/avalon_player.js.coffee +++ b/app/assets/javascripts/avalon_player.js.coffee @@ -93,11 +93,10 @@ class AvalonPlayer scrubber.css('position', 'relative') $('.row.marker').each (i,value) -> offset = $(this)[0].dataset['offset'] - start_str = " ["+mejs.Utility.secondsToTimeCode(offset)+"]" marker_id = $(this)[0].dataset['marker'] - title = $(this).find('.marker_title')[0].text + title = String($(this).find('.marker_title')[0].text).replace(/"/g, '"') + " ["+mejs.Utility.secondsToTimeCode(offset)+"]"; offset_percent = Math.round(if isNaN(parseFloat(offset)) then 0 else (100*offset / duration)) - scrubber.append('') + scrubber.append('') @player.setCurrentTime initialTime @player.options.playlistItemDefaultTitle = @stream_info.embed_title From 72b17a73a13556f873f768e3acc0e6fcc549cfbe Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Mon, 1 Aug 2016 12:18:04 -0400 Subject: [PATCH 3/6] Non-logged in users should be able to read playlist items and markers that are public --- app/models/ability.rb | 16 ++++++++-------- spec/models/avalon_marker_spec.rb | 20 ++++++++++++++++++++ spec/models/playlist_item_spec.rb | 20 ++++++++++++++++++++ 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 2fa8b80ebf..d481dbcb46 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -160,10 +160,10 @@ def playlist_item_permissions can [:create, :update, :delete], PlaylistItem do |playlist_item| can? :manage, playlist_item.playlist end - can :read, PlaylistItem do |playlist_item| - (can? :read, playlist_item.playlist) && - (can? :read, playlist_item.master_file) - end + end + can :read, PlaylistItem do |playlist_item| + (can? :read, playlist_item.playlist) && + (can? :read, playlist_item.master_file) end end @@ -172,10 +172,10 @@ def marker_permissions can [:create, :update, :delete], AvalonMarker do |marker| can? :manage, marker.playlist_item.playlist end - can :read, AvalonMarker do |marker| - (can? :read, marker.playlist_item.playlist) && - (can? :read, marker.playlist_item.master_file) - end + end + can :read, AvalonMarker do |marker| + (can? :read, marker.playlist_item.playlist) && + (can? :read, marker.playlist_item.master_file) end end diff --git a/spec/models/avalon_marker_spec.rb b/spec/models/avalon_marker_spec.rb index 103757739d..5b9f0b981b 100644 --- a/spec/models/avalon_marker_spec.rb +++ b/spec/models/avalon_marker_spec.rb @@ -62,5 +62,25 @@ it { is_expected.to be_able_to(:read, avalon_marker) } end end + + context 'when not logged in' do + let(:ability) { Ability.new(nil) } + let(:playlist) { FactoryGirl.create(:playlist, visibility: Playlist::PUBLIC) } + + it { is_expected.not_to be_able_to(:create, avalon_marker) } + it { is_expected.not_to be_able_to(:update, avalon_marker) } + it { is_expected.not_to be_able_to(:delete, avalon_marker) } + + context 'when master file is NOT readable by public' do + it { is_expected.not_to be_able_to(:read, avalon_marker) } + end + + context 'when master file is readable by public' do + let(:media_object) { FactoryGirl.create(:published_media_object, visibility: 'public') } + let(:master_file) { FactoryGirl.create(:master_file, mediaobject: media_object) } + + it { is_expected.to be_able_to(:read, avalon_marker) } + end + end end end diff --git a/spec/models/playlist_item_spec.rb b/spec/models/playlist_item_spec.rb index b103aeba35..ed6013f5c9 100644 --- a/spec/models/playlist_item_spec.rb +++ b/spec/models/playlist_item_spec.rb @@ -52,5 +52,25 @@ it{ is_expected.to be_able_to(:read, playlist_item) } end end + + context 'when other user' do + let(:ability){ Ability.new(nil) } + let(:playlist) { FactoryGirl.create(:playlist, visibility: Playlist::PUBLIC) } + + it{ is_expected.not_to be_able_to(:create, playlist_item) } + it{ is_expected.not_to be_able_to(:update, playlist_item) } + it{ is_expected.not_to be_able_to(:delete, playlist_item) } + + context 'when master file is NOT readable by public' do + it{ is_expected.not_to be_able_to(:read, playlist_item) } + end + + context 'when master file is readable by public' do + let(:media_object) { FactoryGirl.create(:published_media_object, visibility: 'public') } + let(:master_file) { FactoryGirl.create(:master_file, mediaobject: media_object) } + + it{ is_expected.to be_able_to(:read, playlist_item) } + end + end end end From 3bbb4ba8780e25f6f2c4c4eb1a582262776aec84 Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Mon, 1 Aug 2016 12:21:02 -0400 Subject: [PATCH 4/6] Only show marker if user can read the marker; only show edit/delete buttons if the user has those abilities --- app/views/playlists/_markers.html.erb | 42 +++++++++++++++------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/app/views/playlists/_markers.html.erb b/app/views/playlists/_markers.html.erb index 59b91610df..2b4812e770 100644 --- a/app/views/playlists/_markers.html.erb +++ b/app/views/playlists/_markers.html.erb @@ -20,26 +20,30 @@ Unless required by applicable law or agreed to in writing, software distributed
Actions
<% @markers.sort_by(&:start_time).each do |marker| %> - <% if can? :read, marker.master_file %> - <% start = marker.start_time.to_f/1000 %> -
- <%= form_for(marker, remote: true) do |f| %> -
- <%= marker.title %> + <% if can? :read, marker %> + <% start = marker.start_time.to_f/1000 %> +
+ <%= form_for(marker, remote: true) do |f| %> + +
+ <%= pretty_time(marker.start_time) %> +
+
+ <% if can? :edit, marker %> + <%= button_tag name: 'edit_marker', id: "edit_marker_#{marker.id}", class:'btn btn-default btn-xs edit_marker', type: 'button' do %> + Edit + <% end %> + <% end %> + <% if can? :delete, marker %> + <%= button_tag name: 'delete_marker', class:'btn btn-danger btn-xs btn-confirmation', form: "edit_avalon_marker_#{marker.id}", data: {placement: 'top'} do %> + Delete + <% end %> + <% end %> +
+ <% end %>
-
- <%= pretty_time(marker.start_time) %> -
-
- <%= button_tag name: 'edit_marker', id: "edit_marker_#{marker.id}", class:'btn btn-default btn-xs edit_marker', type: 'button' do %> - Edit - <% end %> - <%= button_tag name: 'delete_marker', class:'btn btn-danger btn-xs btn-confirmation', form: "edit_avalon_marker_#{marker.id}", data: {placement: 'top'} do %> - Delete - <% end %> -
- <% end %> -
<% end %> <% end %>
From 2ada69fb3881357dd076746c3b16500788053eb8 Mon Sep 17 00:00:00 2001 From: Brian Keese Date: Mon, 1 Aug 2016 12:17:42 -0400 Subject: [PATCH 5/6] Add migration that converts tables to UTF8 --- .../20160801161257_convert_tables_to_utf8.rb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 db/migrate/20160801161257_convert_tables_to_utf8.rb diff --git a/db/migrate/20160801161257_convert_tables_to_utf8.rb b/db/migrate/20160801161257_convert_tables_to_utf8.rb new file mode 100644 index 0000000000..7e6a5a17f1 --- /dev/null +++ b/db/migrate/20160801161257_convert_tables_to_utf8.rb @@ -0,0 +1,26 @@ +class ConvertTablesToUtf8 < ActiveRecord::Migration + def change_encoding(encoding,collation) + connection = ActiveRecord::Base.connection + if connection.adapter_name == 'Mysql2' + tables = connection.tables + dbname = connection.current_database + execute <<-SQL + ALTER DATABASE #{dbname} CHARACTER SET #{encoding} COLLATE #{collation}; + SQL + tables.each do |tablename| + execute <<-SQL + ALTER TABLE #{dbname}.#{tablename} CONVERT TO CHARACTER SET #{encoding} COLLATE #{collation}; + SQL + end + end + end + + def up + change_encoding('utf8','utf8_general_ci') + end + + def down + raise ActiveRecord::IrreversibleMigration + #change_encoding('latin1','latin1_swedish_ci') + end +end From 02c02919fa31a8f25319b6d0a82f79f3b10d4d1c Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Tue, 2 Aug 2016 10:56:02 -0400 Subject: [PATCH 6/6] Prep for 5.1.1 --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 7501138fe8..d0d20023e5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,7 +11,7 @@ end module Avalon - VERSION = '5.0' + VERSION = '5.1.1' class MissingUserId < Exception; end class Application < Rails::Application