django-simple-redis-admin-1.4.0/0000755000000000000240000000000012770372607016536 5ustar rootstaff00000000000000django-simple-redis-admin-1.4.0/django_simple_redis_admin.egg-info/0000755000000000000240000000000012770372607025401 5ustar rootstaff00000000000000django-simple-redis-admin-1.4.0/django_simple_redis_admin.egg-info/dependency_links.txt0000644000000000000240000000000112770372607031447 0ustar rootstaff00000000000000 django-simple-redis-admin-1.4.0/django_simple_redis_admin.egg-info/not-zip-safe0000644000000000000240000000000112770372607027627 0ustar rootstaff00000000000000 django-simple-redis-admin-1.4.0/django_simple_redis_admin.egg-info/PKG-INFO0000644000000000000240000000350112770372607026475 0ustar rootstaff00000000000000Metadata-Version: 1.1 Name: django-simple-redis-admin Version: 1.4.0 Summary: A django admin application to manage redis cache keys. Home-page: https://github.com/nicholasserra/django-simple-redis-admin Author: Nicholas Serra Author-email: nick@528hazelwood.com License: UNKNOWN Description: [![Build Status](https://travis-ci.org/nicholasserra/django-simple-redis-admin.svg?branch=travis)](https://travis-ci.org/nicholasserra/django-simple-redis-admin) django-simple-redis-admin ========= `django-simple-redis-admin` is an addition to your Django admin panel that allows you to view and delete your Redis keys. Requirements ------------ * Django >= 1.8 <= 1.10 * A Django redis cache backend. I recommend [django-redis-cache](https://github.com/sebleier/django-redis-cache) Installation ------------ `django-simple-redis-admin` can be installed via pip. ``` pip install django-simple-redis-admin ``` Then just add `redis_admin` to your `INSTALLED_APPS`. Why simple? ----------- This package does not use models, so no database tables need to be created. Just add to INSTALLED_APPS and go. Users must have is_superuser == True to view the Redis admin. No django admin logs are created with this package. To Do ----- * Editing keys * Better representation for Redis sets Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Framework :: Django django-simple-redis-admin-1.4.0/django_simple_redis_admin.egg-info/SOURCES.txt0000644000000000000240000000134712770372607027272 0ustar rootstaff00000000000000MANIFEST.in README.md setup.py django_simple_redis_admin.egg-info/PKG-INFO django_simple_redis_admin.egg-info/SOURCES.txt django_simple_redis_admin.egg-info/dependency_links.txt django_simple_redis_admin.egg-info/not-zip-safe django_simple_redis_admin.egg-info/top_level.txt redis_admin/__init__.py redis_admin/admin.py redis_admin/compat.py redis_admin/models.py redis_admin/templates/redis_admin/delete_confirmation.html redis_admin/templates/redis_admin/delete_selected_confirmation.html redis_admin/templates/redis_admin/index.html redis_admin/templates/redis_admin/key.html redis_admin/templatetags/__init__.py redis_admin/templatetags/compat.py redis_admin/tests/__init__.py redis_admin/tests/test_admin.py redis_admin/tests/test_urls.pydjango-simple-redis-admin-1.4.0/django_simple_redis_admin.egg-info/top_level.txt0000644000000000000240000000001412770372607030126 0ustar rootstaff00000000000000redis_admin django-simple-redis-admin-1.4.0/MANIFEST.in0000755000076500000240000000011012316414265020243 0ustar nickstaff00000000000000include README.md recursive-include redis_admin/templates/redis_admin * django-simple-redis-admin-1.4.0/PKG-INFO0000644000000000000240000000350112770372607017632 0ustar rootstaff00000000000000Metadata-Version: 1.1 Name: django-simple-redis-admin Version: 1.4.0 Summary: A django admin application to manage redis cache keys. Home-page: https://github.com/nicholasserra/django-simple-redis-admin Author: Nicholas Serra Author-email: nick@528hazelwood.com License: UNKNOWN Description: [![Build Status](https://travis-ci.org/nicholasserra/django-simple-redis-admin.svg?branch=travis)](https://travis-ci.org/nicholasserra/django-simple-redis-admin) django-simple-redis-admin ========= `django-simple-redis-admin` is an addition to your Django admin panel that allows you to view and delete your Redis keys. Requirements ------------ * Django >= 1.8 <= 1.10 * A Django redis cache backend. I recommend [django-redis-cache](https://github.com/sebleier/django-redis-cache) Installation ------------ `django-simple-redis-admin` can be installed via pip. ``` pip install django-simple-redis-admin ``` Then just add `redis_admin` to your `INSTALLED_APPS`. Why simple? ----------- This package does not use models, so no database tables need to be created. Just add to INSTALLED_APPS and go. Users must have is_superuser == True to view the Redis admin. No django admin logs are created with this package. To Do ----- * Editing keys * Better representation for Redis sets Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Framework :: Django django-simple-redis-admin-1.4.0/README.md0000644000076500000240000000173312770372524020002 0ustar nickstaff00000000000000[![Build Status](https://travis-ci.org/nicholasserra/django-simple-redis-admin.svg?branch=travis)](https://travis-ci.org/nicholasserra/django-simple-redis-admin) django-simple-redis-admin ========= `django-simple-redis-admin` is an addition to your Django admin panel that allows you to view and delete your Redis keys. Requirements ------------ * Django >= 1.8 <= 1.10 * A Django redis cache backend. I recommend [django-redis-cache](https://github.com/sebleier/django-redis-cache) Installation ------------ `django-simple-redis-admin` can be installed via pip. ``` pip install django-simple-redis-admin ``` Then just add `redis_admin` to your `INSTALLED_APPS`. Why simple? ----------- This package does not use models, so no database tables need to be created. Just add to INSTALLED_APPS and go. Users must have is_superuser == True to view the Redis admin. No django admin logs are created with this package. To Do ----- * Editing keys * Better representation for Redis sets django-simple-redis-admin-1.4.0/redis_admin/0000755000000000000240000000000012770372607021014 5ustar rootstaff00000000000000django-simple-redis-admin-1.4.0/redis_admin/__init__.py0000644000076500000240000000000012316414265023067 0ustar nickstaff00000000000000django-simple-redis-admin-1.4.0/redis_admin/admin.py0000644000076500000240000000755512770372524022453 0ustar nickstaff00000000000000from django.contrib import admin from django.db import models from django.conf.urls import url from django.core.cache import cache from django.shortcuts import render from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, Http404 from django.contrib.auth.decorators import user_passes_test from django.utils.decorators import method_decorator from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.contrib import messages class RedisAdmin(admin.ModelAdmin): def get_urls(self): urls = super(RedisAdmin, self).get_urls() my_urls = [ url(r'^$', self.index), url(r'^(?P.+)/delete/$', self.delete), url(r'^(?P.+)/$', self.key), ] return my_urls + urls @method_decorator(user_passes_test(lambda u: u.is_superuser)) def index(self, request): if request.method == 'POST' and request.POST.getlist('_selected_action') and \ request.POST.get('action') == 'delete_selected' and \ request.POST.get('post') == 'yes': if cache.master_client.delete(*request.POST.getlist('_selected_action')): messages.add_message(request, messages.SUCCESS, 'Successfully deleted %d keys.' % len(request.POST.getlist('_selected_action'))) else: messages.add_message(request, messages.ERROR, 'Could not delete %d keys.' % len(request.POST.getlist('_selected_action'))) elif request.method == 'POST' and request.POST.getlist('_selected_action') and \ request.POST.get('action') == 'delete_selected': return render(request, 'redis_admin/delete_selected_confirmation.html', {'keys': request.POST.getlist('_selected_action')}) if request.GET.get('q'): keys_result = cache.master_client.keys('*%s*' % request.GET.get('q')) else: keys_result = cache.master_client.keys('*') paginator = Paginator(keys_result, 100) page = request.GET.get('p') try: keys = paginator.page(page) except PageNotAnInteger: keys = paginator.page(1) except EmptyPage: keys = paginator.page(paginator.num_pages) return render(request, 'redis_admin/index.html', {'keys': keys, 'count': paginator.count, 'page_range': paginator.page_range}) @method_decorator(user_passes_test(lambda u: u.is_superuser)) def key(self, request, key): key_type = cache.master_client.type(key) if key_type == 'none': raise Http404 context = {'key': key, 'type': key_type} if key_type == 'string': context['value'] = cache.master_client.get(key) elif key_type == 'set': context['value'] = str(cache.master_client.smembers(key)) return render(request, 'redis_admin/key.html', context) @method_decorator(user_passes_test(lambda u: u.is_superuser)) def delete(self, request, key): if request.method == "POST" and request.POST.get('post') == 'yes': if cache.master_client.delete(key): messages.add_message(request, messages.SUCCESS, 'The key "%s" was deleted successfully.' % key) else: messages.add_message(request, messages.ERROR, 'The key "%s" was not deleted successfully.' % key) return HttpResponseRedirect('%sredis_admin/manage/' % reverse('admin:index')) return render(request, 'redis_admin/delete_confirmation.html', {'key': key}) class Meta: app_label = 'redis_admin' verbose_name = 'Manage' verbose_name_plural = "Manage" admin.site.register(type('manage', (models.Model,), {'__module__': '', 'Meta': Meta}), RedisAdmin) django-simple-redis-admin-1.4.0/redis_admin/compat.py0000644000076500000240000000051112710311242022607 0ustar nickstaff00000000000000import django def get_library(): if django.VERSION >= (1, 9): from django.template.library import Library else: from django.template.base import Library return Library if django.VERSION < (1, 5): from django.templatetags.future import url else: from django.template.defaulttags import url django-simple-redis-admin-1.4.0/redis_admin/models.py0000644000076500000240000000000012316414265022613 0ustar nickstaff00000000000000django-simple-redis-admin-1.4.0/redis_admin/templates/0000755000000000000240000000000012770372607023012 5ustar rootstaff00000000000000django-simple-redis-admin-1.4.0/redis_admin/templates/redis_admin/0000755000000000000240000000000012770372607025270 5ustar rootstaff00000000000000django-simple-redis-admin-1.4.0/redis_admin/templates/redis_admin/delete_confirmation.html0000644000076500000240000000145212710311242032133 0ustar nickstaff00000000000000{% extends "admin/base_site.html" %} {% load i18n admin_static admin_modify %} {% load url from compat %} {% load admin_urls %} {% if not is_popup %} {% block breadcrumbs %} {% endblock %} {% endif %} {% block content %}

