Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Respect My Net
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
15
Issues
15
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
Respect My Net
Commits
937ea70a
Commit
937ea70a
authored
Apr 23, 2017
by
jc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds new status 'resolved' + reopen feature
parent
4f9f43f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
bt/models.py
bt/models.py
+14
-4
bt/views.py
bt/views.py
+11
-1
nnmon/templates/list.html
nnmon/templates/list.html
+6
-1
No files found.
bt/models.py
View file @
937ea70a
...
...
@@ -67,6 +67,7 @@ STATUS = (
(
'verified'
,
_
(
'Verified'
)),
(
'duplicate'
,
_
(
'Duplicate'
)),
(
'ooscope'
,
_
(
'Out of scope'
)),
(
'resolved'
,
_
(
'Resolved'
)),
(
'closed'
,
_
(
'Closed'
)),
)
...
...
@@ -102,12 +103,15 @@ class Violation(models.Model):
old
=
models
.
BooleanField
(
default
=
"False"
)
creation_date
=
models
.
DateField
(
auto_now_add
=
True
)
def
confirmations
(
self
):
return
self
.
confirmation_set
.
filter
(
key
=
''
).
count
(
)
def
__unicode__
(
self
):
return
"#%s %s/%s"
%
(
self
.
pk
,
self
.
country
,
self
.
operator
)
class
Admin
:
pass
def
confirmations
(
self
):
return
self
.
confirmation_set
.
filter
(
key
=
''
).
count
()
@
property
def
operator
(
self
):
return
self
.
operator_ref
.
name
...
...
@@ -115,8 +119,14 @@ class Violation(models.Model):
def
get_absolute_url
(
self
):
return
reverse
(
'violation_url'
,
args
=
[
self
.
pk
])
def
__unicode__
(
self
):
return
"#%s %s/%s"
%
(
self
.
pk
,
self
.
country
,
self
.
operator
)
@
property
def
is_resolved
(
self
):
return
self
.
state
==
'resolved'
def
reopen_if_needed
(
self
):
if
self
.
is_resolved
:
self
.
state
=
'new'
class
Comment
(
models
.
Model
):
submitter_email
=
models
.
EmailField
()
...
...
bt/views.py
View file @
937ea70a
...
...
@@ -112,14 +112,24 @@ def moderate(request):
return
HttpResponseRedirect
(
'/'
)
# Redirect after POST
return
render_to_response
(
'view.html'
,
{
'v'
:
v
,
'key'
:
request
.
GET
.
get
(
'key'
)
},
context_instance
=
RequestContext
(
request
))
from
django.db
import
transaction
@
transaction
.
atomic
def
confirm
(
request
,
id
,
name
=
None
):
violation
=
Violation
.
objects
.
filter
(
pk
=
id
).
first
()
if
violation
:
violation
.
reopen_if_needed
()
violation
.
save
()
if
name
:
if
Confirmation
.
objects
.
filter
(
email
=
name
,
violation
=
id
).
count
()
==
0
:
msg
=
_
(
"Thank you for confirming a case. To finalize your confirmation please validate using your confirmation key.
\n
Your confirmation key is %s/%s%s"
)
actid
=
sendverifymail
(
'confirm/'
,
name
,
msg
)
try
:
c
=
Confirmation
(
key
=
actid
,
email
=
name
,
violation
=
Violation
.
objects
.
get
(
pk
=
id
)
)
c
=
Confirmation
(
key
=
actid
,
email
=
name
,
violation
=
violation
)
except
:
# should except IntegrityError properly
return
HttpResponse
(
unicode
(
_
(
'Thank you, this has been already confirmed'
)))
c
.
save
()
return
HttpResponse
(
unicode
(
_
(
'Thank you for your confirmation'
)))
...
...
nnmon/templates/list.html
View file @
937ea70a
...
...
@@ -67,11 +67,16 @@ $("#sortedList").tablesorter({
<td><a
class=
"cell-link"
href=
"{{ violation.get_absolute_url }}"
>
{{ violation.media|media }}
</a></td>
<td>
{{ violation.confirmations }}
</td>
<td>
{% if violation.is_resolved %}
<button
role=
"button"
class=
"btn btn-default"
data-toggle=
"modal"
data-target=
"#modal-{{ violation.pk }}"
>
{% trans "Reopen" %}
</button>
{% else %}
<button
role=
"button"
class=
"btn btn-default"
data-toggle=
"modal"
data-target=
"#modal-{{ violation.pk }}"
>
{% trans "Me too!" %}
</button>
{% endif %}
<div
class=
"modal fade"
id=
"modal-{{ violation.pk }}"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"modal-label-{{ violation.pk }}"
data-backdrop=
"false"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<form
method=
"post"
class=
"metoo inline-from"
action=
"/confirm/{{ violation.pk }}"
id=
"
i
{{ violation.pk }}"
>
<form
method=
"post"
class=
"metoo inline-from"
action=
"/confirm/{{ violation.pk }}"
id=
"{{ violation.pk }}"
>
<div
class=
"modal-body"
>
<div
class=
"form-group"
>
<label
for=
"list-email-{{ violation.pk }}"
>
{% trans "In order to
<strong>
confirm
</strong>
this report, please enter your email address" %}
</label>
...
...
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