Example #1
0
 def test_import_export(self):
     with sudo(User.objects.get_or_create(username='******')[0]):
         sf = self.create_submission_form()
         buf = StringIO()
         serializer = Serializer()
         serializer.write(sf, buf)
         cp = serializer.read(buf)
         self.compare(sf, cp)
Example #2
0
def export_submission(request, submission_pk):
    submission = get_object_or_404(Submission, pk=submission_pk)
    submission_form = submission.current_submission_form
    serializer = Serializer()
    buf = StringIO()
    serializer.write(submission_form, buf)
    response = HttpResponse(buf.getvalue(), mimetype='application/ecx')
    response['Content-Disposition'] = 'attachment;filename=%s.ecx' % submission.get_ec_number_display(separator='-')
    return response
Example #3
0
    def handle(self, ec_number, **options):
        try:
            s = Submission.objects.get(ec_number=ec_number)
        except Submission.DoesNotExist:
            raise CommandError("No submission matches the given EC-Number: %s" % ec_number)

        sf = s.current_submission_form
        if not sf:
            raise CommandError("This submission does not have an attached SubmissionForm.")

        f = file(options['out'] or "%s.ecx" % s.get_ec_number_display(separator='-'), 'w')
        ecxf = Serializer()
        ecxf.write(sf, f)
        f.close()