├── LICENSE ├── MANIFEST.in ├── README.md ├── celery_admin ├── __init__.py └── admin.py └── setup.py /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, National Geographic Society 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | * Neither the name of the National Geographic Society nor the names of 16 | its contributors may be used to endorse or promote products derived 17 | from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include README.md 3 | include MANIFEST.in 4 | recursive-include celery_admin/templates * 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This app adds the ability to manually run a periodic celery task from the Django Admin. It requires *Django 1.3+* and 2 | [ask/django-celery](http://github.com/ask/django-celery). 3 | 4 | This app was forked from and inspired by [erussell/django-redis-status](http://github.com/erussell/django-redis-status). 5 | 6 | 7 | Installation 8 | --------- 9 | 10 | Put ``celery_admin`` in your ``INSTALLED_APPS``. 11 | 12 | That's all. Only admin-users with ``superuser`` permission can see these stats. 13 | -------------------------------------------------------------------------------- /celery_admin/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madirey/django-celery-admin-ext/d6f9b987ccbab7b7bc1c1433494907007001878e/celery_admin/__init__.py -------------------------------------------------------------------------------- /celery_admin/admin.py: -------------------------------------------------------------------------------- 1 | from celery.execute import send_task 2 | from django.contrib import admin 3 | from djcelery import admin as djcelery_admin 4 | from djcelery.models import PeriodicTask 5 | 6 | class ExtendedPeriodicTaskAdmin(djcelery_admin.PeriodicTaskAdmin): 7 | actions = djcelery_admin.PeriodicTaskAdmin.actions + ['run_task'] 8 | 9 | def run_task(self, request, queryset): 10 | if request.user.is_superuser: 11 | for task in queryset.all(): 12 | send_task(task.task) 13 | self.message = 'Tasks are running' 14 | else: 15 | self.message = 'You must be a superuser to perform this action.' 16 | run_task.short_description = 'Run Task' 17 | 18 | admin.site.unregister(PeriodicTask) 19 | admin.site.register(PeriodicTask, ExtendedPeriodicTaskAdmin) 20 | 21 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup( 4 | name='django-celery-admin-ext', 5 | version='1.0-mc2', 6 | description='A django application that lets you kick off periodic celery tasks from the admin.', 7 | long_description=open('README.md').read(), 8 | author='Matt Caldwell', 9 | author_email='mcaldwel@ngs.org', 10 | url='http://github.com/mattcaldwell/django-celery-admin-ext', 11 | packages=find_packages(exclude=[]), 12 | include_package_data=True, 13 | classifiers=[ 14 | 'Development Status :: 4 - Beta', 15 | 'Environment :: Web Environment', 16 | 'Intended Audience :: Developers', 17 | 'License :: OSI Approved :: BSD License', 18 | 'Operating System :: OS Independent', 19 | 'Programming Language :: Python', 20 | 'Framework :: Django', 21 | ], 22 | zip_safe=False, 23 | ) 24 | --------------------------------------------------------------------------------