Skip to content

Commit

Permalink
#389: Make Android app packageId configurable via settings value
Browse files Browse the repository at this point in the history
  • Loading branch information
jjoseba committed Sep 13, 2018
1 parent 2afbcc0 commit 2c605f1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
13 changes: 13 additions & 0 deletions helpers/templatetags/settings_value.py
@@ -0,0 +1,13 @@
from django import template
from django.conf import settings

register = template.Library()

ALLOWABLE_VALUES = ("OPPIA_ANDROID_PACKAGEID", "OPPIA_ANDROID_ON_GOOGLE_PLAY", "OPPIA_ANDROID_DEFAULT_PACKAGEID", "BASESITE_URL", "OPPIA_MAX_UPLOAD_SIZE")

# settings value (based on https://stackoverflow.com/a/21593607)
@register.simple_tag
def settings_value(name):
if name in ALLOWABLE_VALUES:
return getattr(settings, name, '')
return ''
5 changes: 5 additions & 0 deletions oppiamobile/settings.py
Expand Up @@ -199,6 +199,11 @@

OPPIA_EXPORT_LOCAL_MINVERSION = 2017011400 # min version of the export block to process the quizzes locally

# Android app PackageId - for Google Play link and opening activities from digest
OPPIA_ANDROID_DEFAULT_PACKAGEID = 'org.digitalcampus.mobile.learning'
OPPIA_ANDROID_PACKAGEID = 'org.digitalcampus.mobile.learning'
OPPIA_ANDROID_ON_GOOGLE_PLAY = True # if the app is not on Google Play, we rely on the core version for store links

API_LIMIT_PER_PAGE = 0

DEVICE_ADMIN_ENABLED = False
Expand Down
8 changes: 6 additions & 2 deletions oppiamobile/settings_secret.py.template
Expand Up @@ -34,7 +34,6 @@ MANAGERS = ADMINS
SERVER_EMAIL = 'admin@email.org'
EMAIL_SUBJECT_PREFIX = '[Oppia-Core Staging]: '


# Debug mode on/off - display detail error pages
# if DEBUG is False, you also need to properly set the ALLOWED_HOSTS setting.
# Failing to do so will result in all requests being returned as "Bad Request (400)".
Expand All @@ -57,4 +56,9 @@ GCM_APIKEY = 'OPPIA_GOOGLEAPIKEY'
OPPIA_ALLOW_SELF_REGISTRATION = True # turns on/off ability for users to self register
OPPIA_SHOW_GRAVATARS = True
OPPIA_STAFF_ONLY_UPLOAD = True # prevents anyone without is_staff status being able to upload courses,
# setting to False allows any registered user to upload a course
# setting to False allows any registered user to upload a course

# Android app settings
OPPIA_ANDROID_PACKAGEID = 'org.digitalcampus.moeeeebile.learning' #App PackageId
OPPIA_ANDROID_ON_GOOGLE_PLAY = True # if the app is not on Google Play, set this to false.
# The server will rely on the core version for store links
11 changes: 9 additions & 2 deletions templates/oppia/course/activity_digest.html
@@ -1,6 +1,7 @@
{% extends "base.html" %}
{% load i18n %}
{% load display_functions %}
{% load settings_value %}

{% block extra_head_title %}
{% trans 'Courses' %}
Expand All @@ -19,8 +20,14 @@ <h4>{{activity.title|title_lang:LANGUAGE_CODE}}</h4>
<h5>{{activity.section.title|title_lang:LANGUAGE_CODE}}</h5>

<br>
<a href="intent://view?digest={{digest}}#Intent;scheme=oppiamobile;package=org.digitalcampus.mobile.learning;end" class="btn btn-primary">Open in app</a>
<a href="https://play.google.com/store/apps/details?id=org.digitalcampus.mobile.learning" class="btn btn-info">Get it on Google Play</a>

{% settings_value 'OPPIA_ANDROID_PACKAGEID' as package_id %}
{% settings_value 'OPPIA_ANDROID_DEFAULT_PACKAGEID' as default_package_id %}
{% settings_value 'OPPIA_ANDROID_ON_GOOGLE_PLAY' as on_googleplay %}

<a href="intent://view?digest={{digest}}#Intent;scheme=oppiamobile;package={{package_id}};end" class="btn btn-primary">Open in app</a>

<a href="https://play.google.com/store/apps/details?id={% if on_googleplay %}{{package_id}}{% else %}{{default_package_id}}{% endif %}" class="btn btn-info">Get it on Google Play</a>

</div>

Expand Down
8 changes: 6 additions & 2 deletions templates/oppia/home.html
@@ -1,6 +1,7 @@
{% extends "base.html" %}
{% load i18n %}
{% load display_functions %}
{% load display_functions %}
{% load settings_value %}
{% load crispy_forms_tags %}
{% load staticfiles %}

Expand Down Expand Up @@ -28,14 +29,17 @@ <h3>{% trans 'home_leaderboard' %}<a class="btn btn-primary" style="margin-left:
<div><a href="{% url 'oppia_leaderboard' %}">{% trans "more..." %}</a></div>
{% else %}
{% static "oppia/images/dc-logo-150x150.png" as oppia_logo %}

{% settings_value 'OPPIA_ANDROID_PACKAGEID' as package_id %}
{% blocktrans %}
<div style="text-align:center; margin-top:20px;">
<img src="{{ oppia_logo }}" alt="OppiaMobile logo"/>
</div>
<div style="max-width:350px; text-align:center; margin: 10px auto ">
<p><a href="https://digital-campus.org/oppiamobile/overview/">OppiaMobile</a> is the mobile learning platform from <a href="https://digital-campus.org">Digital Campus</a> to deliver learning content, multimedia and quizzes on your smartphone. All the content and activities can
be accessed and used even when you don't have an internet connection available on your mobile.</p>
<div class="btn-primary btn btn-default"><a href="https://play.google.com/store/apps/details?id=org.digitalcampus.mobile.learning">Download OppiaMobile app</a></div>

<div class="btn-primary btn btn-default"><a href="https://play.google.com/store/apps/details?id={{package_id}}">Download OppiaMobile app</a></div>
</div>
{% endblocktrans %}

Expand Down

0 comments on commit 2c605f1

Please sign in to comment.