From 02a8202f2fb83bf629ec5be34dad4dfdfe8623f0 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 20 Dec 2022 14:45:01 +0100 Subject: [PATCH] (feat) private note --- CHANGELOG.md | 1 + app/controllers/api/members_controller.rb | 7 ++++++- .../components/user/user-profile-form.tsx | 7 +++++++ app/views/api/members/show.json.jbuilder | 5 +++++ config/locales/app.shared.en.yml | 2 ++ .../20221220105939_add_note_to_profile.rb | 8 +++++++ db/schema.rb | 21 ++++++++++--------- 7 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20221220105939_add_note_to_profile.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 30ee1fee5..34e9cd3b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog Fab-manager +- Private note on member's profile - Optional external identifier for users - Accounting data is now built each night and saved in database - Ability to define multiple accounting journal codes diff --git a/app/controllers/api/members_controller.rb b/app/controllers/api/members_controller.rb index 514983374..f54e7c66d 100644 --- a/app/controllers/api/members_controller.rb +++ b/app/controllers/api/members_controller.rb @@ -4,6 +4,7 @@ class API::MembersController < API::ApiController before_action :authenticate_user!, except: [:last_subscribed] before_action :set_member, only: %i[update destroy merge complete_tour update_role validate] + before_action :set_operator, only: %i[show update create] respond_to :json def index @@ -213,6 +214,10 @@ class API::MembersController < API::ApiController @member = User.find(params[:id]) end + def set_operator + @operator = current_user + end + def user_params if current_user.id == params[:id].to_i params.require(:user).permit(:username, :email, :password, :password_confirmation, :group_id, :is_allow_contact, :is_allow_newsletter, @@ -235,7 +240,7 @@ class API::MembersController < API::ApiController tag_ids: [], profile_attributes: [:id, :first_name, :last_name, :phone, :interest, :software_mastered, :website, :job, :facebook, :twitter, :google_plus, :viadeo, :linkedin, :instagram, :youtube, :vimeo, - :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr, + :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr, :note, { user_avatar_attributes: %i[id attachment destroy] }], invoicing_profile_attributes: [ :id, :organization, :external_id, diff --git a/app/frontend/src/javascript/components/user/user-profile-form.tsx b/app/frontend/src/javascript/components/user/user-profile-form.tsx index b5c66d4ae..66b7cba8c 100644 --- a/app/frontend/src/javascript/components/user/user-profile-form.tsx +++ b/app/frontend/src/javascript/components/user/user-profile-form.tsx @@ -374,6 +374,13 @@ export const UserProfileForm: React.FC = ({ action, size, label={t('app.shared.user_profile_form.tags')} id="tag_ids" /> } + {new UserLib(operator).isPrivileged(user) &&
+ +
} {showTermsAndConditionsInput && termsAndConditions &&
the terms and conditions" must_accept_terms: "You must accept the terms and conditions" save: "Save" diff --git a/db/migrate/20221220105939_add_note_to_profile.rb b/db/migrate/20221220105939_add_note_to_profile.rb new file mode 100644 index 000000000..9ac30dfd9 --- /dev/null +++ b/db/migrate/20221220105939_add_note_to_profile.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# From this migration, the admins/managers will be able to save a private note per user +class AddNoteToProfile < ActiveRecord::Migration[5.2] + def change + add_column :profiles, :note, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index e26667f13..a35ae1b23 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_12_08_123822) do +ActiveRecord::Schema.define(version: 2022_12_20_105939) do # These are extensions that must be enabled in order to support this database enable_extension "fuzzystrmatch" @@ -19,8 +19,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do enable_extension "unaccent" create_table "abuses", id: :serial, force: :cascade do |t| - t.string "signaled_type" t.integer "signaled_id" + t.string "signaled_type" t.string "first_name" t.string "last_name" t.string "email" @@ -68,8 +68,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do t.string "locality" t.string "country" t.string "postal_code" - t.string "placeable_type" t.integer "placeable_id" + t.string "placeable_type" t.datetime "created_at" t.datetime "updated_at" end @@ -93,8 +93,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do end create_table "assets", id: :serial, force: :cascade do |t| - t.string "viewable_type" t.integer "viewable_id" + t.string "viewable_type" t.string "attachment" t.string "type" t.datetime "created_at" @@ -176,8 +176,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do end create_table "credits", id: :serial, force: :cascade do |t| - t.string "creditable_type" t.integer "creditable_id" + t.string "creditable_type" t.integer "plan_id" t.integer "hours" t.datetime "created_at" @@ -408,15 +408,15 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do create_table "notifications", id: :serial, force: :cascade do |t| t.integer "receiver_id" - t.string "attached_object_type" t.integer "attached_object_id" + t.string "attached_object_type" t.integer "notification_type_id" 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.jsonb "meta_data", default: {} t.index ["notification_type_id"], name: "index_notifications_on_notification_type_id" t.index ["receiver_id"], name: "index_notifications_on_receiver_id" end @@ -656,8 +656,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do create_table "prices", id: :serial, force: :cascade do |t| t.integer "group_id" t.integer "plan_id" - t.string "priceable_type" t.integer "priceable_id" + t.string "priceable_type" t.integer "amount" t.datetime "created_at", null: false t.datetime "updated_at", null: false @@ -743,6 +743,7 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do t.string "flickr" t.string "job" t.string "tours" + t.text "note" t.index "lower(f_unaccent((first_name)::text)) gin_trgm_ops", name: "profiles_lower_unaccent_first_name_trgm_idx", using: :gin t.index "lower(f_unaccent((last_name)::text)) gin_trgm_ops", name: "profiles_lower_unaccent_last_name_trgm_idx", using: :gin t.index ["user_id"], name: "index_profiles_on_user_id" @@ -857,8 +858,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do t.text "message" t.datetime "created_at" t.datetime "updated_at" - t.string "reservable_type" t.integer "reservable_id" + t.string "reservable_type" t.integer "nb_reserve_places" t.integer "statistic_profile_id" t.index ["reservable_type", "reservable_id"], name: "index_reservations_on_reservable_type_and_reservable_id" @@ -867,8 +868,8 @@ ActiveRecord::Schema.define(version: 2022_12_08_123822) do create_table "roles", id: :serial, force: :cascade do |t| t.string "name" - t.string "resource_type" t.integer "resource_id" + t.string "resource_type" t.datetime "created_at" t.datetime "updated_at" t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"