Пример #1
0
 def request_notification(car_problems, business_owner_id, car_id, job_id,
                          time):
     business_owner = User.load_user_reg_id(business_owner_id)
     car = Car.load_car(car_id)
     message = IWSAnnouncement.message_creator(car.name, car_problems, time)
     service_types = IWSAnnouncement.service_type_creator(car_problems)
     data = {
         'info': {
             Keys.CAR_INFO: {
                 Keys.NAME: car.name
             },
             Keys.PROBLEM: {
                 Keys.GRADE:
                 car_problems[0].services_definition.service_grade,
                 Keys.TYPES: service_types,
                 Keys.JOB_ID: job_id,
             },
             Keys.USER_TYPE: Keys.NEW_JOB_REQUEST,
         },
         Keys.ACTIONS: Result.language.ACCEPT_DENY_ACTIONS,
         Keys.MESSAGE: message,
         Keys.TITLE: Result.language.NEW_REQUEST_NOTIFICATION_TITLE,
         Keys.BUSINESS_OWNER: {
             Keys.NAME: business_owner.name,
             Keys.REG_ID: business_owner.reg_id
         }
     }
     response = PushNotification.push(
         data[Keys.BUSINESS_OWNER][Keys.REG_ID], data)
     return response
Пример #2
0
 def cancel_job(job):
     business_owner = User.load_user_reg_id(job.business_owner_id)
     car = Car.load_car(job.car_id)
     info = {
         Keys.USER_TYPE: Keys.CANCEL_JOB,
         Keys.CAR_INFO: {
             Keys.NAME: car.name
         },
         Keys.BUSINESS_OWNER: {
             Keys.NAME: business_owner.name,
             Keys.REG_ID: business_owner.reg_id
         }
     }
     response = PushNotification.push(
         [info[Keys.BUSINESS_OWNER][Keys.REG_ID]], info)
     return response