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
0b5688a3
Commit
0b5688a3
authored
May 22, 2012
by
stef
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] map for country filtered list
parent
aff839f0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
20 deletions
+58
-20
bt/views.py
bt/views.py
+5
-0
media/js/map.js
media/js/map.js
+51
-17
templates/list.html
templates/list.html
+2
-3
No files found.
bt/views.py
View file @
0b5688a3
...
@@ -226,8 +226,13 @@ def filter_violations(request, country, operator=None):
...
@@ -226,8 +226,13 @@ def filter_violations(request, country, operator=None):
violations
=
Violation
.
objects
.
filter
(
activationid
=
''
,
country
=
country
,
operator
=
operator
)
violations
=
Violation
.
objects
.
filter
(
activationid
=
''
,
country
=
country
,
operator
=
operator
)
if
not
request
.
GET
.
get
(
'all'
):
if
not
request
.
GET
.
get
(
'all'
):
violations
=
violations
.
exclude
(
state__in
=
[
'duplicate'
,
'closed'
])
violations
=
violations
.
exclude
(
state__in
=
[
'duplicate'
,
'closed'
])
countries
=
sorted
([(
i
[
'total'
],
i
[
'country'
])
for
i
in
Violation
.
objects
.
values
(
'country'
).
filter
(
activationid
=
''
,
country
=
country
).
exclude
(
state__in
=
[
'duplicate'
,
'closed'
]).
annotate
(
total
=
Count
(
'country'
))],
reverse
=
True
)
countryweights
=
json
.
dumps
([{
'iso2'
:
y
,
'w'
:
x
}
for
x
,
y
in
countries
])
return
render_to_response
(
'list.html'
,
return
render_to_response
(
'list.html'
,
{
"violations"
:
violations
,
{
"violations"
:
violations
,
"country"
:
country
,
"status"
:
STATUS
},
"status"
:
STATUS
},
context_instance
=
RequestContext
(
request
))
context_instance
=
RequestContext
(
request
))
...
...
media/js/map.js
View file @
0b5688a3
...
@@ -6,20 +6,52 @@ $script.ready('kartograph', function() {
...
@@ -6,20 +6,52 @@ $script.ready('kartograph', function() {
window
.
map
=
$K
.
map
(
'
#map
'
);
window
.
map
=
$K
.
map
(
'
#map
'
);
map
.
loadMap
(
'
/site_media/eu.svg
'
,
function
(
map
)
{
map
.
loadMap
(
'
/site_media/eu.svg
'
,
function
(
map
)
{
map
map
.
addLayer
(
'
eu
'
,
'
bgback
'
)
.
addLayer
({
'
id
'
:
'
eu
'
,
.
addLayer
(
'
eu
'
,
'
bg
'
)
'
className
'
:
'
bgback
'
,
.
addLayer
(
'
eu
'
,
'
bgstroke
'
)
filter
:
function
(
d
)
{
if
(
country
.
length
==
2
)
{
return
d
.
iso2
==
country
;
}
return
true
;
}
})
.
addLayer
({
'
id
'
:
'
eu
'
,
'
className
'
:
'
bg
'
,
filter
:
function
(
d
)
{
if
(
country
.
length
==
2
)
{
return
d
.
iso2
==
country
;
}
return
true
;
}
})
.
addLayer
({
'
id
'
:
'
eu
'
,
'
className
'
:
'
bgstroke
'
,
filter
:
function
(
d
)
{
if
(
country
.
length
==
2
)
{
return
d
.
iso2
==
country
;
}
return
true
;
}
})
.
addLayer
({
'
id
'
:
'
countries
'
,
'
className
'
:
'
context
'
})
.
addLayer
({
'
id
'
:
'
countries
'
,
'
className
'
:
'
context
'
})
.
addLayer
(
'
graticule
'
)
.
addLayer
(
'
graticule
'
)
.
addLayer
({
'
id
'
:
'
eu
'
,
.
addLayer
({
'
id
'
:
'
eu
'
,
'
className
'
:
'
fg
'
,
'
className
'
:
'
fg
'
,
filter
:
function
(
d
)
{
if
(
country
.
length
==
2
)
{
return
d
.
iso2
==
country
;
}
return
true
;
},
'
tooltip
'
:
{
'
tooltip
'
:
{
content
:
function
(
obj
,
foo
)
{
content
:
function
(
obj
,
foo
)
{
var
count
=
0
;
var
count
=
0
;
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
data
)
{
if
(
data
[
i
].
iso2
==
foo
.
data
.
iso2
)
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
count
=
data
[
i
].
w
;
if
(
data
[
i
].
iso2
==
foo
.
data
.
iso2
)
{
break
;
count
=
data
[
i
].
w
;
break
;
}
}
}
}
}
if
(
count
>
0
)
{
if
(
count
>
0
)
{
...
@@ -45,16 +77,18 @@ $script.ready('kartograph', function() {
...
@@ -45,16 +77,18 @@ $script.ready('kartograph', function() {
limits
:
chroma
.
limits
(
data
,
'
q
'
,
6
,
'
w
'
)
limits
:
chroma
.
limits
(
data
,
'
q
'
,
6
,
'
w
'
)
});
});
map
.
choropleth
({
if
(
data
)
{
data
:
data
,
map
.
choropleth
({
layer
:
'
fg
'
,
data
:
data
,
key
:
'
iso2
'
,
layer
:
'
fg
'
,
colors
:
function
(
d
)
{
key
:
'
iso2
'
,
if
(
d
==
null
)
return
'
#fff
'
;
colors
:
function
(
d
)
{
return
colorscale
.
getColor
(
d
[
'
w
'
]);
if
(
d
==
null
)
return
'
#fff
'
;
},
return
colorscale
.
getColor
(
d
[
'
w
'
]);
duration
:
0
},
});
duration
:
0
});
}
});
});
});
});
});
});
templates/list.html
View file @
0b5688a3
...
@@ -18,9 +18,8 @@
...
@@ -18,9 +18,8 @@
$script
([
'
{{ MEDIA_URL }}/js/raphael.min.js
'
,
'
{{ MEDIA_URL }}/js/kartograph.min.js
'
,
'
{{ MEDIA_URL }}/js/chroma.min.js
'
,
'
{{ MEDIA_URL }}/js/qtip.min.js
'
],
'
kartograph
'
);
$script
([
'
{{ MEDIA_URL }}/js/raphael.min.js
'
,
'
{{ MEDIA_URL }}/js/kartograph.min.js
'
,
'
{{ MEDIA_URL }}/js/chroma.min.js
'
,
'
{{ MEDIA_URL }}/js/qtip.min.js
'
],
'
kartograph
'
);
</script>
</script>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
{
%
if
countryweights
%
}
var
data
=
{
%
if
countryweights
%
}{{
countryweights
|
safe
}}{
%
else
%
}
null
{
%
endif
%
};
var
data
=
{{
countryweights
|
safe
}};
var
country
=
"
{{country}}
"
;
{
%
endif
%
}
$script
.
ready
([
'
jquery
'
,
'
tables
'
],
function
()
{
$script
.
ready
([
'
jquery
'
,
'
tables
'
],
function
()
{
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
$
.
tablesorter
.
addParser
({
$
.
tablesorter
.
addParser
({
...
...
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