from ._builtin import Page, WaitPage from .models import Constants class Info_Consent(Page): form_model = 'player' form_fields = ['consent'] def before_next_page(self): self.player.UserAgent = self.request.META.get('HTTP_USER_AGENT') class consent_out(Page): def is_displayed(self): return self.player.consent == 0 class mobile_end(Page): def is_displayed(self): user_agent = self.request.META['HTTP_USER_AGENT'] is_mobile = False for substring in ['Mobi', 'Android']: if substring in user_agent: is_mobile = True return is_mobile class Instructions(Page): pass class normal_link(Page): def is_displayed(self): return self.player.condition == "normal" class private_link(Page): def is_displayed(self): return self.player.condition == "private" page_sequence = [ mobile_end, Info_Consent, consent_out, normal_link, private_link ]