Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-cas
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-cas
Commits
c14be685
Commit
c14be685
authored
Dec 08, 2010
by
Ed Crewe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up old tickets
parent
3ae1396d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
django_cas/models.py
+15
-0
No files found.
django_cas/models.py
View file @
c14be685
...
...
@@ -5,6 +5,9 @@ from django.conf import settings
from
django.contrib.auth.models
import
User
from
django.core.exceptions
import
ObjectDoesNotExist
from
django_cas.exceptions
import
CasTicketException
,
CasConfigException
# Ed Crewe - add in signals to delete old tickets
from
django.db.models.signals
import
post_save
from
datetime
import
datetime
class
Tgt
(
models
.
Model
):
username
=
models
.
CharField
(
max_length
=
255
,
unique
=
True
)
...
...
@@ -54,3 +57,15 @@ def get_tgt_for(user):
return
Tgt
.
objects
.
get
(
username
=
user
.
username
)
except
ObjectDoesNotExist
:
raise
CasTicketException
(
"no ticket found for user "
+
user
.
username
)
def
delete_old_tickets
(
**
kwargs
):
""" Delete tickets if they are over 2 days old
kwargs = ['raw', 'signal', 'instance', 'sender', 'created']
"""
sender
=
kwargs
.
get
(
'sender'
,
None
)
now
=
datetime
.
now
()
expire
=
datetime
(
now
.
year
,
now
.
month
,
now
.
day
-
3
)
sender
.
objects
.
filter
(
created__lt
=
expire
)
.
delete
()
post_save
.
connect
(
delete_old_tickets
,
sender
=
pgtIOU
)
post_save
.
connect
(
delete_old_tickets
,
sender
=
Tgt
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment