コード例 #1
0
    def post(self):
        detailID = self.get_argument('detailID', "")
        status = int(self.get_argument('status', 0))

        detail = connection.WeekDetail.find_one({'_id': ObjectId(detailID)})
        if detail:
            detail.update({"status": status})
            detail.save()
            self.write("Success")
            if status == 1:
                team = connection.Team.find_one({"_id": detail['teamID']})
                _team = {
                    "name": team['name'],
                    "week_detail_summary_time":team['week_detail_summary_time']
                }

                _users = []
                _userid = detail['userID']
                key = detail['_id']
                _user = connection.User.find_one({"_id":_userid})
                if _user:
                    name = _user['username']
                    email = _user['email']
                    _users.append([name, email, str(key)])

                _value = {
                    "team": _team
                }
                _queue = {"type":"notifyWeek", "value":_value, "users":_users}
                from db.cache import taskQueue
                taskQueue.put(_queue)
        else:
            self.write("Error")
コード例 #2
0
    def post(self):
        detailID = self.get_argument('detailID', "")
        status = int(self.get_argument('status', 0))

        detail = connection.DayDetail.find_one({'_id': ObjectId(detailID)})

        if detail:
            detail.update({"status": status})
            detail.save()
            self.write("Success")

            if status == 1:
                team = connection.Team.find_one({"_id": detail['teamID']})
                _team = {
                    "name": team['name'],
                    "day_detail_summary_time":team['day_detail_summary_time']
                }

                _users = [[detail["username"], detail["useremail"], str(detail['_id'])]]

                _value = {
                    "team": _team
                }
                _queue = {"type":"notifyDay", "value":_value, "users":_users}
                from db.cache import taskQueue
                taskQueue.put(_queue)
        else:
            self.write("Error")
コード例 #3
0
ファイル: model.py プロジェクト: wangxunxun/tornadoapp
    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)
コード例 #4
0
ファイル: model.py プロジェクト: wangxunxun/tornadoapp
    def newTask(self, teamID, teamname, username, useremail, createusername, createuseremail, pubusername, pubuseremail, name, explain, priority, dead_line_time, weight):
        def _priority2str(priority):
            if priority == 0:
                return u"紧急"
            elif priority == 1:
                return u"高"
            elif priority == 2:
                return u"中"
            elif priority == 3:
                return u"低"
            else:
                return u"随你便"
    
        def _datetime2str(d):
            return str(d.year) + "年" + str(d.month) + "月" + str(d.day) + "日 " + str(d.hour) + ":" + str(d.minute)

        task = self()
        task["teamID"] = teamID
        task["teamname"] = teamname
        
        task['username'] = username
        task['useremail'] = useremail

        task['createusername'] = createusername
        task['createuseremail'] = createuseremail

        task['pubusername'] = pubusername
        task['pubuseremail'] = pubuseremail

        task["name"] = name
        task["dead_line_time"] = dead_line_time
        task["priority"] = priority
        task["create_time"] = datetime.datetime.now()
        task["update_time"] = datetime.datetime.now()
        task["done_time"] = dead_line_time
        task["start_time"] = datetime.datetime.now()
        task["explain"] = explain
        task['weight'] = int(weight)

        task.save()
        
        createTaskEmail = {}        
    
        createTaskEmail["teamname"] = teamname
        createTaskEmail["username"] = username
        createTaskEmail['createUsername'] = createusername
        createTaskEmail["name"] = name
        createTaskEmail["dead_line_time"] = _datetime2str(dead_line_time)
        createTaskEmail["priority"] = _priority2str(priority)
        createTaskEmail["explain"] = explain
        createTaskEmail["now"] = _datetime2str(datetime.datetime.now())
        createTaskEmail['email'] = useremail
        
        from settings import host_url
        createTaskEmail['url'] = host_url + "/edit/task/" + str(task['_id'])

        from db.cache import taskQueue
        _queue = {"type": "createTask", "data":createTaskEmail}
        taskQueue.put(_queue)
コード例 #5
0
ファイル: model.py プロジェクト: wangxunxun/tornadoapp
    def _checkDetailSummary(self, year_week_day, teamID):

        now_year_week_day = get_year_week_day_str()
        team = connection.Team.find_one({"_id":ObjectId(teamID)})
        if team:
            now = datetime.datetime.now()
            _h = now.hour
            _m = now.minute
            if _h < 10:
                _h = "0" + str(_h)
            if _m < 10:
                _m = "0" + str(_m)
            now = str(_h) + ":" + str(_m)
            now = now_year_week_day + now

            team_day_detail_summary_time = team["day_detail_summary_time"]

            s_time = year_week_day + team_day_detail_summary_time

            if now > s_time:
                pass
            else:
                dayDetails = self.find({"teamID": teamID, "year_week_day":year_week_day})
                for detail in dayDetails:
                    if detail['status'] not in [2, 3]:
                        return

            if now_year_week_day == year_week_day:
                team.update({"day_detail_summary_flag":year_week_day})
                team.save()

            from db.cache import taskQueue
            day_summary = team.get_summary_day(year_week_day)
            users = team.get_users()
            _queue = {"type": "summaryDay", "users": users, "value": day_summary, "team": team['name'], "now_flag":year_week_day}
            taskQueue.put(_queue)
