1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00

(feat) private note

This commit is contained in:
Sylvain 2022-12-20 14:45:01 +01:00
parent 86756f911b
commit 02a8202f2f
7 changed files with 40 additions and 11 deletions

View File

@ -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

View File

@ -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,

View File

@ -374,6 +374,13 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
label={t('app.shared.user_profile_form.tags')}
id="tag_ids" />
</div>}
{new UserLib(operator).isPrivileged(user) && <div className="note">
<FormRichText control={control}
label={t('app.shared.user_profile_form.note')}
tooltip={t('app.shared.user_profile_form.note_help')}
limit={null}
id="profile_attributes.note" />
</div>}
{showTermsAndConditionsInput && termsAndConditions && <div className="terms-and-conditions">
<FormSwitch control={control}
disabled={isDisabled}

View File

@ -98,3 +98,8 @@ json.tags @member.tags do |t|
json.name t.name
end
json.merged_at @member.merged_at
if @operator.privileged?
json.profile_attributes do
json.note @member.profile.note
end
end

View File

@ -97,6 +97,8 @@ en:
group: "Group"
trainings: "Trainings"
tags: "Tags"
note: "Private note"
note_help: "This note is only shown to privileged users. The member won't be able to view it."
terms_and_conditions_html: "I've read and accept <a href=\"{POLICY_URL}\" target=\"_blank\">the terms and conditions<a/>"
must_accept_terms: "You must accept the terms and conditions"
save: "Save"

View File

@ -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

View File

@ -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"