Skip to content

Commit dd0c0bc

Browse files
committed
Merge pull request osmlab#365 from mvexel/master
handle optional osmids well, disable tap to dismiss toast messages
2 parents 3e71ffb + e10e2c4 commit dd0c0bc

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

jsx/maproulette.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ toastr.options = {
2121
"toastClass": "notification",
2222
"positionClass": "toast-top-left",
2323
"preventDuplicates": false,
24-
"onclick": null,
2524
"showDuration": "300",
2625
"hideDuration": "1000",
2726
"timeOut": "3000",
2827
"extendedTimeOut": "0",
2928
"showEasing": "swing",
3029
"hideEasing": "linear",
3130
"showMethod": "fadeIn",
32-
"hideMethod": "fadeOut"
31+
"hideMethod": "fadeOut",
32+
"tapToDismiss" : false
3333
};
3434

3535
// React Components

manage.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,11 @@ def create_testdata(challenges=10, tasks=100, users=10):
118118
# create a linestring connecting the two points
119119
# no constructor for linestring from points?
120120
l1 = LineString([(p1.x, p1.y), (p2.x, p2.y)])
121-
# generate some random 'osm ids'
122-
osmids = [random.randrange(1000000, 1000000000) for _ in range(2)]
123121
# add the first point and the linestring to the task's geometries
124-
task_geometries.append(TaskGeometry(osmids[0], p1))
122+
task_geometries.append(TaskGeometry(p1))
125123
# set a linestring for every other challenge
126124
if not j % 2:
127-
task_geometries.append(TaskGeometry(osmids[1], l1))
125+
task_geometries.append(TaskGeometry(l1))
128126
# instantiate the task and register it with challenge 'test'
129127
# Initialize a task with its challenge slug and persistent ID
130128
task = Task(challenge.slug, identifier, task_geometries)

maproulette/api/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,12 +819,15 @@ def post(self, slug):
819819
for task in data:
820820
app.logger.debug(task)
821821
if not isinstance(task['identifier'], basestring):
822+
app.logger.debug('identifier not a string')
822823
abort(400, message='task identifier must exist and be string')
823824
existingTask = get_task_or_none(slug, task['identifier'])
824825
if existingTask is None:
825826
if not re.match("^[\w\d_-]+$", task['identifier']):
827+
app.logger.debug('identifier should contain only a-z, A-Z, 0-9, _, -')
826828
abort(400, message='identifier should contain only a-z, A-Z, 0-9, _, -')
827829
if 'geometries' not in task:
830+
app.logger.debug('new task must have geometries')
828831
abort(400, message='new task must have geometries')
829832
t = json_to_task(slug, task)
830833
db.session.add(t)

maproulette/helpers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,14 @@ def json_to_task(slug, data, task=None, identifier=None):
181181
if 'geometries' in data:
182182
geometries = data.pop('geometries')
183183
# parse the geometries
184+
app.logger.debug(geometries)
184185
for feature in geometries['features']:
185-
osmid = feature['properties'].get('osmid')
186+
osmid = None
187+
if 'properties' in feature and feature['properties'].get('osmid'):
188+
osmid = feature['properties'].get('osmid')
189+
app.logger.debug(feature)
186190
shape = asShape(feature['geometry'])
187-
g = TaskGeometry(osmid, shape)
191+
g = TaskGeometry(shape, osmid)
188192
task.geometries.append(g)
189193
return task
190194

maproulette/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class TaskGeometry(db.Model):
357357
Geometry,
358358
nullable=False)
359359

360-
def __init__(self, osmid, shape):
360+
def __init__(self, shape, osmid=None):
361361
self.osmid = osmid
362362
self.geom = from_shape(shape)
363363

0 commit comments

Comments
 (0)