Пример #1
0
def change_alternative(request, experiment_name, alternative_name):
    experiment = get_object_or_404(Experiment, name=experiment_name)
    if alternative_name not in experiment.alternatives.keys():
        return HttpResponseBadRequest()

    experiment_user = WebUser(request)
    experiment_user.set_enrollment(experiment, alternative_name)
    return HttpResponse('OK')
Пример #2
0
    def render(self, context):
        # Get User object
        request = context.get('request', None)

        if request is None:
            user = StaticUser()
        else:
            # Create experiment_user in session if not already
            if not hasattr(request, 'experiment_user'):
                request.experiment_user = WebUser(request)
            user = request.experiment_user

        # Should we render?
        if Experiment.show_alternative(self.experiment_name, user, self.alternative, experiment_manager):
            response = self.node_list.render(context)
        else:
            response = ""

        return response
Пример #3
0
def authenticated(incorporating):
    User = get_user_model()
    return WebUser(user=User.objects.create(
        username=['incorporating_user', 'incorporated_user'][incorporating]))
Пример #4
0
def anonymous(incorporating):
    return WebUser(session=DatabaseSession())
Пример #5
0
def confirm_human(request):
    experiment_user = WebUser(request)
    experiment_user.confirm_human()
    return HttpResponse(status=204)