Browse Source

revert do notify as param for create/setting workspace members endpoint

Guénaël Muller 6 years ago
parent
commit
703a780f88

+ 0 - 4
backend/tracim_backend/models/context_models.py View File

266
     def __init__(
266
     def __init__(
267
         self,
267
         self,
268
         role: str,
268
         role: str,
269
-        do_notify: bool,
270
     ):
269
     ):
271
         self.role = role
270
         self.role = role
272
-        self.do_notify = do_notify
273
 
271
 
274
 
272
 
275
 class WorkspaceMemberInvitation(object):
273
 class WorkspaceMemberInvitation(object):
281
         user_id: int,
279
         user_id: int,
282
         user_email_or_public_name: str,
280
         user_email_or_public_name: str,
283
         role: str,
281
         role: str,
284
-        do_notify: str,
285
     ):
282
     ):
286
         self.role = role
283
         self.role = role
287
         self.user_email_or_public_name = user_email_or_public_name
284
         self.user_email_or_public_name = user_email_or_public_name
288
         self.user_id = user_id
285
         self.user_id = user_id
289
-        self.do_notify = do_notify
290
 
286
 
291
 
287
 
292
 class WorkspaceUpdate(object):
288
 class WorkspaceUpdate(object):

+ 6 - 14
backend/tracim_backend/tests/functional/test_workspaces.py View File

980
             'user_id': 2,
980
             'user_id': 2,
981
             'user_email_or_public_name': None,
981
             'user_email_or_public_name': None,
982
             'role': 'content-manager',
982
             'role': 'content-manager',
983
-            'do_notify': False,
984
         }
983
         }
985
         res = self.testapp.post_json(
984
         res = self.testapp.post_json(
986
             '/api/v2/workspaces/1/members',
985
             '/api/v2/workspaces/1/members',
1023
             'user_id': None,
1022
             'user_id': None,
1024
             'user_email_or_public_name': 'lawrence-not-real-email@fsf.local',
1023
             'user_email_or_public_name': 'lawrence-not-real-email@fsf.local',
1025
             'role': 'content-manager',
1024
             'role': 'content-manager',
1026
-            'do_notify': 'True',
1027
         }
1025
         }
1028
         res = self.testapp.post_json(
1026
         res = self.testapp.post_json(
1029
             '/api/v2/workspaces/1/members',
1027
             '/api/v2/workspaces/1/members',
1036
         assert user_role_found['workspace_id'] == 1
1034
         assert user_role_found['workspace_id'] == 1
1037
         assert user_role_found['newly_created'] is False
1035
         assert user_role_found['newly_created'] is False
1038
         assert user_role_found['email_sent'] is False
1036
         assert user_role_found['email_sent'] is False
1039
-        assert user_role_found['do_notify'] is True
1037
+        assert user_role_found['do_notify'] is False
1040
 
1038
 
1041
         res = self.testapp.get('/api/v2/workspaces/1/members', status=200).json_body   # nopep8
1039
         res = self.testapp.get('/api/v2/workspaces/1/members', status=200).json_body   # nopep8
1042
         assert len(res) == 2
1040
         assert len(res) == 2
1066
             'user_id': None,
1064
             'user_id': None,
1067
             'user_email_or_public_name': 'Lawrence L.',
1065
             'user_email_or_public_name': 'Lawrence L.',
1068
             'role': 'content-manager',
1066
             'role': 'content-manager',
1069
-            'do_notify': True,
1070
         }
1067
         }
