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
R
Respect My Net
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
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
piks3l
Respect My Net
Commits
01f91674
Commit
01f91674
authored
Oct 19, 2011
by
stef
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[enh] added filters for list by country + operator
parent
96ded2fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
bt/views.py
bt/views.py
+10
-1
urls.py
urls.py
+1
-0
No files found.
bt/views.py
View file @
01f91674
...
@@ -9,7 +9,7 @@ from django.core.exceptions import ObjectDoesNotExist
...
@@ -9,7 +9,7 @@ from django.core.exceptions import ObjectDoesNotExist
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
models
import
Violation
,
Attachment
,
Comment
,
Confirmation
from
models
import
Violation
,
Attachment
,
Comment
,
Confirmation
,
COUNTRIES
from
tempfile
import
mkstemp
from
tempfile
import
mkstemp
from
datetime
import
datetime
from
datetime
import
datetime
import
hashlib
,
os
,
re
,
json
,
smtplib
import
hashlib
,
os
,
re
,
json
,
smtplib
...
@@ -198,6 +198,15 @@ def index(request):
...
@@ -198,6 +198,15 @@ def index(request):
'violations'
:
v_list
},
'violations'
:
v_list
},
context_instance
=
RequestContext
(
request
))
context_instance
=
RequestContext
(
request
))
def
filter_violations
(
request
,
country
,
operator
=
None
):
if
country
not
in
map
(
itemgetter
(
0
),
COUNTRIES
):
raise
Http404
if
not
operator
:
violations
=
Violation
.
objects
.
filter
(
activationid
=
''
,
country
=
country
)
else
:
violations
=
Violation
.
objects
.
filter
(
activationid
=
''
,
country
=
country
,
operator
=
operator
)
return
render_to_response
(
'list.html'
,
{
"violations"
:
violations
},
context_instance
=
RequestContext
(
request
))
def
list_violations
(
request
):
def
list_violations
(
request
):
violations
=
Violation
.
objects
.
filter
(
activationid
=
''
)
violations
=
Violation
.
objects
.
filter
(
activationid
=
''
)
return
render_to_response
(
'list.html'
,
{
"violations"
:
violations
},
context_instance
=
RequestContext
(
request
))
return
render_to_response
(
'list.html'
,
{
"violations"
:
violations
},
context_instance
=
RequestContext
(
request
))
...
...
urls.py
View file @
01f91674
...
@@ -11,6 +11,7 @@ admin.autodiscover()
...
@@ -11,6 +11,7 @@ admin.autodiscover()
urlpatterns
=
patterns
(
''
,
urlpatterns
=
patterns
(
''
,
(
r
'^$'
,
bt
.
index
),
(
r
'^$'
,
bt
.
index
),
(
r
'^list/$'
,
bt
.
list_violations
),
(
r
'^list/$'
,
bt
.
list_violations
),
(
r
'^list/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$'
,
bt
.
filter_violations
),
(
r
'^ajax/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$'
,
bt
.
ajax
),
(
r
'^ajax/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$'
,
bt
.
ajax
),
(
r
'^add/$'
,
bt
.
add
),
(
r
'^add/$'
,
bt
.
add
),
(
r
'^view/(?P<id>[0-9]*)$'
,
bt
.
view
),
(
r
'^view/(?P<id>[0-9]*)$'
,
bt
.
view
),
...
...
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