Пример #1
0
def view_signup_page(request):

    d = get_common_dict(request, 'Sign Up', signup_page=True)

    # If the person is already logged in, go to the homepage
    #
    if request.user.is_authenticated():
        return HttpResponseRedirect(reverse('view_homepage', kwargs={}))

    if request.POST:
        f = SignUpForm(request.POST)
        if f.is_valid():
            tb_user = f.create_tb_user()
            #return HttpResponse('TB user created: %s' % tb_user)
            success_url = reverse('view_signup_success',
                                 kwargs=dict(tb_user_md5=tb_user.md5)
                                )
            return HttpResponseRedirect(success_url)
        else:
            d['ERROR_FOUND'] = True
    else:
        #test_data = get_signup_form_test_data()
        #f = SignUpForm(initial=test_data)
        f = SignUpForm()

    d['signup_form'] = f

    return render_to_response('tb_users/signup_page.html',
                             d,
                             context_instance=RequestContext(request))
Пример #2
0
def view_login_page(request, just_logged_out=False):

    d = get_common_dict(request, 'Log In', login_page=True)
    d['JUST_LOGGED_OUT'] = just_logged_out

    # If the person is already logged in, go to the homepage
    #
    if request.user.is_authenticated():
        d['ALREADY_LOGGED_IN'] = True
        return render_to_response('tb_users/login_page.html',
                             d,
                             context_instance=RequestContext(request))

    if request.POST:
        f = TBUserAuthenticationForm(data=request.POST)
        if f.is_valid():
            user_obj = f.get_user()

            # Log the person in
            login(request, f.get_user())

            # Go to log in success
            success_url = reverse('view_homepage_just_logged_in', kwargs={})
            return HttpResponseRedirect(success_url)

        else:
            d['ERROR_FOUND'] = True
    else:
        f = TBUserAuthenticationForm()

    d['login_form'] = f

    return render_to_response('tb_users/login_page.html',
                             d,
                             context_instance=RequestContext(request))
Пример #3
0
def view_map_page(request):

  d = get_common_dict(request, 'Map', map_page=True)

  return render_to_response('maps/basic_map.html'\
                            , d\
                            , context_instance=RequestContext(request))
Пример #4
0
def view_signup_page(request):

    d = get_common_dict(request, 'Sign Up', signup_page=True)

    # If the person is already logged in, go to the homepage
    #
    if request.user.is_authenticated():
        return HttpResponseRedirect(reverse('view_homepage', kwargs={}))

    if request.POST:
        f = SignUpForm(request.POST)
        if f.is_valid():
            tb_user = f.create_tb_user()
            #return HttpResponse('TB user created: %s' % tb_user)
            success_url = reverse('view_signup_success',
                                  kwargs=dict(tb_user_md5=tb_user.md5))
            return HttpResponseRedirect(success_url)
        else:
            d['ERROR_FOUND'] = True
    else:
        #test_data = get_signup_form_test_data()
        #f = SignUpForm(initial=test_data)
        f = SignUpForm()

    d['signup_form'] = f

    return render_to_response('tb_users/signup_page.html',
                              d,
                              context_instance=RequestContext(request))
Пример #5
0
def view_dataset_contact(request, dataset_md5):
    return HttpResponse('contact here')
    d = get_common_dict(request, 'My Dataset Contact', view_my_datasets=True)

    # Not logged in, show login message
    #
    if not request.user.is_authenticated():
        return render_to_response('predict/my_dataset_contact.html',
                             d,
                             context_instance=RequestContext(request))

    try:
        dataset = PredictDataset.objects.get(md5=dataset_md5)
    except PredictDataset.DoesNotExist:
        raise Http404('PredictDataset not found')

    if not request.user == dataset.user.user:
        raise Http404('This is not your dataset')

    d['dataset'] = dataset
    d['dataset_notes'] = PredictDatasetNote.objects.filter(dataset=dataset).all()
    d['tb_user'] = dataset.user

    return render_to_response('predict/my_dataset_contact.html',
                             d,
                             context_instance=RequestContext(request))
Пример #6
0
def view_explore_page(request):

    d = get_common_dict(request, 'Explore', explore_page=True)

    explore_link_info = ExploreDataFileInfo.objects.filter(active=True).first()
    d.update(dict(explore_link_info=explore_link_info))

    return render_to_response('explore.html'\
                            , d\
                            , context_instance=RequestContext(request))