Are you sure you want to delete the key "{{ key }}"?

{% csrf_token %}
{% endblock %} django-simple-redis-admin-1.4.0/redis_admin/templates/redis_admin/delete_selected_confirmation.html0000644000076500000240000000216612710311242034006 0ustar nickstaff00000000000000{% extends "admin/base_site.html" %} {% load i18n admin_static admin_modify %} {% load url from compat %} {% load admin_urls %} {% if not is_popup %} {% block breadcrumbs %} {% endblock %} {% endif %} {% block content %}

{% blocktrans %}Are you sure you want to delete the selected keys?{% endblocktrans %}

{% csrf_token %}
{% for key in keys %} {% endfor %}
{% endblock %} django-simple-redis-admin-1.4.0/redis_admin/templates/redis_admin/index.html0000644000076500000240000001144312710311242027231 0ustar nickstaff00000000000000{% extends "admin/base_site.html" %} {% load i18n admin_static admin_list %} {% load url from compat %} {% load admin_urls %} {% block extrastyle %} {{ block.super }} {% url 'admin:jsi18n' as jsi18nurl %} {{ media.css }} {% endblock %} {% block extrahead %} {{ block.super }} {% endblock %} {% block bodyclass %}change-list{% endblock %} {% if not is_popup %} {% block breadcrumbs %} {% endblock %} {% endif %} {% block coltype %}flex{% endblock %} {% block content %}
{% csrf_token %}
0 of {{ keys|length }} selected
{% for key in keys %} {% endfor %}
{{ key }}

