Skip to content

Commit

Permalink
Merge pull request #1630 from jasonthomas/add-version
Browse files Browse the repository at this point in the history
Add version endpoint
  • Loading branch information
jasonthomas committed Feb 6, 2016
2 parents 30a5609 + 93e0ce8 commit c35dfec
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/olympia/amo/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,11 @@ def test_exception_rolls_back_transaction(self):
assert qs.count() == 0
finally:
qs.all().delete()


class TestVersion(TestCase):

def test_version_json(self):
res = self.client.get('/__version__')
eq_(res.status_code, 200)
eq_(res._headers['content-type'], ('Content-Type', 'application/json'))
1 change: 1 addition & 0 deletions src/olympia/amo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
url('^contribute.json$', views.contribute, name='contribute.json'),
url(r'^wafflejs$', wafflejs, name='wafflejs'),
('^services/', include(services_patterns)),
url('^__version__$', views.version, name='version.json'),

url('^opensearch.xml$', 'olympia.api.views.render_xml',
{'template': 'amo/opensearch.xml'},
Expand Down
6 changes: 6 additions & 0 deletions src/olympia/amo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ def cspreport(request):
return HttpResponse()


@non_atomic_requests
def version(request):
path = os.path.join(settings.ROOT, 'version.json')
return HttpResponse(open(path, 'rb'), content_type='application/json')


@non_atomic_requests
def plugin_check_redirect(request):
return http.HttpResponseRedirect('%s?%s' % (
Expand Down
3 changes: 2 additions & 1 deletion src/olympia/lib/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,14 @@ def lazy_langs(languages):
'developer_agreement', 'developer_faq', 'developers', 'editors', 'faq',
'jsi18n', 'localizers', 'review_guide', 'google1f3e37b7351799a5.html',
'robots.txt', 'statistics', 'services', 'sunbird', 'static', 'user-media',
'__version__',
)
DEFAULT_APP = 'firefox'

# paths that don't require a locale prefix
SUPPORTED_NONLOCALES = (
'contribute.json', 'google1f3e37b7351799a5.html', 'robots.txt', 'services',
'downloads', 'blocklist', 'static', 'user-media',
'downloads', 'blocklist', 'static', 'user-media', '__version__',
)

# Make this unique, and don't share it with anybody.
Expand Down
5 changes: 5 additions & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"source": "https://github.com/mozilla/addons-server",
"version": "origin/master",
"commit": "0000000"
}

0 comments on commit c35dfec

Please sign in to comment.