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
8249b9de
Commit
8249b9de
authored
Aug 29, 2015
by
Enrico Zini
Browse files
Findperson works with Fingerprint table
parent
b4452e1d
Changes
3
Hide whitespace changes
Inline
Side-by-side
public/templates/public/findperson.html
View file @
8249b9de
...
...
@@ -9,6 +9,9 @@
{% block head %}
{{block.super}}
<style
type=
"text/css"
>
.errorlist
{
color
:
red
;
}
</style>
<script
type=
"text/javascript"
>
{
%
nm_js_support
%
}
...
...
@@ -169,8 +172,10 @@ create a new Person record.
</div>
<form
id=
"search_form"
action=
"{% url 'public_findperson' %}"
method=
"post"
>
{% csrf_token %}
{% for hidden in form.hidden_fields %} {{hidden}} {% endfor %}
{{ form.non_field_errors }}
<table
class=
"personinfo"
>
{% for field in form %}
{% for field in form
.visible_fields
%}
<tr>
<th>
{{field.label_tag}}
</th>
<td>
{{field}} {{field.errors}}
</td>
...
...
public/tests/test_permissions.py
View file @
8249b9de
...
...
@@ -83,6 +83,7 @@ class PermissionsTestCase(NMBasicFixtureMixin, NMTestUtilsMixin, TestCase):
"cn"
:
"Test"
,
"email"
:
"test@example.org"
,
"status"
:
const
.
STATUS_DC
,
"username"
:
"test-guest@users.alioth.debian.org"
,
}
def
setUp
(
self
,
fixture
):
super
(
WhenPost
,
self
).
setUp
(
fixture
)
...
...
public/views.py
View file @
8249b9de
...
...
@@ -617,41 +617,40 @@ class Stats(VisitorTemplateView):
def
make_findperson_form
(
request
,
visitor
):
includes
=
[
"cn"
,
"mn"
,
"sn"
,
"email"
,
"uid"
,
"fpr"
,
"status"
]
includes
=
[
"cn"
,
"mn"
,
"sn"
,
"email"
,
"uid"
,
"status"
]
if
visitor
and
visitor
.
is_admin
:
includes
.
append
(
"username"
)
includes
.
append
(
"fd_comment"
)
class
FindpersonForm
(
forms
.
ModelForm
):
fpr
=
forms
.
CharField
(
label
=
"Fingerprint"
,
required
=
False
,
min_length
=
40
,
widget
=
forms
.
TextInput
(
attrs
=
{
"size"
:
60
}))
class
Meta
:
model
=
bmodels
.
Person
fields
=
includes
def
clean_fpr
(
self
):
return
bmodels
.
FingerprintField
.
clean_fingerprint
(
self
.
cleaned_data
[
'fpr'
])
return
FindpersonForm
class
Findperson
(
Visitor
Template
View
):
class
Findperson
(
Visitor
Mixin
,
Form
View
):
template_name
=
"public/findperson.html"
def
get_context_data
(
self
,
**
kw
):
ctx
=
super
(
Findperson
,
self
).
get_context_data
(
**
kw
)
FindpersonForm
=
make_findperson_form
(
self
.
request
,
self
.
visitor
)
form
=
FindpersonForm
()
ctx
[
"form"
]
=
form
return
ctx
def
get_form_class
(
self
):
return
make_findperson_form
(
self
.
request
,
self
.
visitor
)
def
post
(
self
,
request
,
*
args
,
**
kw
):
def
form_valid
(
self
,
form
):
if
not
self
.
visitor
or
not
self
.
visitor
.
is_admin
:
raise
PermissionDenied
()
FindpersonForm
=
make_findperson_form
(
request
,
self
.
visitor
)
form
=
FindpersonForm
(
request
.
POST
)
if
form
.
is_valid
():
person
=
form
.
save
(
commit
=
False
)
person
.
save
(
audit_author
=
self
.
visitor
,
audit_notes
=
"user created manually"
)
return
redirect
(
person
.
get_absolute_url
())
context
=
self
.
get_context_data
(
**
kw
)
return
self
.
render_to_response
(
context
)
person
=
form
.
save
(
commit
=
False
)
person
.
save
(
audit_author
=
self
.
visitor
,
audit_notes
=
"user created manually"
)
fpr
=
form
.
cleaned_data
[
"fpr"
]
if
fpr
:
bmodels
.
Fingerprint
.
objects
.
create
(
fpr
=
fpr
,
user
=
person
)
return
redirect
(
person
.
get_absolute_url
())
class
StatsLatest
(
VisitorTemplateView
):
...
...
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