Skip to content

Commit cdcb8e0

Browse files
author
Vianpyro
committed
Refactor responsibility insertion calls for improved readability by consolidating SQL statements
1 parent c7b5c3b commit cdcb8e0

File tree

1 file changed

+33
-132
lines changed

1 file changed

+33
-132
lines changed

setup/responsibility.sql

Lines changed: 33 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -2,153 +2,54 @@
22
USE smartcooking;
33

44
-- Administrative
5-
CALL insert_responsibility(
6-
'can_manage_roles',
7-
'Allows the ability to create, edit, or delete user roles and their associated permissions.'
8-
);
9-
CALL insert_responsibility(
10-
'can_view_audit_log',
11-
'Allows access to view detailed records of database activities and changes for auditing purposes.'
12-
);
5+
CALL insert_responsibility('can_manage_roles', 'Allows the ability to create, edit, or delete user roles and their associated permissions.');
6+
CALL insert_responsibility('can_view_audit_log', 'Allows access to view detailed records of database activities and changes for auditing purposes.');
137

148
-- Category management
15-
CALL insert_responsibility(
16-
'can_create_category',
17-
'Grants the ability to create new categories for organizing content.'
18-
);
19-
CALL insert_responsibility(
20-
'can_edit_category',
21-
'Allows editing existing categories to update their details.'
22-
);
23-
CALL insert_responsibility(
24-
'can_delete_category',
25-
'Grants permission to remove categories from the database.'
26-
);
9+
CALL insert_responsibility('can_create_category', 'Grants the ability to create new categories for organizing content.');
10+
CALL insert_responsibility('can_edit_category', 'Allows editing existing categories to update their details.');
11+
CALL insert_responsibility('can_delete_category', 'Grants permission to remove categories from the database.');
2712

2813
-- Comment management
29-
CALL insert_responsibility(
30-
'can_comment_on_recipe',
31-
'Enables the user to post comments on recipes.'
32-
);
33-
CALL insert_responsibility(
34-
'can_edit_own_comment',
35-
'Allows users to edit their own comments.'
36-
);
37-
CALL insert_responsibility(
38-
'can_edit_any_comment',
39-
'Grants the ability to modify any comment in the system.'
40-
);
41-
CALL insert_responsibility(
42-
'can_delete_own_comment',
43-
'Enables users to delete their own comments.'
44-
);
45-
CALL insert_responsibility(
46-
'can_delete_any_comment',
47-
'Grants the ability to remove any comment from the system.'
48-
);
14+
CALL insert_responsibility('can_comment_on_recipe', 'Enables the user to post comments on recipes.');
15+
CALL insert_responsibility('can_edit_own_comment', 'Allows users to edit their own comments.');
16+
CALL insert_responsibility('can_edit_any_comment', 'Grants the ability to modify any comment in the system.');
17+
CALL insert_responsibility('can_delete_own_comment', 'Enables users to delete their own comments.');
18+
CALL insert_responsibility('can_delete_any_comment', 'Grants the ability to remove any comment from the system.');
4919

5020
-- Ingredient management
51-
CALL insert_responsibility(
52-
'can_create_ingredient',
53-
'Allows the addition of new ingredients to the database.'
54-
);
55-
CALL insert_responsibility(
56-
'can_edit_ingredient',
57-
'Grants permission to modify existing ingredient details.'
58-
);
59-
CALL insert_responsibility(
60-
'can_delete_ingredient',
61-
'Allows the removal of ingredients from the database.'
62-
);
21+
CALL insert_responsibility('can_create_ingredient', 'Allows the addition of new ingredients to the database.');
22+
CALL insert_responsibility('can_edit_ingredient', 'Grants permission to modify existing ingredient details.');
23+
CALL insert_responsibility('can_delete_ingredient', 'Allows the removal of ingredients from the database.');
6324

6425
-- Media management
65-
CALL insert_responsibility(
66-
'can_upload_picture',
67-
'Enables users to upload pictures to the system.'
68-
);
69-
CALL insert_responsibility(
70-
'can_delete_picture',
71-
'Grants the ability to remove pictures from the system.'
72-
);
26+
CALL insert_responsibility('can_upload_picture', 'Enables users to upload pictures to the system.');
27+
CALL insert_responsibility('can_delete_picture', 'Grants the ability to remove pictures from the system.');
7328

