def make_instance(name=None, is_public=False, url_name=None, point=None, edge_length=600): if name is None: max_instance = Instance.objects.all().aggregate( Max('id'))['id__max'] or 0 name = 'generated$%d' % (max_instance + 1) if url_name is None: max_instance = Instance.objects.all().aggregate( Max('id'))['id__max'] or 0 url_name = 'generated-%d' % (max_instance + 1) p1 = point or Point(0, 0) instance = Instance(name=name, geo_rev=0, is_public=is_public, url_name=url_name) instance.seed_with_dummy_default_role() d = edge_length / 2 instance.bounds = InstanceBounds.create_from_point(p1.x, p1.y, d) instance.save() new_role = Role.objects.create( name='role-%s' % name, instance=instance, rep_thresh=0, default_permission=FieldPermission.READ_ONLY) instance.default_role = new_role instance.save() return instance
def make_instance(name=None, is_public=False, url_name=None, point=None, edge_length=600): if name is None: max_instance = Instance.objects.all().aggregate( Max('id'))['id__max'] or 0 name = 'generated$%d' % (max_instance + 1) if url_name is None: max_instance = Instance.objects.all().aggregate( Max('id'))['id__max'] or 0 url_name = 'generated-%d' % (max_instance + 1) p1 = point or Point(0, 0) instance = Instance(name=name, geo_rev=0, is_public=is_public, url_name=url_name) instance.seed_with_dummy_default_role() d = edge_length / 2 instance.bounds = InstanceBounds.create_from_point(p1.x, p1.y, d) instance.save() new_role = Role.objects.create( name='role-%s' % name, instance=instance, rep_thresh=0, default_permission_level=FieldPermission.READ_ONLY) instance.default_role = new_role instance.save() return instance