示例#1
0
  def _getShipmentInfo(self):
    if not self._shipment_info:
      id = int(self.data.kwargs['id'])
      self._shipment_info= ShipmentInfo.get_by_id(
          id, parent=self.data.program)

    return self._shipment_info
示例#2
0
 def context(self):
   query = ShipmentInfo.all().ancestor(self.data.program)
   shipment_infos = query.fetch(self.DEF_BATCH_SIZE)
   self.redirect.program()
   return {
       'page_name': 'Sync Trackings Data for %s' % self.data.program.name,
       'shipment_infos': shipment_infos,
       'start_shipment_sync_url': self.redirect.urlOf('start_shipment_sync'),
   }
示例#3
0
  def getListData(self):
    idx = lists.getListIndex(self.request)
    if idx != 0:
      return None

    q = ShipmentInfo.all().ancestor(self.data.program)
    starter = lists.keyStarter
    response_builder = lists.RawQueryContentResponseBuilder(
        self.request, self._list_config, q, starter)

    return response_builder.build()
示例#4
0
  def post(self):
    service = oauth_helper.createDocsServiceWithAccessToken(self.data)

    shipment_info_id = self.data.POST['id']
    shipment_info = ShipmentInfo.get_by_id(
        int(shipment_info_id), parent=self.data.program)

    link = shipment_info.spreadsheet_link
    resource_key = gdocs_helper.get_resource_key_from_document_link(link)
    resource_id = 'spreadsheet:%s' % resource_key

    #get sheet content for USA students
    usa_sheet_content = gdocs_helper.get_content(
        service, resource_id, return_as='csv', gid=0)

    #get sheet content for international students
    intl_sheet_content = gdocs_helper.get_content(
        service, resource_id, return_as='csv', gid=3)

    task_start_url = self.redirect.urlOf('shipment_sync_task_start')

    #start task for USA students
    params = {
        'program_key': str(self.data.program.key()),
        'sheet_content': simplejson.dumps(usa_sheet_content),
        'sheet_type': 'usa',
        'shipment_info_id': shipment_info_id,
    }
    taskqueue.add(url=task_start_url, params=params)

    #start task for international students
    params = {
        'program_key': str(self.data.program.key()),
        'sheet_content': simplejson.dumps(intl_sheet_content),
        'sheet_type': 'intl',
        'shipment_info_id': shipment_info_id,
    }
    taskqueue.add(url=task_start_url, params=params)

    #return back to sync data page
    self.redirect.program()
    self.redirect.to('trackings_sync_data')
示例#5
0
 def setShipmentInfo(self, shipment_info_id):
   self.__shipment_info = ShipmentInfo.get_by_id(shipment_info_id,
                                                 parent=self.__program)