fix fields on deity/government/planet/technology

This commit is contained in:
Andrew Brown 2018-09-05 13:42:12 -05:00
parent 7ad90c53f4
commit fac8c7ded5
7 changed files with 14 additions and 6 deletions

View File

@ -10,6 +10,9 @@ class CharactersController < ContentController
def content_param_list
[
#todo remove all these (for all pages) now that we use custom attributes for them all (minus links)
# all but
#custom_attribute_values: [:name, :value],
:universe_id, :user_id,
:name, :age, :role, :gender, :age, :archetype, :height, :weight, :haircolor,
:facialhair, :eyecolor, :skintone, :bodytype, :identmarks, :hairstyle,

View File

@ -108,7 +108,7 @@ class ContentController < ApplicationController
# Don't set name fields on content that doesn't have a name field
#todo abstract this (and the one in update) to a function
unless [AttributeCategory, AttributeField, Attribute].map(&:name).include?(@content.class.name)
unless [AttributeCategory, AttributeField, Attribute].map(&:name).include?(@content.class.name) && [nil, ''].include?(@content.name)
@content.name = @content.name_field_value || "Untitled"
end
@ -116,6 +116,7 @@ class ContentController < ApplicationController
'content_type': content_type.name
}) if Rails.env.production?
# todo look at this code smell for collab
@content.user = current_user
if @content.update_attributes(content_params)
cache_params = {}

View File

@ -24,7 +24,8 @@ class DeitiesController < ContentController
deity_relics_attributes: [:id, :relic_id, :_destroy],
deity_abilities_attributes: [:id, :ability_id, :_destroy],
deity_related_towns_attributes: [:id, :related_town_id, :_destroy],
deity_related_landmarks_attributes: [:id, :related_landmark_id, :_destroy]
deity_related_landmarks_attributes: [:id, :related_landmark_id, :_destroy],
custom_attribute_values: [:name, :value]
]
end
end

View File

@ -17,7 +17,8 @@ class GovernmentsController < ContentController
government_political_figures_attributes: [:id, :political_figure_id, :_destroy],
government_items_attributes: [:id, :item_id, :_destroy],
government_technologies_attributes: [:id, :technology_id, :_destroy],
government_creatures_attributes: [:id, :creature_id, :_destroy]
government_creatures_attributes: [:id, :creature_id, :_destroy],
custom_attribute_values: [:name, :value]
]
end
end

View File

@ -25,7 +25,8 @@ class PlanetsController < ContentController
planet_groups_attributes: [:id, :group_id, :_destroy],
planet_languages_attributes: [:id, :language_id, :_destroy],
planet_towns_attributes: [:id, :town_id, :_destroy],
planet_nearby_planets_attributes: [:id, :nearby_planet_id, :_destroy]
planet_nearby_planets_attributes: [:id, :nearby_planet_id, :_destroy],
custom_attribute_values: [:name, :value]
]
end
end

View File

@ -18,7 +18,8 @@ class TechnologiesController < ContentController
technology_magics_attributes: [:id, :magic_id, :_destroy],
technology_parent_technologies_attributes: [:id, :parent_technology_id, :_destroy],
technology_child_technologies_attributes: [:id, :child_technology_id, :_destroy],
technology_related_technologies_attributes: [:id, :related_technology_id, :_destroy]
technology_related_technologies_attributes: [:id, :related_technology_id, :_destroy],
custom_attribute_values: [:name, :value]
]
end
end

View File

@ -30,7 +30,7 @@ class PermissionService < Service
end
def self.content_has_no_containing_universe?(content:)
content.universe.nil?
content.universe_field_value.nil?
end
def self.user_is_on_premium_plan?(user:)