Esempio n. 1
0
    def get(self):
        assignment_id = self.request.get('assignmentId', None)

        if assignment_id is None:
            self.not_found()
        elif assignment_id == 'ASSIGNMENT_ID_NOT_AVAILABLE':
            self.render('priv/hit_preview.html',
                        {'experiment': self.experiment})
        else:
            worker_id = self.request.get('workerId')

            worker = worker_lookup(worker_id, assignment_id)

            if worker is None:
                worker = Worker()
                worker.id = worker_id
                worker.assignment_id = assignment_id
                worker.experiment = self.experiment
                worker.nonce = nonce()
                worker.put()

            if worker.has_labeled_an_image():
                self.render('priv/first_stage_complete.html', {})
            else:
                self.render(
                    'priv/labeling_form.html', {
                        'image_url': self.experiment.images[0],
                        'form_action': self.request.url
                    })
Esempio n. 2
0
  def get(self):
    assignment_id = self.request.get('assignmentId', None)

    if assignment_id is None:
      self.not_found()
    elif assignment_id == 'ASSIGNMENT_ID_NOT_AVAILABLE':
      self.render('priv/hit_preview.html', {'experiment': self.experiment})
    else:
      worker_id = self.request.get('workerId')

      worker = worker_lookup(worker_id, assignment_id)

      if worker is None:
        worker = Worker()
        worker.id = worker_id
        worker.assignment_id = assignment_id
        worker.experiment = self.experiment
        worker.nonce = nonce()
        worker.put()

      if worker.has_labeled_an_image():
        self.render('priv/first_stage_complete.html', {})
      else:
        self.render('priv/labeling_form.html', {
          'image_url': self.experiment.images[0]
        , 'form_action': self.request.url
        })
Esempio n. 3
0
  def _fn(self, *args, **kwargs):
    worker_id = self.request.get('workerId', None)

    assignment_id = self.request.get('assignmentId', None)

    if worker_id is None:
      self.bad_request('No workerId')
    elif assignment_id is None:
      self.bad_request('No assignmentId')
    else:
      try:
        self.worker = worker_lookup(worker_id, assignment_id)

        if self.worker is None:
          self.not_found()
        else:
          return fn(self, *args, **kwargs)
      except datastore.BadKeyError:
        self.not_found()
Esempio n. 4
0
    def _fn(self, *args, **kwargs):
        worker_id = self.request.get('workerId', None)

        assignment_id = self.request.get('assignmentId', None)

        if worker_id is None:
            self.bad_request('No workerId')
        elif assignment_id is None:
            self.bad_request('No assignmentId')
        else:
            try:
                self.worker = worker_lookup(worker_id, assignment_id)

                if self.worker is None:
                    self.not_found()
                else:
                    return fn(self, *args, **kwargs)
            except datastore.BadKeyError:
                self.not_found()