Skip to content

Commit

Permalink
revert changes made to queue field in model (moved back queue choices…
Browse files Browse the repository at this point in the history
… to admin form)
  • Loading branch information
ftrabucchi-eab authored and tom-price committed Jul 1, 2018
1 parent d868081 commit 12f6a5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 8 additions & 0 deletions scheduler/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from scheduler.models import CronJob, RepeatableJob, ScheduledJob


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


class QueueMixin(object):
actions = ['delete_model']

Expand All @@ -15,6 +18,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 @@ -16,16 +16,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)
timeout = models.IntegerField(
Expand Down

0 comments on commit 12f6a5d

Please sign in to comment.