Ver código fonte

improve way to not show deleted workspaces

Damien Accorsi 7 anos atrás
pai
commit
02da1993a0

+ 10 - 0
tracim/tracim/model/auth.py Ver arquivo

@@ -280,6 +280,16 @@ class User(DeclarativeBase):
280 280
         from tracim.model.data import UserRoleInWorkspace
281 281
         return UserRoleInWorkspace.NOT_APPLICABLE
282 282
 
283
+    def get_active_roles(self) -> ['UserRoleInWorkspace']:
284
+        """
285
+        :return: list of roles of the user for all not-deleted workspaces
286
+        """
287
+        roles = []
288
+        for role in self.roles:
289
+            if not role.workspace.is_deleted:
290
+                roles.append(role)
291
+        return roles
292
+
283 293
     def ensure_auth_token(self) -> None:
284 294
         """
285 295
         Create auth_token if None, regenerate auth_token if too much old.

+ 1 - 1
tracim/tracim/model/serializers.py Ver arquivo

@@ -914,7 +914,7 @@ def serialize_user_for_user(user: User, context: Context):
914 914
     result['id'] = user.user_id
915 915
     result['name'] = user.get_display_name()
916 916
     result['email'] = user.email
917
-    result['roles'] = context.toDict(user.roles)
917
+    result['roles'] = context.toDict(user.get_active_roles())
918 918
     result['enabled'] = user.is_active
919 919
     result['profile'] = user.profile
920 920
     result['calendar_url'] = user.calendar_url

+ 1 - 1
tracim/tracim/templates/home.mak Ver arquivo

@@ -138,7 +138,7 @@
138 138
                         </thead>
139 139
                         % for role in fake_api.current_user.roles:
140 140
                             % if not role.workspace.is_deleted:
141
-                            ${TABLE_ROW.USER_ROLE_IN_WORKSPACE(fake_api.current_user, role, show_id=False, enable_link='/user/me/workspaces/{workspace}/enable_notifications?next_url=/home', disable_link='/user/me/workspaces/{workspace}/disable_notifications?next_url=/home', base_link='/workspaces/{workspace}')}
141
+                                ${TABLE_ROW.USER_ROLE_IN_WORKSPACE(fake_api.current_user, role, show_id=False, enable_link='/user/me/workspaces/{workspace}/enable_notifications?next_url=/home', disable_link='/user/me/workspaces/{workspace}/disable_notifications?next_url=/home', base_link='/workspaces/{workspace}')}
142 142
                             % endif
143 143
                         % endfor
144 144
                     </table>