Esempio n. 1
0
def update_profile_for_studies(request, study_pk):

    form = UserProfileForm(request.POST or None, instance=request.user.userprofile, request=request)

    if form.is_valid():
        form.save()
        messages.info(request, "Personal details updated.")
        execute_the_todo_list(user=request.user)
        return HttpResponseRedirect(reverse('user_homepage'))

    return render(request, 'signalbox/additional_info.html',
                              {'form': form})
Esempio n. 2
0
def allocate_new_membership(sender, created, instance, **kwargs):
    """When a participant joins a study, we need to randomise them and add observations
    if the Study settings say so."""

    if created and instance.study.auto_randomise:
        _, _ = allocate(instance)

    if created and instance.study.auto_add_observations and instance.study.auto_randomise:
        instance.add_observations()
        # we don't execute at this point if we are testing because it makes unit
        # tests awkward (we can't test the intermediate states of some functions.)
        if not settings.TESTING:
            execute_the_todo_list()
Esempio n. 3
0
def allocate_new_membership(sender, created, instance, **kwargs):
    """When a participant joins a study, we need to randomise them and add observations
    if the Study settings say so."""

    if created and instance.study.auto_randomise:
        _, _ = allocate(instance)

    if created and instance.study.auto_add_observations and instance.study.auto_randomise:
        instance.add_observations()
        # we don't execute at this point if we are testing because it makes unit
        # tests awkward (we can't test the intermediate states of some functions.)
        if not settings.TESTING:
            execute_the_todo_list()
Esempio n. 4
0
def user_homepage(request):
    """Just returns the request to the template.

    This makes the User available to the template as {{user}} which  is used to
    output relevant details for them."""

    if not request.user.userprofile.has_all_required_details():
        return HttpResponseRedirect(reverse('update_profile_for_studies'))
    else:
        execute_the_todo_list(user=request.user)

    return render(request, 'signalbox/user_home.html',
                              {'hideprofilebutton': False })