[Python-modules-commits] [django-simple-redis-admin] 01/06: import django-simple-redis-admin_1.4.0.orig.tar.gz

Scott Kitterman kitterman at moszumanska.debian.org
Tue Nov 15 05:03:55 UTC 2016


This is an automated email from the git hooks/post-receive script.

kitterman pushed a commit to branch master
in repository django-simple-redis-admin.

commit a4f05b8303ed4eed7280bfae65cd7dcde66bf7c9
Author: Scott Kitterman <scott at kitterman.com>
Date:   Mon Nov 14 22:01:33 2016 -0500

    import django-simple-redis-admin_1.4.0.orig.tar.gz
---
 MANIFEST.in                                        |   2 +
 PKG-INFO                                           |  49 +++++++++
 README.md                                          |  32 ++++++
 django_simple_redis_admin.egg-info/PKG-INFO        |  49 +++++++++
 django_simple_redis_admin.egg-info/SOURCES.txt     |  21 ++++
 .../dependency_links.txt                           |   1 +
 django_simple_redis_admin.egg-info/not-zip-safe    |   1 +
 django_simple_redis_admin.egg-info/top_level.txt   |   1 +
 redis_admin/__init__.py                            |   0
 redis_admin/admin.py                               |  98 +++++++++++++++++
 redis_admin/compat.py                              |  15 +++
 redis_admin/models.py                              |   0
 .../templates/redis_admin/delete_confirmation.html |  25 +++++
 .../redis_admin/delete_selected_confirmation.html  |  35 ++++++
 redis_admin/templates/redis_admin/index.html       | 120 +++++++++++++++++++++
 redis_admin/templates/redis_admin/key.html         |  55 ++++++++++
 redis_admin/templatetags/__init__.py               |   0
 redis_admin/templatetags/compat.py                 |  10 ++
 redis_admin/tests/__init__.py                      |   1 +
 redis_admin/tests/test_admin.py                    |  44 ++++++++
 redis_admin/tests/test_urls.py                     |   8 ++
 setup.cfg                                          |   5 +
 setup.py                                           |  23 ++++
 23 files changed, 595 insertions(+)

diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100755
index 0000000..f5b5780
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,2 @@
+include README.md
+recursive-include redis_admin/templates/redis_admin *
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..ad2114b
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,49 @@
+Metadata-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 at 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
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1f338fe
--- /dev/null
+++ b/README.md
@@ -0,0 +1,32 @@
+[![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
diff --git a/django_simple_redis_admin.egg-info/PKG-INFO b/django_simple_redis_admin.egg-info/PKG-INFO
new file mode 100644
index 0000000..ad2114b
--- /dev/null
+++ b/django_simple_redis_admin.egg-info/PKG-INFO
@@ -0,0 +1,49 @@
+Metadata-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 at 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
diff --git a/django_simple_redis_admin.egg-info/SOURCES.txt b/django_simple_redis_admin.egg-info/SOURCES.txt
new file mode 100644
index 0000000..1e84e60
--- /dev/null
+++ b/django_simple_redis_admin.egg-info/SOURCES.txt
@@ -0,0 +1,21 @@
+MANIFEST.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.py
\ No newline at end of file
diff --git a/django_simple_redis_admin.egg-info/dependency_links.txt b/django_simple_redis_admin.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/django_simple_redis_admin.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/django_simple_redis_admin.egg-info/not-zip-safe b/django_simple_redis_admin.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/django_simple_redis_admin.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/django_simple_redis_admin.egg-info/top_level.txt b/django_simple_redis_admin.egg-info/top_level.txt
new file mode 100644
index 0000000..bbfcff2
--- /dev/null
+++ b/django_simple_redis_admin.egg-info/top_level.txt
@@ -0,0 +1 @@
+redis_admin
diff --git a/redis_admin/__init__.py b/redis_admin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/redis_admin/admin.py b/redis_admin/admin.py
new file mode 100644
index 0000000..a604225
--- /dev/null
+++ b/redis_admin/admin.py
@@ -0,0 +1,98 @@
+from 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<key>.+)/delete/$', self.delete),
+            url(r'^(?P<key>.+)/$', 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)
diff --git a/redis_admin/compat.py b/redis_admin/compat.py
new file mode 100644
index 0000000..94afc38
--- /dev/null
+++ b/redis_admin/compat.py
@@ -0,0 +1,15 @@
+import 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
diff --git a/redis_admin/models.py b/redis_admin/models.py
new file mode 100644
index 0000000..e69de29
diff --git a/redis_admin/templates/redis_admin/delete_confirmation.html b/redis_admin/templates/redis_admin/delete_confirmation.html
new file mode 100644
index 0000000..3a2dec3
--- /dev/null
+++ b/redis_admin/templates/redis_admin/delete_confirmation.html
@@ -0,0 +1,25 @@
+{% extends "admin/base_site.html" %}
+{% load i18n admin_static admin_modify %}
+{% load url from compat %}
+{% load admin_urls %}
+
+{% if not is_popup %}
+{% block breadcrumbs %}
+<div class="breadcrumbs">
+    <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
+    › <a href="{% url 'admin:index' %}redis_admin/manage/">Manage</a> ›
+    {% trans 'Delete' %}
+</div>
+{% endblock %}
+{% endif %}
+
+{% block content %}
+    <p>Are you sure you want to delete the key "{{ key }}"?</p>
+    <ul><li>Key: <a href="{% url 'admin:index' %}redis_admin/manage/{{ key }}">{{ key }}</a></li></ul>
+    <form action="" method="post">{% csrf_token %}
+    <div>
+    <input type="hidden" name="post" value="yes" />
+    <input type="submit" value="{% trans "Yes, I'm sure" %}" />
+    </div>
+    </form>
+{% endblock %}
diff --git a/redis_admin/templates/redis_admin/delete_selected_confirmation.html b/redis_admin/templates/redis_admin/delete_selected_confirmation.html
new file mode 100644
index 0000000..e9730c6
--- /dev/null
+++ b/redis_admin/templates/redis_admin/delete_selected_confirmation.html
@@ -0,0 +1,35 @@
+{% extends "admin/base_site.html" %}
+{% load i18n admin_static admin_modify %}
+{% load url from compat %}
+{% load admin_urls %}
+
+
+{% if not is_popup %}
+{% block breadcrumbs %}
+    <div class="breadcrumbs">
+        <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
+        › <a href="{% url 'admin:index' %}redis_admin/manage/">Manage</a> ›
+        {% trans 'Delete multiple objects' %}
+</div>
+{% endblock %}
+{% endif %}
+
+
+{% block content %}
+    <p>{% blocktrans %}Are you sure you want to delete the selected keys?{% endblocktrans %}</p>
+        <ul>
+            {% for key in keys %}
+            <li>Key: <a href="{% url 'admin:index' %}redis_admin/manage/{{ key }}">{{ key }}</a></li>
+            {% endfor %}
+        </ul>
+    <form action="" method="post">{% csrf_token %}
+    <div>
+    {% for key in keys %}
+    <input type="hidden" name="_selected_action" value="{{ key }}" />
+    {% endfor %}
+    <input type="hidden" name="action" value="delete_selected" />
+    <input type="hidden" name="post" value="yes" />
+    <input type="submit" value="{% trans "Yes, I'm sure" %}" />
+    </div>
+    </form>
+{% endblock %}
diff --git a/redis_admin/templates/redis_admin/index.html b/redis_admin/templates/redis_admin/index.html
new file mode 100644
index 0000000..3184ebb
--- /dev/null
+++ b/redis_admin/templates/redis_admin/index.html
@@ -0,0 +1,120 @@
+{% extends "admin/base_site.html" %}
+{% load i18n admin_static admin_list %}
+{% load url from compat %}
+{% load admin_urls %}
+
+{% block extrastyle %}
+  {{ block.super }}
+  <link rel="stylesheet" type="text/css" href="{% static "admin/css/changelists.css" %}" />
+    <link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />
+    {% url 'admin:jsi18n' as jsi18nurl %}
+    <script type="text/javascript" src="{{ jsi18nurl|default:'../../jsi18n/' }}"></script>
+  {{ media.css }}
+{% endblock %}
+
+{% block extrahead %}
+{{ block.super }}
+
+
+<script type="text/javascript" src="{{ STATIC_URL }}admin/js/core.js"></script>
+<script type="text/javascript" src="{{ STATIC_URL }}admin/js/admin/RelatedObjectLookups.js"></script>
+<script type="text/javascript" src="{{ STATIC_URL }}admin/js/jquery.js"></script>
+<script type="text/javascript" src="{{ STATIC_URL }}admin/js/jquery.init.js"></script>
+<script type="text/javascript" src="{{ STATIC_URL }}admin/js/actions.js"></script>
+
+
+<script type="text/javascript">
+(function($) {
+    $(document).ready(function($) {
+        $("tr input.action-select").actions();
+    });
+})(django.jQuery);
+</script>
+{% endblock %}
+
+{% block bodyclass %}change-list{% endblock %}
+
+{% if not is_popup %}
+{% block breadcrumbs %}
+<div class="breadcrumbs">
+<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
+</div>
+{% endblock %}
+{% endif %}
+
+{% block coltype %}flex{% endblock %}
+
+
+{% block content %}
+<div id="content-main">
+    <div class="module" id="changelist">
+        <div id="toolbar">
+            <form id="changelist-search" action="" method="get">
+                <div><!-- DIV needed for valid HTML -->
+                    <label for="searchbar"><img src="{{ STATIC_URL }}admin/img/icon_searchbox.png" alt="Search" /></label>
+                    <input type="text" size="40" name="q" value="" id="searchbar" />
+                    <input type="submit" value="Search" />
+                </div>
+            </form>
+        </div>
+        <script type="text/javascript">document.getElementById("searchbar").focus();</script>
+        <form id="changelist-form" action="" method="post">{% csrf_token %}
+            <div class="actions">
+                <label>Action: 
+                    <select name="action">
+                        <option value="" selected="selected">---------</option>
+                        <option value="delete_selected">Delete selected keys</option>
+                    </select>
+                </label>
+                <input type="hidden" class="select-across" value="0" name="select_across" />
+                <button type="submit" class="button" title="Run the selected action" name="index" value="0">Go</button>
+                <script type="text/javascript">var _actions_icnt="{{ keys|length }}";</script>
+                <span class="action-counter">0 of {{ keys|length }} selected</span>
+            </div>
+            <div class="results">
+                <table id="result_list">
+                    <thead>
+                        <tr>
+                            <th scope="col"  class="action-checkbox-column">
+                               <div class="text"><span><input type="checkbox" id="action-toggle" style="display: inline;" /></span></div>
+                               <div class="clear"></div>
+                            </th>
+                            <th scope="col"  class="sortable">
+                                <div class="text"><a href="?o=5.1">Key</a></div>
+                                <div class="clear"></div>
+                            </th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        {% for key in keys %}
+                        <tr class="{% cycle 'row1' 'row2' %}">
+                            <td class="action-checkbox">
+                                <input type="checkbox" class="action-select" value="{{ key }}" name="_selected_action" />
+                            </td>
+                            <th>
+                                <a href="{% url 'admin:index' %}redis_admin/manage/{{ key }}/">{{ key }}</a>
+                            </th>
+                        </tr>
+                        {% endfor %}
+                    </tbody>
+                </table>
+            </div>
+            
+            <p class="paginator">
+                {% for page in page_range %}
+                
+                    {% if keys.number == forloop.counter %}
+                    <span class="this-page">{{ keys.number }}</span> 
+                    {% elif forloop.last %}
+                    <a class="end" href="?p={{ page }}">{{ page }}</a>
+                    {% else %}
+                    <a href="?p={{ page }}">{{ page }}</a>
+                    {% endif %}
+                {% endfor %}
+
+            {{ count }} keys
+            </p>
+        </form>
+    </div>
+</div>
+{% endblock %}
diff --git a/redis_admin/templates/redis_admin/key.html b/redis_admin/templates/redis_admin/key.html
new file mode 100644
index 0000000..f142ce7
--- /dev/null
+++ b/redis_admin/templates/redis_admin/key.html
@@ -0,0 +1,55 @@
+{% 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 %}
+<script type="text/javascript" src="{{ jsi18nurl|default:"../../../jsi18n/" }}"></script>
+{{ media }}
+{% endblock %}
+
+{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% 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 %}
+<div class="breadcrumbs">
+<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
+› <a href="{% url 'admin:index' %}redis_admin/manage/">Manage</a>
+</div>
+{% endblock %}
+{% endif %}
+
+{% block content %}
+<div id="content-main">
+    <div>
+        {% if errors %}
+        <p class="errornote">
+            {% blocktrans count counter=errors|length %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
+        </p>
+        {{ adminform.form.non_field_errors }}
+        {% endif %}
+        <fieldset class="module aligned">
+            <div class="form-row">
+                <div>
+                    <label for="id_key" class="required">Key</label>
+                    <p>{{ key }}</p>
+                </div>
+            </div>
+            <div class="form-row">
+                <div>
+                    <label for="id_value" class="required">Value</label>
+                    <textarea id="id_value" rows="10" cols="40" name="value" class="vLargeTextField">{{ value }}</textarea>
+                </div>
+            </div>
+        </fieldset>
+        <div class="submit-row">
+            <p class="deletelink-box"><a href="delete/" class="deletelink">Delete</a></p>
+        </div>
+    </div>
+</div>
+{% endblock %}
diff --git a/redis_admin/templatetags/__init__.py b/redis_admin/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/redis_admin/templatetags/compat.py b/redis_admin/templatetags/compat.py
new file mode 100644
index 0000000..80bee80
--- /dev/null
+++ b/redis_admin/templatetags/compat.py
@@ -0,0 +1,10 @@
+from redis_admin.compat import url as redis_admin_url, get_library
+
+
+Library = get_library()
+register = Library()
+
+
+ at register.tag
+def url(parser, token):
+    return redis_admin_url(parser, token)
diff --git a/redis_admin/tests/__init__.py b/redis_admin/tests/__init__.py
new file mode 100644
index 0000000..1723617
--- /dev/null
+++ b/redis_admin/tests/__init__.py
@@ -0,0 +1 @@
+from test_admin import *
\ No newline at end of file
diff --git a/redis_admin/tests/test_admin.py b/redis_admin/tests/test_admin.py
new file mode 100644
index 0000000..eda4efc
--- /dev/null
+++ b/redis_admin/tests/test_admin.py
@@ -0,0 +1,44 @@
+from django.contrib.auth.models import User
+from django.core.cache import cache
+from django.test import override_settings, TestCase
+
+
+ at override_settings(ROOT_URLCONF='redis_admin.tests.test_urls')
+class RedisAdminSanityTests(TestCase):
+
+    def setUp(self):
+        self.user = User.objects.create_superuser('test', 'test at 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)
+
+
+ at override_settings(ROOT_URLCONF='redis_admin.tests.test_urls')
+class RedisAdminViewsTests(TestCase):
+
+    def setUp(self):
+        self.user = User.objects.create_superuser('test', 'test at 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')
diff --git a/redis_admin/tests/test_urls.py b/redis_admin/tests/test_urls.py
new file mode 100644
index 0000000..7191b32
--- /dev/null
+++ b/redis_admin/tests/test_urls.py
@@ -0,0 +1,8 @@
+from django.conf.urls import include, url
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = [
+    url(r'^admin/', include(admin.site.urls)),
+]
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..861a9f5
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,5 @@
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..893b6a9
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,23 @@
+from 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 at 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,
+)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-simple-redis-admin.git



More information about the Python-modules-commits mailing list