Let notify_credentials get args from db

To allow the notify_credentials management command to run from a
jenkins job, we want to allow the command to pull its arguments
from the database, rather than the jenkins interface.

So this adds a table that admins can adjust in the DB and a new
argument for notify_credentials to tell it to go look there.

LEARNER-6196
LEARNER-6197
This commit is contained in:
Michael Terry
2018-08-17 13:45:36 -04:00
committed by Michael Terry
parent f022e98971
commit 6f7b19b6bf
5 changed files with 104 additions and 2 deletions

View File

@@ -108,3 +108,22 @@ class CredentialsApiConfig(ConfigurationModel):
def is_cache_enabled(self):
"""Whether responses from the Credentials API will be cached."""
return self.cache_ttl > 0
class NotifyCredentialsConfig(ConfigurationModel):
"""
Manages configuration for a run of the notify_credentials management command.
"""
class Meta(object):
app_label = 'credentials'
verbose_name = 'notify_credentials argument'
arguments = models.TextField(
blank=True,
help_text='Useful for manually running a Jenkins job. Specify like "--start-date=2018 --courses A B".',
default='',
)
def __unicode__(self):
return unicode(self.arguments)