Example #1
0
def submit_study(request, format=None):
    """
    Submit a study
    ---

    serializer: SubmissionDetailSerializer
    omit_serializer: false

    produces:
        - application/json
    """
    if request.method == "POST":
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            try:
                submission = form.save()
                email = EmailMessage('Study submitted to AraPheno',
                                     submission.get_email_text(),
                                     '*****@*****.**',
                                     [submission.email],
                                     [settings.ADMINS[0][1]],
                                     reply_to=['*****@*****.**'])
                email.send(True)
                serializer = SubmissionDetailSerializer(
                    submission, many=False, context={'request': request})

                return Response(serializer.data, status.HTTP_201_CREATED)
            except Accession.DoesNotExist as err:
                return Response('Unknown accession with ID: %s' % err.args[-1],
                                status.HTTP_400_BAD_REQUEST)
            except Exception as err:
                return Response(str(err), status.HTTP_400_BAD_REQUEST)
        else:
            return Response('Some fields are missing',
                            status.HTTP_400_BAD_REQUEST)
Example #2
0
def submission_infos(request, pk, format=None):
    """
    Retrieve detailed information about the submission
    ---

    serializer: SubmissionDetailSerializer
    omit_serializer: false

    produces:
        - application/json
    """
    if request.method == "GET":
        try:
            submission = Submission.objects.get(pk=pk)
            serializer = SubmissionDetailSerializer(
                submission, many=False, context={'request': request})
            return Response(serializer.data)
        except Exception as err:
            return HttpResponse(str(err), status=404)