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)
Exemple #2
0
    def get(self, teamID):

        def get_year_week_day_list():
            _ = []
            now_flag_year_week = "-".join([str(i) for i in datetime.datetime.now().isocalendar()[:2]])
            now_day = datetime.datetime.now().isocalendar()[2]
            for d in xrange(1, now_day+1):
                if d in [1,2,3,4,5]:
                    _.append(now_flag_year_week + "-" + str(d))

            return _

        def get_week_str(i):
            s = i.split("-")[2]
            if s == "1":
                return "周一"
            elif s == "2":
                return "周二"
            elif s == "3":
                return "周三"
            elif s == "4":
                return "周四"
            elif s == "5":
                return "周五"
            elif s == "6":
                return "周六"
            elif s == "7":
                return "周日"
            else:
                return "见鬼了"


        email = self.get_secure_cookie("user")
        user = connection.User.get_user_by_email(email)
        if user:
            username = user['name']
            email = user['email']
        else:
            username = email
        userID = user['_id']
        teamID = ObjectId(teamID)

        _d = datetime.datetime.now()
        date_str = str(_d.year) + u"年" + str(_d.month) + u"月" + str(_d.day) + u"日"

        team = connection.Team.find_one({"_id": teamID})
        members = team['members']

        details = []

        for m in members:
            user_daydetails = []
            _username = m['name']
            for ywd in get_year_week_day_list():
                detail = connection.DayDetail.find_one({"teamID": teamID, "useremail": m['email'], "year_week_day": ywd})
                if detail:
                    user_daydetails.append([detail, get_week_str(ywd)])

            if len(user_daydetails) > 0:
                details.append([_username, user_daydetails])


        self.render("summary_report_day.html", owner=username, date=date_str, details=details)