Skip to content

Commit

Permalink
Merge pull request #46 from ekonstantinidis/rename-hidden-setting
Browse files Browse the repository at this point in the history
Change 'HIDDEN' setting to 'HIDE_DOCS'
  • Loading branch information
ekonstantinidis committed Jan 5, 2016
2 parents c2dc2ad + 4fb1c1b commit c8740b1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion rest_framework_docs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class DRFSettings(object):

def __init__(self):
self.drf_settings = {
"HIDDEN": self.get_setting("HIDDEN") or False
"HIDE_DOCS": self.get_setting("HIDE_DOCS") or False
}

def get_setting(self, name):
Expand Down
2 changes: 1 addition & 1 deletion rest_framework_docs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DRFDocsView(TemplateView):

def get_context_data(self, **kwargs):
settings = DRFSettings().settings
if settings["HIDDEN"]:
if settings["HIDE_DOCS"]:
raise Http404("Django Rest Framework Docs are hidden. Check your settings.")

context = super(DRFDocsView, self).get_context_data(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
ROOT_URLCONF = 'tests.urls'

REST_FRAMEWORK_DOCS = {
'HIDDEN': False
'HIDE_DOCS': False
}

# Static files (CSS, JavaScript, Images)
Expand Down
8 changes: 4 additions & 4 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class DRFDocsViewTests(TestCase):

SETTINGS_HIDE_DOCS = {
'HIDDEN': True # Default: False
'HIDE_DOCS': True # Default: False
}

def setUp(self):
Expand All @@ -16,7 +16,7 @@ def test_settings_module(self):

settings = DRFSettings()

self.assertEqual(settings.get_setting("HIDDEN"), False)
self.assertEqual(settings.get_setting("HIDE_DOCS"), False)
self.assertEqual(settings.get_setting("TEST"), None)

def test_index_view_with_endpoints(self):
Expand Down Expand Up @@ -52,8 +52,8 @@ def test_index_search_with_endpoints(self):
@override_settings(REST_FRAMEWORK_DOCS=SETTINGS_HIDE_DOCS)
def test_index_view_docs_hidden(self):
"""
Should prevent the docs from loading the "HIDDEN" is set
to "False" in settings
Should prevent the docs from loading the "HIDE_DOCS" is set
to "True" or undefined under settings
"""
response = self.client.get(reverse('drfdocs'))

Expand Down

0 comments on commit c8740b1

Please sign in to comment.