Merge pull request #3 from jedmund/team-details
Add the ability to add details to teams
This commit is contained in:
commit
58173606ed
16 changed files with 87 additions and 8 deletions
|
|
@ -25,7 +25,7 @@ class Api::V1::PartiesController < Api::V1::ApiController
|
||||||
if @party.user != current_user
|
if @party.user != current_user
|
||||||
render_unauthorized_response
|
render_unauthorized_response
|
||||||
else
|
else
|
||||||
@party.extra = party_params['is_extra']
|
@party.attributes = party_params
|
||||||
render :update, status: :ok if @party.save!
|
render :update, status: :ok if @party.save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -71,6 +71,6 @@ class Api::V1::PartiesController < Api::V1::ApiController
|
||||||
end
|
end
|
||||||
|
|
||||||
def party_params
|
def party_params
|
||||||
params.require(:party).permit(:user_id, :is_extra)
|
params.require(:party).permit(:user_id, :extra, :name, :description, :raid_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
6
app/controllers/api/v1/raids_controller.rb
Normal file
6
app/controllers/api/v1/raids_controller.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
class Api::V1::RaidsController < Api::V1::ApiController
|
||||||
|
def all
|
||||||
|
@raids = Raid.all()
|
||||||
|
render :all, status: :ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
class Party < ApplicationRecord
|
class Party < ApplicationRecord
|
||||||
##### ActiveRecord Associations
|
##### ActiveRecord Associations
|
||||||
belongs_to :user, optional: true
|
belongs_to :user, optional: true
|
||||||
|
belongs_to :raid, optional: true
|
||||||
has_many :characters, foreign_key: "party_id", class_name: "GridCharacter", dependent: :destroy
|
has_many :characters, foreign_key: "party_id", class_name: "GridCharacter", dependent: :destroy
|
||||||
has_many :weapons, foreign_key: "party_id", class_name: "GridWeapon", dependent: :destroy
|
has_many :weapons, foreign_key: "party_id", class_name: "GridWeapon", dependent: :destroy
|
||||||
has_many :summons, foreign_key: "party_id", class_name: "GridSummon", dependent: :destroy
|
has_many :summons, foreign_key: "party_id", class_name: "GridSummon", dependent: :destroy
|
||||||
|
|
|
||||||
2
app/models/raid.rb
Normal file
2
app/models/raid.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
class Raid < ApplicationRecord
|
||||||
|
end
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
object :party
|
object :party
|
||||||
|
|
||||||
attributes :id, :user_id, :shortcode
|
attributes :id, :user_id, :name, :description, :shortcode
|
||||||
|
|
||||||
node :is_extra do |p|
|
node :is_extra do |p|
|
||||||
p.extra
|
p.extra
|
||||||
end
|
end
|
||||||
|
|
||||||
|
node :raid do |p|
|
||||||
|
partial('raids/base', :object => p.raid)
|
||||||
|
end
|
||||||
|
|
||||||
node :characters do |p|
|
node :characters do |p|
|
||||||
partial('grid_characters/base', :object => p.characters)
|
partial('grid_characters/base', :object => p.characters)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
object @party
|
object @party
|
||||||
|
|
||||||
attributes :id, :user_id, :shortcode
|
attributes :id, :user_id, :name, :description, :shortcode
|
||||||
|
|
||||||
|
node :raid do |p|
|
||||||
|
partial('raids/base', :object => p.raid)
|
||||||
|
end
|
||||||
|
|
||||||
node :characters do |p|
|
node :characters do |p|
|
||||||
partial('grid_characters/base', :object => p.characters)
|
partial('grid_characters/base', :object => p.characters)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
object @party
|
object @party
|
||||||
|
|
||||||
attributes :id, :user_id, :shortcode
|
attributes :id, :user_id, :name, :description, :shortcode
|
||||||
|
|
||||||
|
node :raid do |p|
|
||||||
|
partial('raids/base', :object => p.raid)
|
||||||
|
end
|
||||||
|
|
||||||
node :summons do |p|
|
node :summons do |p|
|
||||||
partial('grid_summons/base', :object => p.summons)
|
partial('grid_summons/base', :object => p.summons)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
object @party
|
object @party
|
||||||
|
|
||||||
attributes :id, :user_id, :shortcode
|
attributes :id, :user_id, :name, :description, :shortcode
|
||||||
|
|
||||||
|
node :raid do |p|
|
||||||
|
partial('raids/base', :object => p.raid)
|
||||||
|
end
|
||||||
|
|
||||||
node :is_extra do |p|
|
node :is_extra do |p|
|
||||||
p.extra
|
p.extra
|
||||||
|
|
|
||||||
3
app/views/api/v1/raids/all.json.rabl
Normal file
3
app/views/api/v1/raids/all.json.rabl
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
collection @raids
|
||||||
|
|
||||||
|
extends 'raids/base'
|
||||||
10
app/views/api/v1/raids/base.json.rabl
Normal file
10
app/views/api/v1/raids/base.json.rabl
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
object :raid
|
||||||
|
|
||||||
|
attributes :id, :level, :group, :element
|
||||||
|
|
||||||
|
node :name do |r|
|
||||||
|
{
|
||||||
|
:en => r.name_en,
|
||||||
|
:jp => r.name_jp
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
@ -20,6 +20,8 @@ Rails.application.routes.draw do
|
||||||
get 'search/weapons', to: 'search#weapons'
|
get 'search/weapons', to: 'search#weapons'
|
||||||
get 'search/summons', to: 'search#summons'
|
get 'search/summons', to: 'search#summons'
|
||||||
|
|
||||||
|
get 'raids', to: 'raids#all'
|
||||||
|
|
||||||
post 'characters', to: 'grid_characters#create'
|
post 'characters', to: 'grid_characters#create'
|
||||||
post 'characters/update_uncap', to: 'grid_characters#update_uncap_level'
|
post 'characters/update_uncap', to: 'grid_characters#update_uncap_level'
|
||||||
delete 'characters', to: 'grid_characters#destroy'
|
delete 'characters', to: 'grid_characters#destroy'
|
||||||
|
|
|
||||||
13
db/migrate/20220224015505_add_details_to_party.rb
Normal file
13
db/migrate/20220224015505_add_details_to_party.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
class AddDetailsToParty < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
create_table :raids, id: :uuid, default: -> { "gen_random_uuid()" } do |t|
|
||||||
|
t.string :name_en
|
||||||
|
t.string :name_jp
|
||||||
|
t.integer :level
|
||||||
|
end
|
||||||
|
|
||||||
|
add_column :parties, :name, :string
|
||||||
|
add_column :parties, :description, :text
|
||||||
|
add_reference :parties, :raids, index: true
|
||||||
|
end
|
||||||
|
end
|
||||||
5
db/migrate/20220224024415_add_group_to_raids.rb
Normal file
5
db/migrate/20220224024415_add_group_to_raids.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddGroupToRaids < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :raids, :group, :integer
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
class FixRaidAssociationOnParties < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :parties, :raid_id, :uuid
|
||||||
|
remove_column :parties, :raids_id, :bigint
|
||||||
|
end
|
||||||
|
end
|
||||||
5
db/migrate/20220225014523_add_element_to_raids.rb
Normal file
5
db/migrate/20220225014523_add_element_to_raids.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddElementToRaids < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :raids, :element, :integer
|
||||||
|
end
|
||||||
|
end
|
||||||
14
db/schema.rb
14
db/schema.rb
|
|
@ -10,12 +10,11 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2022_02_23_213548) do
|
ActiveRecord::Schema.define(version: 2022_02_25_014523) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pgcrypto"
|
enable_extension "pgcrypto"
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
enable_extension "timescaledb"
|
|
||||||
|
|
||||||
create_table "characters", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
create_table "characters", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||||
t.string "name_en"
|
t.string "name_en"
|
||||||
|
|
@ -129,9 +128,20 @@ ActiveRecord::Schema.define(version: 2022_02_23_213548) do
|
||||||
t.datetime "created_at", precision: 6, null: false
|
t.datetime "created_at", precision: 6, null: false
|
||||||
t.datetime "updated_at", precision: 6, null: false
|
t.datetime "updated_at", precision: 6, null: false
|
||||||
t.boolean "extra", default: false, null: false
|
t.boolean "extra", default: false, null: false
|
||||||
|
t.string "name"
|
||||||
|
t.text "description"
|
||||||
|
t.uuid "raid_id"
|
||||||
t.index ["user_id"], name: "index_parties_on_user_id"
|
t.index ["user_id"], name: "index_parties_on_user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "raids", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||||
|
t.string "name_en"
|
||||||
|
t.string "name_jp"
|
||||||
|
t.integer "level"
|
||||||
|
t.integer "group"
|
||||||
|
t.integer "element"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "summons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
create_table "summons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||||
t.string "name_en"
|
t.string "name_en"
|
||||||
t.string "name_jp"
|
t.string "name_jp"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue