コード例 #1
0
 def test_save_timer(self):
     dao = TimerDAO()
     t1 = TimerEntity(notes="My Test LegacyTimer Running!",
                      user=TestObjects().get_test_user(),
                      running=True)
     dao.put(t1)
     assert (t1.id is not None)
コード例 #2
0
 def delete(self, id):
     api_v1_root = '/api/v1'
     dao = TimerDAO()
     count_deleted = dao.delete(id)
     if count_deleted == 1:
         return Response(status=204)
     else:
         return Response(status=404)
コード例 #3
0
 def delete(self, id):
     api_v1_root = '/api/v1'
     dao = TimerDAO()
     count_deleted = dao.delete(id)
     if count_deleted == 1:
         return Response(status=204)
     else:
         return Response(status=404)
コード例 #4
0
    def get_many(self):
        args = self._get_args(request)
        # For now, just get everything for the current user:
        dao = TimerDAO()
        timers = dao.get_all_timers_for_user(current_user.id)
        formatter = TimerFormatter()
        timers_payload = [formatter.model_to_dict(timer) for timer in timers]

        return jsonify(dict(timers=timers_payload))
コード例 #5
0
    def get_many(self):
        args = self._get_args(request)
        # For now, just get everything for the current user:
        dao = TimerDAO()
        timers = dao.get_all_timers_for_user(current_user.id)
        formatter = TimerFormatter()
        timers_payload = [formatter.model_to_dict(timer) for timer in timers]

        return jsonify(dict(timers=timers_payload))
コード例 #6
0
 def post(self):
     api_v1_root = '/api/v1'
     timer = TimerFormatter().dict_to_model(TimerEntity, request.json)
     dao = TimerDAO()
     dao.put(timer)
     id = str(timer.id)
     resp = jsonify(dict(id=id))
     resp.headers["Location"] = self.make_location(request.url, id)
     resp.status_code = http.client.CREATED
     return resp
コード例 #7
0
 def get_one(self, id):
     parser = RequestParser()
     # Look only in the querystring
     parser.add_argument('user', location='args', default=None)
     args = parser.parse_args(request)
     dao = TimerDAO()
     timer = dao.get(id)
     as_dict = TimerFormatter().model_to_dict(timer)
     resp = jsonify(as_dict)
     return resp
コード例 #8
0
def index():
    user = current_user
    dao = TimerDAO()
    timers = dao.get_all_timers_for_user(current_user.id)
    formatter = TimerFormatter()
    timers_payload = [formatter.model_to_dict(timer) for timer in timers]
    #timers = render_template("timer/user_timer.html", userId=user.id, userEmail=user.email, authToken=user.get_auth_token())
    # timers_json = dumps(timers)

    return render_template("timer/user_timer.html", userId=user.id, userEmail=user.email, authToken=user.get_auth_token(), timers=timers_payload)
コード例 #9
0
 def post(self):
     api_v1_root = '/api/v1'
     timer = TimerFormatter().dict_to_model(TimerEntity, request.json)
     dao = TimerDAO()
     dao.put(timer)
     id = str(timer.id)
     resp = jsonify(dict(id=id))
     resp.headers["Location"] = self.make_location(request.url, id)
     resp.status_code = http.client.CREATED
     return resp
コード例 #10
0
 def get_one(self, id):
     parser = RequestParser()
     # Look only in the querystring
     parser.add_argument('user', location='args', default=None)
     args = parser.parse_args(request)
     dao = TimerDAO()
     timer = dao.get(id)
     as_dict = TimerFormatter().model_to_dict(timer)
     resp = jsonify(as_dict)
     return resp
コード例 #11
0
 def put(self, id):
     #api_v1_root = '/api/v1'
     timer_new = TimerFormatter().dict_to_model(TimerEntity, request.json)
     dao = TimerDAO()
     timer = dao.get(id)
     if timer is not None:
         timer.update_attributes(timer_new)
         dao.put(timer)
         id = str(timer.id)
         resp = jsonify(dict(id=id))
         #resp.headers["Location"] = api_v1_root + self.root + "/" + id
         resp.headers["Location"] = self.make_location(request.url, id)
         resp.status_code = http.client.OK
         return resp
コード例 #12
0
 def put(self, id):
     #api_v1_root = '/api/v1'
     timer_new = TimerFormatter().dict_to_model(TimerEntity, request.json)
     dao = TimerDAO()
     timer = dao.get(id)
     if timer is not None:
         timer.update_attributes(timer_new)
         dao.put(timer)
         id = str(timer.id)
         resp = jsonify(dict(id=id))
         #resp.headers["Location"] = api_v1_root + self.root + "/" + id
         resp.headers["Location"] = self.make_location(request.url, id)
         resp.status_code = http.client.OK
         return resp
コード例 #13
0
def project_hours():
    timerDao = TimerDAO()
    account = Account.objects(name="Goalboost").first()
    users = [user.id for user in account.get_users()]
    timer_stats = timerDao.get_weekly_timer_statistics(users, ["Goalboost"])
    return render_template("timer/project_hours.html", stats = timer_stats)
コード例 #14
0
 def test_save_timer(self):
     dao = TimerDAO()
     t1 = Timer(notes="My Test LegacyTimer Running!", user=TestObjects().get_test_user(), running=True)
     dao.put(t1)
     assert(t1.id is not None)