Пример #7
0
def view_explore_page(request):

    d = get_common_dict(request, 'Explore', explore_page=True)

    explore_link_info = ExploreDataFileInfo.objects.filter(active=True).first()
    d.update(dict(explore_link_info=explore_link_info))

    return render_to_response('explore.html'\
                            , d\
                            , context_instance=RequestContext(request))
Пример #8
0
def view_homepage(request, just_logged_in=False):

    d = get_common_dict(request, 'Home', home_page=True)

    d['just_logged_in'] = just_logged_in

    #d['page_title'] = 'Phthisis Ravens: TB Project'

    return render_to_response('homepage.html'\
                              , d\
                              , context_instance=RequestContext(request))
Пример #9
0
def view_homepage(request, just_logged_in=False):

    d = get_common_dict(request, 'Home', home_page=True)

    d['just_logged_in'] = just_logged_in

    #d['page_title'] = 'Phthisis Ravens: TB Project'

    return render_to_response('homepage.html'\
                              , d\
                              , context_instance=RequestContext(request))
Пример #10
0
def view_logout_page(request):

    d = get_common_dict(request, 'Log Out', logout_page=True)

    # Not logged in, redirect to the log in page
    if d[IS_LOGGED_IN_KEY] is False:
        d['NOT_LOGGED_IN'] = True
        login_url = reverse('view_login_page',
                                 kwargs={})

        return HttpResponseRedirect(login_url)

    # Log the person out
    logout(request)

    return view_login_after_logout(request)
Пример #11
0
def view_my_datasets(request):
    d = get_common_dict(request, 'My Datasets', view_my_datasets=True)

    # Not logged in, show login message
    #
    if not request.user.is_authenticated():
        return render_to_response('predict/my_datasets.html',
                                  d,
                                  context_instance=RequestContext(request))

    d['datasets'] = PredictDataset.objects.filter(user=request.user.tbuser)

    return render_to_response('predict/my_datasets.html',
                              d,
                              context_instance=RequestContext(request))
    """
Пример #12
0
def view_test_upload_success(request):


    #print ('msg_or_data', type(msg_or_data))
    d = get_common_dict(request, 'Test Predict Upload Success', predict_page=True)

    d['UPLOAD_SUCCESS'] = True

    d['FILE_PROCESS_SUCCESS'] = True
    d['FILE_PROCESS_ERR_OR_DATA'] = { 'test_data' : True }#msg_or_data

    #d['shared_file_info'] = shared_file_info


    return render_to_response('predict/predict_upload_success.html',
                             d,
                             context_instance=RequestContext(request))
Пример #13
0
def view_test_upload_success(request):

    #print ('msg_or_data', type(msg_or_data))
    d = get_common_dict(request,
                        'Test Predict Upload Success',
                        predict_page=True)

    d['UPLOAD_SUCCESS'] = True

    d['FILE_PROCESS_SUCCESS'] = True
    d['FILE_PROCESS_ERR_OR_DATA'] = {'test_data': True}  #msg_or_data

    #d['shared_file_info'] = shared_file_info

    return render_to_response('predict/predict_upload_success.html',
                              d,
                              context_instance=RequestContext(request))
Пример #14
0
def view_my_datasets(request):
    d = get_common_dict(request, 'My Datasets', view_my_datasets=True)

    # Not logged in, show login message
    #
    if not request.user.is_authenticated():
        return render_to_response('predict/my_datasets.html',
                             d,
                             context_instance=RequestContext(request))


    d['datasets'] = PredictDataset.objects.filter(user=request.user.tbuser)

    return render_to_response('predict/my_datasets.html',
                             d,
                             context_instance=RequestContext(request))
    """
Пример #15
0
def view_predict_upload_success(request, dataset_md5):

    d = get_common_dict(request, 'Predict Upload Success', predict_page=True)

    try:
        dataset = PredictDataset.objects.get(md5=dataset_md5)
    except PredictDataset.DoesNotExist:
        raise Http404('PredictDataset not found')

    d['dbox_log'] = DropboxRetrievalLog.objects.filter(dataset=dataset).first()
    #print ('get it?', d['dbox_log'])

    d['dataset'] = dataset
    d['tb_user'] = dataset.user

    return render_to_response('predict/predict_upload_success.html',
                              d,
                              context_instance=RequestContext(request))
Пример #16
0
def view_predict_upload_success(request, dataset_md5):

    d = get_common_dict(request, 'Predict Upload Success', predict_page=True)

    try:
        dataset = PredictDataset.objects.get(md5=dataset_md5)
    except PredictDataset.DoesNotExist:
        raise Http404('PredictDataset not found')

    d['dbox_log'] = DropboxRetrievalLog.objects.filter(dataset=dataset).first()
    #print ('get it?', d['dbox_log'])

    d['dataset'] = dataset
    d['tb_user'] = dataset.user

    return render_to_response('predict/predict_upload_success.html',
                             d,
                             context_instance=RequestContext(request))
Пример #17
0
def view_single_dataset(request, dataset_md5):

    d = get_common_dict(request, 'My Dataset Detail', view_my_datasets=True)

    # Not logged in, show login message
    #
    if not request.user.is_authenticated():
        return render_to_response('predict/my_dataset_detail.html',
                                  d,
                                  context_instance=RequestContext(request))

    try:
        dataset = PredictDataset.objects.get(md5=dataset_md5)
    except PredictDataset.DoesNotExist:
        raise Http404('PredictDataset not found')

    d['dataset'] = dataset
    d['dataset_notes'] = PredictDatasetNote.objects.filter(
        dataset=dataset).all()
    d['script_runs'] = DatasetScriptRun.objects.filter(dataset=dataset).all()
    d['tb_user'] = dataset.user

    # Pipeline command
    (pipeline_command_found, pipeline_command_or_err
     ) = PipelineScriptRunner.get_pipeline_command(dataset)
    d['pipeline_command_found'] = pipeline_command_found

    try:
        local_directory_contents = os.listdir(dataset.file_directory)
        d['local_directory_contents'] = local_directory_contents
    except:
        d['local_directory_err'] = "Could not list directory contents"

    if pipeline_command_found:
        d['pipeline_command'] = pipeline_command_or_err
    else:
        d['pipeline_command_err'] = pipeline_command_or_err

    return render_to_response('predict/my_dataset_detail.html',
                              d,
                              context_instance=RequestContext(request))
Пример #18
0
def view_predict_page(request, previous_attempt_deleted=False):

    #logger.info("view_predict_page: info")
    #logger.error('ahhh!')
    logging.debug("view_predict_page")

    d = get_common_dict(request, 'Predict', predict_page=True)

    d['PREVIOUS_ATTEMPT_DELETED'] = previous_attempt_deleted

    # Not logged in, show login message
    #
    if not request.user.is_authenticated():
        return render_to_response('predict/predict_upload.html',
                             d,
                             context_instance=RequestContext(request))

    if request.POST:

        f = UploadPredictionDataForm(request.POST)
        if f.is_valid():
            new_dataset = f.get_dataset(request.user.tbuser)

            #kick_off_retrieval(new_dataset)
            #get_dropbox_metadata(new_dataset)
            #send_new_dataset_message_to_tb_admins(new_dataset)

            success_url = reverse('view_predict_upload_step2_confirm',
                                  kwargs=dict(dataset_md5=new_dataset.md5)
                                )
            return HttpResponseRedirect(success_url)
        else:
            d['ERROR_FOUND']  = True
    else:
        f = UploadPredictionDataForm(label_suffix='')

    d['predict_form'] = f

    return render_to_response('predict/predict_upload.html',
                             d,
                             context_instance=RequestContext(request))
Пример #19
0
def view_predict_page(request, previous_attempt_deleted=False):

    #logger.info("view_predict_page: info")
    #logger.error('ahhh!')
    logging.debug("view_predict_page")

    d = get_common_dict(request, 'Predict', predict_page=True)

    d['PREVIOUS_ATTEMPT_DELETED'] = previous_attempt_deleted

    # Not logged in, show login message
    #
    if not request.user.is_authenticated():
        return render_to_response('predict/predict_upload.html',
                                  d,
                                  context_instance=RequestContext(request))

    if request.POST:

        f = UploadPredictionDataForm(request.POST)
        if f.is_valid():
            new_dataset = f.get_dataset(request.user.tbuser)

            #kick_off_retrieval(new_dataset)
            #get_dropbox_metadata(new_dataset)
            #send_new_dataset_message_to_tb_admins(new_dataset)

            success_url = reverse('view_predict_upload_step2_confirm',
                                  kwargs=dict(dataset_md5=new_dataset.md5))
            return HttpResponseRedirect(success_url)
        else:
            d['ERROR_FOUND'] = True
    else:
        f = UploadPredictionDataForm(label_suffix='')

    d['predict_form'] = f

    return render_to_response('predict/predict_upload.html',
                              d,
                              context_instance=RequestContext(request))
