| | 1 | == Admin Removes a Story |
| | 2 | |
| | 3 | === Actor: **Admin** |
| | 4 | An admin removes an inappropriate published story from the platform after reviewing it for content violations. |
| | 5 | |
| | 6 | **1.** The admin navigates to the content moderation dashboard. |
| | 7 | |
| | 8 | **2.** The system displays all published stories with their details. |
| | 9 | {{{#!sql |
| | 10 | SELECT s.story_id, s.short_description, s.mature_content, |
| | 11 | u.username AS author, st.status, |
| | 12 | COUNT(DISTINCT c.comment_id) AS total_comments, |
| | 13 | s.created_at |
| | 14 | FROM STORY s |
| | 15 | JOIN USERS u ON s.user_id = u.user_id |
| | 16 | JOIN STATUS st ON s.story_id = st.story_id |
| | 17 | LEFT JOIN COMMENT c ON s.story_id = c.story_id |
| | 18 | WHERE st.status = 'published' |
| | 19 | GROUP BY s.story_id, u.username, st.status |
| | 20 | ORDER BY s.created_at DESC; |
| | 21 | }}} |
| | 22 | |
| | 23 | **3.** The admin selects a story flagged for inappropriate content and reviews it. |
| | 24 | |
| | 25 | **4.** The admin confirms the story violates platform rules and proceeds to delete it. |
| | 26 | |
| | 27 | **5.** The system deletes the story, and all related records are automatically removed via CASCADE. |
| | 28 | {{{#!sql |
| | 29 | DELETE FROM STORY |
| | 30 | WHERE story_id = 3; |
| | 31 | }}} |
| | 32 | |
| | 33 | **6.** The system notifies the writer that their story was removed due to a policy violation. |
| | 34 | {{{#!sql |
| | 35 | INSERT INTO NOTIFICATION (content, is_read, created_at) |
| | 36 | VALUES ('Your story "Moonlight Promises" has been removed by an administrator due to a content policy violation.', FALSE, CURRENT_TIMESTAMP); |
| | 37 | }}} |
| | 38 | |
| | 39 | **7.** The system logs the action and confirms the story is no longer visible on the platform. |