def get(self, request, *args, **kwargs): mturk_settings = self.session.config['mturk_hit_settings'] initial = { 'title': mturk_settings['title'], 'description': mturk_settings['description'], 'keywords': ', '.join(mturk_settings['keywords']), 'money_reward': self.session.config['participation_fee'], 'use_sandbox': settings.DEBUG, 'minutes_allotted_per_assignment': (mturk_settings['minutes_allotted_per_assignment']), 'expiration_hours': mturk_settings['expiration_hours'], 'assignments': self.session.mturk_num_participants, } form = self.get_form(initial=initial) context = self.get_context_data(form=form) url = self.request.build_absolute_uri( reverse('MTurkCreateHIT', args=(self.session.code, ))) parsed_url = urlparse(url) https = parsed_url.scheme == 'https' secured_url = urlunparse(parsed_url._replace(scheme='https')) aws_keys_exist = bool( getattr(settings, 'AWS_ACCESS_KEY_ID', None) and getattr(settings, 'AWS_SECRET_ACCESS_KEY', None)) boto3_installed = bool(boto3) mturk_ready = aws_keys_exist and boto3_installed and https missing_next_button_warning = MTurkValidator( self.session).validation_message() context.update({ # boto3 module must be imported, not None 'boto3_installed': boto3_installed, 'https': https, 'aws_keys_exist': aws_keys_exist, 'mturk_ready': mturk_ready, 'runserver': ('runserver' in sys.argv) or ('devserver' in sys.argv), 'secured_url': secured_url, 'missing_next_button_warning': missing_next_button_warning }) return self.render_to_response(context)
def get(self, request, **kwargs): mturk_settings = self.session.config['mturk_hit_settings'] keywords = mturk_settings['keywords'] if isinstance(keywords, (list, tuple)): keywords = ', '.join(keywords) initial = { 'title': mturk_settings['title'], 'description': mturk_settings['description'], 'keywords': keywords, 'money_reward': self.session.config['participation_fee'], 'use_sandbox': True, 'minutes_allotted_per_assignment': (mturk_settings['minutes_allotted_per_assignment']), 'expiration_hours': mturk_settings['expiration_hours'], 'assignments': self.session.mturk_num_participants, } form = self.get_form(initial=initial) url = self.request.build_absolute_uri() parsed_url = urlparse(url) https = parsed_url.scheme == 'https' context = self.get_context_data( form=form, boto3_installed=self.boto3_installed, https=https, aws_keys_exist=self.aws_keys_exist, mturk_ready=self.aws_keys_exist and self.boto3_installed and https, missing_next_button_warning=MTurkValidator( self.session).validation_message(), ) return self.render_to_response(context)