Closed thomas-qah closed 4 months ago
This pull request has had no activity for 60 days and will be closed in 7 days. Removing the "Stale" label or posting a comment will prevent it from being closed automatically. You can also add the "Pinned" label to ensure it isn't marked as stale in the future.
What?
This PR adds multi-user scenario functionality to ETEngine.
Why?
Some of our clients would like to be able to share scenarios and collaborate on them together with other users. A way to do so is by being able to link multiple users to one scenario and have the ability to give them different roles. This PR does just that.
How?
Backend
ScenarioUser
: This model serves as the coupling link betweenScenarios
andUsers
and symbolizes the role that a user has in relation to a given scenario. For the model to work ascenario_users
table was also added. This table contains all said information.Scenario.owner
toScenario.users
, which is now Array of Users and no longer one User.API::ScenarioUsersController
: This is the controller handling API requests towards/api/v3/scenarios/:id/users/
. It handles requests for:/
: Returns all ScenarioUsers for a given Scenario/
: Handles adding multiple ScenarioUsers in one go. Expects an array in the form of:[{user_id:, user_email:, role:}, {...}, ...]
. Additionally, aninvitation_args
object can be included in each user object to make ETEngine send out an invitation mail to the user that was just added to the scenario. For this, it uses the newScenarioInvitationMailer
described below./
: Handles updating multipleScenarioUsers
in one go. Expects an array in the form of:[{id: / user_id: / user_email:, role:}, {...}, ...]
/
: Handles destroying multipleSavedScenarioUsers
in one go. Expects an array in the form of:[{id: / user_id: / user_email:}, {...}, ...]
ScenarioInvitationMailer
was added to send out invitation mails to both existing and new users (for which the email address was not found). The contents of the mails themselves can found in app/views/scenario_invitation_mailer/,Scenario
,ScenarioSerializer
, andYearInterpolator
to keep working properly despite changes ownership (i.e. the change fromowner
tousers
described above).Closes #1375 .