1071
         res = self.testapp.post_json(
1068
         res = self.testapp.post_json(
1072
             '/api/v2/workspaces/1/members',
1069
             '/api/v2/workspaces/1/members',
1079
         assert user_role_found['workspace_id'] == 1
1076
         assert user_role_found['workspace_id'] == 1
1080
         assert user_role_found['newly_created'] is False
1077
         assert user_role_found['newly_created'] is False
1081
         assert user_role_found['email_sent'] is False
1078
         assert user_role_found['email_sent'] is False
1082
-        assert user_role_found['do_notify'] is True
1079
+        assert user_role_found['do_notify'] is False
1083
 
1080
 
1084
         res = self.testapp.get('/api/v2/workspaces/1/members', status=200).json_body   # nopep8
1081
         res = self.testapp.get('/api/v2/workspaces/1/members', status=200).json_body   # nopep8
1085
         assert len(res) == 2
1082
         assert len(res) == 2
1109
             'user_id': None,
1106
             'user_id': None,
1110
             'user_email_or_public_name': None,
1107
             'user_email_or_public_name': None,
1111
             'role': 'content-manager',
1108
             'role': 'content-manager',
1112
-            'do_notify': True,
1113
         }
1109
         }
1114
         res = self.testapp.post_json(
1110
         res = self.testapp.post_json(
1115
             '/api/v2/workspaces/1/members',
1111
             '/api/v2/workspaces/1/members',
1134
             'user_id': 47,
1130
             'user_id': 47,
1135
             'user_email_or_public_name': None,
1131
             'user_email_or_public_name': None,
1136
             'role': 'content-manager',
1132
             'role': 'content-manager',
1137
-            'do_notify': True,
1138
         }
1133
         }
1139
         res = self.testapp.post_json(
1134
         res = self.testapp.post_json(
1140
             '/api/v2/workspaces/1/members',
1135
             '/api/v2/workspaces/1/members',
1159
             'user_id': None,
1154
             'user_id': None,
1160
             'user_email_or_public_name': 'nothing@nothing.nothing',
1155
             'user_email_or_public_name': 'nothing@nothing.nothing',
1161
             'role': 'content-manager',
1156
             'role': 'content-manager',
1162
-            'do_notify': True,
1163
         }
1157
         }
