Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
e57ed4b2
Commit
e57ed4b2
authored
Aug 29, 2015
by
Enrico Zini
Browse files
Added is_active field to Fingerprint
parent
e95e7534
Changes
4
Hide whitespace changes
Inline
Side-by-side
backend/housekeeping.py
View file @
e57ed4b2
...
...
@@ -329,3 +329,16 @@ class DDUsernames(hk.Task):
self
.
IDENTIFIER
,
self
.
hk
.
link
(
p
),
p
.
status
,
new_username
)
p
.
username
=
new_username
p
.
save
(
audit_author
=
self
.
hk
.
housekeeper
.
user
,
audit_notes
=
"updated SSO username to @debian.org version"
)
class
CheckOneActiveKeyPerPerson
(
hk
.
Task
):
"""
Check that one does not have more than one open process at the current time
"""
DEPENDS
=
[
MakeLink
]
def
run_main
(
self
,
stage
):
from
django.db.models
import
Count
for
p
in
bmodels
.
Person
.
objects
.
filter
(
fprs__is_active
=
True
)
\
.
annotate
(
num_fprs
=
Count
(
"fprs"
))
\
.
filter
(
num_fprs__gt
=
1
):
log
.
warn
(
"%s: %s has %d active keys"
,
self
.
IDENTIFIER
,
self
.
hk
.
link
(
p
),
p
.
num_fprs
)
backend/migrations/0005_fingerprint_is_active.py
0 → 100644
View file @
e57ed4b2
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'backend'
,
'0004_remove_person_fpr'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'fingerprint'
,
name
=
'is_active'
,
field
=
models
.
BooleanField
(
default
=
False
,
help_text
=
'whether this key is curently in use'
),
preserve_default
=
True
,
),
]
backend/migrations/0006_auto_20150829_1716.py
0 → 100644
View file @
e57ed4b2
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
def
set_existing_fingerprints_as_active
(
apps
,
schema_editor
):
Fingerprint
=
apps
.
get_model
(
"backend"
,
"Fingerprint"
)
Fingerprint
.
objects
.
update
(
is_active
=
True
)
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'backend'
,
'0005_fingerprint_is_active'
),
]
operations
=
[
migrations
.
RunPython
(
set_existing_fingerprints_as_active
),
]
backend/models.py
View file @
e57ed4b2
...
...
@@ -533,9 +533,10 @@ class Person(PermissionsMixin, models.Model):
"""
Return the current fingerprint for this Person
"""
# TODO: add a way to tell the current valid fingerprints from
# old/revoked ones
for
f
in
self
.
fprs
.
all
():
# If there is more than one active fields, return a random one. This
# should not happen, and a nightly maintenance task will warn if it
# happens.
for
f
in
self
.
fprs
.
filter
(
is_active
=
True
):
return
f
.
fpr
return
None
...
...
@@ -777,8 +778,8 @@ class Fingerprint(models.Model):
db_table
=
"fingerprints"
user
=
models
.
ForeignKey
(
Person
,
related_name
=
"fprs"
)
#
OpenPGP fingerprint,
NULL until one has been provided
fpr
=
FingerprintField
(
"OpenPGP key fingerprint"
,
max_length
=
40
,
unique
=
True
)
fpr
=
FingerprintField
(
verbose_name
=
"
OpenPGP
key
fingerprint
"
,
max_length
=
40
,
unique
=
True
)
is_active
=
models
.
BooleanField
(
default
=
False
,
help_text
=
"whether this key is curently in use"
)
class
PersonAuditLog
(
models
.
Model
):
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment