mirror of
https://github.com/publiclab/mapknitter.git
synced 2025-12-11 18:59:59 +01:00
chore: 🤖 add status columns to maps and users tables (#1753)
* chore: 🤖 add status columns to maps and users tables * style: 💄 remove extra indentation
This commit is contained in:
@@ -66,6 +66,7 @@ class MapsController < ApplicationController
|
||||
def archive
|
||||
if logged_in? && current_user.can_delete?(@map)
|
||||
@map.archived = true
|
||||
@map.status = 0
|
||||
if @map.save
|
||||
flash[:notice] = 'Archived map.'
|
||||
else
|
||||
|
||||
17
db/migrate/20220608115906_add_status_to_users_and_maps.rb
Normal file
17
db/migrate/20220608115906_add_status_to_users_and_maps.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class AddStatusToUsersAndMaps < ActiveRecord::Migration[5.2]
|
||||
class Map < ApplicationRecord
|
||||
end
|
||||
|
||||
def up
|
||||
add_column :users, :status, :integer, :default => 1
|
||||
add_column :maps, :status, :integer, :default => 1
|
||||
|
||||
Map.reset_column_information
|
||||
Map.where(archived: true).update(status: 0)
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :users, :status
|
||||
remove_column :maps, :status
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_12_19_051509) do
|
||||
ActiveRecord::Schema.define(version: 2022_06_08_115906) do
|
||||
|
||||
create_table "annotations", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
t.integer "map_id"
|
||||
@@ -77,6 +77,7 @@ ActiveRecord::Schema.define(version: 2019_12_19_051509) do
|
||||
t.boolean "anon_annotatable", default: false
|
||||
t.string "slug"
|
||||
t.boolean "display_welcome", default: true
|
||||
t.integer "status", default: 1
|
||||
t.index ["author"], name: "index_maps_on_author"
|
||||
t.index ["slug"], name: "index_maps_on_slug", unique: true
|
||||
t.index ["user_id"], name: "index_maps_on_user_id"
|
||||
@@ -122,6 +123,7 @@ ActiveRecord::Schema.define(version: 2019_12_19_051509) do
|
||||
t.datetime "updated_at"
|
||||
t.string "remember_token", limit: 40
|
||||
t.datetime "remember_token_expires_at"
|
||||
t.integer "status", default: 1
|
||||
t.index ["login"], name: "index_users_on_login", unique: true
|
||||
end
|
||||
|
||||
|
||||
@@ -191,6 +191,7 @@ class MapsControllerTest < ActionController::TestCase
|
||||
|
||||
assert_redirected_to '/'
|
||||
assert @map.archived
|
||||
assert_equal 0, @map.status
|
||||
end
|
||||
|
||||
test 'should not archive map without enough permissions' do
|
||||
@@ -200,6 +201,7 @@ class MapsControllerTest < ActionController::TestCase
|
||||
|
||||
assert_redirected_to '/'
|
||||
assert_not @map.archived
|
||||
assert_equal 1, @map.status
|
||||
end
|
||||
|
||||
test 'should update map' do
|
||||
|
||||
Reference in New Issue
Block a user