Browse Source

improve way to not show deleted workspaces

Damien Accorsi 7 years ago
parent
commit
02da1993a0

+ 10 - 0
tracim/tracim/model/auth.py View File

280
         from tracim.model.data import UserRoleInWorkspace
280
         from tracim.model.data import UserRoleInWorkspace
281
         return UserRoleInWorkspace.NOT_APPLICABLE
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
     def ensure_auth_token(self) -> None:
293
     def ensure_auth_token(self) -> None:
284
         """
294
         """
285
         Create auth_token if None, regenerate auth_token if too much old.
295
         Create auth_token if None, regenerate auth_token if too much old.

+ 1 - 1
tracim/tracim/model/serializers.py View File

914
     result['id'] = user.user_id
914
     result['id'] = user.user_id
915
     result['name'] = user.get_display_name()
915
     result['name'] = user.get_display_name()
916
     result['email'] = user.email
916
     result['email'] = user.email
917
-    result['roles'] = context.toDict(user.roles)
917
+    result['roles'] = context.toDict(user.get_active_roles())
918
     result['enabled'] = user.is_active
918
     result['enabled'] = user.is_active
919
     result['profile'] = user.profile
919
     result['profile'] = user.profile
920
     result['calendar_url'] = user.calendar_url
920
     result['calendar_url'] = user.calendar_url

+ 1 - 1
tracim/tracim/templates/home.mak View File

138
                         </thead>
138
                         </thead>
139
                         % for role in fake_api.current_user.roles:
139
                         % for role in fake_api.current_user.roles:
140
                             % if not role.workspace.is_deleted:
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
                             % endif
142
                             % endif
143
                         % endfor
143
                         % endfor
144
                     </table>
144
                     </table>