Esempio n. 1
0
    def find_by_id_verbose(self, key):
        task = self.find_one({"_id": ObjectId(key)})
        if task:
            teamID = task['teamID']

            team = connection.Team.find_one({"_id":teamID})
            if team:
                ms = team['members']
                members = []
                for m in ms:
                    members.append({"username":m['name'], "email":m['email'], "role": m['role']})
            else:
                return None

            status = task['status']

            priority = task['priority']

            remarks = task['remarks']

            name = task['name']

            explain = task['explain']

            dead_line_time = task['dead_line_time']
            dead_line_time = str(dead_line_time.year) + "年" + str(dead_line_time.month) + "月" + str(dead_line_time.day) + "日 " + str(dead_line_time.hour) + ":" + str(dead_line_time.minute)

            createtime = task['create_time']
            createtime = [str(createtime.year) + "年" + str(createtime.month) + "月" + str(createtime.day) + "日 " + str(createtime.hour) + ":" + str(createtime.minute) ,  createtime.weekday()]

            done_100 = task['done_100']

            taskDict = {
                "status": status,
                "dead_line_time": dead_line_time,
                "explain": explain,
                "remarks": remarks,
                "name": name,
                "createtime": createtime,
                "members": members,
                "priority": priority,
                "username": task["username"],
                "createusername": task["createusername"],
                "pubusername": task["pubusername"],
                "email": task["useremail"],
                "done_100": done_100,
                'start_time': [get_year_month_day_str_ch(task['start_time']), get_hour_minute_str(task['start_time'])],
                'done_time': [get_year_month_day_str_ch(task['done_time']), get_hour_minute_str(task['done_time'])],
            }
            return taskDict

        else:
            return None
Esempio n. 2
0
    def teamSummaryTask(self, team):
        year_week_day_str = get_year_week_day_str()
        now_hour_minute_str = get_hour_minute_str()
        team_task_summary_time = team['team_task_summary_time']
        team_task_summary_flag = team['team_task_summary_flag']

        if year_week_day_str == team_task_summary_flag:
            return
        else:
            if now_hour_minute_str < team_task_summary_time:
                return

        team.update({"team_task_summary_flag": year_week_day_str})
        team['status'] = int(team['status'])
        team.save()

        emailList = []

        userTaskList = []

        now_date_str = [get_year_month_day_str_ch(), get_week_str()]

        i = 0

        for m in team['members']:
            username = m['name']
            useremail = m['email']
            emailList.append(useremail)
            tasks_db = connection.Task.find({"teamID":team["_id"], "username":username, "useremail":useremail, "$or":[{"status":0} ,{"status":1}, {"status":3}]})
            tasks = []
            for t in tasks_db:
                task = {}
                task['username'] = username
                task['status'] = int(t['status'])
                task['name'] = t['name']
                task['id'] = str(t['_id'])
                task['rfs'] = t['rfs']
                task['pubusername'] = t['pubusername']
                task['explain'] = t['explain']
                task['remarks'] = t['remarks']
                task['priority'] = t['priority']
                task['done_100'] = t['done_100']
                task['dead_line_time'] = [get_year_month_day_str_ch(t['dead_line_time']), get_hour_minute_str(t['dead_line_time'])]
                tasks.append(task)
                i += 1
            userTaskList.append({"username": username, "tasks": tasks})
        if i == 0:
            return

        data = {
            "userTaskList": userTaskList,
            "teamID": team['_id'],
            "teamname": team['name'],
            "now_date_str": now_date_str, 
            "emails":emailList
        }

        _queue = {"type":"taskTeamSummary", "data":data}
        self.taskQueue.put(_queue)
Esempio n. 3
0
    def _get_tasks_by_status(self, thisteam, status):
        members = thisteam['members']

        u_t_l = []

        for m in members:
            u_t = {}
            username = m['name']
            email = m['email']
            tasks_db = connection.Task.find({"teamID":thisteam['_id'], "status":status, "useremail": email})
            tasks = []
            for t in tasks_db:
                task = {}
                task['username'] = username
                task['useremail'] = t['useremail']
                task['status'] = t['status']
                task['name'] = t['name']
                task['pubusername'] = t["pubusername"]
                task['explain'] = t['explain']
                task['remarks'] = t['remarks']
                task['priority'] = t['priority']
                task['done_100'] = t['done_100']
                task['weight'] = t['weight']
                task['score'] = t['score']
                task['dead_line_time'] = [get_year_month_day_str_ch(t['dead_line_time']), get_hour_minute_str(t['dead_line_time'])]
                task['start_time'] = [get_year_month_day_str_ch(t['start_time']), get_hour_minute_str(t['start_time'])]
                task['done_time'] = [get_year_month_day_str_ch(t['done_time']), get_hour_minute_str(t['done_time'])]
                task['id'] = str(t['_id'])
                tasks.append(task)
            if status == 2:
                tasks_db = connection.Task.find({"teamID":thisteam['_id'], "status":4, "useremail": email})
                for t in tasks_db:
                    task = {}
                    task['username'] = username
                    task['useremail'] = t['useremail']
                    task['status'] = t['status']
                    task['name'] = t['name']
                    task['pubusername'] = t["pubusername"]
                    task['explain'] = t['explain']
                    task['remarks'] = t['remarks']
                    task['priority'] = t['priority']
                    task['done_100'] = t['done_100']
                    task['weight'] = t['weight']
                    task['score'] = t['score']
                    task['dead_line_time'] = [get_year_month_day_str_ch(t['dead_line_time']), get_hour_minute_str(t['dead_line_time'])]
                    task['start_time'] = [get_year_month_day_str_ch(t['start_time']), get_hour_minute_str(t['start_time'])]
                    task['done_time'] = [get_year_month_day_str_ch(t['done_time']), get_hour_minute_str(t['done_time'])]
                    task['id'] = str(t['_id'])
                    tasks.append(task)

            if len(tasks) == 0:
                continue

            u_t['username'] = username
            u_t['email'] = email
            u_t['id'] = email
            u_t['tasks'] = tasks

            u_t_l.append(u_t)

        return u_t_l