mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
Merge branch 'master' into rails5-upgrade
This commit is contained in:
commit
dab5d5f0ea
4
Gemfile
4
Gemfile
@ -76,6 +76,10 @@ gem 'csv'
|
||||
# Tech debt & hacks
|
||||
gem 'binding_of_caller' # see has_changelog.rb
|
||||
|
||||
group :development do
|
||||
gem 'web-console'
|
||||
end
|
||||
|
||||
group :production do
|
||||
gem 'rails_12factor'
|
||||
gem 'uglifier', '>= 1.3.0'
|
||||
|
||||
@ -490,6 +490,10 @@ GEM
|
||||
unicode-display_width (1.4.0)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
web-console (3.3.0)
|
||||
activemodel (>= 4.2)
|
||||
debug_inspector
|
||||
railties (>= 4.2)
|
||||
webmock (3.4.2)
|
||||
addressable (>= 2.3.6)
|
||||
crack (>= 0.3.2)
|
||||
@ -567,6 +571,7 @@ DEPENDENCIES
|
||||
thredded
|
||||
tzinfo-data
|
||||
uglifier (>= 1.3.0)
|
||||
web-console
|
||||
webmock
|
||||
|
||||
RUBY VERSION
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
= Notebook.ai
|
||||
= Notebook.ai
|
||||
{<img src="https://travis-ci.org/indentlabs/notebook.png?branch=master" alt="Build Status" />}[https://travis-ci.org/indentlabs/notebook]
|
||||
{<img src="https://codeclimate.com/github/indentlabs/notebook/badges/gpa.svg" />}[https://codeclimate.com/github/indentlabs/notebook]
|
||||
{<img src="https://codeclimate.com/github/indentlabs/notebook/badges/coverage.svg" />}[https://codeclimate.com/github/indentlabs/notebook/coverage]
|
||||
|
||||
@ -14,4 +14,4 @@
|
||||
|
||||
.collection-header {
|
||||
padding: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,10 +11,11 @@ class ReligionsController < ContentController
|
||||
) + [
|
||||
custom_attribute_values: [:name, :value],
|
||||
religious_figureships_attributes: [:id, :notable_figure_id, :_destroy],
|
||||
deityships_attributes: [:id, :deity_id, :_destroy],
|
||||
deityships_attributes: [:id, :deity_character_id, :_destroy],
|
||||
religious_locationships_attributes: [:id, :practicing_location_id, :_destroy],
|
||||
artifactships_attributes: [:id, :artifact_id, :_destroy],
|
||||
religious_raceships_attributes: [:id, :race_id, :_destroy]
|
||||
religious_raceships_attributes: [:id, :race_id, :_destroy],
|
||||
religion_deities_attributes: [:id, :deity_id, :_destroy]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@ -12,12 +12,22 @@ module HasContentGroupers
|
||||
connecting_class = with.to_s.singularize.camelize.constantize
|
||||
connecting_class_name = with
|
||||
|
||||
if relation == :deity_characters
|
||||
# sadface, SADFACE
|
||||
singularized_relation = :deity
|
||||
end
|
||||
|
||||
# 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
|
||||
# sadface
|
||||
if relation.name == :deity_character && singularized_relation == :deity
|
||||
true
|
||||
else
|
||||
relation.name.to_s == singularized_relation
|
||||
end
|
||||
end
|
||||
if through_relation.options.key?(:class_name)
|
||||
through_relation_class = through_relation.options[:class_name] # Character
|
||||
|
||||
@ -2,7 +2,18 @@ class Deityship < ApplicationRecord
|
||||
include HasContentLinking
|
||||
|
||||
belongs_to :user
|
||||
|
||||
belongs_to :religion
|
||||
belongs_to :deity, class_name: 'Character'
|
||||
|
||||
# This is hacky because we had Deityships pointing at character "deities" before
|
||||
# actually having deity models. When we added a ReligionDeityship that points to
|
||||
# a deity "deity", this got renamed to "deity_character" and we needed this
|
||||
# foreign key / alias.
|
||||
belongs_to :deity_character, class_name: 'Character', foreign_key: 'deity_id'
|
||||
def deity_character_id
|
||||
deity_id
|
||||
end
|
||||
|
||||
def deity_character_id=(x)
|
||||
self.deity_id = x
|
||||
end
|
||||
end
|
||||
|
||||
6
app/models/content_groupers/religion_deity.rb
Normal file
6
app/models/content_groupers/religion_deity.rb
Normal file
@ -0,0 +1,6 @@
|
||||
class ReligionDeity < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
|
||||
belongs_to :religion
|
||||
belongs_to :deity
|
||||
end
|
||||
@ -21,7 +21,7 @@ class Religion < ApplicationRecord
|
||||
|
||||
# Characters
|
||||
relates :notable_figures, with: :religious_figureships
|
||||
relates :deities, with: :deityships
|
||||
relates :deity_characters, with: :deityships
|
||||
|
||||
# Locations
|
||||
relates :practicing_locations, with: :religious_locationships
|
||||
@ -32,6 +32,9 @@ class Religion < ApplicationRecord
|
||||
# Races
|
||||
relates :races, with: :religious_raceships
|
||||
|
||||
# Deities
|
||||
relates :deities, with: :religion_deities
|
||||
|
||||
def self.color
|
||||
'yellow'
|
||||
end
|
||||
|
||||
@ -123,11 +123,16 @@
|
||||
</ul>
|
||||
|
||||
<div class="navbar-fixed">
|
||||
<nav class="light-blue">
|
||||
<nav class="black">
|
||||
<div class="nav-wrapper">
|
||||
<%= link_to 'Notebook.ai', main_app.root_url, class: 'brand-logo center' %>
|
||||
|
||||
<ul class="right">
|
||||
<li>
|
||||
<%= link_to 'https://www.notebook.ai/forum/announcements/remembering-james-brown' do %>
|
||||
<div class="hide-on-small-and-down"><i class="material-icons red-text">favorite</i></div>
|
||||
<% end %>
|
||||
</li>
|
||||
<% if user_signed_in? %>
|
||||
<li>
|
||||
<a class="dropdown-trigger tooltipped" href="#!" data-target="help-dropdown" data-position="bottom" data-delay="100" data-tooltip="Need help?">
|
||||
|
||||
@ -72,6 +72,9 @@
|
||||
html {
|
||||
font-size: inherit !important;
|
||||
}
|
||||
nav {
|
||||
line-height: 64px !important;
|
||||
}
|
||||
nav form {
|
||||
height: inherit;
|
||||
}
|
||||
|
||||
@ -26,6 +26,8 @@
|
||||
:attributes:
|
||||
- :name: deities
|
||||
:label: Deities
|
||||
- :name: deity_characters
|
||||
:label: Deities
|
||||
- :name: teachings
|
||||
:label: Teachings
|
||||
- :name: prophecies
|
||||
|
||||
11
db/migrate/20180715184447_create_religion_deities.rb
Normal file
11
db/migrate/20180715184447_create_religion_deities.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreateReligionDeities < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :religion_deities do |t|
|
||||
t.references :user, index: true, foreign_key: true
|
||||
t.references :religion, index: true, foreign_key: true
|
||||
t.references :deity, index: true, foreign_key: true
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
49
db/schema.rb
49
db/schema.rb
@ -1313,6 +1313,43 @@ ActiveRecord::Schema.define(version: 2018_06_20_012919) do
|
||||
t.index ["page_category_id"], name: "index_page_fields_on_page_category_id"
|
||||
end
|
||||
|
||||
create_table "page_categories", force: :cascade do |t|
|
||||
t.string "label"
|
||||
t.integer "universe_id"
|
||||
t.string "content_type"
|
||||
t.string "icon"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
add_index "page_categories", ["universe_id", "content_type"], name: "index_page_categories_on_universe_id_and_content_type"
|
||||
add_index "page_categories", ["universe_id"], name: "index_page_categories_on_universe_id"
|
||||
add_index "page_categories", ["user_id"], name: "index_page_categories_on_user_id"
|
||||
|
||||
create_table "page_field_values", force: :cascade do |t|
|
||||
t.integer "page_field_id"
|
||||
t.integer "page_id"
|
||||
t.text "value"
|
||||
t.integer "user_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.datetime "deleted_at"
|
||||
end
|
||||
|
||||
add_index "page_field_values", ["page_field_id"], name: "index_page_field_values_on_page_field_id"
|
||||
add_index "page_field_values", ["user_id"], name: "index_page_field_values_on_user_id"
|
||||
|
||||
create_table "page_fields", force: :cascade do |t|
|
||||
t.string "label"
|
||||
t.integer "page_category_id"
|
||||
t.string "field_type", default: "textarea"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_index "page_fields", ["page_category_id"], name: "index_page_fields_on_page_category_id"
|
||||
|
||||
create_table "past_ownerships", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "item_id"
|
||||
@ -1541,6 +1578,18 @@ ActiveRecord::Schema.define(version: 2018_06_20_012919) do
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "religion_deities", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "religion_id"
|
||||
t.integer "deity_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_index "religion_deities", ["deity_id"], name: "index_religion_deities_on_deity_id"
|
||||
add_index "religion_deities", ["religion_id"], name: "index_religion_deities_on_religion_id"
|
||||
add_index "religion_deities", ["user_id"], name: "index_religion_deities_on_user_id"
|
||||
|
||||
create_table "religions", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "description"
|
||||
|
||||
11
test/fixtures/religion_deities.yml
vendored
Normal file
11
test/fixtures/religion_deities.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
user_id:
|
||||
religion_id:
|
||||
deity_id:
|
||||
|
||||
two:
|
||||
user_id:
|
||||
religion_id:
|
||||
deity_id:
|
||||
7
test/models/religion_deity_test.rb
Normal file
7
test/models/religion_deity_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ReligionDeityTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user