コード例 #6
0
ファイル: teamHandler.py プロジェクト: wangxunxun/tornadoapp
    def patch(self, teamID):
        def _priority2str(priority):
            if priority == 0:
                return u"紧急"
            elif priority == 1:
                return u"高"
            elif priority == 2:
                return u"中"
            elif priority == 3:
                return u"低"
            else:
                return u"随你便"
    
        def _datetime2str(d):
            return str(d.year) + "年" + str(d.month) + "月" + str(d.day) + "日 " + str(d.hour) + ":" + str(d.minute)

        taskid = self.get_argument("taskid", "")
        name = self.get_argument("name", "")
        explain = self.get_argument("explain", "")
        priority = int(self.get_argument("priority", "0"))
        dead_line_time = self.get_argument("dead_line_time", "")
        useremail = self.get_argument("useremail", "")
        username = self.get_argument("username", "")
        remarks = self.get_argument("remarks", "")
        status = int(self.get_argument("status", "0"))
        done_100 = int(self.get_argument("done_100", "0"))
        weight = int(self.get_argument("weight", "1"))
        score = float(self.get_argument("score", "1.0"))
        real_time = self.get_argument("real_time", "")

        task = connection.Task.find_one({"_id": ObjectId(taskid)})
        if task:
            dead_line_time = ",".join(dead_line_time.split(" "))
            dead_line_time = eval("datetime.datetime(" + dead_line_time + ")")

            real_time = ",".join(real_time.split(" "))
            real_time = eval("datetime.datetime(" + real_time + ")")

            now = datetime.datetime.now()

            if (now - dead_line_time).total_seconds() > 0:
                self.write(u"不要这么难为人嘛,人生没有后悔药,所以你也不能安排人家在已经消逝的时间里面完成未来的事情。")
            else:
                if status == 2 and real_time > dead_line_time:
                    status = 4
                task['status'] = status
                task['name'] = name
                task['priority'] = priority
                task['explain'] = explain
                task['done_100'] = done_100
                task['remarks'] = remarks
                task['username'] = username
                task['dead_line_time'] = dead_line_time
                task['update_time'] = datetime.datetime.now()
                task['weight'] = int(weight)
                task['score'] = float(score)
                if status == 1:
                    task['start_time'] = real_time
                elif status in [2, 4]:
                    task['done_time'] = real_time
                else:
                    pass

                if task['useremail'] == useremail:
                    task['useremail'] = useremail
                else:
                    thisuseremail = self.get_secure_cookie("user")
                    thisuser = connection.User.find_one({"email":thisuseremail})
                    thisusername = thisuser['name']
                    task['pubusername'] = thisusername
                    task['pubuseremail'] = thisuseremail

                    pubTaskEmail = {}
    
                    pubTaskEmail["teamname"] = task["teamname"]
                    pubTaskEmail["username"] = username
                    pubTaskEmail['pubusername'] = thisusername
                    pubTaskEmail["name"] = task['name']
                    pubTaskEmail["dead_line_time"] = _datetime2str(task["dead_line_time"])
                    pubTaskEmail["priority"] = _priority2str(task["priority"])
                    pubTaskEmail["explain"] = task["explain"]
                    pubTaskEmail["now"] = _datetime2str(datetime.datetime.now())
                    pubTaskEmail['email'] = useremail
                    
                    from settings import host_url
                    pubTaskEmail['url'] = host_url + "/edit/task/" + str(task['_id'])

                    from db.cache import taskQueue
                    _queue = {"type": "pubTask", "data":pubTaskEmail}
                    taskQueue.put(_queue)

                task.save()
                self.write("Success")
        else:
            self.write("No Task")
コード例 #7
0
ファイル: model.py プロジェクト: wangxunxun/tornadoapp
    def updateByService(self, key, status, pub, pub_text, update_task_remarks, update_task_done_100, real_time):
        def _priority2str(priority):
            if priority == 0:
                return u"紧急"
            elif priority == 1:
                return u"高"
            elif priority == 2:
                return u"中"
            elif priority == 3:
                return u"低"
            else:
                return u"随你便"
    
        def _datetime2str(d):
            return str(d.year) + "年" + str(d.month) + "月" + str(d.day) + "日 " + str(d.hour) + ":" + str(d.minute)

        task = self.find_one({"_id": ObjectId(key)})
        if status == 2 and real_time > task["dead_line_time"]:
            status = 4
        if task:
            if pub == 1:
                if status == 2 and real_time > task["dead_line_time"]:
                    status = 4
                useremail = pub_text.split("(")[1].split(")")[0]
                username = pub_text.split("(")[0]

                pubuseremail = task['useremail']
                pubusername = task['username']

                task['useremail'] = useremail
                task['username'] = username
                task['pubuseremail'] = pubuseremail
                task['pubusername'] = pubusername

                pubTaskEmail = {}
    
                pubTaskEmail["teamname"] = task["teamname"]
                pubTaskEmail["username"] = username
                pubTaskEmail['pubusername'] = pubusername
                pubTaskEmail["name"] = task['name']
                pubTaskEmail["dead_line_time"] = _datetime2str(task["dead_line_time"])
                pubTaskEmail["priority"] = _priority2str(task["priority"])
                pubTaskEmail["explain"] = task["explain"]
                pubTaskEmail["now"] = _datetime2str(datetime.datetime.now())
                pubTaskEmail['email'] = useremail
                
                from settings import host_url
                pubTaskEmail['url'] = host_url + "/edit/task/" + str(task['_id'])

                from db.cache import taskQueue
                _queue = {"type": "pubTask", "data":pubTaskEmail}
                taskQueue.put(_queue)

            task['status'] = status
            task['remarks'] = update_task_remarks
            task['done_100'] = update_task_done_100
            task['update_time'] = datetime.datetime.now()

            if status == 1:
                task['start_time'] = real_time
            elif status in [2, 4]:
                task['done_time'] = real_time
            else:
                pass

            if status in [2, 4]:
                task['done_100'] = 100
            if status == 0:
                task['done_100'] = 0
            task.save()
            return "Success"
        else:
            return "No Task"