1164
         res = self.testapp.post_json(
1158
         res = self.testapp.post_json(
1165
             '/api/v2/workspaces/1/members',
1159
             '/api/v2/workspaces/1/members',
1173
         assert user_role_found['workspace_id'] == 1
1167
         assert user_role_found['workspace_id'] == 1
1174
         assert user_role_found['newly_created'] is True
1168
         assert user_role_found['newly_created'] is True
1175
         assert user_role_found['email_sent'] is False
1169
         assert user_role_found['email_sent'] is False
1176
-        assert user_role_found['do_notify'] is True
1170
+        assert user_role_found['do_notify'] is False
1177
 
1171
 
1178
         res = self.testapp.get('/api/v2/workspaces/1/members',
1172
         res = self.testapp.get('/api/v2/workspaces/1/members',
1179
                                status=200).json_body  # nopep8
1173
                                status=200).json_body  # nopep8
1205
         assert user_role['role'] == 'workspace-manager'
1199
         assert user_role['role'] == 'workspace-manager'
1206
         assert user_role['user_id'] == 1
1200
         assert user_role['user_id'] == 1
1207
         assert user_role['workspace_id'] == 1
1201
         assert user_role['workspace_id'] == 1
1202
+        assert user_role['do_notify'] is True
1208
         # update workspace role
1203
         # update workspace role
1209
         params = {
1204
         params = {
1210
             'role': 'content-manager',
1205
             'role': 'content-manager',
1211
-            'do_notify': False,
1212
         }
1206
         }
1213
         res = self.testapp.put_json(
1207
         res = self.testapp.put_json(
1214
             '/api/v2/workspaces/1/members/1',
1208
             '/api/v2/workspaces/1/members/1',
1224
         assert len(res) == 1
1218
         assert len(res) == 1
1225
         user_role = res[0]
1219
         user_role = res[0]
1226
         assert user_role['role'] == 'content-manager'
1220
         assert user_role['role'] == 'content-manager'
1227
-        assert user_role['do_notify'] is False
1221
+        assert user_role['do_notify'] is True
1228
         assert user_role['user_id'] == 1
1222
         assert user_role['user_id'] == 1
1229
         assert user_role['workspace_id'] == 1
1223
         assert user_role['workspace_id'] == 1
1230
 
1224
 
1367
             'user_id': None,
1361
             'user_id': None,
1368
             'user_email_or_public_name': 'bob@bob.bob',
1362
             'user_email_or_public_name': 'bob@bob.bob',
1369
             'role': 'content-manager',
1363
             'role': 'content-manager',
1370
-            'do_notify': True,
1371
         }
1364
         }
1372
         res = self.testapp.post_json(
1365
         res = self.testapp.post_json(
1373
             '/api/v2/workspaces/1/members',
1366
             '/api/v2/workspaces/1/members',
1381
         assert user_role_found['workspace_id'] == 1
1374
         assert user_role_found['workspace_id'] == 1
1382
         assert user_role_found['newly_created'] is True
1375
         assert user_role_found['newly_created'] is True
1383
         assert user_role_found['email_sent'] is True
1376
         assert user_role_found['email_sent'] is True
1384
-        assert user_role_found['do_notify'] is True
1377
+        assert user_role_found['do_notify'] is False
1385
 
1378
 
1386
         # check mail received
1379
         # check mail received
1387
         response = requests.get('http://127.0.0.1:8025/api/v1/messages')
1380
         response = requests.get('http://127.0.0.1:8025/api/v1/messages')
1418
             'user_id': None,
1411
             'user_id': None,
1419
             'user_email_or_public_name': 'bob@bob.bob',
1412
             'user_email_or_public_name': 'bob@bob.bob',
1420
             'role': 'content-manager',
1413
             'role': 'content-manager',
1421
-            'do_notify': True,
1422
         }
1414
         }
1423
         res = self.testapp.post_json(
1415
         res = self.testapp.post_json(
1424
             '/api/v2/workspaces/1/members',
1416
             '/api/v2/workspaces/1/members',

+ 0 - 6
backend/tracim_backend/views/core_api/schemas.py View File

466
         example='contributor',
466
         example='contributor',
467
         validate=OneOf(UserRoleInWorkspace.get_all_role_slug())
467
         validate=OneOf(UserRoleInWorkspace.get_all_role_slug())
468
     )
468
     )
469
-    do_notify = marshmallow.fields.Bool(
470
-        description='has user enabled notification for this workspace',
471
-        example=True,
472
-        default=None,
473
-        allow_none=True,
474
-    )
475
 
469
 
476
     @post_load
470
     @post_load
477
     def make_role(self, data):
471
     def make_role(self, data):

+ 2 - 3
backend/tracim_backend/views/core_api/workspace_controller.py View File

221
         workspace_role = WorkspaceRoles.get_role_from_slug(hapic_data.body.role)
221
         workspace_role = WorkspaceRoles.get_role_from_slug(hapic_data.body.role)
222
         role = rapi.update_role(
222
         role = rapi.update_role(
223
             role,
223
             role,
224
-            role_level=workspace_role.level,
225
-            with_notif=hapic_data.body.do_notify
224
+            role_level=workspace_role.level
226
         )
225
         )
227
         return rapi.get_user_role_workspace_with_context(role)
226
         return rapi.get_user_role_workspace_with_context(role)
228
 
227
 
303
             user=user,
302
             user=user,
304
             workspace=request.current_workspace,
303
             workspace=request.current_workspace,
305
             role_level=WorkspaceRoles.get_role_from_slug(hapic_data.body.role).level,  # nopep8
304
             role_level=WorkspaceRoles.get_role_from_slug(hapic_data.body.role).level,  # nopep8
306
-            with_notif=hapic_data.body.do_notify or False,  # nopep8, default value as false
305
+            with_notif=False,
307
             flush=True,
306
             flush=True,
308
         )
307
         )
309
         return rapi.get_user_role_workspace_with_context(
308
         return rapi.get_user_role_workspace_with_context(