diff --git a/app/controllers/scenes_controller.rb b/app/controllers/scenes_controller.rb
new file mode 100644
index 00000000..d0054a33
--- /dev/null
+++ b/app/controllers/scenes_controller.rb
@@ -0,0 +1,15 @@
+class ScenesController < ContentController
+ private
+
+ def content_params
+ params.require(:scene).permit(content_param_list)
+ end
+
+ def content_param_list
+ %i(
+ name summary universe_id
+ cause description results
+ notes private_notes
+ )
+ end
+end
diff --git a/app/models/content_types/scene.rb b/app/models/content_types/scene.rb
new file mode 100644
index 00000000..1fde456b
--- /dev/null
+++ b/app/models/content_types/scene.rb
@@ -0,0 +1,53 @@
+class Scene < ActiveRecord::Base
+ validates :name, presence: true
+
+ belongs_to :user
+ validates :user_id, presence: true
+
+ belongs_to :universe
+
+ include HasPrivacy
+ include HasContentGroupers
+ include Serendipitous::Concern
+
+ # Characters
+ # relates :notable_figures, with: :something
+ # relates :dieties, with: :something
+
+ # Locations
+ # relates :practicing_locations, with: :something
+
+ # Items
+ # relates :artifacts, with: :something
+
+ scope :is_public, -> { eager_load(:universe).where('creatures.privacy = ? OR universes.privacy = ?', 'public', 'public') }
+
+ def self.color
+ 'silver'
+ end
+
+ def self.icon
+ 'local_movies'
+ end
+
+ def self.attribute_categories
+ {
+ overview: {
+ icon: 'info',
+ attributes: %w(name summary universe_id)
+ },
+ # contents: {
+ # icon: 'face',
+ # attributes: %w()
+ # },
+ prompts: {
+ icon: 'fingerprint',
+ attributes: %w(cause description results)
+ },
+ notes: {
+ icon: 'edit',
+ attributes: %w(notes private_notes)
+ }
+ }
+ end
+end
diff --git a/app/models/content_types/universe.rb b/app/models/content_types/universe.rb
index a574573a..8ab4299b 100644
--- a/app/models/content_types/universe.rb
+++ b/app/models/content_types/universe.rb
@@ -24,6 +24,8 @@ class Universe < ActiveRecord::Base
has_many :magics
has_many :languages
+ has_many :scenes
+
scope :is_public, -> { where(privacy: 'public') }
def content
diff --git a/app/models/user.rb b/app/models/user.rb
index 97f26e97..eb643b35 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -24,6 +24,8 @@ class User < ActiveRecord::Base
has_many :magics
has_many :languages
+ has_many :scenes
+
# as_json creates a hash structure, which you then pass to ActiveSupport::json.encode to actually encode the object as a JSON string.
# This is different from to_json, which converts it straight to an escaped JSON string,
# which is undesireable in a case like this, when we want to modify it
@@ -77,7 +79,8 @@ class User < ActiveRecord::Base
def recent_content
[
characters, locations, items, universes,
- creatures, races, religions, magics, languages
+ creatures, races, religions, magics, languages,
+ scenes
].flatten
.sort_by(&:updated_at)
.last(10)
diff --git a/app/views/layouts/_sidenav.html.erb b/app/views/layouts/_sidenav.html.erb
index a3765016..a171a4dd 100644
--- a/app/views/layouts/_sidenav.html.erb
+++ b/app/views/layouts/_sidenav.html.erb
@@ -72,6 +72,30 @@
+ <%
+ [Scene].each do |extended_content_type|
+ %>
+
+ <%= link_to polymorphic_path(extended_content_type) do %>
+
+ <%= extended_content_type.icon %>
+
+ <%= extended_content_type.name.pluralize %>
+
+ <%=
+ if @universe_scope
+ @universe_scope.send(extended_content_type.name.downcase.pluralize).count
+ else
+ current_user.send(extended_content_type.name.downcase.pluralize).count
+ end
+ %>
+
+ <% end %>
+
+ <%
+ end
+ %>
+
wc
@@ -79,13 +103,6 @@
29
-
-
- local_movies
- Scenes
- 16
-
-
diff --git a/config/routes.rb b/config/routes.rb
index d3a70086..1dee2eb0 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -42,6 +42,9 @@ Rails.application.routes.draw do
resources :magics
resources :languages
+ # Content usage
+ resources :scenes
+
# Coming Soon TM
get '/plots', to: 'main#comingsoon'
end
diff --git a/db/migrate/20161016220220_create_scenes.rb b/db/migrate/20161016220220_create_scenes.rb
new file mode 100644
index 00000000..819edeb5
--- /dev/null
+++ b/db/migrate/20161016220220_create_scenes.rb
@@ -0,0 +1,19 @@
+class CreateScenes < ActiveRecord::Migration
+ def change
+ create_table :scenes do |t|
+ t.integer :scene_number
+ t.string :name
+ t.string :summary
+ t.integer :universe_id
+ t.integer :user_id
+ t.string :cause
+ t.string :description
+ t.string :results
+ t.string :prose
+ t.string :notes
+ t.string :private_notes
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index fae0cf53..15731696 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20161016213335) do
+ActiveRecord::Schema.define(version: 20161016220220) do
create_table "archenemyships", force: :cascade do |t|
t.integer "user_id"
@@ -346,6 +346,22 @@ ActiveRecord::Schema.define(version: 20161016213335) do
t.datetime "updated_at", null: false
end
+ create_table "scenes", force: :cascade do |t|
+ t.integer "scene_number"
+ t.string "name"
+ t.string "summary"
+ t.integer "universe_id"
+ t.integer "user_id"
+ t.string "cause"
+ t.string "description"
+ t.string "results"
+ t.string "prose"
+ t.string "notes"
+ t.string "private_notes"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "sessions", force: :cascade do |t|
t.string "username", null: false
t.string "password", null: false
diff --git a/test/fixtures/scenes.yml b/test/fixtures/scenes.yml
new file mode 100644
index 00000000..937a34ba
--- /dev/null
+++ b/test/fixtures/scenes.yml
@@ -0,0 +1,23 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ scene_number: 1
+ name: MyString
+ description: MyString
+ universe_id: 1
+ user_id: 1
+ cause: MyString
+ description: MyString
+ results: MyString
+ prose: MyString
+
+two:
+ scene_number: 1
+ name: MyString
+ description: MyString
+ universe_id: 1
+ user_id: 1
+ cause: MyString
+ description: MyString
+ results: MyString
+ prose: MyString
diff --git a/test/models/scene_test.rb b/test/models/scene_test.rb
new file mode 100644
index 00000000..7a3bec9d
--- /dev/null
+++ b/test/models/scene_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class SceneTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end