Пример #20
0
def view_single_dataset(request, dataset_md5):

    d = get_common_dict(request, 'My Dataset Detail', view_my_datasets=True)

    # Not logged in, show login message
    #
    if not request.user.is_authenticated():
        return render_to_response('predict/my_dataset_detail.html',
                             d,
                             context_instance=RequestContext(request))

    try:
        dataset = PredictDataset.objects.get(md5=dataset_md5)
    except PredictDataset.DoesNotExist:
        raise Http404('PredictDataset not found')

    d['dataset'] = dataset
    d['dataset_notes'] = PredictDatasetNote.objects.filter(dataset=dataset).all()
    d['script_runs'] = DatasetScriptRun.objects.filter(dataset=dataset).all()
    d['tb_user'] = dataset.user

    # Pipeline command
    (pipeline_command_found, pipeline_command_or_err) = PipelineScriptRunner.get_pipeline_command(dataset)
    d['pipeline_command_found'] = pipeline_command_found

    try:
        local_directory_contents = os.listdir(dataset.file_directory)
        d['local_directory_contents'] = local_directory_contents
    except:
        d['local_directory_err'] = "Could not list directory contents"

    if pipeline_command_found:
        d['pipeline_command'] = pipeline_command_or_err
    else:
        d['pipeline_command_err'] = pipeline_command_or_err

    return render_to_response('predict/my_dataset_detail.html',
                             d,
                             context_instance=RequestContext(request))
Пример #21
0
def view_signup_success(request, tb_user_md5):

    d = get_common_dict(request, 'Sign Up', signup_page=True)

    try:
        tb_user = TBUser.objects.get(md5=tb_user_md5)
    except TBUser.DoesNotExist:
        raise Http404('User not found')

    # This page should only be seen once, expire it in 10 minutes
    #
    right_now = timezone.now()  #datetime.now()
    elapsed = right_now - tb_user.user.date_joined
    if elapsed > timedelta(minutes=15):
        raise Http404('Page not found')

    d['tb_user'] = tb_user.user
    d['tb_user_affiliation'] = tb_user.affiliation

    return render_to_response('tb_users/signup_success_page.html',
                              d,
                              context_instance=RequestContext(request))
Пример #22
0
def view_signup_success(request, tb_user_md5):


    d = get_common_dict(request, 'Sign Up', signup_page=True)

    try:
        tb_user = TBUser.objects.get(md5=tb_user_md5)
    except TBUser.DoesNotExist:
        raise Http404('User not found')

    # This page should only be seen once, expire it in 10 minutes
    #
    right_now = timezone.now()  #datetime.now()
    elapsed = right_now - tb_user.user.date_joined
    if elapsed > timedelta(minutes=15):
        raise Http404('Page not found')

    d['tb_user'] = tb_user.user
    d['tb_user_affiliation'] = tb_user.affiliation

    return render_to_response('tb_users/signup_success_page.html',
                             d,
                             context_instance=RequestContext(request))
Пример #23
0
def view_data_upload_information(request):
    d = get_common_dict(request, 'Data Upload', share_page=True)

    return render_to_response('data_upload_instructions.html'\
                            , d\
                            , context_instance=RequestContext(request))
Пример #24
0
def view_data_upload_information(request):
    d = get_common_dict(request, 'Data Upload', share_page=True)

    return render_to_response('data_upload_instructions.html'\
                            , d\
                            , context_instance=RequestContext(request))
Пример #25
0
def view_share_page(request):
    d = get_common_dict(request, 'Share', share_page=True)

    return render_to_response('share.html'\
                            , d\
                            , context_instance=RequestContext(request))
Пример #26
0
def view_about_page(request):
    d = get_common_dict(request, 'About', about_page=True)

    return render_to_response('about.html'\
                              , d\
                              , context_instance=RequestContext(request))
