Beispiel #1
0
 def item(self, hit):
   return {
     'url': self.hit_url(hit)
   , 'title': hit.title
   , 'location': hit.location
   , 'time': unix_timestamp(hit.time)
   , 'key': str(hit.key())
   , 'added': datetime_format(hit.added)
   }
Beispiel #2
0
 def item(self, hit):
     return {
         'url': self.hit_url(hit),
         'title': hit.title,
         'location': hit.location,
         'time': unix_timestamp(hit.time),
         'key': str(hit.key()),
         'added': datetime_format(hit.added)
     }
Beispiel #3
0
  def get(self, key):
    hit = HIT.get(key)

    if hit:
      workers = []

      for worker in hit_workers(hit):
        workers.append({
          'last_seen': unix_timestamp(worker.last_seen)
        , 'remote_addr': worker.remote_addr
        , 'mturkid': worker.mturkid
        , 'assignment_id': worker.assignment_id
        , 'click_go': worker.click_go
        })

      self.json({'workers': workers})
    else:
      self.not_found()
Beispiel #4
0
    def get(self, key):
        hit = HIT.get(key)

        if hit:
            workers = []

            for worker in hit_workers(hit):
                workers.append({
                    'last_seen': unix_timestamp(worker.last_seen),
                    'remote_addr': worker.remote_addr,
                    'mturkid': worker.mturkid,
                    'assignment_id': worker.assignment_id,
                    'click_go': worker.click_go
                })

            self.json({'workers': workers})
        else:
            self.not_found()
Beispiel #5
0
    def get(self, key):
        hit = HIT.get(key)

        if hit:
            if self.request.get(
                    'assignmentId') != 'ASSIGNMENT_ID_NOT_AVAILABLE':
                if self.request.get('workerId') in hit.blacklist:
                    self.render('priv/hit_blacklisted.html',
                                {'title': hit.title})
                    return

                worker = worker_lookup(hit, self.request.get('workerId'))

                if worker is None:
                    worker = Worker()
                    worker.hit = hit
                    worker.mturkid = self.request.get('workerId')
                    worker.assignment_id = self.request.get('assignmentId')
                    worker.number = next_worker_number(hit)  # save number ASAP

                worker.remote_addr = self.request.remote_addr
                worker.user_agent = self.request.headers['User-Agent']
                worker.put()

                clickgo_url = json.dumps(self.worker_click_go(worker))

            else:
                clickgo_url = json.dumps('')

            self.render(
                'priv/hit_countdown.html', {
                    'time': unix_timestamp(hit.time),
                    'title': hit.title,
                    'heartbeat_url': json.dumps(self.hit_heartbeat_url(hit)),
                    'location_url': json.dumps(self.hit_location_url(hit)),
                    'info': hit.info,
                    'hit': hit,
                    'clickgo_url': clickgo_url
                })
        else:
            self.not_found()
Beispiel #6
0
  def get(self, key):
    hit = HIT.get(key)

    if hit:
      if hit.focal_time:
        focal_time = datetime_format(hit.focal_time)
      else:
        focal_time = None

      self.render('priv/hit_detail.html', {
        'hit': hit
      , 'hit_group_url': hit_group_url(hit)
      , 'added': datetime_format(hit.added)
      , 'timestamp': json.dumps(unix_timestamp(hit.time))
      , 'workers_url': json.dumps(self.hit_workers_url(hit))
      , 'cancel_url': json.dumps(self.hit_cancel_url(hit))
      , 'user': users.get_current_user()
      , 'focal_time': focal_time
      })
    else:
      self.not_found()
Beispiel #7
0
    def get(self, key):
        hit = HIT.get(key)

        if hit:
            if hit.focal_time:
                focal_time = datetime_format(hit.focal_time)
            else:
                focal_time = None

            self.render(
                'priv/hit_detail.html', {
                    'hit': hit,
                    'hit_group_url': hit_group_url(hit),
                    'added': datetime_format(hit.added),
                    'timestamp': json.dumps(unix_timestamp(hit.time)),
                    'workers_url': json.dumps(self.hit_workers_url(hit)),
                    'cancel_url': json.dumps(self.hit_cancel_url(hit)),
                    'user': users.get_current_user(),
                    'focal_time': focal_time
                })
        else:
            self.not_found()
Beispiel #8
0
  def get(self, key):
    hit = HIT.get(key)

    if hit:
      if self.request.get('assignmentId') != 'ASSIGNMENT_ID_NOT_AVAILABLE':
        if self.request.get('workerId') in hit.blacklist:
          self.render('priv/hit_blacklisted.html', {'title': hit.title})
          return

        worker = worker_lookup(hit, self.request.get('workerId'))

        if worker is None:
          worker = Worker()
          worker.hit = hit
          worker.mturkid = self.request.get('workerId')
          worker.assignment_id = self.request.get('assignmentId')
          worker.number = next_worker_number(hit)  # save number ASAP

        worker.remote_addr = self.request.remote_addr
        worker.user_agent = self.request.headers['User-Agent']
        worker.put()
      
        clickgo_url = json.dumps(self.worker_click_go(worker))

      else:
        clickgo_url = json.dumps('')

      self.render('priv/hit_countdown.html', {
        'time': unix_timestamp(hit.time)
      , 'title': hit.title
      , 'heartbeat_url': json.dumps(self.hit_heartbeat_url(hit))
      , 'location_url': json.dumps(self.hit_location_url(hit))
      , 'info': hit.info
      , 'hit': hit
      , 'clickgo_url': clickgo_url
      })
    else:
      self.not_found()