diff --git a/app/frontend/src/javascript/components/user/change-role-modal.tsx b/app/frontend/src/javascript/components/user/change-role-modal.tsx index c141795d1..a13ebb05f 100644 --- a/app/frontend/src/javascript/components/user/change-role-modal.tsx +++ b/app/frontend/src/javascript/components/user/change-role-modal.tsx @@ -39,10 +39,9 @@ type selectGroupOption = { value: number, label: string }; */ export const ChangeRoleModal: React.FC = ({ isOpen, toggleModal, user, onSuccess, onError }) => { const { t } = useTranslation('admin'); - const { control, handleSubmit } = useForm({ defaultValues: { groupId: user.group_id } }); + const { control, handleSubmit } = useForm({ defaultValues: { role: user.role, groupId: user.group_id } }); const [groups, setGroups] = useState>([]); - const [selectedRole, setSelectedRole] = useState(user.role); useEffect(() => { GroupAPI.index({ disabled: false }).then(setGroups).catch(onError); @@ -64,10 +63,10 @@ export const ChangeRoleModal: React.FC = ({ isOpen, toggle }; /** - * Callback triggered when the user changes the selected role in the dropdown selection list + * Check if we can change the group of the user */ - const onRoleSelect = (data: UserRole) => { - setSelectedRole(data); + const canChangeGroup = (): boolean => { + return !user.subscription; }; /** @@ -104,15 +103,14 @@ export const ChangeRoleModal: React.FC = ({ isOpen, toggle control={control} id="role" label={t('app.admin.change_role_modal.new_role')} - rules={{ required: true }} - onChange={onRoleSelect} /> - {selectedRole !== 'admin' && - } + rules={{ required: true }} /> + ); diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index fbc7e14eb..7419041eb 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -999,13 +999,13 @@ en: refuse_documents_info: "After verification, you may notify the member that the evidence submitted is not acceptable. You can specify the reasons for your refusal and indicate the actions to be taken. The member will be notified by e-mail." change_role_modal: change_role: "Change role" - warning_role_change: "

Warning: changing the role of a user is not a harmless operation.

  • Members can only book reservations for themselves, paying by card or wallet.
  • Managers can book reservations for themselves, paying by card or wallet, and for other members and managers, by collecting payments at the checkout.
  • Administrators can only book reservations for members and managers, by collecting payments at the checkout. Moreover, they can change every settings of the application.
" + warning_role_change: "

Warning: changing the role of a user is not a harmless operation.

  • Members can only book reservations for themselves, paying by card or wallet.
  • Managers can book reservations for themselves, paying by card or wallet, and for other members and managers, by collecting payments at the checkout.
  • Administrators as managers, they can book reservations for themselves and for others. Moreover, they can change every settings of the application.
" new_role: "New role" admin: "Administrator" manager: "Manager" member: "Member" new_group: "New group" - new_group_help: "Members and managers must be placed in a group." + new_group_help: "Users with a running subscription cannot be changed from their current group." confirm: "Change role" role_changed: "Role successfully changed from {OLD} to {NEW}." error_while_changing_role: "An error occurred while changing the role. Please try again later." diff --git a/doc/postgresql_readme.md b/doc/postgresql_readme.md index 465261364..36a1087dc 100644 --- a/doc/postgresql_readme.md +++ b/doc/postgresql_readme.md @@ -18,18 +18,19 @@ Use the following commands to dump the PostgreSQL database to an archive file cd /apps/fabmanager/ docker-compose exec postgres bash cd /var/lib/postgresql/data/ -pg_dump -U postgres fabmanager_production > fabmanager_production_$(date -I).sql -tar cvzf fabmanager_production_$(date -I).tar.gz fabmanager_production_$(date -I).sql +DB=$(psql -U postgres -c \\l | grep production | awk '{print $1}') +pg_dump -U postgres "$DB" > "$DB_$(date -I).sql" +tar cvzf "fabmanager_database_dump_$(date -I).tar.gz" "$DB_$(date -I).sql" ``` If you're connected to your server thought SSH, you can download the resulting dump file using the following: ```bash -scp root@remote.server.fab:/apps/fabmanager/postgresql/fabmanager_production_$(date -I).tar.gz . +scp root@remote.server.fab:/apps/fabmanager/postgresql/fabmanager_database_dump_$(date -I).tar.gz . ``` Restore the dump with the following: ```bash -tar xvf fabmanager_production_$(date -I).tar.gz +tar xvf fabmanager_database_dump_$(date -I).tar.gz sudo cp fabmanager_production_$(date -I).sql /apps/fabmanager/postgresql/ cd /apps/fabmanager/ docker-compose down @@ -76,7 +77,7 @@ This is currently not supported, because of some PostgreSQL specific instruction - `db/migrate/20200511075933_fix_accounting_periods.rb` is using `CREATE RULE` and `DROP RULE`; - `app/models/project.rb` is using the `pg_search` gem. - `db/migrate/20200622135401_add_pg_search_dmetaphone_support_functions.rb` is using [fuzzystrmatch](http://www.postgresql.org/docs/current/static/fuzzystrmatch.html) module and defines a PL/pgSQL function (`pg_search_dmetaphone()`); - - `db/migrate/20200623134900_add_search_vector_to_project.rb` is using [tsvector](https://www.postgresql.org/docs/10/datatype-textsearch.html), a PostgreSQL datatype and [GIN (Generalized Inverted Index)](https://www.postgresql.org/docs/9.1/textsearch-indexes.html) a PostgreSQL index type; + - `db/migrate/20200623134900_add_search_vector_to_project.rb` is using [tsvector](https://www.postgresql.org/docs/10/datatype-textsearch.html), a PostgreSQL datatype and [GIN (Generalized Inverted Index)](https://www.postgresql.org/docs/9.1/textsearch-indexes.html) a PostgreSQL index type; - `db/migrate/20200623141305_update_search_vector_of_projects.rb` defines a PL/pgSQL function (`fill_search_vector_for_project()`) and create an SQL trigger for this function; - `db/migrate/20200629123011_update_pg_trgm.rb` is using [ALTER EXTENSION](https://www.postgresql.org/docs/10/sql-alterextension.html); - `db/migrate/20201027101809_create_payment_schedule_items.rb` is using [jsonb](https://www.postgresql.org/docs/9.4/static/datatype-json.html);