Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
9832af02
Commit
9832af02
authored
1 year ago
by
Jonas Braathen
Browse files
Options
Downloads
Patches
Plain Diff
Add support for running a one-off role end notification, for debugging
parent
88a03127
No related branches found
No related tags found
1 merge request
!404
Role end notifier insight
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
greg/management/commands/role_end_notifier.py
+30
-7
30 additions, 7 deletions
greg/management/commands/role_end_notifier.py
with
30 additions
and
7 deletions
greg/management/commands/role_end_notifier.py
+
30
−
7
View file @
9832af02
"""
"""
Command for scheduling
the django-q
task for notifying sponsors of
Command for scheduling
or running the
task for notifying sponsors of
expiring roles.
expiring roles.
Instead of having a task that gets scheduled, we could have had a
management command that was run as a cronjob. However, that would mean
another cronjob
"""
"""
import
logging
import
logging
import
logging.config
import
logging.config
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.management.base
import
BaseCommand
from
django.core.management.base
import
BaseCommand
,
CommandParser
from
django.db
import
transaction
from
django_q.tasks
import
schedule
from
django_q.tasks
import
schedule
from
greg.tasks
import
notify_sponsors_roles_ending
logging
.
config
.
dictConfig
(
settings
.
LOGGING
)
logging
.
config
.
dictConfig
(
settings
.
LOGGING
)
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
help
=
"
Schedule notification of sponsors
"
help
=
__doc__
def
add_arguments
(
self
,
parser
:
CommandParser
)
->
None
:
parser
.
add_argument
(
"
--schedule
"
,
default
=
False
,
action
=
"
store_true
"
,
help
=
"
Add a scheduled task for running the role end notifier
"
,
)
parser
.
add_argument
(
"
--run-once
"
,
default
=
False
,
action
=
"
store_true
"
,
help
=
"
Run the import once
"
,
)
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
if
options
[
"
schedule
"
]:
self
.
schedule
()
return
if
options
[
"
run_once
"
]:
notify_sponsors_roles_ending
()
return
logger
.
info
(
"
Nothing done
"
)
def
schedule
(
self
,
*
args
,
**
options
):
logger
.
info
(
"
Scheduling role end notifier task...
"
)
logger
.
info
(
"
Scheduling role end notifier task...
"
)
schedule
(
schedule
(
func
=
"
greg.tasks.notify_sponsors_roles_ending
"
,
func
=
"
greg.tasks.notify_sponsors_roles_ending
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment