Beispiel #1
0
 def get(self, *args, **kwargs):
     self.set_cookie('index-mode', self._mode)
     tasks = Task.assigned_tasks(user_id=self.user.id)
     # num = Task.number(assigned_id=self.user.id, status__le=Task._status_assigned)
     # paginator = Paginator(page, num, Task._per_page)
     auths = Auth.find_user_projects(self.user.id)
     return self.render('index.html', datas=tasks, auths=auths, paginator=None, page=0)
Beispiel #2
0
 def get(self, *args, **kwargs):
     self.set_cookie('index-mode', self._mode)
     page = self.get_args('p', 1, int)
     focuses = TaskFocus.user_focs(user_id=self.user.id, page=page)
     for f in focuses:
         f.task = Task.get(id=f.task_id)
     num = TaskFocus.number(user_id=self.user.id)
     paginator = Paginator(page, num, TaskFocus._per_page)
     #auths
     auths = Auth.find_user_projects(self.user.id)
     return self.render('index.html', datas=focuses, auths=auths, paginator=paginator, page=page)
Beispiel #3
0
 def get(self, *args, **kwargs):
     self.set_cookie('index-mode', self._mode)
     page = self.get_args('p', 1, int)
     messages = Message.user_msgs(user_id=self.user.id, page=page)
     Message.mark_read(user_id=self.user.id)
     # for m in messages:
     #     if m.status == m._status_unread:
     #         self.add_message(u'你有新的消息')
     #         break
     num = Message.number(user_id=self.user.id)
     paginator = Paginator(page, num, Message._per_page)
     # auth
     auths = Auth.find_user_projects(self.user.id)
     return self.render('index.html', datas=messages, auths=auths, paginator=paginator, page=page)
Beispiel #4
0
 def get(self, *args, **kwargs):
     """ 任务home页
     """
     pros = Auth.find_user_projects(uid=self.user.id)
     if not pros:
         self.add_message(u'您目前还没有可用的项目哦!')
         return self.redirect('/')  # 首页展示用户消息
     cur_pro = pros[0]
     cur_auth_id = self.get_cookie('cur_auth', pros[0].id)
     for p in pros:
         if p.id == int(cur_auth_id):
             cur_pro = p
     status = self.get_cookie('status', 'unsolved')
     order = self.get_cookie('order', 'p')
     return self.redirect('/%s/task?s=%s&&o=%s' % (cur_pro.project_id, status, order))
Beispiel #5
0
 def get(self, *args, **kwargs):
     """ 任务home页
     """
     pros = Auth.find_user_projects(uid=self.user.id)
     if not pros:
         self.add_message(u'您目前还没有可用的项目哦!')
         return self.redirect('/')  # 首页展示用户消息
     cur_pro = pros[0]
     cur_auth_id = self.get_cookie('cur_auth', pros[0].id)
     for p in pros:
         if p.id == int(cur_auth_id):
             cur_pro = p
     status = self.get_cookie('status', 'unsolved')
     order = self.get_cookie('order', 'p')
     return self.redirect('/%s/task?s=%s&&o=%s' %
                          (cur_pro.project_id, status, order))
Beispiel #6
0
 def get(self, *args, **kwargs):
     """ order: p, s, t default desc p_, s_, t_ - asc
     """
     # get args
     status = self.get_args('s') or self.get_cookie('status', 'unsolved')
     order = self.get_args('o') or self.get_cookie('order', 'p')  # _o - desc, o_ - asc
     page = self.get_args('p', 1)
     # 记录状态
     self.set_cookie('status', status)
     self.set_cookie('order', order)
     self.set_cookie('cur_auth', str(self.auth.id))
     # set order_by
     if order not in self._order.keys():
         order = 'p'
     order_by = self._order.get(order)
     page = int(page)
     pros = Auth.find_user_projects(uid=self.user.id)
     where = dict(
         uid=self.user.id,
         pid=self.pid,
         status=status
     )
     if status != 'assigned':
         tasks, num = Task.find_project_tasks(
             page=page,
             order_by=order_by,
             get_num=True,
             **where)
         paginator = Paginator(page, num, Task._per_page)
     else:
         tasks = Task.assigned_tasks(
             user_id=self.user.id,
             order_by=order_by,
             pid=self.pid,
         )
         paginator = None
     unread_num = Message.unread_num(user_id=self.user.id)
     return self.render(
         'task-home.html',
         cur_pro=self.auth,
         pros=pros,
         tasks=tasks,
         status=status,
         order=order,
         page=page,
         paginator=paginator,
         unread_num=unread_num)
Beispiel #7
0
 def get(self, *args, **kwargs):
     """ order: p, s, t default desc p_, s_, t_ - asc
     """
     # get args
     status = self.get_args('s') or self.get_cookie('status', 'unsolved')
     order = self.get_args('o') or self.get_cookie(
         'order', 'p')  # _o - desc, o_ - asc
     page = self.get_args('p', 1)
     # 记录状态
     self.set_cookie('status', status)
     self.set_cookie('order', order)
     self.set_cookie('cur_auth', str(self.auth.id))
     # set order_by
     if order not in self._order.keys():
         order = 'p'
     order_by = self._order.get(order)
     page = int(page)
     pros = Auth.find_user_projects(uid=self.user.id)
     where = dict(uid=self.user.id, pid=self.pid, status=status)
     if status != 'assigned':
         tasks, num = Task.find_project_tasks(page=page,
                                              order_by=order_by,
                                              get_num=True,
                                              **where)
         paginator = Paginator(page, num, Task._per_page)
     else:
         tasks = Task.assigned_tasks(
             user_id=self.user.id,
             order_by=order_by,
             pid=self.pid,
         )
         paginator = None
     unread_num = Message.unread_num(user_id=self.user.id)
     return self.render('task-home.html',
                        cur_pro=self.auth,
                        pros=pros,
                        tasks=tasks,
                        status=status,
                        order=order,
                        page=page,
                        paginator=paginator,
                        unread_num=unread_num)