| | 1 | == Writer Invites a Collaborator to a Story |
| | 2 | |
| | 3 | === Authors: **Writter** |
| | 4 | A writer invites another writer to collaborate on their story, assigning them a role and permission level within the collaboration. |
| | 5 | |
| | 6 | **1.** The writer navigates to their story management page and selects "Manage Collaborators". |
| | 7 | |
| | 8 | **2.** The system displays the current list of collaborators on the story. |
| | 9 | |
| | 10 | {{{#!sql |
| | 11 | SELECT u.username, u.name, u.surname, r.roles, p.permission_level |
| | 12 | FROM COLLABORATION c |
| | 13 | JOIN USERS u ON c.user_id = u.user_id |
| | 14 | JOIN ROLES r ON c.user_id = r.user_id AND c.story_id = r.story_id |
| | 15 | JOIN PERMISSION_LEVEL p ON c.user_id = p.user_id AND c.story_id = p.story_id |
| | 16 | WHERE c.story_id = 5; |
| | 17 | }}} |
| | 18 | |
| | 19 | **3.** The writer searches for another writer by username and selects them. |
| | 20 | |
| | 21 | **4.** The writer assigns a role and permission level to the new collaborator. |
| | 22 | |
| | 23 | **5.** TThe system inserts the new collaborator into the COLLABORATION table. |
| | 24 | |
| | 25 | {{{#!sql |
| | 26 | INSERT INTO COLLABORATION (user_id, story_id, created_at) |
| | 27 | VALUES (9, 5, CURRENT_TIMESTAMP); |
| | 28 | }}} |
| | 29 | |
| | 30 | **6.** The system assigns the role to the collaborator. |
| | 31 | |
| | 32 | {{{#!sql |
| | 33 | INSERT INTO ROLES (user_id, story_id, roles) |
| | 34 | VALUES (9, 5, 'co-author'); |
| | 35 | }}} |
| | 36 | |
| | 37 | **7.** The system assigns the permission level to the collaborator. |
| | 38 | |
| | 39 | {{{#!sql |
| | 40 | INSERT INTO PERMISSION_LEVEL (user_id, story_id, permission_level) |
| | 41 | VALUES (9, 5, 4); |
| | 42 | }}} |
| | 43 | |
| | 44 | **8.**The system sends a notification to the invited writer informing them of the collaboration. |
| | 45 | {{{#!sql |
| | 46 | INSERT INTO NOTIFICATION (content, is_read, created_at) |
| | 47 | VALUES ('You have been invited to collaborate on "Letters from Constantinople"', FALSE, CURRENT_TIMESTAMP); |
| | 48 | }}} |
| | 49 | **9.** The system confirms the collaborator was successfully added. |
| | 50 | |