Commit ddafeb92 authored by pr0totyp's avatar pr0totyp

Merge branch 'master' of gitlab.com:innovationslandkarte/innoMap

parents ec93e967 ec51f9e8
Pipeline #116354651 failed with stages
in 4 minutes and 2 seconds
......@@ -8,12 +8,10 @@ class PagesController < ApplicationController
def scene_overview
if current_user
@main_scenes = MainScene.all.order(:created_at).select { |scene| current_user.reading_permission_for?(scene) }
@geo_scenes = GeoScene.all.order(:created_at).select { |scene| current_user.reading_permission_for?(scene) }
else
# @main_scenes = MainScene.where(public: true).order(:created_at)
# @geo_scenes = GeoScene.where(public: true).order(:created_at)
@main_scenes = MainScene.all.order(:created_at)
@geo_scenes = GeoScene.all.order(:created_at)
@main_scenes = MainScene.public_access.order(:created_at)
end
end
......
......@@ -3,6 +3,8 @@ require 'sanitize'
class MainScene < InnoMapBaseModel
mount_uploader :base_image, ImageUploader
scope :public_access, -> { where(public: true) }
has_many :scenes, dependent: :destroy
has_many :graphical_scenes
has_many :geo_scenes
......
class RemovePolymporphicColumns < ActiveRecord::Migration
class OldGeoScene < ActiveRecord::Base
self.table_name = 'geo_scenes'
end
def change
add_column :sub_scenes, :scene_id, :integer, null: false, default: 0
add_column :scene_categories, :scene_id, :integer, null: false, default: 0
add_column :content_attributes, :scene_id, :integer, null: false, default: 0
Scene.all.each do |scene|
sub_scenes = SubScene.where(subscenable_type: 'Scene', subscenable_id: scene.id)
sub_scenes.each do |sub_scene|
sub_scene.update_attributes(scene_id: scene.id)
end
cats = SceneCategory.where(scenecategorizable_type: 'Scene', scenecategorizable_id: scene.id)
cats.each do |cat|
cat.update_attributes(scene_id: scene.id)
end
attributes = ContentAttribute.where(attributable_type: 'Scene', attributable_id: scene.id)
attributes.each do |attribute|
attribute.update_attributes(scene_id: scene.id)
end
end
OldGeoScene.all.each do |old_geo_scene|
main_scene = MainScene.create(text: old_geo_scene.text)
geo_scene = main_scene.geo_scenes.create(
text: old_geo_scene.text,
tile_layer: old_geo_scene.tile_layer
)
sub_scenes = SubScene.where(subscenable_type: 'GeoScene', subscenable_id: old_geo_scene.id)
sub_scenes.each do |sub_scene|
sub_scene.update_attributes(scene_id: geo_scene.id)
end
cats = SceneCategory.where(scenecategorizable_type: 'GeoScene', scenecategorizable_id: old_geo_scene.id)
cats.each do |cat|
cat.update_attributes(scene_id: geo_scene.id)
end
attributes = ContentAttribute.where(attributable_type: 'GeoScene', attributable_id: old_geo_scene.id)
attributes.each do |attribute|
attribute.update_attributes(scene_id: geo_scene.id)
end
end
remove_column :sub_scenes, :subscenable_type
remove_column :sub_scenes, :subscenable_id
remove_column :scene_categories, :scenecategorizable_type
remove_column :scene_categories, :scenecategorizable_id
remove_column :content_attributes, :attributable_type
remove_column :content_attributes, :attributable_id
drop_table :geo_scenes
end
end
class RemovePolymporphicColumnsFromSubScenes < ActiveRecord::Migration
def change
remove_column :sub_scenes, :subscenable_type
remove_column :sub_scenes, :subscenable_id
add_column :sub_scenes, :scene_id, :integer, null: false, default: 0
end
end
class RemovePolymorphicColumnsFromContentAttributes < ActiveRecord::Migration
def change
remove_column :content_attributes, :attributable_type
remove_column :content_attributes, :attributable_id
add_column :content_attributes, :scene_id, :integer, null: false, default: 0
end
end
class RemovePolymorphicColumnsFromSceneCategories < ActiveRecord::Migration
def change
remove_column :scene_categories, :scenecategorizable_type
remove_column :scene_categories, :scenecategorizable_id
add_column :scene_categories, :scene_id, :integer, null: false, default: 0
end
end
class RemoveGeoScenes < ActiveRecord::Migration
def change
drop_table :geo_scenes
end
end
......@@ -64,13 +64,12 @@ ActiveRecord::Schema.define(version: 20190320131608) do
add_index "main_scene_categories", ["main_scene_id"], name: "index_main_scene_categories_on_main_scene_id", using: :btree
create_table "main_scenes", force: :cascade do |t|
t.string "text", null: false
t.string "text", null: false
t.string "base_image"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "welcome"
t.boolean "public", default: true, null: false
t.boolean "used", default: false, null: false
t.boolean "public", default: true, null: false
end
create_table "main_scenes_users", force: :cascade do |t|
......@@ -80,6 +79,17 @@ ActiveRecord::Schema.define(version: 20190320131608) do
t.boolean "own", default: false, null: false
end
create_table "overlays", force: :cascade do |t|
t.string "image", null: false
t.integer "scene_id", null: false
t.integer "category_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "overlays", ["category_id"], name: "index_overlays_on_category_id", using: :btree
add_index "overlays", ["scene_id"], name: "index_overlays_on_scene_id", using: :btree
create_table "scene_categories", force: :cascade do |t|
t.string "image"
t.datetime "created_at", null: false
......@@ -99,8 +109,8 @@ ActiveRecord::Schema.define(version: 20190320131608) do
t.datetime "updated_at", null: false
t.string "base_image"
t.string "main_scene_id", null: false
t.float "latitude", default: 47.0
t.float "longitude", default: 37.0
t.float "latitude", default: 34.0
t.float "longitude", default: 47.0
t.text "welcome"
t.boolean "public_contributions_allowed", default: false, null: false
t.string "base_image_overlay"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment