Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 14221-oauth_pretty_consent
- Loading branch information
Showing
21 changed files
with
356 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# encoding: utf-8 | ||
|
||
module Carto | ||
class OauthAppOrganization < ActiveRecord::Base | ||
belongs_to :organization, inverse_of: :oauth_app_organizations | ||
belongs_to :oauth_app, inverse_of: :oauth_app_organizations | ||
|
||
validates :organization, presence: true, uniqueness: { scope: :oauth_app } | ||
validates :oauth_app, presence: true | ||
validates :seats, presence: true, numericality: { only_integer: true, greater_than: 0 } | ||
|
||
def open_seats? | ||
oauth_app.oauth_app_users.joins(:user).where(users: { organization_id: organization.id }).count < seats | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
db/migrate/20180821144500_create_oauth_app_organizations.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'carto/db/migration_helper' | ||
|
||
include Carto::Db::MigrationHelper | ||
|
||
migration( | ||
Proc.new do | ||
create_table :oauth_app_organizations do | ||
Uuid :id, primary_key: true, default: 'uuid_generate_v4()'.lit | ||
foreign_key :oauth_app_id, :oauth_apps, type: :uuid, null: false, index: true, on_delete: :cascade | ||
foreign_key :organization_id, :organizations, type: :uuid, null: false, index: true, on_delete: :cascade | ||
Integer :seats, null: false | ||
DateTime :created_at, null: false, default: Sequel::CURRENT_TIMESTAMP | ||
DateTime :updated_at, null: false, default: Sequel::CURRENT_TIMESTAMP | ||
end | ||
|
||
add_column :oauth_apps, :restricted, :boolean, null: false, default: false | ||
end, | ||
Proc.new do | ||
drop_column :oauth_apps, :restricted | ||
|
||
drop_table :oauth_app_organizations | ||
end | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.