Skip to content

Commit

Permalink
error handling...
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterCat12 committed Apr 28, 2017
1 parent d8ceae7 commit e2bd98a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 5 additions & 4 deletions django_version_viewer/templatetags/pip_version_viewer_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

@register.inclusion_tag('version_viewer.html', takes_context=True)
def show_pip_package_versions(context):
if accessor.allow_access(request=context['request']):
return {'allow': True}
else:
return {'allow': False}
request = context.get('request', None)
results = {'allow': False}
if request and accessor.allow_access(request=request):
results = {'allow': True}
return results
11 changes: 10 additions & 1 deletion example18/templates/admin/base_site.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{% extends "admin/base.html" %}
{% load i18n pip_version_viewer_tags %}

{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}

{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('Django administration') }}</a></h1>
{% endblock %}

{% load pip_version_viewer_tags %}

{% block extrahead %}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
Expand All @@ -9,3 +16,5 @@
{% block pretitle %}
{% show_pip_package_versions %}
{% endblock %}

{% block nav-global %}{% endblock %}

0 comments on commit e2bd98a

Please sign in to comment.