{% for page in page_range %} {% if keys.number == forloop.counter %} {{ keys.number }} {% elif forloop.last %} {{ page }} {% else %} {{ page }} {% endif %} {% endfor %} {{ count }} keys

{% endblock %} django-simple-redis-admin-1.4.0/redis_admin/templates/redis_admin/key.html0000644000076500000240000000364612710311242026720 0ustar nickstaff00000000000000{% extends "admin/base_site.html" %} {% load i18n admin_static admin_modify %} {% load url from compat %} {% load admin_urls %} {% block extrahead %}{{ block.super }} {% url 'admin:jsi18n' as jsi18nurl %} {{ media }} {% endblock %} {% block extrastyle %}{{ block.super }}{% endblock %} {% block coltype %}{% if ordered_objects %}colMS{% else %}colM{% endif %}{% endblock %} {% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %} {% if not is_popup %} {% block breadcrumbs %} {% endblock %} {% endif %} {% block content %}
{% if errors %}

{% blocktrans count counter=errors|length %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}

{{ adminform.form.non_field_errors }} {% endif %}

{{ key }}

{% endblock %} django-simple-redis-admin-1.4.0/redis_admin/templatetags/0000755000000000000240000000000012770372607023506 5ustar rootstaff00000000000000django-simple-redis-admin-1.4.0/redis_admin/templatetags/__init__.py0000644000076500000240000000000012710311242025546 0ustar nickstaff00000000000000django-simple-redis-admin-1.4.0/redis_admin/templatetags/compat.py0000644000076500000240000000030412710311242025301 0ustar nickstaff00000000000000from redis_admin.compat import url as redis_admin_url, get_library Library = get_library() register = Library() @register.tag def url(parser, token): return redis_admin_url(parser, token) django-simple-redis-admin-1.4.0/redis_admin/tests/0000755000000000000240000000000012770372607022156 5ustar rootstaff00000000000000django-simple-redis-admin-1.4.0/redis_admin/tests/__init__.py0000644000076500000240000000003012316615102024225 0ustar nickstaff00000000000000from test_admin import *django-simple-redis-admin-1.4.0/redis_admin/tests/test_admin.py0000644000076500000240000000321112770372524024635 0ustar nickstaff00000000000000from django.contrib.auth.models import User from django.core.cache import cache from django.test import override_settings, TestCase @override_settings(ROOT_URLCONF='redis_admin.tests.test_urls') class RedisAdminSanityTests(TestCase): def setUp(self): self.user = User.objects.create_superuser('test', 'test@test.com', 'password') self.client.login(username=self.user.username, password='password') def test_admin_accessible(self): response = self.client.get('/admin/') self.assertEqual(200, response.status_code) @override_settings(ROOT_URLCONF='redis_admin.tests.test_urls') class RedisAdminViewsTests(TestCase): def setUp(self): self.user = User.objects.create_superuser('test', 'test@test.com', 'password') self.client.login(username=self.user.username, password='password') cache.master_client.set('test-redis-admin', 'test') def test_index(self): response = self.client.get('/admin/redis_admin/manage/') self.assertEqual(200, response.status_code) def test_key(self): response = self.client.get('/admin/redis_admin/manage/test-redis-admin/') self.assertEqual(200, response.status_code) def test_delete_key_confirmation(self): response = self.client.get('/admin/redis_admin/manage/test-redis-admin/delete/') self.assertEqual(200, response.status_code) def test_delete_key_action(self): response = self.client.post('/admin/redis_admin/manage/test-redis-admin/delete/', {'post': 'yes'}) self.assertEqual(302, response.status_code) def tearDown(self): cache.master_client.delete('test-redis-admin') django-simple-redis-admin-1.4.0/redis_admin/tests/test_urls.py0000644000076500000240000000024312770372524024534 0ustar nickstaff00000000000000from django.conf.urls import include, url from django.contrib import admin admin.autodiscover() urlpatterns = [ url(r'^admin/', include(admin.site.urls)), ] django-simple-redis-admin-1.4.0/setup.cfg0000644000000000000240000000007312770372607020357 0ustar rootstaff00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 django-simple-redis-admin-1.4.0/setup.py0000755000076500000240000000142312770372524020234 0ustar nickstaff00000000000000from setuptools import setup, find_packages setup( name='django-simple-redis-admin', version='1.4.0', description='A django admin application to manage redis cache keys.', long_description=open('README.md').read(), author='Nicholas Serra', author_email='nick@528hazelwood.com', url='https://github.com/nicholasserra/django-simple-redis-admin', packages=find_packages(exclude=[]), include_package_data=True, classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Framework :: Django', ], zip_safe=False, )