Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
thomasDOTwtf
hub
Commits
ff238b1d
Commit
ff238b1d
authored
Aug 14, 2023
by
HeJ
Browse files
Options
Downloads
Patches
Plain Diff
api/map export: include 'hidden' villages' POI (+unittest)
parent
2ce90e33
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/api/tests/__init__.py
+1
-0
1 addition, 0 deletions
src/api/tests/__init__.py
src/api/tests/map.py
+79
-0
79 additions, 0 deletions
src/api/tests/map.py
src/api/views/maps.py
+2
-1
2 additions, 1 deletion
src/api/views/maps.py
with
82 additions
and
1 deletion
src/api/tests/__init__.py
+
1
−
0
View file @
ff238b1d
from
.bbb
import
*
# noqa: F401, F403
from
.bbb
import
*
# noqa: F401, F403
from
.engelsystem
import
*
# noqa: F401, F403
from
.engelsystem
import
*
# noqa: F401, F403
from
.map
import
*
# noqa: F401, F403
from
.metrics
import
*
# noqa: F401, F403
from
.metrics
import
*
# noqa: F401, F403
from
.schedule
import
*
# noqa: F401, F403
from
.schedule
import
*
# noqa: F401, F403
from
.workadventure
import
*
# noqa: F401, F403
from
.workadventure
import
*
# noqa: F401, F403
...
...
This diff is collapsed.
Click to expand it.
src/api/tests/map.py
0 → 100644
+
79
−
0
View file @
ff238b1d
from
datetime
import
datetime
import
json
from
zoneinfo
import
ZoneInfo
from
django.contrib.gis.geos
import
Point
from
django.test
import
TestCase
from
django.urls
import
reverse
from
core.models
import
Assembly
,
ConferenceExportCache
,
Conference
,
PlatformUser
class
MapTest
(
TestCase
):
def
setUp
(
self
):
tz
=
ZoneInfo
(
'
CET
'
)
self
.
conf
=
Conference
(
slug
=
'
conf
'
,
name
=
'
TestConf
'
,
is_public
=
True
,
start
=
datetime
(
2020
,
12
,
27
,
1
,
23
,
45
,
tzinfo
=
tz
),
end
=
datetime
(
2020
,
12
,
30
,
23
,
45
,
00
,
tzinfo
=
tz
),
)
self
.
conf
.
save
()
self
.
conf
.
tracks
.
create
(
slug
=
'
community
'
,
name
=
'
Community
'
).
save
()
self
.
conf
.
tracks
.
create
(
slug
=
'
security
'
,
name
=
'
Security
'
).
save
()
self
.
assembly
=
Assembly
(
name
=
'
TestAssembly
'
,
slug
=
'
asmbly
'
,
conference
=
self
.
conf
)
self
.
assembly
.
save
()
self
.
user
=
PlatformUser
(
username
=
'
bernd
'
,
is_active
=
True
)
self
.
user
.
save
()
def
test_map_poi
(
self
):
url
=
reverse
(
'
api:map-assemblies-poi
'
,
kwargs
=
{
'
conference
'
:
self
.
conf
.
slug
})
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
self
.
assertEqual
(
resp
[
'
Content-Type
'
],
'
application/geo+json
'
)
# decode JSON
content
=
json
.
loads
(
resp
.
content
.
decode
(
'
utf-8
'
))
# check that there are no POIs yet
self
.
assertEqual
(
'
FeatureCollection
'
,
content
.
get
(
'
type
'
))
self
.
assertIsInstance
(
content
.
get
(
'
features
'
),
list
)
self
.
assertEqual
(
0
,
len
(
content
[
'
features
'
]))
# set POI on assembly and accept it
self
.
assembly
.
location_point
=
Point
(
8.9
,
52.9
)
self
.
assembly
.
state_assembly
=
Assembly
.
State
.
ACCEPTED
self
.
assembly
.
save
()
ConferenceExportCache
.
objects
.
all
().
delete
()
# check again, there should be no POI exported as the assembly is not placed yet
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
content
=
json
.
loads
(
resp
.
content
.
decode
(
'
utf-8
'
))
self
.
assertEqual
(
0
,
len
(
content
[
'
features
'
]))
# change state to 'placed', now there should be a POI
self
.
assembly
.
state_assembly
=
Assembly
.
State
.
PLACED
self
.
assembly
.
save
()
ConferenceExportCache
.
objects
.
all
().
delete
()
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
content
=
json
.
loads
(
resp
.
content
.
decode
(
'
utf-8
'
))
self
.
assertEqual
(
1
,
len
(
content
[
'
features
'
]))
# check the POI
feature
=
content
[
'
features
'
][
0
]
self
.
assertEqual
(
'
Feature
'
,
feature
.
get
(
'
type
'
))
self
.
assertEqual
(
'
Point
'
,
feature
.
get
(
'
geometry
'
,
{}).
get
(
'
type
'
))
self
.
assertListEqual
([
8.9
,
52.9
],
feature
.
get
(
'
geometry
'
,
{}).
get
(
'
coordinates
'
))
self
.
assertEqual
(
self
.
assembly
.
name
,
feature
.
get
(
'
properties
'
,
{}).
get
(
'
name
'
))
self
.
assertEqual
(
self
.
assembly
.
is_cluster
,
feature
.
get
(
'
properties
'
,
{}).
get
(
'
cluster
'
))
# change assembly to 'hidden', POI should still be there
self
.
assembly
.
state_assembly
=
Assembly
.
State
.
HIDDEN
self
.
assembly
.
save
()
ConferenceExportCache
.
objects
.
all
().
delete
()
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
200
,
resp
.
status_code
)
content
=
json
.
loads
(
resp
.
content
.
decode
(
'
utf-8
'
))
self
.
assertEqual
(
1
,
len
(
content
[
'
features
'
]))
This diff is collapsed.
Click to expand it.
src/api/views/maps.py
+
2
−
1
View file @
ff238b1d
...
@@ -14,7 +14,8 @@ class AssembliesExportView(ConferenceSlugMixin, APIView, metaclass=abc.ABCMeta):
...
@@ -14,7 +14,8 @@ class AssembliesExportView(ConferenceSlugMixin, APIView, metaclass=abc.ABCMeta):
_cts
=
{}
# cache of CoordTransforms (if needed)
_cts
=
{}
# cache of CoordTransforms (if needed)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
return
Assembly
.
objects
.
filter
(
conference
=
self
.
conference
,
state_assembly__in
=
Assembly
.
PLACED_STATES
)
exportable_states
=
Assembly
.
PLACED_STATES
+
[
Assembly
.
State
.
HIDDEN
]
return
Assembly
.
objects
.
filter
(
conference
=
self
.
conference
,
state_assembly__in
=
exportable_states
)
@staticmethod
@staticmethod
def
get_field_geojson
(
value
,
srid
:
int
,
ct_cache
:
dict
=
None
):
def
get_field_geojson
(
value
,
srid
:
int
,
ct_cache
:
dict
=
None
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment