Esempio n. 1
0
def index(request):
    """
    Starting page for app.
    """
    context = {}
    try:
        auth_url = OpenHumansMember.get_auth_url()
        context['auth_url'] = auth_url
    except ImproperlyConfigured as e:
        messages.info(
            request,
            mark_safe(
                f'<b>Received an error ${e}. You might to set up your ".env" file?</b>'
            ))
    # if request.user.is_authenticated:
    # context['overland_file'] = get_overland_file(request.user.openhumansmember)
    # context['overland_endpoint'] = urllib.parse.urljoin(settings.OPENHUMANS_APP_BASE_URL, request.user.openhumansmember.garminuser.endpoint_token + "/")
    if request.user.is_authenticated and request.user.openhumansmember.garmin_member:
        context['is_garmin_member'] = True

        # member= GarminMember.objects.get(oh_member_id=request.user.openhumansmember.)
        # print(f"queueing backfill ${request.user.openhumansmember.garmin_member.userid}")
        # handle_backfill(request.user.openhumansmember.garmin_member.userid)
    # print(current_app.tasks.keys())

    return render(request, 'main/index.html', context=context)
Esempio n. 2
0
def about(request):
    """
    Share further details about the project.
    """
    auth_url = OpenHumansMember.get_auth_url()
    context = {'auth_url': auth_url}
    return render(request, 'main/about.html', context=context)
Esempio n. 3
0
def index(request):
    """
    Starting page for app.
    """

    test_step_data = {
        "stepper": [{
            "id": 1,
            "label": "Login"
        }, {
            "id": 2,
            "label": "Define Profile"
        }, {
            "id": 3,
            "label": "Add Event"
        }],
    }
    stepper_object = Stepper.Stepper(test_step_data, request)

    stepper_object.update()

    stepper_data = stepper_object.get_stepper_data()

    auth_url = OpenHumansMember.get_auth_url()
    context = {'auth_url': auth_url, 'oh_proj_page': settings.OH_PROJ_PAGE}
    if request.user.is_authenticated:
        return redirect('overview')
    # return render(request, 'index.html', context=context)
    return render(request, 'index.html', stepper_data)
Esempio n. 4
0
def index(request):
    """
    Starting page for app.
    """
    try:
        auth_url = OpenHumansMember.get_auth_url()
    except ImproperlyConfigured:
        auth_url = None
    if not auth_url:
        messages.info(
            request, mark_safe('<b>You need to set up your ".env"'
                               ' file!</b>'))

    context = {'auth_url': auth_url}
    if request.user.is_authenticated:
        context['fb_redirect_uri'] = (settings.OPENHUMANS_APP_BASE_URL + '/'
                                      'fitbit/authorized')
        if hasattr(request.user.openhumansmember, 'fitbituser'):
            context['fitbituser'] = request.user.openhumansmember.fitbituser
            if not request.user.openhumansmember.fitbituser.access_token:
                fb_user = request.user.openhumansmember.fitbituser
                fb_auth_url = (
                    'https://www.fitbit.com/oauth2/authorize?response_type=code'
                    '&client_id=' + fb_user.personal_client_id + '&scope'
                    '=activity%20nutrition%20heartrate%20location'
                    '%20nutrition%20profile%20settings%20sleep%20social%20weight'
                    '&redirect_uri=' + settings.OPENHUMANS_APP_BASE_URL + '/'
                    'fitbit/authorized')
                context['fb_auth_url'] = fb_auth_url
    return render(request, 'main/index.html', context=context)
Esempio n. 5
0
 def get_context_data(self, *args, **kwargs):
     """
     Add auth url to context
     """
     context = super().get_context_data(*args, **kwargs)
     auth_url = OpenHumansMember.get_auth_url()
     context.update({"auth_url": auth_url})
     return context
Esempio n. 6
0
def index(request):
    """
    Starting page for app.
    """
    auth_url = OpenHumansMember.get_auth_url()
    context = {'auth_url': auth_url, 'oh_proj_page': settings.OH_PROJ_PAGE}
    if request.user.is_authenticated:
        return redirect('main:overview')
    return render(request, 'main/home.html', context=context)
Esempio n. 7
0
def index(request):
    """
    Starting page for app.
    """
    if request.user.is_authenticated:
        return redirect('dashboard')

    auth_url = OpenHumansMember.get_auth_url()
    context = {'auth_url': auth_url}

    return render(request, 'main/index.html', context=context)
Esempio n. 8
0
def index(request):
    """
    Starting page for app.
    """
    if request.user.is_authenticated:
        return redirect('/dashboard')

    context = {
        'oh_auth_url': OpenHumansMember.get_auth_url(),
        'oh_proj_page': settings.OH_ACTIVITY_PAGE
    }

    return render(request, 'main/index.html', context=context)
