def _checkDetailSummary(self, year_week, teamID): weekDetails = self.find({"teamID": teamID, "year_week":year_week}) all_ok = True for detail in weekDetails: if detail['status'] not in [2, 3]: all_ok = False now_year_week = get_year_week_str() team = connection.Team.find_one({"_id":ObjectId(teamID)}) if team: if now_year_week == year_week: team.update({"week_detail_summary_flag":year_week}) team.save() now_time_str = str(datetime.datetime.now().isocalendar()[2]) + datetime.datetime.now().strftime('%H:%M') team_time_str = team['week_detail_summary_time'] if not all_ok and now_year_week == year_week and now_time_str <= team_time_str: return from db.cache import taskQueue week_summary = team.get_summary_week(year_week) users = team.get_users() _queue = {"type": "summaryWeek", "users": users, "value": week_summary, "team": team['name'], "now_flag":year_week} taskQueue.put(_queue)
def find_for_notify(self, teamID, member): year_week = get_year_week_str() return self.find_one({ "teamID":teamID, "username":member['name'], "useremail":member['email'], "year_week":year_week })
def get_summary_week(self, year_week=None): year_week = year_week or get_year_week_str() teamID = self['_id'] weeks = connection.WeekDetail.find({"teamID":teamID, "year_week":year_week}) weeks_detail = [] for w in weeks: _week = {} username = w['username'] _week['username'] = username _week['status'] = w['status'] _week['submit_list'] = w['submit_list'] _week['rfs'] = w['rfs'] weeks_detail.append(_week) return weeks_detail
def summaryWeekDetail(self, team): members = team['members'] week_detail_summary_time =team["week_detail_summary_time"] week_detail_summary_flag =team["week_detail_summary_flag"] now_time_str = str(datetime.datetime.now().isocalendar()[2]) + "-" + datetime.datetime.now().strftime('%H:%M') if now_time_str >= week_detail_summary_time: now_flag = get_year_week_str() if now_flag > week_detail_summary_flag: team.update({"week_detail_summary_flag": now_flag}) team['status'] = int(team['status']) team.save() week_summary = team.get_summary_week(now_flag) users = team.get_users() _queue = {"type": "summaryWeek", "users": users, "value": week_summary, "team": team['name'], "now_flag":now_flag} self.taskQueue.put(_queue)
def createByUserList(self, teamID, members, teamname, week_detail_summary_time): weekDetails = [] year_week = get_year_week_str() print week_detail_summary_time for m in members: if m['role'] not in [0, 3]: continue d = { "teamID": teamID, "teamname": teamname, "username": m["name"], "useremail": m["email"], "year_week": year_week } if connection.DayDetail.find_one(d): continue detail = [] weekDetail = self() weekDetail["status"] = 0 weekDetail["create_time"] = datetime.datetime.now() weekDetail["teamID"] = teamID weekDetail["teamname"] = teamname weekDetail["username"] = m["name"] weekDetail["useremail"] = m["email"] weekDetail["year_week"] = year_week weekDetail["submit_time"] = datetime.datetime.now() weekDetail["update_time"] = datetime.datetime.now() weekDetail["deadline_time"] = datetime.datetime.now() weekDetail["expend_time"] = 40 weekDetail.save() key = weekDetail['_id'] detail = [m["name"], m["email"], str(key)] weekDetails.append(detail) return weekDetails
def createWeekDetail(self, team): week_detail_create_time = team["week_detail_create_time"] week_detail_create_flag = team["week_detail_create_flag"] now_week_flag = str(datetime.datetime.now().isocalendar()[2]) + "-" + datetime.datetime.now().strftime('%H:%M') if now_week_flag > week_detail_create_time: now_flag = get_year_week_str() if now_flag > week_detail_create_flag: users = connection.WeekDetail.createByUserList(team['_id'], team['members'], team['name'], team['week_detail_summary_time']) team.update({"week_detail_create_flag": now_flag}) team.update({"week_detail_notify_flag": 0}) team['status'] = int(team['status']) team.save() _team = { "name": team['name'], "week_detail_summary_time":team['week_detail_summary_time'] } _value = { "team": _team } _queue = {"type":"createWeek", "value":_value, "users": users} self.taskQueue.put(_queue)