Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nwolff committed Aug 26, 2017
0 parents commit 0d46b67
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Python
.env
*.pyc
__pycache__
*.egg-info
/dist/
/build/
.tox
.coverage
.cache

# MyPy
.mypy_cache

# Intellij idea
.idea
*.iml

18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
sudo: false
language: python
matrix:
include:
- python: '3.5'
env: TOXENV=py35-django111-flake
install:
- pip install tox
script:
- tox
deploy:
provider: pypi
user: skioo
password:
secure: mGqHmR7lP8qtS8hG9Evobsrvgon8S5Xed2EmFfonaAJok0p5Gw8nVym+g8AVy7yA/hTbApOecM0DEX4JkUNoP77j1/kucs1O01sYqeYG+plK89cOCyW+hV2jN8i6RralIJrls8UFxIZtG2FvJaRosGXol+NeCoEf364iDKPpMdTFx7n/ZueWf/UxKZ56QZjHJdPNHmA5GyrjMQY96eOnEmoZV7HUH4GLT91UzJlAyz1ODjlLJlPLXqNKSm9/EPMP1kBwxjAKdzettOgqQPgHidXrYrMxfjd6qgBDBZpuR826psJR55k9HjkzeQ0OWeYJTGPbLg9SNrvcss3zoGvlPpfoZfCpvQNRNTdzmgHWFO5yG7L7ZVIiBcVtXqB3GniHQtvcOftlrgZ229zg7ZonYRWhfEKzQGegOjN9gW003lTKHTc62BM3Ay8H4V0GuD5SnDjpQgkQx18Ry8rXOew+j+qWCd9PW/wpfR+rhUCAJj8Uh5DbRBwLDhDjfN+0zgsYOs0SGO2bsnUCdBveXCfcPl7z5KIQaTwiwapUt/jpRAqYvY485VmG1gHROMm8Ft487gUiWRdcq0u6rrjbSXtUQXfLWrnwHG/vSvAxT8mjNllMvYMjdl3Kao0jkGd83vthHCC0qNljnKY+BK20Hu/ZdvS8IN6Lgi5ksfi6s04kXNM=
distribution: sdist bdist_wheel
on:
tags: true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) 2007, Skioo SA and individual contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY KYLE FULLER ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL KYLE FULLER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
django-admin-ribbon
===================

[![Build Status](https://travis-ci.org/skioo/django-admin-ribbon.svg?branch=master)](https://travis-ci.org/skioo/django-admin-ribbon)


Overlays a configurable ribbon across the admin-ui, in order to differentiate between environments.
For example:

![Example ribbon](docs/admin_with_ribbon.png)

Requirements
------------

* **Python**: any version
* **Django**: any version


Installation
------------

- Add `'adminribbon'` to your `INSTALLED_APPS`, before `'django.contrib.admin'` (because we override their template).
- Add `'adminribbon.context_processors.from_settings'` to the templates `'context_processors'`.
- For each environment (usually in different settings files) configure the text and color
of the ribbon, for example:

```
ADMIN_RIBBON = {
'TEXT': 'dev',
'COLOR': 'green',
}
```



To work on this code
--------------------

pip install -e .

To run tests:

tox

To release a version to pypi:
- Edit \_\_version\_\_ in \_\_init\_\_.py
- Push and wait for the build to succeed
- Create a release in github, travis will build and deploy the new version to pypi: https://pypi.python.org/pypi/django-admin-ribbon
4 changes: 4 additions & 0 deletions adminribbon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__version__ = '0.1.0'
__copyright__ = 'Copyright (c) 2017, skioo SA'
__licence__ = 'BSD'
__URL__ = 'https://github.com/skioo/django-admin-ribbon'
8 changes: 8 additions & 0 deletions adminribbon/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.conf import settings


def from_settings(_request):
return {
'ADMIN_RIBBON_TEXT': settings.ADMIN_RIBBON['TEXT'],
'ADMIN_RIBBON_COLOR': settings.ADMIN_RIBBON['COLOR'],
}
28 changes: 28 additions & 0 deletions adminribbon/templates/admin/base_site.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% extends "admin/base_site.html" %}

{% block extrastyle %}

<style type="text/css">
body:before {
width: 200px;
margin: 0;
padding: 0;
overflow: hidden;
position: fixed;
display: block;
top: auto;
left: auto;
right: -50px;
bottom: 25px;
transform: rotate(-45deg);

line-height: 35px;
text-align: center;
color: white;

content: "{{ ADMIN_RIBBON_TEXT }}";
background-color: {{ ADMIN_RIBBON_COLOR }};
}
</style>

{% endblock %}
Binary file added docs/admin_with_ribbon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
exclude = .git,.tox
max-line-length = 119

35 changes: 35 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python
from setuptools import setup

import adminribbon

setup(
name='django-admin-ribbon',
version=adminribbon.__version__,
description='Quickly differentiate django environments',
long_description='',
author='Nicholas Wolff',
author_email='nwolff@gmail.com',
url=adminribbon.__URL__,
download_url='https://pypi.python.org/pypi/django-admin-ribbon',
packages=[
'adminribbon',
],
package_data={'adminribbon': [
'templates/admin/base_site.html',
]},
install_requires=[
'Django>=1.7',
],
license=adminribbon.__licence__,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3.5',
],
)
14 changes: 14 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tox]
envlist =
py35-django111-flake,

[testenv]
basepython =
py35: python3.5
commands =
test: ./runtests.py
mypy: mypy .
flake: flake8
deps =
django111: Django>=1.11,<2.0
flake: flake8

0 comments on commit 0d46b67

Please sign in to comment.