1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

finish moving organization & address to invoiving profile: fix create & edit user

This commit is contained in:
Sylvain 2019-06-03 12:06:01 +02:00
parent 80ae50cae7
commit 6011f27268
8 changed files with 145 additions and 131 deletions

View File

@ -314,15 +314,14 @@ Application.Controllers.controller('EditMemberController', ['$scope', '$state',
// Form action on the above URL
$scope.method = 'patch';
// List of tags associables with user
// List of tags joinable with user
$scope.tags = tagsPromise;
// The user to edit
$scope.user = memberPromise;
// Should the passord be modified?
$scope.password =
{ change: false };
// Should the password be modified?
$scope.password = { change: false };
// the user subscription
if (($scope.user.subscribed_plan != null) && ($scope.user.subscription != null)) {
@ -576,22 +575,20 @@ Application.Controllers.controller('NewMemberController', ['$scope', '$state', '
// Form action on the above URL
$scope.method = 'post';
// Should the passord be set manually or generated?
$scope.password =
{ change: false };
// Should the password be set manually or generated?
$scope.password = { change: false };
// Default member's profile parameters
$scope.user =
{ plan_interval: '' };
$scope.user = { plan_interval: '' };
// Callback when the admin check/unckeck the box telling that the new user is an organization.
// Callback when the admin check/uncheck the box telling that the new user is an organization.
// Disable or enable the organization fields in the form, accordingly
$scope.toggleOrganization = function () {
if ($scope.user.organization) {
if (!$scope.user.profile) { $scope.user.profile = {}; }
return $scope.user.profile.organization = {};
if (!$scope.user.invoicing_profile) { $scope.user.invoicing_profile = {}; }
$scope.user.invoicing_profile.organization = {};
} else {
return $scope.user.profile.organization = undefined;
$scope.user.invoicing_profile.organization = undefined;
}
};

View File

@ -2,6 +2,7 @@
<input name="_method" type="hidden" ng-value="method">
<input name="user[profile_attributes][id]" type="hidden" ng-value="user.profile.id">
<input name="user[invoicing_profile_attributes][id]" type="hidden" ng-value="user.invoicing_profile.id">
<div class="row m-t">
<div class="col-sm-3 col-sm-offset-1">
@ -165,36 +166,36 @@
<span class="help-block" ng-show="userForm['user[password_confirmation]'].$error.match" translate>{{ 'confirmation_mismatch_with_password' }}</span>
</div>
<div class="form-group" ng-if="user.profile.organization" ng-class="{'has-error': userForm['user[invoicing_profile_attributes][organization_attributes][name]'].$dirty && userForm['user[invoicing_profile_attributes][organization_attributes][name]'].$invalid}">
<div class="form-group" ng-if="user.invoicing_profile.organization" ng-class="{'has-error': userForm['user[invoicing_profile_attributes][organization_attributes][name]'].$dirty && userForm['user[invoicing_profile_attributes][organization_attributes][name]'].$invalid}">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-building-o"></i> <span class="exponent"><i class="fa fa-asterisk" aria-hidden="true"></i></span></span>
<input type="hidden"
name="user[invoicing_profile_attributes][organization_attributes][id]"
ng-value="user.profile.organization.id" />
ng-value="user.invoicing_profile.organization.id" />
<input type="text"
name="user[invoicing_profile_attributes][organization_attributes][name]"
ng-model="user.profile.organization.name"
ng-model="user.invoicing_profile.organization.name"
class="form-control"
placeholder="{{ 'organization_name' | translate }}"
ng-required="user.profile.organization"
ng-disabled="preventField['profile.organization_name'] && user.profile.organization.name && !userForm['user[invoicing_profile_attributes][organization_attributes][name]'].$dirty">
ng-required="user.invoicing_profile.organization"
ng-disabled="preventField['profile.organization_name'] && user.invoicing_profile.organization.name && !userForm['user[invoicing_profile_attributes][organization_attributes][name]'].$dirty">
</div>
<span class="help-block" ng-show="userForm['user[invoicing_][organization_attributes][name]'].$dirty && userForm['user[invoicing_profile_attributes][organization_attributes][name]'].$error.required" translate>{{ 'organization_name_is_required' }}</span>
</div>
<div class="form-group" ng-if="user.profile.organization" ng-class="{'has-error': userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$dirty && userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$invalid}">
<div class="form-group" ng-if="user.invoicing_profile.organization" ng-class="{'has-error': userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$dirty && userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$invalid}">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-map-marker"></i> <span class="exponent"><i class="fa fa-asterisk" aria-hidden="true"></i></span></span>
<input type="hidden"
name="user[invoicing_profile_attributes][organization_attributes][address_attributes][id]"
ng-value="user.profile.organization.address.id" />
ng-value="user.invoicing_profile.organization.address.id" />
<input type="text"
name="user[invoicing_profile_attributes][organization_attributes][address_attributes][address]"
ng-model="user.profile.organization.address.address"
ng-model="user.invoicing_profile.organization.address.address"
class="form-control"
placeholder="{{ 'organization_address' | translate }}"
ng-required="user.profile.organization"
ng-disabled="preventField['profile.organization_address'] && user.profile.organization.address.address && !userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$dirty">
ng-required="user.invoicing_profile.organization"
ng-disabled="preventField['profile.organization_address'] && user.invoicing_profile.organization.address.address && !userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$dirty">
</div>
<span class="help-block" ng-show="userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$dirty && userForm['user[invoicing_profile_attributes][organization_attributes][address_attributes][address]'].$error.required" translate>{{ 'organization_address_is_required' }}</span>
</div>
@ -225,13 +226,13 @@
<span class="input-group-addon"><i class="fa fa-map-marker"></i> </span>
<input type="hidden"
name="user[invoicing_profile_attributes][address_attributes][id]"
ng-value="user.profile.address.id" />
ng-value="user.invoicing_profile.address.id" />
<input type="text"
name="user[invoicing_profile_attributes][address_attributes][address]"
ng-model="user.profile.address.address"
ng-model="user.invoicing_profile.address.address"
class="form-control"
id="user_address"
ng-disabled="preventField['profile.address'] && user.profile.address.address && !userForm['user[invoicing_profile_attributes][address_attributes][address]'].$dirty"
ng-disabled="preventField['profile.address'] && user.invoicing_profile.address.address && !userForm['user[invoicing_profile_attributes][address_attributes][address]'].$dirty"
placeholder="{{ 'address' | translate }}"/>
</div>
</div>

View File

@ -211,6 +211,7 @@ class API::MembersController < API::ApiController
:dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr,
user_avatar_attributes: %i[id attachment destroy]],
invoicing_profile_attributes: [
:id,
address_attributes: %i[id address],
organization_attributes: [:id, :name, address_attributes: %i[id address]]
])

View File

@ -69,6 +69,7 @@ class User < ActiveRecord::Base
after_commit :create_stripe_customer, on: [:create]
after_commit :notify_admin_when_user_is_created, on: :create
after_update :notify_group_changed, if: :group_id_changed?
after_save :update_invoicing_profile
attr_accessor :cgu
delegate :first_name, to: :profile
@ -194,11 +195,11 @@ class User < ActiveRecord::Base
when 'profile.avatar'
profile.user_avatar.remote_attachment_url
when 'profile.address'
profile.address.address
invoicing_profile.address.address
when 'profile.organization_name'
profile.organization.name
invoicing_profile.organization.name
when 'profile.organization_address'
profile.organization.address.address
invoicing_profile.organization.address.address
else
profile[parsed[2].to_sym]
end
@ -217,15 +218,15 @@ class User < ActiveRecord::Base
profile.user_avatar ||= UserAvatar.new
profile.user_avatar.remote_attachment_url = data
when 'profile.address'
profile.address ||= Address.new
profile.address.address = data
invoicing_profile.address ||= Address.new
invoicing_profile.address.address = data
when 'profile.organization_name'
profile.organization ||= Organization.new
profile.organization.name = data
invoicing_profile.organization ||= Organization.new
invoicing_profile.organization.name = data
when 'profile.organization_address'
profile.organization ||= Organization.new
profile.organization.address ||= Address.new
profile.organization.address.address = data
invoicing_profile.organization ||= Organization.new
invoicing_profile.organization.address ||= Address.new
invoicing_profile.organization.address.address = data
else
profile[sso_mapping[8..-1].to_sym] = data unless data.nil?
end
@ -362,4 +363,17 @@ class User < ActiveRecord::Base
receiver: self,
attached_object: self
end
def update_invoicing_profile
if invoicing_profile.nil?
InvoicingProfile.create!(
user: user,
email: email
)
else
invoicing_profile.update_attributes(
email: email
)
end
end
end

View File

@ -24,6 +24,7 @@ json.profile do
end
json.invoicing_profile do
json.id member.invoicing_profile.id
if member.invoicing_profile.address
json.address do
json.id member.invoicing_profile.address.id

View File

@ -44,7 +44,7 @@ wb.add_worksheet(name: t('export_members.members')) do |sheet|
member.is_allow_newsletter,
member.profile.gender ? t('export_members.man') : t('export_members.woman'),
member.profile.age,
member.profile.address ? member.profile.address.address : '',
member.invoicing_profile.address ? member.invoicing_profile.address.address : '',
member.profile.phone,
member.profile.website,
member.profile.job,
@ -60,8 +60,8 @@ wb.add_worksheet(name: t('export_members.members')) do |sheet|
member.profile.facebook || '',
member.profile.twitter || '',
member.profile.echosciences || '',
member.profile.organization ? member.profile.organization.name : '',
member.profile.organization ? member.profile.organization.address.address : ''
member.invoicing_profile.organization ? member.invoicing_profile.organization.name : '',
member.invoicing_profile.organization ? member.invoicing_profile.organization.address.address : ''
]
styles = [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, date, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]

View File

@ -2,6 +2,6 @@
<p><%= t('.body.new_account_created') %> "<%= @attached_object.profile.full_name %> &lt;<%= @attached_object.email%>&gt;"</p>
<% if @attached_object.profile.organization %>
<p><%= t('.body.account_for_organization') %> <%= @attached_object.profile.organization.name %></p>
<% if @attached_object.invoicing_profile.organization %>
<p><%= t('.body.account_for_organization') %> <%= @attached_object.invoicing_profile.organization.name %></p>
<% end %>

View File

@ -15,8 +15,8 @@ ActiveRecord::Schema.define(version: 20190529120814) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "pg_trgm"
enable_extension "unaccent"
enable_extension "pg_trgm"
create_table "abuses", force: :cascade do |t|
t.integer "signaled_id"
@ -44,14 +44,14 @@ ActiveRecord::Schema.define(version: 20190529120814) do
end
create_table "addresses", force: :cascade do |t|
t.string "address", limit: 255
t.string "street_number", limit: 255
t.string "route", limit: 255
t.string "locality", limit: 255
t.string "country", limit: 255
t.string "postal_code", limit: 255
t.string "address"
t.string "street_number"
t.string "route"
t.string "locality"
t.string "country"
t.string "postal_code"
t.integer "placeable_id"
t.string "placeable_type", limit: 255
t.string "placeable_type"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -67,9 +67,9 @@ ActiveRecord::Schema.define(version: 20190529120814) do
create_table "assets", force: :cascade do |t|
t.integer "viewable_id"
t.string "viewable_type", limit: 255
t.string "attachment", limit: 255
t.string "type", limit: 255
t.string "viewable_type"
t.string "attachment"
t.string "type"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -86,12 +86,12 @@ ActiveRecord::Schema.define(version: 20190529120814) do
create_table "availabilities", force: :cascade do |t|
t.datetime "start_at"
t.datetime "end_at"
t.string "available_type", limit: 255
t.string "available_type"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "nb_total_places"
t.boolean "destroying", default: false
t.boolean "lock", default: false
t.boolean "destroying", default: false
t.boolean "lock", default: false
end
create_table "availability_tags", force: :cascade do |t|
@ -105,7 +105,7 @@ ActiveRecord::Schema.define(version: 20190529120814) do
add_index "availability_tags", ["tag_id"], name: "index_availability_tags_on_tag_id", using: :btree
create_table "categories", force: :cascade do |t|
t.string "name", limit: 255
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "slug"
@ -114,7 +114,7 @@ ActiveRecord::Schema.define(version: 20190529120814) do
add_index "categories", ["slug"], name: "index_categories_on_slug", unique: true, using: :btree
create_table "components", force: :cascade do |t|
t.string "name", limit: 255, null: false
t.string "name", null: false
end
create_table "coupons", force: :cascade do |t|
@ -132,7 +132,7 @@ ActiveRecord::Schema.define(version: 20190529120814) do
create_table "credits", force: :cascade do |t|
t.integer "creditable_id"
t.string "creditable_type", limit: 255
t.string "creditable_type"
t.integer "plan_id"
t.integer "hours"
t.datetime "created_at"
@ -173,7 +173,7 @@ ActiveRecord::Schema.define(version: 20190529120814) do
add_index "event_themes", ["slug"], name: "index_event_themes_on_slug", unique: true, using: :btree
create_table "events", force: :cascade do |t|
t.string "title", limit: 255
t.string "title"
t.text "description"
t.datetime "created_at"
t.datetime "updated_at"
@ -211,10 +211,10 @@ ActiveRecord::Schema.define(version: 20190529120814) do
add_index "exports", ["user_id"], name: "index_exports_on_user_id", using: :btree
create_table "friendly_id_slugs", force: :cascade do |t|
t.string "slug", limit: 255, null: false
t.integer "sluggable_id", null: false
t.string "slug", null: false
t.integer "sluggable_id", null: false
t.string "sluggable_type", limit: 50
t.string "scope", limit: 255
t.string "scope"
t.datetime "created_at"
end
@ -224,10 +224,10 @@ ActiveRecord::Schema.define(version: 20190529120814) do
add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type", using: :btree
create_table "groups", force: :cascade do |t|
t.string "name", limit: 255
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "slug", limit: 255
t.string "slug"
t.boolean "disabled"
end
@ -247,7 +247,7 @@ ActiveRecord::Schema.define(version: 20190529120814) do
create_table "invoice_items", force: :cascade do |t|
t.integer "invoice_id"
t.string "stp_invoice_item_id", limit: 255
t.string "stp_invoice_item_id"
t.integer "amount"
t.datetime "created_at"
t.datetime "updated_at"
@ -261,16 +261,16 @@ ActiveRecord::Schema.define(version: 20190529120814) do
create_table "invoices", force: :cascade do |t|
t.integer "invoiced_id"
t.string "invoiced_type", limit: 255
t.string "stp_invoice_id", limit: 255
t.string "invoiced_type"
t.string "stp_invoice_id"
t.integer "total"
t.datetime "created_at"
t.datetime "updated_at"
t.string "reference", limit: 255
t.string "avoir_mode", limit: 255
t.string "reference"
t.string "avoir_mode"
t.datetime "avoir_date"
t.integer "invoice_id"
t.string "type", limit: 255
t.string "type"
t.boolean "subscription_to_expire"
t.text "description"
t.integer "wallet_amount"
@ -299,17 +299,17 @@ ActiveRecord::Schema.define(version: 20190529120814) do
add_index "invoicing_profiles", ["user_id"], name: "index_invoicing_profiles_on_user_id", using: :btree
create_table "licences", force: :cascade do |t|
t.string "name", limit: 255, null: false
t.string "name", null: false
t.text "description"
end
create_table "machines", force: :cascade do |t|
t.string "name", limit: 255, null: false
t.string "name", null: false
t.text "description"
t.text "spec"
t.datetime "created_at"
t.datetime "updated_at"
t.string "slug", limit: 255
t.string "slug"
t.boolean "disabled"
end
@ -326,14 +326,14 @@ ActiveRecord::Schema.define(version: 20190529120814) do
create_table "notifications", force: :cascade do |t|
t.integer "receiver_id"
t.integer "attached_object_id"
t.string "attached_object_type", limit: 255
t.string "attached_object_type"
t.integer "notification_type_id"
t.boolean "is_read", default: false
t.boolean "is_read", default: false
t.datetime "created_at"
t.datetime "updated_at"
t.string "receiver_type"
t.boolean "is_send", default: false
t.jsonb "meta_data", default: {}
t.boolean "is_send", default: false
t.jsonb "meta_data", default: {}
end
add_index "notifications", ["notification_type_id"], name: "index_notifications_on_notification_type_id", using: :btree
@ -402,20 +402,20 @@ ActiveRecord::Schema.define(version: 20190529120814) do
add_index "organizations", ["invoicing_profile_id"], name: "index_organizations_on_invoicing_profile_id", using: :btree
create_table "plans", force: :cascade do |t|
t.string "name", limit: 255
t.string "name"
t.integer "amount"
t.string "interval", limit: 255
t.string "interval"
t.integer "group_id"
t.string "stp_plan_id", limit: 255
t.string "stp_plan_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "training_credit_nb", default: 0
t.boolean "is_rolling", default: true
t.integer "training_credit_nb", default: 0
t.boolean "is_rolling", default: true
t.text "description"
t.string "type"
t.string "base_name"
t.integer "ui_weight", default: 0
t.integer "interval_count", default: 1
t.integer "ui_weight", default: 0
t.integer "interval_count", default: 1
t.string "slug"
t.boolean "disabled"
end
@ -445,11 +445,11 @@ ActiveRecord::Schema.define(version: 20190529120814) do
create_table "profiles", force: :cascade do |t|
t.integer "user_id"
t.string "first_name", limit: 255
t.string "last_name", limit: 255
t.string "first_name"
t.string "last_name"
t.boolean "gender"
t.date "birthday"
t.string "phone", limit: 255
t.string "phone"
t.text "interest"
t.text "software_mastered"
t.datetime "created_at"
@ -479,7 +479,7 @@ ActiveRecord::Schema.define(version: 20190529120814) do
t.integer "project_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "title", limit: 255
t.string "title"
t.integer "step_nb"
end
@ -490,27 +490,27 @@ ActiveRecord::Schema.define(version: 20190529120814) do
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "is_valid", default: false
t.string "valid_token", limit: 255
t.boolean "is_valid", default: false
t.string "valid_token"
end
add_index "project_users", ["project_id"], name: "index_project_users_on_project_id", using: :btree
add_index "project_users", ["user_id"], name: "index_project_users_on_user_id", using: :btree
create_table "projects", force: :cascade do |t|
t.string "name", limit: 255
t.string "name"
t.text "description"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "author_id"
t.text "tags"
t.integer "licence_id"
t.string "state", limit: 255
t.string "slug", limit: 255
t.string "state"
t.string "slug"
t.datetime "published_at"
end
add_index "projects", ["slug"], name: "index_projects_on_slug", using: :btree
add_index "projects", ["slug"], name: "index_projects_on_slug", unique: true, using: :btree
create_table "projects_components", force: :cascade do |t|
t.integer "project_id"
@ -550,19 +550,19 @@ ActiveRecord::Schema.define(version: 20190529120814) do
t.datetime "created_at"
t.datetime "updated_at"
t.integer "reservable_id"
t.string "reservable_type", limit: 255
t.string "stp_invoice_id", limit: 255
t.string "reservable_type"
t.string "stp_invoice_id"
t.integer "nb_reserve_places"
end
add_index "reservations", ["reservable_id", "reservable_type"], name: "index_reservations_on_reservable_id_and_reservable_type", using: :btree
add_index "reservations", ["reservable_type", "reservable_id"], name: "index_reservations_on_reservable_type_and_reservable_id", using: :btree
add_index "reservations", ["stp_invoice_id"], name: "index_reservations_on_stp_invoice_id", using: :btree
add_index "reservations", ["user_id"], name: "index_reservations_on_user_id", using: :btree
create_table "roles", force: :cascade do |t|
t.string "name", limit: 255
t.string "name"
t.integer "resource_id"
t.string "resource_type", limit: 255
t.string "resource_type"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -636,18 +636,18 @@ ActiveRecord::Schema.define(version: 20190529120814) do
create_table "statistic_fields", force: :cascade do |t|
t.integer "statistic_index_id"
t.string "key", limit: 255
t.string "label", limit: 255
t.string "key"
t.string "label"
t.datetime "created_at"
t.datetime "updated_at"
t.string "data_type", limit: 255
t.string "data_type"
end
add_index "statistic_fields", ["statistic_index_id"], name: "index_statistic_fields_on_statistic_index_id", using: :btree
create_table "statistic_graphs", force: :cascade do |t|
t.integer "statistic_index_id"
t.string "chart_type", limit: 255
t.string "chart_type"
t.integer "limit"
t.datetime "created_at"
t.datetime "updated_at"
@ -656,17 +656,17 @@ ActiveRecord::Schema.define(version: 20190529120814) do
add_index "statistic_graphs", ["statistic_index_id"], name: "index_statistic_graphs_on_statistic_index_id", using: :btree
create_table "statistic_indices", force: :cascade do |t|
t.string "es_type_key", limit: 255
t.string "label", limit: 255
t.string "es_type_key"
t.string "label"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "table", default: true
t.boolean "ca", default: true
t.boolean "table", default: true
t.boolean "ca", default: true
end
create_table "statistic_sub_types", force: :cascade do |t|
t.string "key", limit: 255
t.string "label", limit: 255
t.string "key"
t.string "label"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -683,8 +683,8 @@ ActiveRecord::Schema.define(version: 20190529120814) do
create_table "statistic_types", force: :cascade do |t|
t.integer "statistic_index_id"
t.string "key", limit: 255
t.string "label", limit: 255
t.string "key"
t.string "label"
t.boolean "graph"
t.datetime "created_at"
t.datetime "updated_at"
@ -702,7 +702,7 @@ ActiveRecord::Schema.define(version: 20190529120814) do
create_table "subscriptions", force: :cascade do |t|
t.integer "plan_id"
t.integer "user_id"
t.string "stp_subscription_id", limit: 255
t.string "stp_subscription_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "expiration_date"
@ -721,7 +721,7 @@ ActiveRecord::Schema.define(version: 20190529120814) do
add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
create_table "themes", force: :cascade do |t|
t.string "name", limit: 255, null: false
t.string "name", null: false
end
create_table "tickets", force: :cascade do |t|
@ -736,13 +736,13 @@ ActiveRecord::Schema.define(version: 20190529120814) do
add_index "tickets", ["reservation_id"], name: "index_tickets_on_reservation_id", using: :btree
create_table "trainings", force: :cascade do |t|
t.string "name", limit: 255
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "nb_total_places"
t.string "slug", limit: 255
t.string "slug"
t.text "description"
t.boolean "public_page", default: true
t.boolean "public_page", default: true
t.boolean "disabled"
end
@ -798,31 +798,31 @@ ActiveRecord::Schema.define(version: 20190529120814) do
add_index "user_trainings", ["user_id"], name: "index_user_trainings_on_user_id", using: :btree
create_table "users", force: :cascade do |t|
t.string "email", limit: 255, default: "", null: false
t.string "encrypted_password", limit: 255, default: "", null: false
t.string "reset_password_token", limit: 255
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip", limit: 255
t.string "last_sign_in_ip", limit: 255
t.string "confirmation_token", limit: 255
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email", limit: 255
t.integer "failed_attempts", default: 0, null: false
t.string "unlock_token", limit: 255
t.string "unconfirmed_email"
t.integer "failed_attempts", default: 0, null: false
t.string "unlock_token"
t.datetime "locked_at"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "is_allow_contact", default: true
t.boolean "is_allow_contact", default: true
t.integer "group_id"
t.string "stp_customer_id", limit: 255
t.string "username", limit: 255
t.string "slug", limit: 255
t.boolean "is_active", default: true
t.string "stp_customer_id"
t.string "username"
t.string "slug"
t.boolean "is_active", default: true
t.string "provider"
t.string "uid"
t.string "auth_token"