Esempio n. 9
0
def index(request):
    """
    Starting page for app.
    """
    try:
        auth_url = OpenHumansMember.get_auth_url()
    except ImproperlyConfigured:
        auth_url = None
    if not auth_url:
        messages.info(
            request, mark_safe('<b>You need to set up your ".env"'
                               ' file!</b>'))

    context = {'auth_url': auth_url}
    return render(request, 'main/index.html', context=context)
Esempio n. 10
0
 def get_context_data(self, *args, **kwargs):
     context = super().get_context_data(*args, **kwargs)
     published_member_reports = 0
     any_member_reports = 0
     if not self.request.user.is_anonymous:
         published_member_reports = self.object_list.filter(
             member=self.request.user.openhumansmember).count()
         any_member_reports = RetrospectiveEvent.objects.filter(
             member=self.request.user.openhumansmember).count()
     context.update({
         "published_member_reports": published_member_reports,
         "any_member_reports": any_member_reports,
         "openhumans_login_url": OpenHumansMember.get_auth_url(),
     })
     return context
Esempio n. 11
0
def index(request):
    """
    Starting page for app.
    """
    context = {}
    try:
        auth_url = OpenHumansMember.get_auth_url()
        context['auth_url'] = auth_url
    except ImproperlyConfigured as e:
        messages.info(request, mark_safe(f'<b>Received an error {e}. You might to set up your ".env" file?</b>'))
    if request.user.is_authenticated and hasattr(request.user.openhumansmember, 'garmin_member') and request.user.openhumansmember.garmin_member.userid:
        context['is_garmin_member'] = True
        retrieved_data = RetrievedData.objects.filter(member=request.user.openhumansmember)
        context['retrieved_data'] = retrieved_data
        context['has_data'] = len(retrieved_data) > 0

    return render(request, 'main/index.html', context=context)
Esempio n. 12
0
    def get_context_data(self, *args, **kwargs):
        context = super().get_context_data(*args, **kwargs)

        if self.request.user.is_authenticated:
            openhumansmember = self.request.user.openhumansmember

            context.update({
                "openhumansmember": openhumansmember,
                "files": self.files
            })

        # Not logged in.
        else:
            context.update(
                {"openhumans_login_url": OpenHumansMember.get_auth_url()})

        return context
Esempio n. 13
0
def index(request):
    """
    Starting page for app.
    """
    try:
        auth_url = OpenHumansMember.get_auth_url()
    except ImproperlyConfigured:
        auth_url = None
    if not auth_url:
        messages.info(
            request, mark_safe('<b>You need to set up your ".env"'
                               ' file!</b>'))

    context = {'auth_url': auth_url}
    if request.user.is_authenticated:
        context['overland_file'] = get_overland_file(
            request.user.openhumansmember)
        context['overland_endpoint'] = urllib.parse.urljoin(
            settings.OPENHUMANS_APP_BASE_URL,
            request.user.openhumansmember.overlanduser.endpoint_token + "/")
    return render(request, 'main/index.html', context=context)
Esempio n. 14
0
    def get_context_data(self, *args, **kwargs):
        context = super().get_context_data(*args, **kwargs)

        if self.request.user.is_authenticated:
            openhumansmember = self.request.user.openhumansmember

            # checkin_form
            try:
                schedule = CheckinSchedule.objects.get(member=openhumansmember)
                checkin_form = CheckinScheduleForm(instance=schedule)
                schedule_exists = True
            except CheckinSchedule.DoesNotExist:
                checkin_form = CheckinScheduleForm()
                schedule_exists = False

            # fitbit_auth_url
            fitbit_auth_url = (
                "https://www.fitbit.com/oauth2/authorize?response_type=code&client_id="
                + settings.FITBIT_CLIENT_ID +
                "&scope=activity%20nutrition%20heartrate%20location%20nutrition%20profile%20settings%20sleep%20social%20weight"
            )

            context.update({
                "checkin_form": checkin_form,
                "fitbit_auth_url": fitbit_auth_url,
                "missing_sources": self.missing_sources,
                "openhumansmember": openhumansmember,
                "schedule_exists": schedule_exists,
            })

        # Not logged in.
        else:
            context.update(
                {"openhumans_login_url": OpenHumansMember.get_auth_url()})

        return context
Esempio n. 15
0
def about(request):
    context = {"openhumans_login_url": OpenHumansMember.get_auth_url()}
    return render(request, "quantified_flu/about.html", context)
Esempio n. 16
0
    def __call__(self, request):
        request.openhumans_login_url = OpenHumansMember.get_auth_url()

        response = self.get_response(request)
        return response