Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
41af46a4
Commit
41af46a4
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
cron job for marking vouchers as expired
parent
c90f0a96
No related branches found
No related tags found
1 merge request
!120
Resolve "auto-expire of vouchers"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smash/smash/settings.py
+2
-1
2 additions, 1 deletion
smash/smash/settings.py
smash/web/views/voucher.py
+18
-1
18 additions, 1 deletion
smash/web/views/voucher.py
with
20 additions
and
2 deletions
smash/smash/settings.py
+
2
−
1
View file @
41af46a4
...
@@ -72,7 +72,8 @@ TEMPLATES = [
...
@@ -72,7 +72,8 @@ TEMPLATES = [
CRON_CLASSES
=
[
CRON_CLASSES
=
[
'
web.views.kit.KitRequestEmailSendJob
'
,
'
web.views.kit.KitRequestEmailSendJob
'
,
'
web.redcap_connector.RedCapRefreshJob
'
'
web.redcap_connector.RedCapRefreshJob
'
,
'
web.voucher_expiry_job
'
,
]
]
# Password validation
# Password validation
...
...
This diff is collapsed.
Click to expand it.
smash/web/views/voucher.py
+
18
−
1
View file @
41af46a4
...
@@ -6,10 +6,12 @@ from django.urls import reverse_lazy
...
@@ -6,10 +6,12 @@ from django.urls import reverse_lazy
from
django.views.generic
import
CreateView
from
django.views.generic
import
CreateView
from
django.views.generic
import
ListView
from
django.views.generic
import
ListView
from
django.views.generic
import
UpdateView
from
django.views.generic
import
UpdateView
from
django_cron
import
CronJobBase
,
Schedule
from
views.notifications
import
get_today_midnight_date
from
web.forms
import
VoucherForm
from
web.forms
import
VoucherForm
from
web.models
import
Voucher
,
StudySubject
from
web.models
import
Voucher
,
StudySubject
from
web.models.constants
import
GLOBAL_STUDY_ID
from
web.models.constants
import
GLOBAL_STUDY_ID
,
VOUCHER_STATUS_NEW
,
VOUCHER_STATUS_EXPIRED
from
.
import
WrappedView
from
.
import
WrappedView
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -64,3 +66,18 @@ class VoucherEditView(SuccessMessageMixin, UpdateView, WrappedView):
...
@@ -64,3 +66,18 @@ class VoucherEditView(SuccessMessageMixin, UpdateView, WrappedView):
def
get_study_subject_id
(
self
):
def
get_study_subject_id
(
self
):
return
Voucher
.
objects
.
get
(
id
=
self
.
kwargs
[
'
pk
'
]).
study_subject
.
id
return
Voucher
.
objects
.
get
(
id
=
self
.
kwargs
[
'
pk
'
]).
study_subject
.
id
class
ExpireVouchersJob
(
CronJobBase
):
RUN_EVERY_MINUTES
=
120
schedule
=
Schedule
(
run_every_mins
=
RUN_EVERY_MINUTES
)
code
=
'
web.voucher_expiry_job
'
# a unique code
# noinspection PyMethodMayBeStatic
def
do
(
self
):
due_date
=
get_today_midnight_date
()
vouchers
=
Voucher
.
objects
.
filter
(
status
=
VOUCHER_STATUS_NEW
,
expiry_date__lte
=
due_date
)
count
=
vouchers
.
count
()
if
count
>
0
:
vouchers
.
update
(
status
=
VOUCHER_STATUS_EXPIRED
)
return
count
+
"
vouchers expired
"
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