Skip to content

Commit

Permalink
[staged-updates] [participant-timezones] should make apk download lin…
Browse files Browse the repository at this point in the history
…ks work every time.
  • Loading branch information
biblicabeebli committed Oct 6, 2023
1 parent e4af971 commit c289be3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
15 changes: 10 additions & 5 deletions api/admin_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import uuid

from django.contrib import messages
from django.core.exceptions import ValidationError
from django.http.request import HttpRequest
Expand Down Expand Up @@ -144,29 +146,32 @@ def toggle_easy_enrollment_study(request: ResearcherRequest, study_id: int):

"""##### Methods responsible for distributing APK file of Android app. #####"""

# these download app version urls are redirects, which get cached in the browser. The uniqueify
# parameter is used to make the url look unique, so the browser uses a new url every time.

def download_current(request: ResearcherRequest):
return redirect(DOWNLOADABLE_APK_URL)
return redirect(DOWNLOADABLE_APK_URL + "?uniqueify=" + str(uuid.uuid4()))


@authenticate_researcher_login
def download_current_debug(request: ResearcherRequest):
return redirect("https://s3.amazonaws.com/beiwe-app-backups/release/Beiwe-debug.apk")
# add a uuid value to the end so the link always works
return redirect("https://s3.amazonaws.com/beiwe-app-backups/debug/Beiwe-debug.apk?uniqueify=" + str(uuid.uuid4()))


@authenticate_researcher_login
def download_beta(request: ResearcherRequest):
return redirect("https://s3.amazonaws.com/beiwe-app-backups/release/Beiwe.apk")
return redirect("https://s3.amazonaws.com/beiwe-app-backups/release/Beiwe.apk?uniqueify=" + str(uuid.uuid4()))


@authenticate_researcher_login
def download_beta_debug(request: ResearcherRequest):
return redirect("https://s3.amazonaws.com/beiwe-app-backups/debug/Beiwe-debug.apk")
return redirect("https://s3.amazonaws.com/beiwe-app-backups/debug/Beiwe-debug.apk?uniqueify=" + str(uuid.uuid4()))


@authenticate_researcher_login
def download_beta_release(request: ResearcherRequest):
return redirect("https://s3.amazonaws.com/beiwe-app-backups/release/Beiwe-2.2.3-onnelaLabServer-release.apk")
return redirect("https://s3.amazonaws.com/beiwe-app-backups/release/Beiwe-2.2.3-onnelaLabServer-release.apk?uniqueify=" + str(uuid.uuid4()))


def download_privacy_policy(request: HttpRequest):
Expand Down
6 changes: 3 additions & 3 deletions database/study_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import operator
from datetime import datetime, tzinfo
from typing import List, Optional
from typing import Any, Dict, Optional

from dateutil.tz import gettz
from django.core.exceptions import ObjectDoesNotExist
Expand All @@ -12,8 +12,8 @@
from django.db.models.query import QuerySet
from django.utils import timezone
from django.utils.timezone import localtime
from constants.data_stream_constants import ALL_DATA_STREAMS

from constants.data_stream_constants import ALL_DATA_STREAMS
from constants.study_constants import (ABOUT_PAGE_TEXT, CONSENT_FORM_TEXT,
DEFAULT_CONSENT_SECTIONS_JSON, SURVEY_SUBMIT_SUCCESS_TOAST_TEXT)
from constants.user_constants import ResearcherRole
Expand Down Expand Up @@ -211,7 +211,7 @@ class DeviceSettings(TimestampedModel):
""" The DeviceSettings database contains the structure that defines settings pushed to devices
of users in of a study. """

def export(self) -> List[str]:
def export(self) -> Dict[str, Any]:
""" DeviceSettings is a special case where we want to export all fields. Do not add fields
to this model that cannot be trivially exported inside as_unpacked_native_python. """
field_names = self.local_field_names()
Expand Down

0 comments on commit c289be3

Please sign in to comment.