Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
django-sshkey
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f5ddf5a6
authored
Jul 07, 2014
by
Scott Duckworth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make UserKey.touch() save without updating last_modified
parent
7bc8252f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
django_sshkey/models.py
+9
-2
No files found.
django_sshkey/models.py
View file @
f5ddf5a6
...
...
@@ -26,6 +26,8 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import
datetime
from
django.db
import
models
from
django.contrib.auth.models
import
User
from
django.core.exceptions
import
ValidationError
...
...
@@ -40,7 +42,7 @@ class UserKey(models.Model):
key
=
models
.
TextField
(
max_length
=
2000
)
fingerprint
=
models
.
CharField
(
max_length
=
47
,
blank
=
True
,
db_index
=
True
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
)
last_modified
=
models
.
DateTimeField
(
auto_now
=
True
,
null
=
True
)
last_modified
=
models
.
DateTimeField
(
null
=
True
)
last_used
=
models
.
DateTimeField
(
null
=
True
)
class
Meta
:
...
...
@@ -97,9 +99,14 @@ class UserKey(models.Model):
return
pubkey
.
format_pem
()
raise
ValueError
(
"Invalid format"
)
def
save
(
self
,
*
args
,
**
kwargs
):
if
kwargs
.
pop
(
'update_last_modified'
,
True
):
self
.
last_modified
=
datetime
.
datetime
.
now
()
super
(
UserKey
,
self
)
.
save
(
*
args
,
**
kwargs
)
def
touch
(
self
):
import
datetime
self
.
last_used
=
datetime
.
datetime
.
now
()
self
.
save
(
update_last_modified
=
False
)
@receiver
(
pre_save
,
sender
=
UserKey
)
def
send_email_add_key
(
sender
,
instance
,
**
kwargs
):
...
...
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