From d5bda9ae00e8bbe629268c831b74f9df23901599 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 3 Mar 2020 12:31:28 -0600 Subject: [PATCH 1/3] bandaid heisenbug on universe contrib partials --- app/views/content/display/_contributors.html.erb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/content/display/_contributors.html.erb b/app/views/content/display/_contributors.html.erb index d3da8deb..3f74be6e 100644 --- a/app/views/content/display/_contributors.html.erb +++ b/app/views/content/display/_contributors.html.erb @@ -1,9 +1,13 @@ <%# Usage: render partial: 'content/display/contributors', locals: { content: content } %> -<% if content.contributors.any? %> +<% + raw_model = content.is_a?(Universe) ? content : content.raw_model +%> + +<% if raw_model.contributors.any? %>
- <%= render partial: 'content/form/contributors/leave', locals: { content: content } %> + <%= render partial: 'content/form/contributors/leave', locals: { content: raw_model } %>
<% end %> \ No newline at end of file From a2bb61ac552d920e115ec3230cc502e8ffa1c26f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 4 Mar 2020 00:14:45 -0600 Subject: [PATCH 2/3] fix document sharing --- app/views/content/_share.html.erb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/views/content/_share.html.erb b/app/views/content/_share.html.erb index c45c020d..51276c63 100644 --- a/app/views/content/_share.html.erb +++ b/app/views/content/_share.html.erb @@ -44,9 +44,21 @@
Page-specific sharing
- <%= + <%= + # Big oof here. + content_obj = if shared_content.is_a?(Document) + { + id: shared_content.id, + name: shared_content.title, + page_type: 'Document', + privacy: shared_content.privacy + } + else + shared_content.attributes.slice('id', 'name', 'page_type', 'privacy') + end + react_component("PrivacyToggle", { - content: shared_content.attributes.slice('id', 'name', 'page_type', 'privacy'), + content: content_obj, content_icon: shared_content.class.icon, content_color: shared_content.class.color, submit_path: polymorphic_path(shared_content), From 2050140a735ed7391bb476368c5fa46bb9515f1f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 4 Mar 2020 00:16:08 -0600 Subject: [PATCH 3/3] update document authorizer to look at universe privacy setting also --- app/authorizers/document_authorizer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/authorizers/document_authorizer.rb b/app/authorizers/document_authorizer.rb index 79cc9dfd..f0a10aa6 100644 --- a/app/authorizers/document_authorizer.rb +++ b/app/authorizers/document_authorizer.rb @@ -6,7 +6,8 @@ class DocumentAuthorizer < ApplicationAuthorizer def readable_by?(user) [ resource.user_id == user.id, - resource.privacy == 'public' + resource.privacy == 'public', + resource.universe.present? && resource.universe.privacy == 'public' ].any? end