universe serialization fixes

This commit is contained in:
Andrew Brown 2018-11-27 04:55:49 -06:00
parent d321c1acc2
commit dab47b8e01
5 changed files with 8 additions and 10 deletions

View File

@ -29,7 +29,7 @@ class ContentSerializer
self.id = content.id
self.name = content.name
self.user = content.user
self.universe = content.universe
self.universe = content.is_a?(Universe) ? self : content.universe
self.raw_model = content
@ -40,9 +40,9 @@ class ContentSerializer
self.data = {
name: content.try(:name),
description: content.try(:description),
universe: content.universe_id.nil? ? nil : {
id: content.universe_id,
name: content.universe.try(:name)
universe: self.universe.nil? ? nil : {
id: self.universe.id,
name: self.universe.try(:name)
},
categories: self.categories.map { |category|
{

View File

@ -2,7 +2,7 @@
<div>
<ul class="collection">
<% content.contributors.each do |contributor| %>
<% content.raw_model.contributors.each do |contributor| %>
<% next if contributor.user.nil? && (current_user != content.user) %>
<li class="collection-item avatar">
<i class="material-icons circle white-text">person</i>

View File

@ -24,7 +24,7 @@
</ul>
</p>
<% if content.contributors.any? %>
<% if content.raw_model.contributors.any? %>
<p>
The following users are enabled as contributors to this universe.
<% if user_signed_in? && content.user == current_user %>

View File

@ -1,6 +1,6 @@
<%# Usage: render partial: 'content/form/contributors/leave', locals: { content: content } %>
<% if user_signed_in? && content.contributors.pluck(:user_id).include?(current_user.id) %>
<% if user_signed_in? && content.raw_model.contributors.pluck(:user_id).include?(current_user.id) %>
<p class="grey-text">
You are a contributor to this universe. You may dismiss yourself as a contributor at any time, but will need to be reinvited to begin contributing again.
You will lose access to all content in this universe unless it is shared publicly, even if you created or edited it previously.
@ -12,4 +12,4 @@
method: 'delete',
data: { confirm: "Are you sure? You will no longer have contributor access to this universe." } %>
</p>
<% end %>
<% end %>

View File

@ -1,5 +1,3 @@
<%= render 'attribute_fields/modal', content: @content %>
<div class="row">
<%= form_for @content, multipart: true do |form| %>
<div class="col s12 m9">