7429
-- Moderation
75-
CALL insert_responsibility(
76-
'can_review_flagged_content',
77-
'Allows reviewing and managing content flagged as inappropriate.'
78-
);
79-
CALL insert_responsibility(
80-
'can_suspend_user_account',
81-
'Grants the ability to temporarily suspend a user’s account.'
82-
);
83-
CALL insert_responsibility(
84-
'can_ban_user_account',
85-
'Enables the banning of user accounts permanently.'
86-
);
30+
CALL insert_responsibility('can_review_flagged_content', 'Allows reviewing and managing content flagged as inappropriate.');
31+
CALL insert_responsibility('can_suspend_user_account', 'Grants the ability to temporarily suspend a user’s account.');
32+
CALL insert_responsibility('can_ban_user_account', 'Enables the banning of user accounts permanently.');
8733

8834
-- Person management
89-
CALL insert_responsibility(
90-
'can_manage_any_person_profile',
91-
'Grants access to edit profiles of any user in the system.'
92-
);
93-
CALL insert_responsibility(
94-
'can_delete_any_person_account',
95-
'Allows the permanent removal of any user account.'
96-
);
35+
CALL insert_responsibility('can_manage_any_person_profile', 'Grants access to edit profiles of any user in the system.');
36+
CALL insert_responsibility('can_delete_any_person_account', 'Allows the permanent removal of any user account.');
9737

9838
-- Recipe management
99-
CALL insert_responsibility(
100-
'can_create_recipe',
101-
'Allows users to create and submit new recipes.'
102-
);
103-
CALL insert_responsibility(
104-
'can_edit_own_recipe',
105-
'Grants users the ability to edit their own recipes.'
106-
);
107-
CALL insert_responsibility(
108-
'can_edit_any_recipe',
109-
'Allows editing any recipe in the system.'
110-
);
111-
CALL insert_responsibility(
112-
'can_delete_own_recipe',
113-
'Enables users to delete their own recipes.'
114-
);
115-
CALL insert_responsibility(
116-
'can_delete_any_recipe',
117-
'Grants the ability to remove any recipe from the system.'
118-
);
119-
CALL insert_responsibility(
120-
'can_publish_recipe',
121-
'Allows the publication of recipes to make them publicly visible.'
122-
);
123-
CALL insert_responsibility(
124-
'can_review_recipe',
125-
'Grants permission to review recipes for approval or feedback.'
126-
);
39+
CALL insert_responsibility('can_create_recipe', 'Allows users to create and submit new recipes.');
40+
CALL insert_responsibility('can_edit_own_recipe', 'Grants users the ability to edit their own recipes.');
41+
CALL insert_responsibility('can_edit_any_recipe', 'Allows editing any recipe in the system.');
42+
CALL insert_responsibility('can_delete_own_recipe', 'Enables users to delete their own recipes.');
43+
CALL insert_responsibility('can_delete_any_recipe', 'Grants the ability to remove any recipe from the system.');
44+
CALL insert_responsibility('can_publish_recipe', 'Allows the publication of recipes to make them publicly visible.');
45+
CALL insert_responsibility('can_review_recipe', 'Grants permission to review recipes for approval or feedback.');
12746

12847
-- Tag management
129-
CALL insert_responsibility(
130-
'can_create_tag',
131-
'Allows the creation of new tags for categorizing content.'
132-
);
133-
CALL insert_responsibility(
134-
'can_edit_tag',
135-
'Grants the ability to edit existing tags.'
136-
);
137-
CALL insert_responsibility(
138-
'can_delete_tag',
139-
'Allows the removal of tags from the database.'
140-
);
48+
CALL insert_responsibility('can_create_tag', 'Allows the creation of new tags for categorizing content.');
49+
CALL insert_responsibility('can_edit_tag', 'Grants the ability to edit existing tags.');
50+
CALL insert_responsibility('can_delete_tag', 'Allows the removal of tags from the database.');
14151

14252
-- Translation management
143-
CALL insert_responsibility(
144-
'can_add_translation',
145-
'Enables the addition of new translations for system content.'
146-
);
147-
CALL insert_responsibility(
148-
'can_edit_translation',
149-
'Grants permission to modify existing translations.'
150-
);
151-
CALL insert_responsibility(
152-
'can_delete_translation',
153-
'Allows the deletion of translations from the database.'
154-
);
53+
CALL insert_responsibility('can_add_translation', 'Enables the addition of new translations for system content.');
54+
CALL insert_responsibility('can_edit_translation', 'Grants permission to modify existing translations.');
55+
CALL insert_responsibility('can_delete_translation', 'Allows the deletion of translations from the database.');

0 commit comments

Comments
 (0)