├── .envrc ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── adminribbon ├── __init__.py ├── context_processors.py └── templates │ └── admin │ └── base_site.html ├── docs └── admin_with_ribbon.png ├── setup.cfg ├── setup.py └── tox.ini /.envrc: -------------------------------------------------------------------------------- 1 | layout python3 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Python 2 | .env 3 | *.pyc 4 | __pycache__ 5 | *.egg-info 6 | /dist/ 7 | /build/ 8 | .tox 9 | .coverage 10 | .cache 11 | 12 | # MyPy 13 | .mypy_cache 14 | 15 | # Intellij idea 16 | .idea 17 | *.iml 18 | 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: python 3 | matrix: 4 | include: 5 | - python: '3.8' 6 | env: TOXENV=py38-django32-flake 7 | install: 8 | - pip install tox 9 | script: 10 | - tox 11 | deploy: 12 | provider: pypi 13 | user: skioo 14 | password: 15 | secure: mGqHmR7lP8qtS8hG9Evobsrvgon8S5Xed2EmFfonaAJok0p5Gw8nVym+g8AVy7yA/hTbApOecM0DEX4JkUNoP77j1/kucs1O01sYqeYG+plK89cOCyW+hV2jN8i6RralIJrls8UFxIZtG2FvJaRosGXol+NeCoEf364iDKPpMdTFx7n/ZueWf/UxKZ56QZjHJdPNHmA5GyrjMQY96eOnEmoZV7HUH4GLT91UzJlAyz1ODjlLJlPLXqNKSm9/EPMP1kBwxjAKdzettOgqQPgHidXrYrMxfjd6qgBDBZpuR826psJR55k9HjkzeQ0OWeYJTGPbLg9SNrvcss3zoGvlPpfoZfCpvQNRNTdzmgHWFO5yG7L7ZVIiBcVtXqB3GniHQtvcOftlrgZ229zg7ZonYRWhfEKzQGegOjN9gW003lTKHTc62BM3Ay8H4V0GuD5SnDjpQgkQx18Ry8rXOew+j+qWCd9PW/wpfR+rhUCAJj8Uh5DbRBwLDhDjfN+0zgsYOs0SGO2bsnUCdBveXCfcPl7z5KIQaTwiwapUt/jpRAqYvY485VmG1gHROMm8Ft487gUiWRdcq0u6rrjbSXtUQXfLWrnwHG/vSvAxT8mjNllMvYMjdl3Kao0jkGd83vthHCC0qNljnKY+BK20Hu/ZdvS8IN6Lgi5ksfi6s04kXNM= 16 | distribution: sdist bdist_wheel 17 | on: 18 | tags: true 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, Skioo SA and individual contributors. 2 | 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | django-admin-ribbon 2 | =================== 3 | 4 | [![Build Status](https://travis-ci.org/skioo/django-admin-ribbon.svg?branch=master)](https://travis-ci.org/skioo/django-admin-ribbon) 5 | [![PyPI version](https://badge.fury.io/py/django-admin-ribbon.svg)](https://badge.fury.io/py/django-admin-ribbon) 6 | [![Requirements Status](https://requires.io/github/skioo/django-admin-ribbon/requirements.svg?branch=master)](https://requires.io/github/skioo/django-admin-ribbon/requirements/?branch=master) 7 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) 8 | 9 | Overlays a configurable ribbon across the admin-ui, in order to differentiate between environments. 10 | 11 | For example: 12 | 13 | ![Example ribbon](docs/admin_with_ribbon.png) 14 | 15 | Requirements 16 | ------------ 17 | 18 | * Python: Any version 19 | * Django: 1.8 and over 20 | 21 | Setup 22 | ----- 23 | 24 | Install from pip: 25 | 26 | pip install django-admin-ribbon 27 | 28 | 29 | Add `'adminribbon'` to your `INSTALLED_APPS`, before `'django.contrib.admin'` (because we override their template). 30 | 31 | 32 | INSTALLED_APPS = ( 33 | ... 34 | 'adminribbon', 35 | 'django-contrib.admin', 36 | ... 37 | ) 38 | 39 | 40 | 41 | Add `'adminribbon.context_processors.from_settings'` to the templates `'context_processors'`. 42 | 43 | 44 | For each environment (usually in different settings files) configure the text and color of the ribbon, for example: 45 | 46 | ADMIN_RIBBON = { 47 | 'TEXT': 'Dev', 48 | 'COLOR': 'green', 49 | } 50 | 51 | 52 | Credits 53 | ------- 54 | 55 | Inspired by https://hackernoon.com/5-ways-to-make-django-admin-safer-eb7753698ac8 56 | -------------------------------------------------------------------------------- /adminribbon/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.1.8' 2 | __copyright__ = 'Copyright (c) 2017, skioo SA' 3 | __licence__ = 'MIT' 4 | __URL__ = 'https://github.com/skioo/django-admin-ribbon' 5 | -------------------------------------------------------------------------------- /adminribbon/context_processors.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | 3 | 4 | def from_settings(_request): 5 | return { 6 | 'ADMIN_RIBBON_TEXT': settings.ADMIN_RIBBON['TEXT'], 7 | 'ADMIN_RIBBON_COLOR': settings.ADMIN_RIBBON['COLOR'], 8 | } 9 | -------------------------------------------------------------------------------- /adminribbon/templates/admin/base_site.html: -------------------------------------------------------------------------------- 1 | {% extends "admin/base_site.html" %} 2 | 3 | {% block extrastyle %} 4 | 5 | 30 | 31 | {% endblock %} 32 | -------------------------------------------------------------------------------- /docs/admin_with_ribbon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skioo/django-admin-ribbon/52b60f726a24431768b950d0dc0ae6a071b6a03f/docs/admin_with_ribbon.png -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [flake8] 2 | exclude = .git,.tox,.env 3 | max-line-length = 119 4 | 5 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from setuptools import setup 3 | 4 | import adminribbon 5 | 6 | setup( 7 | name='django-admin-ribbon', 8 | version=adminribbon.__version__, 9 | description='Quickly differentiate django environments', 10 | long_description='', 11 | author='Nicholas Wolff', 12 | author_email='nwolff@gmail.com', 13 | url=adminribbon.__URL__, 14 | download_url='https://pypi.python.org/pypi/django-admin-ribbon', 15 | packages=[ 16 | 'adminribbon', 17 | ], 18 | package_data={'adminribbon': [ 19 | 'templates/admin/base_site.html', 20 | ]}, 21 | install_requires=[ 22 | 'Django>=1.8', 23 | ], 24 | license=adminribbon.__licence__, 25 | classifiers=[ 26 | 'Development Status :: 5 - Production/Stable', 27 | 'Environment :: Web Environment', 28 | 'Framework :: Django', 29 | 'Intended Audience :: Developers', 30 | 'License :: OSI Approved :: BSD License', 31 | 'Operating System :: OS Independent', 32 | 'Programming Language :: Python', 33 | 'Programming Language :: Python :: 3.5', 34 | 'Programming Language :: Python :: 3.6', 35 | 'Programming Language :: Python :: 3.7', 36 | 'Programming Language :: Python :: 3.8', 37 | ], 38 | ) 39 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = 3 | py38-{django32}-flake 4 | 5 | [testenv] 6 | basepython = 7 | py38: python3.8 8 | commands = 9 | test: ./runtests.py 10 | mypy: mypy . 11 | flake: flake8 12 | deps = 13 | django32: Django>=3.2 14 | flake: flake8 15 | --------------------------------------------------------------------------------