def init(request): if not request.user.is_superuser and\ request.user.is_authenticated(): return redirect_user_to_current_step(request.user) else: current_phase = Phase.objects.all().first().phase context = dict(current_phase=current_phase) return render(request, "home.djhtml", context)
def step3(request): """PAGE - The last page where the user is invited to share the experience.""" current_phase = Phase.objects.all().first().phase if (request.user.userstep.phase2_step not in (3, 4) or current_phase != 2) and\ not request.user.is_superuser: return redirect_user_to_current_step(request.user) return render(request, 'phase2/step3.djhtml')
def main(request): """PAGE""" current_phase = Phase.objects.all().first().phase if (request.user.userstep.phase2_step != 1 or current_phase != 2) and\ not request.user.is_superuser: return redirect_user_to_current_step(request.user) else: Tracked.objects.create( user=request.user, data={ 'userAgent': request.META.get('HTTP_USER_AGENT', None), 'referrer': request.META.get('HTTP_REFERER', None), }, hook='WISHLIST_APP_ENTERED', ) return render(request, "phase2/main.djhtml")
def step2(request): """PAGE -- The questionnaire.""" current_phase = Phase.objects.all().first().phase # We increment the user step if not request.user.is_superuser and\ get_number_reviews(request.user) >= settings.MIN_NUMBER_REVIEWS and\ request.user.userstep.phase1_step == 1: set_user_step(request.user, step=2, phase=1) # We redirect if necessary if (request.user.userstep.phase1_step != 2 or current_phase != 1) and\ not request.user.is_superuser: return redirect_user_to_current_step(request.user) else: questionnaire = get_questionnaire_as_dict(phase=1) context_dict = {'questionnaire': questionnaire} return render(request, 'phase1/step2.djhtml', context_dict)
def step2(request): """PAGE -- The questionnaire.""" current_phase = Phase.objects.all().first().phase # We increment the user step if not request.user.is_superuser and\ get_number_wishes(request.user) >= settings.MIN_NUMBER_WISHES and\ request.user.userstep.phase2_step == 1: set_user_step(request.user, step=2, phase=2) # We redirect if necessary if (request.user.userstep.phase2_step != 2 or current_phase != 2) and\ not request.user.is_superuser: return redirect_user_to_current_step(request.user) try: questionnaire = get_questionnaire_as_dict(phase=2) except: raise Exception('You need to create a questionnaire for phase 2!') context_dict = { 'questionnaire': questionnaire } return render(request, 'phase2/step2.djhtml', context_dict)
def step1(request): """PAGE -- The main phase 1 reviewing page that loads the React app.""" current_phase = Phase.objects.all().first().phase if (request.user.userstep.phase1_step != 1 or current_phase != 1) and\ not request.user.is_superuser: return redirect_user_to_current_step(request.user) else: try: Tracked.objects.create( user=request.user, data={ 'userAgent': request.META.get('HTTP_USER_AGENT', None), 'referrer': request.META.get('HTTP_REFERER', None), }, hook='REVIEW_APP_ENTERED', ) except: pass products = get_products() # We add the review data for each product for p in products: rd = dict(review=get_review_data(request.user, p['id'])) p.update(rd) tags = Tag.objects.get_tag_names() number_reviews = get_number_reviews(request.user) review_tree = get_review_tree() context_dict = { 'products': json.dumps(products), 'tags': tags, 'name': request.user.first_name, 'review_elements': review_tree, 'number_reviews': number_reviews } return render(request, 'phase1/step1.djhtml', context_dict)
def login_success(request): return redirect_user_to_current_step(request.user)