Пример #27
0
def view_predict_upload_step2_confirm(request, dataset_md5):
    """
    At this point:
        - We have a PredictDataset object and
        - Have validated the Dropbox link--it has either .fastq or .vcf files

    Now, Ask the user to confirm that these are the files
    """
    d = get_common_dict(request, 'Predict Upload - Confirm', predict_page=True)

    # Retrieve the PredictDataset
    #
    try:
        predict_dataset = PredictDataset.objects.get(md5=dataset_md5)
    except PredictDataset.DoesNotExist:
        raise Http404('PredictDataset not found')

    d['dataset'] = predict_dataset
    d['tb_user'] = predict_dataset.user


    # Retrieve the DropboxRetrievalLog
    #
    dbox_log = DropboxRetrievalLog.objects.filter(dataset=predict_dataset).first()
    if dbox_log is None:
        raise Http404('DropboxRetrievalLog for PredictDataset not found')

    # Handle this better!
    if dbox_log.file_metadata_err_msg:
        return HttpResponse('DropboxRetrievalLog shows fail: {0}<br />{1}'.format(\
                        dbox_log.file_metadata_err_msg, 'view_predict_upload_step2_confirm')
                        )

    # Show or validate the confirmation form
    #
    if request.POST:
        f = SimpleConfirmationForm(request.POST)
        if f.is_valid():
            if f.do_not_use_files():
                """
                Delete the info and return to predict Upload page
                """
                predict_dataset.delete() # cascades to DropboxRetrievalLog
                next_url = reverse('view_predict_upload_delete', args=())
            else:
                # Cron job will kick off download process
                predict_dataset.set_status_confirmed()
                next_url = reverse('view_predict_upload_success',
                                  kwargs=dict(dataset_md5=predict_dataset.md5)
                                )
            return HttpResponseRedirect(next_url)
        else:
            d['ERROR_FOUND']  = True
    else:
        f = SimpleConfirmationForm()

    d['dbox_log'] = dbox_log
    d['confirm_form'] = f

    return render_to_response('predict/predict_upload_step2.html',
                        d,
                        context_instance=RequestContext(request))
Пример #28
0
def view_share_page(request):
    d = get_common_dict(request, 'Share', share_page=True)

    return render_to_response('share.html'\
                            , d\
                            , context_instance=RequestContext(request))
Пример #29
0
def view_predict_upload_step2_confirm(request, dataset_md5):
    """
    At this point:
        - We have a PredictDataset object and
        - Have validated the Dropbox link--it has either .fastq or .vcf files

    Now, Ask the user to confirm that these are the files
    """
    d = get_common_dict(request, 'Predict Upload - Confirm', predict_page=True)

    # Retrieve the PredictDataset
    #
    try:
        predict_dataset = PredictDataset.objects.get(md5=dataset_md5)
    except PredictDataset.DoesNotExist:
        raise Http404('PredictDataset not found')

    d['dataset'] = predict_dataset
    d['tb_user'] = predict_dataset.user

    # Retrieve the DropboxRetrievalLog
    #
    dbox_log = DropboxRetrievalLog.objects.filter(
        dataset=predict_dataset).first()
    if dbox_log is None:
        raise Http404('DropboxRetrievalLog for PredictDataset not found')

    # Handle this better!
    if dbox_log.file_metadata_err_msg:
        return HttpResponse('DropboxRetrievalLog shows fail: {0}<br />{1}'.format(\
                        dbox_log.file_metadata_err_msg, 'view_predict_upload_step2_confirm')
                        )

    # Show or validate the confirmation form
    #
    if request.POST:
        f = SimpleConfirmationForm(request.POST)
        if f.is_valid():
            if f.do_not_use_files():
                """
                Delete the info and return to predict Upload page
                """
                predict_dataset.delete()  # cascades to DropboxRetrievalLog
                next_url = reverse('view_predict_upload_delete', args=())
            else:
                # Cron job will kick off download process
                predict_dataset.set_status_confirmed()
                next_url = reverse(
                    'view_predict_upload_success',
                    kwargs=dict(dataset_md5=predict_dataset.md5))
            return HttpResponseRedirect(next_url)
        else:
            d['ERROR_FOUND'] = True
    else:
        f = SimpleConfirmationForm()

    d['dbox_log'] = dbox_log
    d['confirm_form'] = f

    return render_to_response('predict/predict_upload_step2.html',
                              d,
                              context_instance=RequestContext(request))
Пример #30
0
def view_about_page(request):
    d = get_common_dict(request, 'About', about_page=True)

    return render_to_response('about.html'\
                              , d\
                              , context_instance=RequestContext(request))