Example #1
0
    def get_dummy_submission(self, context_id):
        """
        this may works until the content of the fields do not start to be validated. like
        numbers shall contain only number, and not URL.
        This validation would not be implemented in validate_jmessage but in structures.Fields

        need to be enhanced generating appropriate data based on the fields.type
        """
        defer.returnValue({
            'context_id':
            context_id,
            'receivers': (yield get_context(context_id, 'en'))['receivers'],
            'files': [],
            'human_captcha_answer':
            0,
            'graph_captcha_answer':
            '',
            'proof_of_work_answer':
            0,
            'identity_provided':
            False,
            'total_score':
            0,
            'answers': (yield self.fill_random_answers(context_id))
        })
Example #2
0
    def get_dummy_submission(self, context_id):
        """
        this may works until the content of the fields do not start to be validated. like
        numbers shall contain only number, and not URL.
        This validation would not be implemented in validate_jmessage but in structures.Fields

        need to be enhanced generating appropriate data based on the fields.type
        """
        defer.returnValue({
            'context_id': context_id,
            'receivers': (yield get_context(context_id, 'en'))['receivers'],
            'files': [],
            'human_captcha_answer': 0,
            'graph_captcha_answer': '',
            'proof_of_work_answer': 0,
            'identity_provided': False,
            'answers': (yield self.fill_random_answers(context_id))
        })
Example #3
0
    def get_dummy_submission(self, context_id):
        """
        this may works until the content of the fields do not start to be validated. like
        numbers shall contain only number, and not URL.
        This validation would not be implemented in validate_jmessage but in structures.Fields

        need to be enhanced generating appropriate data based on the fields.type
        """
        dummySubmissionDict = {}
        dummySubmissionDict['context_id'] = context_id
        dummySubmissionDict['receivers'] = (yield get_context(context_id, 'en'))['receivers']
        dummySubmissionDict['files'] = []
        dummySubmissionDict['human_captcha_answer'] = 0
        dummySubmissionDict['graph_captcha_answer'] = ''
        dummySubmissionDict['proof_of_work_answer'] = 0
        dummySubmissionDict['identity_provided'] = False
        dummySubmissionDict['answers'] = yield self.fill_random_answers(context_id)

        defer.returnValue(dummySubmissionDict)
Example #4
0
    def get_dummy_submission(self, context_id):
        """
        this may works until the content of the fields do not start to be validated. like
        numbers shall contain only number, and not URL.
        This validation would not be implemented in validate_jmessage but in structures.Fields

        need to be enhanced generating appropriate data based on the fields.type
        """
        context = yield get_context(1, context_id, 'en')
        answers = yield self.fill_random_answers(context['questionnaire_id'])

        defer.returnValue({
            'context_id': context_id,
            'receivers': context['receivers'],
            'files': [],
            'answer': 0,
            'identity_provided': False,
            'total_score': 0,
            'answers': answers
        })
Example #5
0
    def get_dummy_submission(self, context_id):
        """
        this may works until the content of the fields do not start to be validated. like
        numbers shall contain only number, and not URL.
        This validation would not be implemented in validate_jmessage but in structures.Fields

        need to be enhanced generating appropriate data based on the fields.type
        """
        context = yield get_context(1, context_id, 'en')
        answers = yield self.fill_random_answers(context['questionnaire_id'])

        defer.returnValue({
            'context_id': context_id,
            'receivers': context['receivers'],
            'removed_files': [],
            'answer': 0,
            'identity_provided': False,
            'total_score': 0,
            'answers': answers
        })
Example #6
0
    def get_dummy_submission(self, context_id):
        """
        this may works until the content of the fields do not start to be validated. like
        numbers shall contain only number, and not URL.
        This validation would not be implemented in validate_jmessage but in structures.Fields

        need to be enhanced generating appropriate data based on the fields.type
        """
        dummySubmissionDict = {}
        dummySubmissionDict['context_id'] = context_id
        dummySubmissionDict['receivers'] = (yield
                                            get_context(context_id,
                                                        'en'))['receivers']
        dummySubmissionDict['files'] = []
        dummySubmissionDict['human_captcha_answer'] = 0
        dummySubmissionDict['graph_captcha_answer'] = ''
        dummySubmissionDict['proof_of_work_answer'] = 0
        dummySubmissionDict['identity_provided'] = False
        dummySubmissionDict['answers'] = yield self.fill_random_answers(
            context_id)

        defer.returnValue(dummySubmissionDict)
Example #7
0
    def post(self, rtip_id):
        files_dict = yield download_all_files(self.current_user.user_id, rtip_id)
        node_dict = yield node.admin_serialize_node(self.request.language)
        receiver_dict = yield get_receiver_from_rtip(rtip_id, self.request.language)
        rtip_dict = yield get_rtip_info(rtip_id, self.request.language)
        collection_tip_dict = yield get_collection_info(rtip_id)
        context_dict = yield context.get_context(rtip_dict['context_id'], 'en')
        notif_dict = yield notification.get_notification(self.request.language)

        mock_event = Event(
            type=u'archive_description',
            trigger='Download',
            node_info=node_dict,
            receiver_info=receiver_dict,
            context_info=context_dict,
            tip_info=rtip_dict,
            subevent_info=collection_tip_dict,
            do_mail=False,
        )

        formatted_coll = Templating().format_template(notif_dict['archive_description'], mock_event).encode('utf-8')

        files_dict.append(
            {
               'buf': formatted_coll,
               'name': "COLLECTION_INFO.txt"
            }
        )

        self.set_status(200)

        self.set_header('X-Download-Options', 'noopen')
        self.set_header('Content-Type', 'application/octet-stream')
        self.set_header('Content-Disposition', 'attachment; filename=\"collection.zip\"')

        for data in ZipStream(files_dict):
            self.write(data)

        self.finish()