mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
Merge pull request #261 from indentlabs/jan-release-1
January release 1 (WIP)
This commit is contained in:
commit
23ecbae406
BIN
app/assets/images/card-headers/.DS_Store
vendored
Normal file
BIN
app/assets/images/card-headers/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
app/assets/images/card-headers/deities.jpg
Normal file
BIN
app/assets/images/card-headers/deities.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 593 KiB |
BIN
app/assets/images/card-headers/governments.jpg
Normal file
BIN
app/assets/images/card-headers/governments.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 794 KiB |
BIN
app/assets/images/card-headers/planets.jpg
Normal file
BIN
app/assets/images/card-headers/planets.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 740 KiB |
BIN
app/assets/images/card-headers/technologies.jpg
Normal file
BIN
app/assets/images/card-headers/technologies.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 579 KiB |
@ -28,7 +28,15 @@ class CharactersController < ContentController
|
||||
birthings_attributes: [:id, :birthplace_id, :_destroy],
|
||||
childrenships_attributes: [:id, :child_id, :_destroy],
|
||||
lingualisms_attributes: [:id, :spoken_language_id, :_destroy],
|
||||
raceships_attributes: [:id, :race_id, :_destroy]
|
||||
raceships_attributes: [:id, :race_id, :_destroy],
|
||||
character_items_attributes: [:id, :item_id, :_destroy],
|
||||
character_technologies_attributes: [:id, :technology_id, :_destroy],
|
||||
character_floras_attributes: [:id, :flora_id, :_destroy],
|
||||
character_friends_attributes: [:id, :friend_id, :_destroy],
|
||||
character_companions_attributes: [:id, :companion_id, :_destroy],
|
||||
character_birthtowns_attributes: [:id, :birthtown_id, :_destroy],
|
||||
character_magics_attributes: [:id, :magic_id, :_destroy],
|
||||
character_enemies_attributes: [:id, :enemy_id, :_destroy]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@ -17,7 +17,8 @@ class CountriesController < ContentController
|
||||
country_religions_attributes: [:id, :religion_id, :_destroy],
|
||||
country_landmarks_attributes: [:id, :landmark_id, :_destroy],
|
||||
country_creatures_attributes: [:id, :creature_id, :_destroy],
|
||||
country_floras_attributes: [:id, :flora_id, :_destroy]
|
||||
country_floras_attributes: [:id, :flora_id, :_destroy],
|
||||
country_governments_attributes: [:id, :government_id, :_destroy]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
class CreaturesController < ContentController
|
||||
private
|
||||
|
||||
def content_params
|
||||
params.require(:creature).permit(content_param_list)
|
||||
end
|
||||
|
||||
def content_param_list
|
||||
%i(
|
||||
name description type_of other_names universe_id color shape size notable_features
|
||||
@ -12,6 +8,7 @@ class CreaturesController < ContentController
|
||||
attack_method defense_method maximum_speed food_sources
|
||||
migratory_patterns reproduction herd_patterns
|
||||
similar_animals symbolisms privacy notes private_notes
|
||||
phylum class_string order family genus species
|
||||
) + [
|
||||
custom_attribute_values: [:name, :value],
|
||||
wildlifeships_attributes: [:id, :habitat_id, :_destroy],
|
||||
|
||||
27
app/controllers/deities_controller.rb
Normal file
27
app/controllers/deities_controller.rb
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
class DeitiesController < ContentController
|
||||
private
|
||||
|
||||
def content_param_list
|
||||
[
|
||||
:name, :description, :other_names, :physical_description, :height,
|
||||
:weight, :symbols, :elements, :strengths, :weaknesses, :prayers, :rituals,
|
||||
:human_interaction, :notable_events, :family_history, :life_story, :notes,
|
||||
:private_notes, :privacy, :universe_id
|
||||
] + [
|
||||
deity_character_parents_attributes: [:id, :character_parent_id, :_destroy],
|
||||
deity_character_partners_attributes: [:id, :character_partner_id, :_destroy],
|
||||
deity_character_children_attributes: [:id, :character_child_id, :_destroy],
|
||||
deity_deity_parents_attributes: [:id, :deity_parent_id, :_destroy],
|
||||
deity_deity_partners_attributes: [:id, :deity_partner_id, :_destroy],
|
||||
deity_deity_children_attributes: [:id, :deity_child_id, :_destroy],
|
||||
deity_creatures_attributes: [:id, :creature_id, :_destroy],
|
||||
deity_floras_attributes: [:id, :flora_id, :_destroy],
|
||||
deity_religions_attributes: [:id, :religion_id, :_destroy],
|
||||
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]
|
||||
]
|
||||
end
|
||||
end
|
||||
@ -1,5 +1,6 @@
|
||||
class ExportController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :whitelist_pluralized_model, only: [:csv]
|
||||
|
||||
def index
|
||||
Mixpanel::Tracker.new(Rails.application.config.mixpanel_token).track(current_user.id, 'viewed export page', {
|
||||
@ -14,81 +15,9 @@ class ExportController < ApplicationController
|
||||
}) if Rails.env.production?
|
||||
end
|
||||
|
||||
# Formats
|
||||
|
||||
def universes_csv
|
||||
report_to_mixpanel 'csv', 'universes'
|
||||
send_data to_csv(current_user.universes), filename: "universes-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def characters_csv
|
||||
report_to_mixpanel 'csv', 'characters'
|
||||
send_data to_csv(current_user.characters), filename: "characters-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def locations_csv
|
||||
report_to_mixpanel 'csv', 'locations'
|
||||
send_data to_csv(current_user.locations), filename: "locations-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def items_csv
|
||||
report_to_mixpanel 'csv', 'items'
|
||||
send_data to_csv(current_user.items), filename: "items-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def creatures_csv
|
||||
report_to_mixpanel 'csv', 'creatures'
|
||||
send_data to_csv(current_user.creatures), filename: "creatures-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def races_csv
|
||||
report_to_mixpanel 'csv', 'races'
|
||||
send_data to_csv(current_user.races), filename: "races-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def floras_csv
|
||||
report_to_mixpanel 'csv', 'flora'
|
||||
send_data to_csv(current_user.floras), filename: "floras-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def religions_csv
|
||||
report_to_mixpanel 'csv', 'religions'
|
||||
send_data to_csv(current_user.religions), filename: "religions-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def magics_csv
|
||||
report_to_mixpanel 'csv', 'magics'
|
||||
send_data to_csv(current_user.magics), filename: "magics-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def languages_csv
|
||||
report_to_mixpanel 'csv', 'languages'
|
||||
send_data to_csv(current_user.languages), filename: "languages-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def groups_csv
|
||||
report_to_mixpanel 'csv', 'groups'
|
||||
send_data to_csv(current_user.groups), filename: "groups-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def towns_csv
|
||||
report_to_mixpanel 'csv', 'towns'
|
||||
send_data to_csv(current_user.towns), filename: "towns-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def landmarks_csv
|
||||
report_to_mixpanel 'csv', 'landmarks'
|
||||
send_data to_csv(current_user.landmarks), filename: "landmarks-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def countries_csv
|
||||
report_to_mixpanel 'csv', 'countries'
|
||||
send_data to_csv(current_user.countries), filename: "countries-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def scenes_csv
|
||||
report_to_mixpanel 'csv', 'scenes'
|
||||
send_data to_csv(current_user.scenes), filename: "scenes-#{Date.today}.csv"
|
||||
def csv # params[:model] needed
|
||||
report_to_mixpanel 'csv', @pluralized_model
|
||||
send_data to_csv(current_user.send(@pluralized_model)), filename: "#{@pluralized_model}-#{Date.today}.csv"
|
||||
end
|
||||
|
||||
def outline
|
||||
@ -119,6 +48,16 @@ class ExportController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def whitelist_pluralized_model
|
||||
@pluralized_model = params[:model]
|
||||
valid_models_to_export = Rails.application.config.content_types[:all].map { |p| p.name.downcase.pluralize }
|
||||
|
||||
unless valid_models_to_export.include?(@pluralized_model)
|
||||
redirect_to root_path, notice: "You don't have permission to do that!"
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def to_csv ar_relation
|
||||
ar_class = ar_relation.build.class
|
||||
attribute_categories = ar_class.attribute_categories(current_user)
|
||||
|
||||
@ -10,7 +10,7 @@ class FlorasController < ContentController
|
||||
name description aliases universe_id
|
||||
order family genus
|
||||
colorings size smell taste
|
||||
fruits seeds nuts berries medicinal_purposes
|
||||
fruits seeds nuts berries medicinal_purposes material_uses
|
||||
reproduction seasonality
|
||||
privacy
|
||||
notes private_notes
|
||||
|
||||
23
app/controllers/governments_controller.rb
Normal file
23
app/controllers/governments_controller.rb
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
class GovernmentsController < ContentController
|
||||
private
|
||||
|
||||
def content_param_list
|
||||
[
|
||||
:name, :description, :type_of_government, :power_structure, :power_source,
|
||||
:checks_and_balances, :sociopolitical, :socioeconomical, :geocultural,
|
||||
:laws, :immigration, :privacy_ideologies, :electoral_process,
|
||||
:term_lengths, :criminal_system, :approval_ratings, :military, :navy,
|
||||
:airforce, :space_program, :international_relations, :civilian_life,
|
||||
:founding_story, :flag_design_story, :notable_wars, :notes,
|
||||
:private_notes, :privacy, :universe_id
|
||||
] + [ #<relations>
|
||||
government_leaders_attributes: [:id, :leader_id, :_destroy],
|
||||
government_groups_attributes: [:id, :group_id, :_destroy],
|
||||
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]
|
||||
]
|
||||
end
|
||||
end
|
||||
@ -28,6 +28,7 @@ class GroupsController < ContentController
|
||||
officeships_attributes: [:id, :office_id, :_destroy],
|
||||
group_equipmentships_attributes: [:id, :equipment_id, :_destroy],
|
||||
key_itemships_attributes: [:id, :key_item_id, :_destroy],
|
||||
group_creatures_attributes: [:id, :creature_id, :_destroy]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@ -21,6 +21,7 @@ class ItemsController < ContentController
|
||||
current_ownerships_attributes: [:id, :current_owner_id, :_destroy],
|
||||
past_ownerships_attributes: [:id, :past_owner_id, :_destroy],
|
||||
maker_relationships_attributes: [:id, :maker_id, :_destroy],
|
||||
item_magics_attributes: [:id, :magic_id, :_destroy],
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@ -23,7 +23,11 @@ class LocationsController < ContentController
|
||||
capital_cities_relationships_attributes: [:id, :capital_city_id, :_destroy],
|
||||
largest_cities_relationships_attributes: [:id, :largest_city_id, :_destroy],
|
||||
notable_cities_relationships_attributes: [:id, :notable_city_id, :_destroy],
|
||||
location_languageships_attributes: [:id, :language_id, :_destroy]
|
||||
location_languageships_attributes: [:id, :language_id, :_destroy],
|
||||
location_capital_towns_attributes: [:id, :capital_town_id, :_destroy],
|
||||
location_largest_towns_attributes: [:id, :largest_town_id, :_destroy],
|
||||
location_notable_towns_attributes: [:id, :notable_town_id, :_destroy],
|
||||
location_landmarks_attributes: [:id, :landmark_id, :_destroy]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
class MagicsController < ContentController
|
||||
private
|
||||
|
||||
def content_params
|
||||
params.require(:magic).permit(content_param_list)
|
||||
end
|
||||
|
||||
def content_param_list
|
||||
%i(
|
||||
name description type_of universe_id visuals effects positive_effects
|
||||
|
||||
@ -22,7 +22,10 @@ class MainController < ApplicationController
|
||||
def dashboard
|
||||
return redirect_to new_user_session_path unless user_signed_in?
|
||||
|
||||
@content_types = current_user.user_content_type_activators.pluck(:content_type)
|
||||
@content_types = (
|
||||
Rails.application.config.content_types[:all].map(&:name) & # Use config to dictate order
|
||||
current_user.user_content_type_activators.pluck(:content_type)
|
||||
)
|
||||
|
||||
ask_question
|
||||
end
|
||||
|
||||
31
app/controllers/planets_controller.rb
Normal file
31
app/controllers/planets_controller.rb
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
class PlanetsController < ContentController
|
||||
private
|
||||
|
||||
def content_param_list
|
||||
[
|
||||
:name, :description, :size, :surface, :landmarks, :climate, :weather,
|
||||
:water_content, :natural_resources, :length_of_day, :length_of_night,
|
||||
:calendar_system, :population, :moons, :orbit, :visible_constellations,
|
||||
:first_inhabitants_story, :world_history, :public_notes, :private_notes,
|
||||
:privacy, :universe_id
|
||||
] + [
|
||||
#todo refactor all models to use:
|
||||
# self.class.relates.map do |relation|
|
||||
# #{with_relation}_attributes: [:id, :#{relates_relation.singularize}_id, :_destroy]
|
||||
# end
|
||||
planet_countries_attributes: [:id, :country_id, :_destroy],
|
||||
planet_locations_attributes: [:id, :location_id, :_destroy],
|
||||
planet_landmarks_attributes: [:id, :landmark_id, :_destroy],
|
||||
planet_races_attributes: [:id, :race_id, :_destroy],
|
||||
planet_floras_attributes: [:id, :flora_id, :_destroy],
|
||||
planet_creatures_attributes: [:id, :creature_id, :_destroy],
|
||||
planet_religions_attributes: [:id, :religion_id, :_destroy],
|
||||
planet_deities_attributes: [:id, :deity_id, :_destroy],
|
||||
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]
|
||||
]
|
||||
end
|
||||
end
|
||||
@ -1,10 +1,6 @@
|
||||
class RacesController < ContentController
|
||||
private
|
||||
|
||||
def content_params
|
||||
params.require(:race).permit(content_param_list)
|
||||
end
|
||||
|
||||
def content_param_list
|
||||
%i(
|
||||
name description other_names universe_id
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
class ReligionsController < ContentController
|
||||
private
|
||||
|
||||
def content_params
|
||||
params.require(:religion).permit(content_param_list)
|
||||
end
|
||||
|
||||
def content_param_list
|
||||
%i(
|
||||
name description other_names universe_id
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
class ScenesController < ContentController
|
||||
private
|
||||
|
||||
def content_params
|
||||
params.require(:scene).permit(content_param_list)
|
||||
end
|
||||
|
||||
def content_param_list
|
||||
%i(
|
||||
name summary universe_id
|
||||
|
||||
24
app/controllers/technologies_controller.rb
Normal file
24
app/controllers/technologies_controller.rb
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
class TechnologiesController < ContentController
|
||||
private
|
||||
|
||||
def content_param_list
|
||||
[
|
||||
:name, :description, :other_names, :materials, :manufacturing_process,
|
||||
:sales_process, :cost, :rarity, :purpose, :how_it_works, :resources_used,
|
||||
:physical_description, :size, :weight, :colors, :notes, :private_notes,
|
||||
:privacy, :universe_id
|
||||
] + [ #<relations>
|
||||
technology_characters_attributes: [:id, :character_id, :_destroy],
|
||||
technology_towns_attributes: [:id, :town_id, :_destroy],
|
||||
technology_countries_attributes: [:id, :country_id, :_destroy],
|
||||
technology_groups_attributes: [:id, :group_id, :_destroy],
|
||||
technology_creatures_attributes: [:id, :creature_id, :_destroy],
|
||||
technology_planets_attributes: [:id, :planet_id, :_destroy],
|
||||
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]
|
||||
]
|
||||
end
|
||||
end
|
||||
@ -1,14 +1,20 @@
|
||||
class UniversesController < ContentController
|
||||
|
||||
# TODO: pull list of content types out from some centralized list somewhere
|
||||
[
|
||||
:characters, :locations, :items, :creatures, :races, :religions, :groups, :magics, :languages, :floras, :scenes
|
||||
].each do |content_type_name|
|
||||
Rails.application.config.content_types[:all_non_universe].each do |content_type|
|
||||
content_type_name = content_type.name.downcase.pluralize.to_sym
|
||||
define_method content_type_name do
|
||||
@content_type = content_type_name.to_s.singularize.capitalize.constantize
|
||||
|
||||
@universe = Universe.find(params[:id])
|
||||
@content_list = @universe.send(content_type_name).is_public.order(:name)
|
||||
@content_list = @universe.send(content_type_name)
|
||||
|
||||
# todo just use current_user.can_view?(@universe) and/or individual filtering
|
||||
unless user_signed_in? && (current_user == @universe.user || Contributor.exists?(user_id: current_user.id, universe_id: @universe.id))
|
||||
@content_list = @content_list.is_public
|
||||
end
|
||||
|
||||
@content_list = @content_list.order(:name)
|
||||
|
||||
render :content_list
|
||||
end
|
||||
@ -24,7 +30,7 @@ class UniversesController < ContentController
|
||||
[
|
||||
:user_id,
|
||||
:name, :description, :genre,
|
||||
:laws_of_physics, :magic_system, :technologies,
|
||||
:laws_of_physics, :magic_system, :technology,
|
||||
:history,
|
||||
:privacy,
|
||||
:notes, :private_notes,
|
||||
|
||||
@ -4,8 +4,6 @@ module HasContentGroupers
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
@@relations = {}
|
||||
|
||||
# Example:
|
||||
# relates :siblings, with: :siblingships, where: { alive: true }, type: :two_way
|
||||
# Defines :siblings and :siblingships relations, their inverses, and accepts_nested_attributes for siblingships
|
||||
@ -14,12 +12,32 @@ module HasContentGroupers
|
||||
connecting_class = with.to_s.singularize.camelize.constantize
|
||||
connecting_class_name = with
|
||||
|
||||
# Store all added relations on the class model, so we can dynamically fetch them all whenever needed.
|
||||
# e.g. Character.class_variable_get(:@@relations) => [:mothers, :fathers, :siblings, ...]
|
||||
@@relations[relation] = { # @@relations[:siblings] = {
|
||||
with: with, # with: :siblingships,
|
||||
related_class: connecting_class # related_class: Siblingship
|
||||
} # }
|
||||
# Fetch the connecting class's through class (e.g. Character for sibling_id).
|
||||
# If there isn't one defined, it means it already maps to a model (e.g. race_id),
|
||||
# so we can use the name as the class as well.
|
||||
belongs_to_relations = connecting_class.reflect_on_all_associations(:belongs_to)
|
||||
through_relation = belongs_to_relations.detect do |relation| # sibling
|
||||
relation.name.to_s == singularized_relation
|
||||
end
|
||||
if through_relation.options.key?(:class_name)
|
||||
through_relation_class = through_relation.options[:class_name] # Character
|
||||
else
|
||||
through_relation_class = through_relation.name.to_s.titleize # Character
|
||||
end
|
||||
|
||||
# Store all added relations on the config object, so we can dynamically
|
||||
# fetch them all whenever needed. These are used to find all relations
|
||||
# where a particular page is the target of a content_grouper, rather than
|
||||
# the parent (e.g. one of its has_many's).
|
||||
Rails.application.config.content_relations[through_relation_class] ||= {}
|
||||
Rails.application.config.content_relations[through_relation_class][connecting_class.name] = \
|
||||
{ # ['Character'][:siblings] = {
|
||||
with: with, # with: :siblingships,
|
||||
related_class: connecting_class, # related_class: Siblingship,
|
||||
inverse_class: name, # inverse_class: 'Character',
|
||||
relation_text: singularized_relation, # relation_text: "Sibling"
|
||||
through_relation: singularized_relation # through_relation: 'Sibling'
|
||||
} # }
|
||||
|
||||
# Siblingships
|
||||
has_many connecting_class_name, dependent: :destroy
|
||||
|
||||
5
app/models/content_groupers/character_birthtown.rb
Normal file
5
app/models/content_groupers/character_birthtown.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class CharacterBirthtown < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :character
|
||||
belongs_to :birthtown, class_name: Town.name
|
||||
end
|
||||
5
app/models/content_groupers/character_companion.rb
Normal file
5
app/models/content_groupers/character_companion.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class CharacterCompanion < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :character
|
||||
belongs_to :companion, class_name: Creature.name
|
||||
end
|
||||
5
app/models/content_groupers/character_enemy.rb
Normal file
5
app/models/content_groupers/character_enemy.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class CharacterEnemy < ActiveRecord::Base
|
||||
belongs_to :character
|
||||
belongs_to :user
|
||||
belongs_to :enemy, class_name: Character.name
|
||||
end
|
||||
5
app/models/content_groupers/character_flora.rb
Normal file
5
app/models/content_groupers/character_flora.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class CharacterFlora < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :character
|
||||
belongs_to :flora
|
||||
end
|
||||
5
app/models/content_groupers/character_friend.rb
Normal file
5
app/models/content_groupers/character_friend.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class CharacterFriend < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :character
|
||||
belongs_to :friend, class_name: Character.name
|
||||
end
|
||||
5
app/models/content_groupers/character_item.rb
Normal file
5
app/models/content_groupers/character_item.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class CharacterItem < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :character
|
||||
belongs_to :item
|
||||
end
|
||||
5
app/models/content_groupers/character_magic.rb
Normal file
5
app/models/content_groupers/character_magic.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class CharacterMagic < ActiveRecord::Base
|
||||
belongs_to :character
|
||||
belongs_to :magic
|
||||
belongs_to :user
|
||||
end
|
||||
5
app/models/content_groupers/character_technology.rb
Normal file
5
app/models/content_groupers/character_technology.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class CharacterTechnology < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :character
|
||||
belongs_to :technology
|
||||
end
|
||||
5
app/models/content_groupers/country_government.rb
Normal file
5
app/models/content_groupers/country_government.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class CountryGovernment < ActiveRecord::Base
|
||||
belongs_to :country
|
||||
belongs_to :government
|
||||
belongs_to :user
|
||||
end
|
||||
5
app/models/content_groupers/deity_ability.rb
Normal file
5
app/models/content_groupers/deity_ability.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityAbility < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :ability, class_name: Magic.name
|
||||
end
|
||||
5
app/models/content_groupers/deity_character_child.rb
Normal file
5
app/models/content_groupers/deity_character_child.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityCharacterChild < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :character_child, class_name: Character.name
|
||||
end
|
||||
5
app/models/content_groupers/deity_character_parent.rb
Normal file
5
app/models/content_groupers/deity_character_parent.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityCharacterParent < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :character_parent, class_name: Character.name
|
||||
end
|
||||
5
app/models/content_groupers/deity_character_partner.rb
Normal file
5
app/models/content_groupers/deity_character_partner.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityCharacterPartner < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :character_partner, class_name: Character.name
|
||||
end
|
||||
5
app/models/content_groupers/deity_creature.rb
Normal file
5
app/models/content_groupers/deity_creature.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityCreature < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :creature
|
||||
end
|
||||
5
app/models/content_groupers/deity_deity_child.rb
Normal file
5
app/models/content_groupers/deity_deity_child.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityDeityChild < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :deity_child, class_name: Deity.name
|
||||
end
|
||||
5
app/models/content_groupers/deity_deity_parent.rb
Normal file
5
app/models/content_groupers/deity_deity_parent.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityDeityParent < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :deity_parent, class_name: Deity.name
|
||||
end
|
||||
5
app/models/content_groupers/deity_deity_partner.rb
Normal file
5
app/models/content_groupers/deity_deity_partner.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityDeityPartner < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :deity_partner, class_name: Deity.name
|
||||
end
|
||||
5
app/models/content_groupers/deity_flora.rb
Normal file
5
app/models/content_groupers/deity_flora.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityFlora < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :flora
|
||||
end
|
||||
5
app/models/content_groupers/deity_related_landmark.rb
Normal file
5
app/models/content_groupers/deity_related_landmark.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityRelatedLandmark < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :related_landmark, class_name: Landmark.name
|
||||
end
|
||||
5
app/models/content_groupers/deity_related_town.rb
Normal file
5
app/models/content_groupers/deity_related_town.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityRelatedTown < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :related_town, class_name: Town.name
|
||||
end
|
||||
5
app/models/content_groupers/deity_relic.rb
Normal file
5
app/models/content_groupers/deity_relic.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityRelic < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :relic, class_name: Item.name
|
||||
end
|
||||
5
app/models/content_groupers/deity_religion.rb
Normal file
5
app/models/content_groupers/deity_religion.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class DeityReligion < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :deity
|
||||
belongs_to :religion
|
||||
end
|
||||
5
app/models/content_groupers/government_creature.rb
Normal file
5
app/models/content_groupers/government_creature.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class GovernmentCreature < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :government
|
||||
belongs_to :creature
|
||||
end
|
||||
5
app/models/content_groupers/government_group.rb
Normal file
5
app/models/content_groupers/government_group.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class GovernmentGroup < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :government
|
||||
belongs_to :group
|
||||
end
|
||||
5
app/models/content_groupers/government_item.rb
Normal file
5
app/models/content_groupers/government_item.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class GovernmentItem < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :government
|
||||
belongs_to :item
|
||||
end
|
||||
5
app/models/content_groupers/government_leader.rb
Normal file
5
app/models/content_groupers/government_leader.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class GovernmentLeader < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :government
|
||||
belongs_to :leader, class_name: Character.name
|
||||
end
|
||||
@ -0,0 +1,5 @@
|
||||
class GovernmentPoliticalFigure < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :government
|
||||
belongs_to :political_figure, class_name: Character.name
|
||||
end
|
||||
5
app/models/content_groupers/government_technology.rb
Normal file
5
app/models/content_groupers/government_technology.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class GovernmentTechnology < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :government
|
||||
belongs_to :technology
|
||||
end
|
||||
5
app/models/content_groupers/group_creature.rb
Normal file
5
app/models/content_groupers/group_creature.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class GroupCreature < ActiveRecord::Base
|
||||
belongs_to :group
|
||||
belongs_to :creature
|
||||
belongs_to :user
|
||||
end
|
||||
5
app/models/content_groupers/item_magic.rb
Normal file
5
app/models/content_groupers/item_magic.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class ItemMagic < ActiveRecord::Base
|
||||
belongs_to :item
|
||||
belongs_to :magic
|
||||
belongs_to :user
|
||||
end
|
||||
5
app/models/content_groupers/location_capital_town.rb
Normal file
5
app/models/content_groupers/location_capital_town.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class LocationCapitalTown < ActiveRecord::Base
|
||||
belongs_to :location
|
||||
belongs_to :user
|
||||
belongs_to :capital_town, class_name: Town.name
|
||||
end
|
||||
5
app/models/content_groupers/location_landmark.rb
Normal file
5
app/models/content_groupers/location_landmark.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class LocationLandmark < ActiveRecord::Base
|
||||
belongs_to :location
|
||||
belongs_to :landmark
|
||||
belongs_to :user
|
||||
end
|
||||
5
app/models/content_groupers/location_largest_town.rb
Normal file
5
app/models/content_groupers/location_largest_town.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class LocationLargestTown < ActiveRecord::Base
|
||||
belongs_to :location
|
||||
belongs_to :user
|
||||
belongs_to :largest_town, class_name: Town.name
|
||||
end
|
||||
5
app/models/content_groupers/location_notable_town.rb
Normal file
5
app/models/content_groupers/location_notable_town.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class LocationNotableTown < ActiveRecord::Base
|
||||
belongs_to :location
|
||||
belongs_to :user
|
||||
belongs_to :notable_town, class_name: Town.name
|
||||
end
|
||||
5
app/models/content_groupers/planet_country.rb
Normal file
5
app/models/content_groupers/planet_country.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class PlanetCountry < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :country
|
||||
end
|
||||
5
app/models/content_groupers/planet_creature.rb
Normal file
5
app/models/content_groupers/planet_creature.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class PlanetCreature < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :creature
|
||||
end
|
||||
5
app/models/content_groupers/planet_deity.rb
Normal file
5
app/models/content_groupers/planet_deity.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class PlanetDeity < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :deity
|
||||
end
|
||||
5
app/models/content_groupers/planet_flora.rb
Normal file
5
app/models/content_groupers/planet_flora.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class PlanetFlora < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :flora
|
||||
end
|
||||
5
app/models/content_groupers/planet_group.rb
Normal file
5
app/models/content_groupers/planet_group.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class PlanetGroup < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :group
|
||||
end
|
||||
5
app/models/content_groupers/planet_landmark.rb
Normal file
5
app/models/content_groupers/planet_landmark.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class PlanetLandmark < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :landmark
|
||||
end
|
||||
5
app/models/content_groupers/planet_language.rb
Normal file
5
app/models/content_groupers/planet_language.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class PlanetLanguage < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :language
|
||||
end
|
||||
5
app/models/content_groupers/planet_location.rb
Normal file
5
app/models/content_groupers/planet_location.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class PlanetLocation < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :location
|
||||
end
|
||||
24
app/models/content_groupers/planet_nearby_planet.rb
Normal file
24
app/models/content_groupers/planet_nearby_planet.rb
Normal file
@ -0,0 +1,24 @@
|
||||
class PlanetNearbyPlanet < ActiveRecord::Base
|
||||
include HasContentLinking
|
||||
LINK_TYPE = :two_way
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :nearby_planet, class_name: Planet.name
|
||||
|
||||
after_create do
|
||||
self.reciprocate(
|
||||
relation: :planet_nearby_planets,
|
||||
parent_object_ref: :planet,
|
||||
added_object_ref: :nearby_planet
|
||||
)
|
||||
end
|
||||
|
||||
after_destroy do
|
||||
# This is a two-way relation, so we should also delete the reverse association
|
||||
this_object = Planet.find_by(id: self.planet_id)
|
||||
other_object = Planet.find_by(id: self.nearby_planet_id)
|
||||
|
||||
other_object.nearby_planets.delete(this_object)
|
||||
end
|
||||
end
|
||||
5
app/models/content_groupers/planet_race.rb
Normal file
5
app/models/content_groupers/planet_race.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class PlanetRace < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :race
|
||||
end
|
||||
5
app/models/content_groupers/planet_religion.rb
Normal file
5
app/models/content_groupers/planet_religion.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class PlanetReligion < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :religion
|
||||
end
|
||||
5
app/models/content_groupers/planet_town.rb
Normal file
5
app/models/content_groupers/planet_town.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class PlanetTown < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :planet
|
||||
belongs_to :town
|
||||
end
|
||||
@ -4,7 +4,7 @@ class Sistergroupship < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
|
||||
belongs_to :group
|
||||
belongs_to :sistergroup, class_name: 'Group'
|
||||
belongs_to :sistergroup, class_name: Group.name
|
||||
|
||||
after_create do
|
||||
self.reciprocate relation: :sistergroupships, parent_object_ref: :group, added_object_ref: :sistergroup
|
||||
@ -17,4 +17,4 @@ class Sistergroupship < ActiveRecord::Base
|
||||
|
||||
other_object.sistergroups.delete this_object
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -10,7 +10,7 @@ class Subgroupship < ActiveRecord::Base
|
||||
this_object = Group.find_by(id: self.group_id)
|
||||
other_object = Group.find_by(id: self.subgroup_id)
|
||||
|
||||
other_object.supergroupships.create(group: other_object, supergroup: this_object) unless other_object.supergroups.include? this_object
|
||||
other_object.supergroupships.create(group: other_object, supergroup: this_object) unless other_object.supergroups.include?(this_object)
|
||||
end
|
||||
|
||||
after_destroy do
|
||||
@ -18,6 +18,6 @@ class Subgroupship < ActiveRecord::Base
|
||||
this_object = Group.find_by(id: self.group_id)
|
||||
other_object = Group.find_by(id: self.subgroup_id)
|
||||
|
||||
other_object.supergroups.delete this_object
|
||||
other_object.supergroups.delete(this_object)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -4,7 +4,7 @@ class Supergroupship < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
|
||||
belongs_to :group
|
||||
belongs_to :supergroup, class_name: 'Group'
|
||||
belongs_to :supergroup, class_name: Group.name
|
||||
|
||||
after_create do
|
||||
this_object = Group.find_by(id: self.group_id)
|
||||
@ -20,4 +20,4 @@ class Supergroupship < ActiveRecord::Base
|
||||
|
||||
other_object.subgroups.delete this_object
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
5
app/models/content_groupers/technology_character.rb
Normal file
5
app/models/content_groupers/technology_character.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class TechnologyCharacter < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :technology
|
||||
belongs_to :character
|
||||
end
|
||||
25
app/models/content_groupers/technology_child_technology.rb
Normal file
25
app/models/content_groupers/technology_child_technology.rb
Normal file
@ -0,0 +1,25 @@
|
||||
class TechnologyChildTechnology < ActiveRecord::Base
|
||||
include HasContentLinking
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :technology
|
||||
belongs_to :child_technology, class_name: Technology.name
|
||||
|
||||
after_create do
|
||||
this_object = Technology.find_by(id: self.technology_id)
|
||||
other_object = Technology.find_by(id: self.child_technology_id)
|
||||
|
||||
other_object.technology_parent_technologies.create(
|
||||
technology: other_object,
|
||||
parent_technology: this_object
|
||||
) unless other_object.parent_technologies.include?(this_object)
|
||||
end
|
||||
|
||||
after_destroy do
|
||||
# This is a two-way relation, so we should also delete the reverse association
|
||||
this_object = Technology.find_by(id: self.technology_id)
|
||||
other_object = Technology.find_by(id: self.child_technology_id)
|
||||
|
||||
other_object.parent_technologies.delete(this_object)
|
||||
end
|
||||
end
|
||||
5
app/models/content_groupers/technology_country.rb
Normal file
5
app/models/content_groupers/technology_country.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class TechnologyCountry < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :technology
|
||||
belongs_to :country
|
||||
end
|
||||
5
app/models/content_groupers/technology_creature.rb
Normal file
5
app/models/content_groupers/technology_creature.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class TechnologyCreature < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :technology
|
||||
belongs_to :creature
|
||||
end
|
||||
5
app/models/content_groupers/technology_group.rb
Normal file
5
app/models/content_groupers/technology_group.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class TechnologyGroup < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :technology
|
||||
belongs_to :group
|
||||
end
|
||||
5
app/models/content_groupers/technology_magic.rb
Normal file
5
app/models/content_groupers/technology_magic.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class TechnologyMagic < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :technology
|
||||
belongs_to :magic
|
||||
end
|
||||
25
app/models/content_groupers/technology_parent_technology.rb
Normal file
25
app/models/content_groupers/technology_parent_technology.rb
Normal file
@ -0,0 +1,25 @@
|
||||
class TechnologyParentTechnology < ActiveRecord::Base
|
||||
include HasContentLinking
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :technology
|
||||
belongs_to :parent_technology, class_name: Technology.name
|
||||
|
||||
after_create do
|
||||
this_object = Technology.find_by(id: self.technology_id)
|
||||
other_object = Technology.find_by(id: self.parent_technology_id)
|
||||
|
||||
other_object.technology_child_technologies.create(
|
||||
technology: other_object,
|
||||
child_technology: this_object
|
||||
) unless other_object.child_technologies.include?(this_object)
|
||||
end
|
||||
|
||||
after_destroy do
|
||||
# This is a two-way relation, so we should also delete the reverse association
|
||||
this_object = Technology.find_by(id: self.technology_id)
|
||||
other_object = Technology.find_by(id: self.parent_technology_id)
|
||||
|
||||
other_object.child_technologies.delete(this_object)
|
||||
end
|
||||
end
|
||||
5
app/models/content_groupers/technology_planet.rb
Normal file
5
app/models/content_groupers/technology_planet.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class TechnologyPlanet < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :technology
|
||||
belongs_to :planet
|
||||
end
|
||||
19
app/models/content_groupers/technology_related_technology.rb
Normal file
19
app/models/content_groupers/technology_related_technology.rb
Normal file
@ -0,0 +1,19 @@
|
||||
class TechnologyRelatedTechnology < ActiveRecord::Base
|
||||
include HasContentLinking
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :technology
|
||||
belongs_to :related_technology, class_name: Technology.name
|
||||
|
||||
after_create do
|
||||
self.reciprocate relation: :technology_related_technologies, parent_object_ref: :technology, added_object_ref: :related_technology
|
||||
end
|
||||
|
||||
after_destroy do
|
||||
# This is a two-way relation, so we should also delete the reverse association
|
||||
this_object = Technology.find_by(id: self.technology_id)
|
||||
other_object = Technology.find_by(id: self.related_technology_id)
|
||||
|
||||
other_object.related_technologies.delete(this_object)
|
||||
end
|
||||
end
|
||||
5
app/models/content_groupers/technology_town.rb
Normal file
5
app/models/content_groupers/technology_town.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class TechnologyTown < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :technology
|
||||
belongs_to :town
|
||||
end
|
||||
@ -27,7 +27,6 @@ class Character < ActiveRecord::Base
|
||||
include Authority::Abilities
|
||||
self.authorizer_name = 'CoreContentAuthorizer'
|
||||
|
||||
# Characters
|
||||
relates :fathers, with: :fatherships
|
||||
relates :mothers, with: :motherships
|
||||
relates :siblings, with: :siblingships
|
||||
@ -36,18 +35,17 @@ class Character < ActiveRecord::Base
|
||||
relates :best_friends, with: :best_friendships
|
||||
relates :archenemies, with: :archenemyship
|
||||
relates :love_interests, with: :character_love_interests
|
||||
|
||||
# Locations
|
||||
relates :birthplaces, with: :birthings
|
||||
|
||||
# Items
|
||||
#relates :favorite_items, with: :ownerships, where: { favorite: true }
|
||||
|
||||
# Races
|
||||
relates :races, with: :raceships
|
||||
|
||||
# Languages
|
||||
relates :spoken_languages, with: :lingualisms
|
||||
relates :items, with: :character_items
|
||||
relates :technologies, with: :character_technologies
|
||||
relates :floras, with: :character_floras
|
||||
relates :friends, with: :character_friends
|
||||
relates :companions, with: :character_companions
|
||||
relates :birthtowns, with: :character_birthtowns
|
||||
relates :magics, with: :character_magics
|
||||
relates :enemies, with: :character_enemies
|
||||
|
||||
def description
|
||||
role
|
||||
|
||||
@ -25,7 +25,8 @@ class Country < ActiveRecord::Base
|
||||
relates :religions, with: :country_religions
|
||||
relates :landmarks, with: :country_landmarks
|
||||
relates :creatures, with: :country_creatures
|
||||
relates :floras, with: :country_floras
|
||||
relates :floras, with: :country_floras
|
||||
relates :governments, with: :country_governments
|
||||
|
||||
def self.content_name
|
||||
'country'
|
||||
|
||||
44
app/models/content_types/deity.rb
Normal file
44
app/models/content_types/deity.rb
Normal file
@ -0,0 +1,44 @@
|
||||
class Deity < ActiveRecord::Base
|
||||
acts_as_paranoid
|
||||
|
||||
belongs_to :user
|
||||
validates :name, presence: true
|
||||
validates :user_id, presence: true
|
||||
|
||||
include BelongsToUniverse
|
||||
include HasAttributes
|
||||
include HasPrivacy
|
||||
include HasContentGroupers
|
||||
include HasImageUploads
|
||||
include HasChangelog
|
||||
include Serendipitous::Concern
|
||||
|
||||
include Authority::Abilities
|
||||
self.authorizer_name = 'ExtendedContentAuthorizer'
|
||||
|
||||
relates :character_parents, with: :deity_character_parents
|
||||
relates :character_partners, with: :deity_character_partners
|
||||
relates :character_children, with: :deity_character_children
|
||||
relates :deity_parents, with: :deity_deity_parents
|
||||
relates :deity_partners, with: :deity_deity_partners
|
||||
relates :deity_children, with: :deity_deity_children
|
||||
relates :creatures, with: :deity_creatures
|
||||
relates :floras, with: :deity_floras
|
||||
relates :religions, with: :deity_religions
|
||||
relates :relics, with: :deity_relics
|
||||
relates :abilities, with: :deity_abilities
|
||||
relates :related_towns, with: :deity_related_towns
|
||||
relates :related_landmarks, with: :deity_related_landmarks
|
||||
|
||||
def self.color
|
||||
'text-lighten-1 grey'
|
||||
end
|
||||
|
||||
def self.icon
|
||||
'ac_unit'
|
||||
end
|
||||
|
||||
def self.content_name
|
||||
'deity'
|
||||
end
|
||||
end
|
||||
37
app/models/content_types/government.rb
Normal file
37
app/models/content_types/government.rb
Normal file
@ -0,0 +1,37 @@
|
||||
class Government < ActiveRecord::Base
|
||||
acts_as_paranoid
|
||||
|
||||
belongs_to :user
|
||||
validates :name, presence: true
|
||||
validates :user_id, presence: true
|
||||
|
||||
include BelongsToUniverse
|
||||
include HasAttributes
|
||||
include HasPrivacy
|
||||
include HasContentGroupers
|
||||
include HasImageUploads
|
||||
include HasChangelog
|
||||
include Serendipitous::Concern
|
||||
|
||||
include Authority::Abilities
|
||||
self.authorizer_name = 'ExtendedContentAuthorizer'
|
||||
|
||||
relates :leaders, with: :government_leaders
|
||||
relates :groups, with: :government_groups
|
||||
relates :political_figures, with: :government_political_figures
|
||||
relates :items, with: :government_items
|
||||
relates :technologies, with: :government_technologies
|
||||
relates :creatures, with: :government_creatures
|
||||
|
||||
def self.color
|
||||
'darken-2 green'
|
||||
end
|
||||
|
||||
def self.icon
|
||||
'account_balance'
|
||||
end
|
||||
|
||||
def self.content_name
|
||||
'government'
|
||||
end
|
||||
end
|
||||
@ -19,11 +19,8 @@ class Group < ActiveRecord::Base
|
||||
include Authority::Abilities
|
||||
self.authorizer_name = 'ExtendedContentAuthorizer'
|
||||
|
||||
# Characters
|
||||
relates :leaders, with: :group_leaderships
|
||||
relates :members, with: :group_memberships
|
||||
|
||||
# Groups
|
||||
relates :supergroups, with: :supergroupships
|
||||
relates :subgroups, with: :subgroupships
|
||||
relates :sistergroups, with: :sistergroupships
|
||||
@ -32,15 +29,12 @@ class Group < ActiveRecord::Base
|
||||
relates :rivals, with: :group_rivalships
|
||||
relates :clients, with: :group_clientships
|
||||
relates :suppliers, with: :group_supplierships
|
||||
|
||||
# Locations
|
||||
relates :locations, with: :group_locationships
|
||||
relates :headquarters, with: :headquarterships
|
||||
relates :offices, with: :officeships
|
||||
|
||||
# Items
|
||||
relates :equipment, with: :group_equipmentships
|
||||
relates :key_items, with: :key_itemships
|
||||
relates :creatures, with: :group_creatures
|
||||
|
||||
def self.color
|
||||
'cyan'
|
||||
|
||||
@ -30,6 +30,7 @@ class Item < ActiveRecord::Base
|
||||
relates :past_owners, with: :past_ownerships
|
||||
relates :current_owners, with: :current_ownerships
|
||||
relates :makers, with: :maker_relationships
|
||||
relates :magics, with: :item_magics
|
||||
|
||||
def self.color
|
||||
'amber'
|
||||
|
||||
@ -29,16 +29,15 @@ class Location < ActiveRecord::Base
|
||||
include Authority::Abilities
|
||||
self.authorizer_name = 'CoreContentAuthorizer'
|
||||
|
||||
# Characters
|
||||
relates :leaders, with: :location_leaderships
|
||||
|
||||
# Locations
|
||||
relates :capital_cities, with: :capital_cities_relationships
|
||||
relates :largest_cities, with: :largest_cities_relationships
|
||||
relates :notable_cities, with: :notable_cities_relationships
|
||||
|
||||
# Languages
|
||||
relates :languages, with: :location_languageships
|
||||
relates :capital_towns, with: :location_capital_towns
|
||||
relates :largest_towns, with: :location_largest_towns
|
||||
relates :notable_towns, with: :location_notable_towns
|
||||
relates :landmarks, with: :location_landmarks
|
||||
|
||||
def self.icon
|
||||
'terrain'
|
||||
|
||||
43
app/models/content_types/planet.rb
Normal file
43
app/models/content_types/planet.rb
Normal file
@ -0,0 +1,43 @@
|
||||
class Planet < ActiveRecord::Base
|
||||
acts_as_paranoid
|
||||
|
||||
belongs_to :user
|
||||
validates :name, presence: true
|
||||
validates :user_id, presence: true
|
||||
|
||||
include BelongsToUniverse
|
||||
include HasAttributes
|
||||
include HasPrivacy
|
||||
include HasContentGroupers
|
||||
include HasImageUploads
|
||||
include HasChangelog
|
||||
include Serendipitous::Concern
|
||||
|
||||
include Authority::Abilities
|
||||
self.authorizer_name = 'ExtendedContentAuthorizer'
|
||||
|
||||
relates :countries, with: :planet_countries
|
||||
relates :locations, with: :planet_locations
|
||||
relates :landmarks, with: :planet_landmarks
|
||||
relates :races, with: :planet_races
|
||||
relates :floras, with: :planet_floras
|
||||
relates :creatures, with: :planet_creatures
|
||||
relates :religions, with: :planet_religions
|
||||
relates :deities, with: :planet_deities
|
||||
relates :groups, with: :planet_groups
|
||||
relates :languages, with: :planet_languages
|
||||
relates :towns, with: :planet_towns
|
||||
relates :nearby_planets, with: :planet_nearby_planets
|
||||
|
||||
def self.color
|
||||
'text-lighten-2 blue'
|
||||
end
|
||||
|
||||
def self.icon
|
||||
'public'
|
||||
end
|
||||
|
||||
def self.content_name
|
||||
'planet'
|
||||
end
|
||||
end
|
||||
41
app/models/content_types/technology.rb
Normal file
41
app/models/content_types/technology.rb
Normal file
@ -0,0 +1,41 @@
|
||||
class Technology < ActiveRecord::Base
|
||||
acts_as_paranoid
|
||||
|
||||
belongs_to :user
|
||||
validates :name, presence: true
|
||||
validates :user_id, presence: true
|
||||
|
||||
include BelongsToUniverse
|
||||
include HasAttributes
|
||||
include HasPrivacy
|
||||
include HasContentGroupers
|
||||
include HasImageUploads
|
||||
include HasChangelog
|
||||
include Serendipitous::Concern
|
||||
|
||||
include Authority::Abilities
|
||||
self.authorizer_name = 'ExtendedContentAuthorizer'
|
||||
|
||||
relates :characters, with: :technology_characters
|
||||
relates :towns, with: :technology_towns
|
||||
relates :countries, with: :technology_countries
|
||||
relates :groups, with: :technology_groups
|
||||
relates :creatures, with: :technology_creatures
|
||||
relates :planets, with: :technology_planets
|
||||
relates :magics, with: :technology_magics
|
||||
relates :parent_technologies, with: :technology_parent_technologies
|
||||
relates :child_technologies, with: :technology_child_technologies
|
||||
relates :related_technologies, with: :technology_related_technologies
|
||||
|
||||
def self.color
|
||||
'text-darken-2 red'
|
||||
end
|
||||
|
||||
def self.icon
|
||||
'router'
|
||||
end
|
||||
|
||||
def self.content_name
|
||||
'technology'
|
||||
end
|
||||
end
|
||||
@ -22,24 +22,28 @@ class Universe < ActiveRecord::Base
|
||||
validates :user_id, presence: true
|
||||
|
||||
belongs_to :user
|
||||
# Core content types
|
||||
# The following doesn't work because we reference Universe when setting up this config
|
||||
# Rails.application.config.content_types[:all_non_universe].each do |content_type|
|
||||
# has_many content_types.name.downcase.pluralize.to_sym
|
||||
# end
|
||||
has_many :characters
|
||||
has_many :items
|
||||
has_many :locations
|
||||
|
||||
# Extended content types
|
||||
has_many :countries
|
||||
has_many :creatures
|
||||
has_many :deities
|
||||
has_many :floras
|
||||
has_many :governments
|
||||
has_many :groups
|
||||
has_many :items
|
||||
has_many :landmarks
|
||||
has_many :languages
|
||||
has_many :locations
|
||||
has_many :magics
|
||||
has_many :planets
|
||||
has_many :races
|
||||
has_many :religions
|
||||
has_many :magics
|
||||
has_many :languages
|
||||
has_many :floras
|
||||
has_many :towns
|
||||
has_many :countries
|
||||
has_many :landmarks
|
||||
|
||||
has_many :scenes
|
||||
has_many :groups
|
||||
has_many :technologies
|
||||
has_many :towns
|
||||
|
||||
has_many :contributors, dependent: :destroy
|
||||
|
||||
@ -60,7 +64,7 @@ class Universe < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.icon
|
||||
'public'
|
||||
'language'
|
||||
end
|
||||
|
||||
def self.content_name
|
||||
|
||||
@ -56,6 +56,7 @@ render partial: 'content/cards/content_relation_list', locals: { content_type: :
|
||||
<%
|
||||
relation.gsub!('<plural>', '')
|
||||
relation.strip!
|
||||
relation = relation.singularize
|
||||
relation[0] = relation[0].upcase
|
||||
%>
|
||||
|
||||
@ -97,4 +98,4 @@ render partial: 'content/cards/content_relation_list', locals: { content_type: :
|
||||
<br />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
49
app/views/content/contexts/_dynamic.html.erb
Normal file
49
app/views/content/contexts/_dynamic.html.erb
Normal file
@ -0,0 +1,49 @@
|
||||
<%
|
||||
relations = Rails.application.config.content_relations[content.class.name]
|
||||
|
||||
relations ||= []
|
||||
@references ||= {}
|
||||
%>
|
||||
|
||||
<% relations.each do |name, params| %>
|
||||
<%=
|
||||
render partial: 'content/contexts/relation', locals: {
|
||||
content_type: content.class,
|
||||
content: content,
|
||||
relation_class: params[:related_class],
|
||||
inverse_class: params[:inverse_class],
|
||||
relation_class_id: "#{name.to_s.singularize}_id",
|
||||
relation_text: params[:relation_text],
|
||||
through_relation: params[:through_relation]
|
||||
}
|
||||
%>
|
||||
<% end %>
|
||||
|
||||
<% @references.each do |content_type, relations| %>
|
||||
<% next unless relations.any? %>
|
||||
<%
|
||||
card_title = if relations.count == 1
|
||||
if relations.first.first.include? '<plural>'
|
||||
relations.first.first
|
||||
else
|
||||
[
|
||||
relations.first.first,
|
||||
' of ',
|
||||
pluralize(relations.count, "#{content_type.to_s.singularize}")
|
||||
].join
|
||||
end
|
||||
else
|
||||
[
|
||||
'Related to ',
|
||||
pluralize(relations.count, "#{content_type.to_s.singularize}")
|
||||
].join
|
||||
end
|
||||
%>
|
||||
<div class="col s12 m6 l4">
|
||||
<%= render partial: 'content/cards/content_relation_list', locals: {
|
||||
content_type: content_type,
|
||||
relations: relations,
|
||||
card_title: card_title
|
||||
} %>
|
||||
</div>
|
||||
<% end %>
|
||||
@ -3,15 +3,16 @@
|
||||
content_type: Location,
|
||||
content: some_location_to_find_leaders_of,
|
||||
relation_class: LocationLeadership,
|
||||
relation_class_id: :leader_id,
|
||||
relation_text: :leader_of
|
||||
relation_class_id: :leadership_id,
|
||||
relation_text: :leader_of,
|
||||
through_relation: 'Leader'
|
||||
}
|
||||
|
||||
Note: Initializes/appends to @references[content_type]
|
||||
%>
|
||||
|
||||
<%
|
||||
string_content_type = content_type.to_s.downcase
|
||||
string_content_type = inverse_class.downcase
|
||||
references_key = string_content_type.pluralize.to_sym
|
||||
pretty_relation_text = relation_text.to_s.titleize.downcase
|
||||
|
||||
@ -21,8 +22,8 @@
|
||||
|
||||
<%# .joins(:item).where('items.privacy' => ['public']) also works, but doesn't include current_user check %>
|
||||
<%
|
||||
relations = relation_class.where("#{relation_class_id}": content.id)
|
||||
.map { |content| content.send(string_content_type) }
|
||||
relations = relation_class.where("#{through_relation.downcase}_id": content.id)
|
||||
.map { |content| content.send(inverse_class.downcase) }
|
||||
.select { |content| content && content.readable_by?(current_user || User.new) }
|
||||
%>
|
||||
<%
|
||||
@ -32,21 +33,19 @@
|
||||
# pretty_relation_text[0] = pretty_relation_text[0].upcase
|
||||
@references[references_key] << [pretty_relation_text, relations.first]
|
||||
|
||||
|
||||
elsif relations.count > 1
|
||||
if pretty_relation_text.include? '<plural>'
|
||||
pretty_relation_text.gsub!('<plural>', pluralize(relations.count, string_content_type))
|
||||
else
|
||||
pretty_relation_text = "#{pretty_relation_text} #{pluralize(relations.count, string_content_type)}"
|
||||
pretty_relation_text = "#{pretty_relation_text} of #{pluralize(relations.count, string_content_type)}"
|
||||
end
|
||||
pretty_relation_text[0] = pretty_relation_text[0].upcase
|
||||
|
||||
%>
|
||||
<div class="col s12 m6 l4">
|
||||
<%= render partial: 'content/cards/in_universe_content_list', locals: {
|
||||
content_type: content_type.to_s.downcase,
|
||||
content_type: inverse_class.downcase,
|
||||
content_list: relations,
|
||||
card_title: pretty_relation_text
|
||||
card_title: pretty_relation_text
|
||||
} %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
f.select "#{attribute}_id",
|
||||
current_user.send("linkable_#{klass.pluralize}")
|
||||
.in_universe(@universe_scope)
|
||||
.in_universe(@content.universe)
|
||||
.sort_by(&:name)
|
||||
.reject { |content| content.class.name == klass && content.id == @content.id }
|
||||
.map { |c| [c.name, c.id] }
|
||||
|
||||
@ -14,8 +14,9 @@
|
||||
<%= render 'content/form/groupship_fields', f: builder, attribute: attribute.singularize, parent: f.object %>
|
||||
<% end %>
|
||||
<div class="links">
|
||||
<% color = f.object.send(attribute).build.class.color %>
|
||||
<%= link_to_add_association "add #{attribute.to_s.singularize.humanize}", f, relation,
|
||||
<% model_class = f.object.send(attribute).build.class %>
|
||||
<% color = model_class.color %>
|
||||
<%= link_to_add_association "link #{model_class.name.downcase}", f, relation,
|
||||
class: "btn #{color}",
|
||||
partial: 'content/form/groupship_fields',
|
||||
render_options: { locals: {
|
||||
|
||||
@ -24,36 +24,9 @@
|
||||
</script>
|
||||
|
||||
<% if @content.any? %>
|
||||
|
||||
<h4>
|
||||
Your <%= pluralize(@content.count, content_type) %>
|
||||
<% if @content.count > 0 %>
|
||||
<small class="right">
|
||||
<% if current_user.can_create? @content_type_class %>
|
||||
|
||||
<%= link_to new_polymorphic_path(@content_type_class), class: "btn white #{@content_type_class.color}-text" do %>
|
||||
+
|
||||
<i class="material-icons <%= @content_type_class.color %>-text tooltipped" data-position="bottom" data-tooltip="Create another <%= @content_type_class.name %>">
|
||||
<%= @content_type_class.icon %>
|
||||
</i>
|
||||
<% end %>
|
||||
|
||||
<% else %>
|
||||
|
||||
<%= link_to subscription_path, class: "btn grey lighten-3 #{@content_type_class.color}-text tooltipped", data: {
|
||||
position: 'bottom',
|
||||
tooltip: "Upgrade to Premium to create more #{@content_type_class.name.pluralize}",
|
||||
delay: 50
|
||||
} do %>
|
||||
+
|
||||
<i class="material-icons <%= @content_type_class.color %>-text">
|
||||
<%= @content_type_class.icon %>
|
||||
</i>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</small>
|
||||
<% end %>
|
||||
<%= render partial: 'content/list/create_button', locals: { } %>
|
||||
</h4>
|
||||
<%= render partial: 'content/list/list', locals: { content_list: @content, content_type: @content_type_class, show_add_another_form: true } %>
|
||||
|
||||
|
||||
25
app/views/content/list/_create_button.html.erb
Normal file
25
app/views/content/list/_create_button.html.erb
Normal file
@ -0,0 +1,25 @@
|
||||
<% if @content.count > 0 %>
|
||||
<small class="right">
|
||||
<% if current_user.can_create? @content_type_class %>
|
||||
<%= link_to new_polymorphic_path(@content_type_class), class: "btn white #{@content_type_class.color}-text" do %>
|
||||
+
|
||||
<i class="material-icons <%= @content_type_class.color %>-text tooltipped" data-position="bottom" data-tooltip="Create another <%= @content_type_class.name %>">
|
||||
<%= @content_type_class.icon %>
|
||||
</i>
|
||||
<% end %>
|
||||
|
||||
<% else %>
|
||||
<%= link_to subscription_path, class: "btn grey lighten-3 #{@content_type_class.color}-text tooltipped", data: {
|
||||
position: 'bottom',
|
||||
tooltip: "Upgrade to Premium to create more #{@content_type_class.name.pluralize}",
|
||||
delay: 50
|
||||
} do %>
|
||||
+
|
||||
<i class="material-icons <%= @content_type_class.color %>-text">
|
||||
<%= @content_type_class.icon %>
|
||||
</i>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</small>
|
||||
<% end %>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user