Ejemplo n.º 1
0
def _q_index(request):
    user = request.user
    if user:
        all = request.get_form_var('all')
        scope = request.get_form_var('scope')
        unread = not all or all != '1'
        scope = ActionScope.getScope(scope) or ''  # 不带scope则默认所有

        actions = Notification.get_data(user.name)

        # 迁移数据
        all_actions = [migrate_notif_data(action, user.name)
                       for action in actions]

        if scope:
            actions = [action for action in all_actions
                       if action.get('scope') == scope]
        else:
            actions = all_actions

        if unread:
            actions = [action for action in actions if not action.get('read')]
            count_dict = {s: len([a for a in all_actions
                          if a.get('scope') == s and not a.get('read')])
                          for s in ActionScope.all_scopes}
        else:
            count_dict = {s: len([a for a in all_actions
                          if a.get('scope') == s])
                          for s in ActionScope.all_scopes}
        count_dict['all'] = sum(count_dict.values())

        return st('notifications.html', **locals())
    else:
        return request.redirect("/hub/teams")
Ejemplo n.º 2
0
 def scope(self):
     scope = ActionScope.getScope(self.target_type)
     return scope if scope else ActionScope.project
Ejemplo n.º 3
0
 def scope(self):
     scope = ActionScope.getScope(self.target_type)
     return scope if scope else ActionScope.project