Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from advisory/unschedule-when-delete
Browse files Browse the repository at this point in the history
revert changes made to queue field in model
  • Loading branch information
bafio authored Jan 5, 2018
2 parents 383b510 + 84fb328 commit ce4dcd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 9 additions & 0 deletions scheduler/admin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from __future__ import unicode_literals

from django.conf import settings
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from scheduler.models import RepeatableJob, ScheduledJob
from scheduler.forms import JobAdminForm


QUEUES = [(key, key) for key in settings.RQ_QUEUES.keys()]


class QueueMixin(object):
form = JobAdminForm
actions = ['delete_model']
Expand All @@ -16,6 +20,11 @@ def get_actions(self, request):
del actions['delete_selected']
return actions

def get_form(self, request, obj=None, **kwargs):
queue_field = self.model._meta.get_field('queue')
queue_field.choices = QUEUES
return super(QueueMixin, self).get_form(request, obj, **kwargs)

def delete_model(self, request, obj):
if hasattr(obj, 'all'):
for o in obj.all():
Expand Down
5 changes: 1 addition & 4 deletions scheduler/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@
from model_utils.models import TimeStampedModel


QUEUES = [(key, key) for key in settings.RQ_QUEUES.keys()]


@python_2_unicode_compatible
class BaseJob(TimeStampedModel):

name = models.CharField(_('name'), max_length=128, unique=True)
callable = models.CharField(_('callable'), max_length=2048)
enabled = models.BooleanField(_('enabled'), default=True)
queue = models.CharField(_('queue'), max_length=16, choices=QUEUES)
queue = models.CharField(_('queue'), max_length=16)
job_id = models.CharField(
_('job id'), max_length=128, editable=False, blank=True, null=True)
scheduled_time = models.DateTimeField(_('scheduled time'))
Expand Down

0 comments on commit ce4dcd5

Please sign in to comment.