kopia lustrzana https://github.com/OpenDroneMap/WebODM
Unit tests, small bug fixes, renamed URLs module
rodzic
2bc61c2633
commit
44d3674314
|
@ -38,7 +38,7 @@ class ModelView extends React.Component {
|
|||
this.modelReference = null;
|
||||
|
||||
this.toggleTexturedModel = this.toggleTexturedModel.bind(this);
|
||||
this.handleMouseDown = this.handleMouseDown.bind(this);
|
||||
this.handleMouseClick = this.handleMouseClick.bind(this);
|
||||
}
|
||||
|
||||
assetsPath(){
|
||||
|
@ -70,7 +70,7 @@ class ModelView extends React.Component {
|
|||
return 'odm_textured_model.mtl';
|
||||
}
|
||||
|
||||
handleMouseDown(e){
|
||||
handleMouseClick(e){
|
||||
// Make sure the share popup closes
|
||||
this.shareButton.hidePopup();
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ class ModelView extends React.Component {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="potree_sidebar_container" onMouseDown={this.handleMouseDown}>
|
||||
<div id="potree_sidebar_container" onClick={this.handleMouseClick}>
|
||||
|
||||
<div id="sidebar_root"
|
||||
className="navmenu navmenu-default navmenu-fixed-left unselectable">
|
||||
|
|
|
@ -60,7 +60,7 @@ export default {
|
|||
if (path[0] === '/') path = path.slice(1);
|
||||
|
||||
let parser = document.createElement('a');
|
||||
parser.href = window.location.href;
|
||||
parser.href = href;
|
||||
|
||||
return `${parser.protocol}//${parser.host}/${path}`;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class ShareButton extends React.Component {
|
|||
this.handleTaskChanged = this.handleTaskChanged.bind(this);
|
||||
}
|
||||
|
||||
handleClick(){
|
||||
handleClick(e){
|
||||
this.setState({ showPopup: !this.state.showPopup });
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,6 @@ class ShareButton extends React.Component {
|
|||
{this.props.popupPlacement === 'top' && this.state.showPopup ?
|
||||
popup : ""}
|
||||
<button
|
||||
ref={(domNode) => { this.shareButton = domNode; }}
|
||||
type="button"
|
||||
onClick={this.handleClick}
|
||||
className={"shareButton btn btn-sm " + (this.state.task.public ? "btn-primary" : "btn-secondary")}>
|
||||
|
|
|
@ -244,6 +244,39 @@ class TestApiTask(BootTransactionTestCase):
|
|||
res = client.get("/api/projects/{}/tasks/{}/{}/tiles/16/16020/42443.png".format(project.id, task.id, tile_type))
|
||||
self.assertTrue(res.status_code == status.HTTP_200_OK)
|
||||
|
||||
# Another user does not have access to the resources
|
||||
other_client = APIClient()
|
||||
other_client.login(username="testuser2", password="test1234")
|
||||
|
||||
def accessResources(expectedStatus):
|
||||
for tile_type in tile_types:
|
||||
res = other_client.get("/api/projects/{}/tasks/{}/{}/tiles.json".format(project.id, task.id, tile_type))
|
||||
self.assertTrue(res.status_code == expectedStatus)
|
||||
|
||||
res = other_client.get("/api/projects/{}/tasks/{}/{}/tiles/16/16020/42443.png".format(project.id, task.id, tile_type))
|
||||
self.assertTrue(res.status_code == expectedStatus)
|
||||
|
||||
accessResources(status.HTTP_404_NOT_FOUND)
|
||||
|
||||
# Original owner enables sharing
|
||||
res = client.patch("/api/projects/{}/tasks/{}/".format(project.id, task.id), {
|
||||
'public': True
|
||||
})
|
||||
self.assertTrue(res.status_code == status.HTTP_200_OK)
|
||||
|
||||
# Now other user can acccess resources
|
||||
accessResources(status.HTTP_200_OK)
|
||||
|
||||
# User logs out
|
||||
other_client.logout()
|
||||
|
||||
# He can still access the resources as anonymous
|
||||
accessResources(status.HTTP_200_OK)
|
||||
|
||||
# Other user still does not have access to certain parts of the API
|
||||
res = other_client.get("/api/projects/{}/tasks/{}/".format(project.id, task.id))
|
||||
self.assertTrue(res.status_code == status.HTTP_404_NOT_FOUND)
|
||||
|
||||
# Restart a task
|
||||
testWatch.clear()
|
||||
res = client.post("/api/projects/{}/tasks/{}/restart/".format(project.id, task.id))
|
||||
|
|
|
@ -121,6 +121,31 @@ class TestApp(BootTestCase):
|
|||
res = c.get('/3d/project/{}/task/{}/'.format(project.id, task.id))
|
||||
self.assertTrue(res.status_code == status.HTTP_200_OK)
|
||||
|
||||
# Cannot access public URLs unless a task is shared
|
||||
def test_public_views(client, expectedStatus):
|
||||
res = client.get('/public/task/{}/map/'.format(task.id))
|
||||
self.assertTrue(res.status_code == expectedStatus)
|
||||
res = client.get('/public/task/{}/3d/'.format(task.id))
|
||||
self.assertTrue(res.status_code == expectedStatus)
|
||||
res = client.get('/public/task/{}/iframe/3d/'.format(task.id))
|
||||
self.assertTrue(res.status_code == expectedStatus)
|
||||
res = client.get('/public/task/{}/iframe/map/'.format(task.id))
|
||||
self.assertTrue(res.status_code == expectedStatus)
|
||||
|
||||
test_public_views(c, status.HTTP_404_NOT_FOUND)
|
||||
|
||||
# Share task
|
||||
task.public = True
|
||||
task.save()
|
||||
|
||||
# Can now access URLs even as anonymous user
|
||||
ac = Client()
|
||||
test_public_views(ac, status.HTTP_200_OK)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def test_default_group(self):
|
||||
# It exists
|
||||
self.assertTrue(Group.objects.filter(name='Default').count() == 1)
|
||||
|
|
16
app/urls.py
16
app/urls.py
|
@ -1,24 +1,24 @@
|
|||
from django.conf.urls import url, include
|
||||
|
||||
from .views import private as private_views, public as public_views
|
||||
from .views import app as app_views, public as public_views
|
||||
|
||||
from app.boot import boot
|
||||
from webodm import settings
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', private_views.index, name='index'),
|
||||
url(r'^welcome/$', private_views.welcome, name='welcome'),
|
||||
url(r'^dashboard/$', private_views.dashboard, name='dashboard'),
|
||||
url(r'^map/project/(?P<project_pk>[^/.]+)/task/(?P<task_pk>[^/.]+)/$', private_views.map, name='map'),
|
||||
url(r'^map/project/(?P<project_pk>[^/.]+)/$', private_views.map, name='map'),
|
||||
url(r'^3d/project/(?P<project_pk>[^/.]+)/task/(?P<task_pk>[^/.]+)/$', private_views.model_display, name='model_display'),
|
||||
url(r'^$', app_views.index, name='index'),
|
||||
url(r'^welcome/$', app_views.welcome, name='welcome'),
|
||||
url(r'^dashboard/$', app_views.dashboard, name='dashboard'),
|
||||
url(r'^map/project/(?P<project_pk>[^/.]+)/task/(?P<task_pk>[^/.]+)/$', app_views.map, name='map'),
|
||||
url(r'^map/project/(?P<project_pk>[^/.]+)/$', app_views.map, name='map'),
|
||||
url(r'^3d/project/(?P<project_pk>[^/.]+)/task/(?P<task_pk>[^/.]+)/$', app_views.model_display, name='model_display'),
|
||||
|
||||
url(r'^public/task/(?P<task_pk>[^/.]+)/map/$', public_views.map, name='public_map'),
|
||||
url(r'^public/task/(?P<task_pk>[^/.]+)/iframe/map/$', public_views.map_iframe, name='public_map'),
|
||||
url(r'^public/task/(?P<task_pk>[^/.]+)/3d/$', public_views.model_display, name='public_map'),
|
||||
url(r'^public/task/(?P<task_pk>[^/.]+)/iframe/3d/$', public_views.model_display_iframe, name='public_map'),
|
||||
|
||||
url(r'^processingnode/([\d]+)/$', private_views.processing_node, name='processing_node'),
|
||||
url(r'^processingnode/([\d]+)/$', app_views.processing_node, name='processing_node'),
|
||||
|
||||
url(r'^api/', include("app.api.urls")),
|
||||
]
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
from . import private
|
||||
from . import app
|
||||
from . import public
|
||||
|
|
Ładowanie…
Reference in New Issue