Example #1
0
 def post(self, id):
     order = Oder.objects().with_id(id)
     order.update(set__is_Shipping=True, set__is_Received=True)
     user = order.user
     if user.token is not None:
         apikey = "AAAAhgLLpbs:APA91bGLuFvqDwvWs7L7RNnMHwus426M1fi5oLSP2azB5jOhB2jW2i91uIZF7jrECoyUYk-c-h5yyp4DY0oKFhEgg3S6o7fsv7dc-M5aBDdwxbYaWgXVn3HFEqImNYEm6xfyeMqb4lAR"
         push_service = FCMNotification(api_key=apikey)
         push_service.notify_single_device(
             registration_id=user.token,
             message_body="Đơn hàng đã được giao cho shipper!",
             message_title="Chú ý!")
     return {"message": "OK"}, 200
Example #2
0
 def delete(self, id):
     oder = Oder.objects().with_id(id)
     oder.delete()
     user = oder.user
     if user.token is not None:
         apikey = "AAAAhgLLpbs:APA91bGLuFvqDwvWs7L7RNnMHwus426M1fi5oLSP2azB5jOhB2jW2i91uIZF7jrECoyUYk-c-h5yyp4DY0oKFhEgg3S6o7fsv7dc-M5aBDdwxbYaWgXVn3HFEqImNYEm6xfyeMqb4lAR"
         push_service = FCMNotification(api_key=apikey)
         push_service.notify_single_device(
             registration_id=user.token,
             message_body="Đơn hàng của bạn bị huỷ bỏ!",
             message_title="Cảm ơn bạn đã ghé thăm!")
     return {"message": "Ok"}, 200
Example #3
0
def create_event():
    data = request.get_json()
    club_schema = ClubsSchema()
    club_user = Clubs(public_id=str(uuid.uuid4()),
                      name=data['name'],
                      description=data['description'],
                      time_start=data['time_start'],
                      time_end=data['time_end'],
                      date_week=data['date_week'],
                      event_date=data['event_date'],
                      location=data['location'])
    db.session.add(club_user)
    db.session.commit()

    push_service = FCMNotification(
        api_key=
        "AAAAp-1UTKo:APA91bF9KFpF7_cBlfSohNuNTJL-UpLOKSp1b4S_vG44C3GezCsFM-86ltgf152LkZc_ngUblPWVk4ZVRpJZxH8TYuKGt-zje81fYb3A1AQAD0lY_W9EEOs3-nTH99YeRDIRuoIkWp4v"
    )

    registration_id = "ftKlJ-8Vq0E:APA91bFUgrXrt6LdW4_j3-Pe6IBYZwE26n5pQ-JJW-UnUp1pQx-bPe1tQgmBr5e0XfHs6dkStradmxybvD92CjmST328CrD9YU1UIhRKxq6ZAhY-2ox2Q1oA8bziZeQ9y16L9n_ULmnXwBOIDG3LkxVSwgRn5m_7_Q"
    message_title = "New Event Posted"
    message_body = club_user.name + ' ' + club_user.description + ' ' + club_user.time_start + ' ' + club_user.time_end + ' ' + club_user.date_week + ' ' + club_user.event_date + ' ' + club_user.location
    result = push_service.notify_single_device(registration_id=registration_id,
                                               message_title=message_title,
                                               message_body=message_body)
    print result
    return jsonify({
        'message': 'Club event created',
        'secret_id': club_user.public_id
    })
Example #4
0
 def put(self, id):
     oder = Oder.objects().with_id(id)
     if (oder.is_Succues == True):
         return {"message": "Cộng rồi"}, 401
     oder.update(set__is_Succues=True,
                 set__is_Received=True,
                 set__is_Shipping=True)
     oder_add = Oder.objects().with_id(id)
     user = oder["user"]
     spend = float(oder["spend"])
     spend_user = float(user["total_spend"])
     total = spend + spend_user
     user.update(total_spend=total)
     if user.token is not None:
         name = "bạn"
     if user.name is not None:
         name = user.name
         apikey = "AAAAhgLLpbs:APA91bGLuFvqDwvWs7L7RNnMHwus426M1fi5oLSP2azB5jOhB2jW2i91uIZF7jrECoyUYk-c-h5yyp4DY0oKFhEgg3S6o7fsv7dc-M5aBDdwxbYaWgXVn3HFEqImNYEm6xfyeMqb4lAR"
         push_service = FCMNotification(api_key=apikey)
         push_service.notify_single_device(
             registration_id=user.token,
             message_body="Chúc bạn ngon miệng!",
             message_title="Cảm ơn " + name + "!")
     return user.get_json(), 200