Exemple #1
0
def get_map_view_context(request, instance):
    if request.user and not request.user.is_anonymous():
        iuser = request.user.get_instance_user(instance)
        resource_classes = [resource for resource in instance.resource_classes
                            if map_feature_is_creatable(iuser, resource)]
    else:
        resource_classes = []

    context = {
        'fields_for_add_tree': [
            (_('Tree Height'), 'Tree.height')
        ],
        'resource_classes': resource_classes,
        'only_one_resource_class': len(resource_classes) == 1,
    }
    add_map_info_to_context(context, instance)
    return context
Exemple #2
0
def get_map_view_context(request, instance):
    if request.user and not request.user.is_anonymous():
        iuser = request.user.get_instance_user(instance)
        resource_names = [mfn for mfn in instance.map_feature_types
                          if mfn != 'Plot']
        resource_classes = [resource for resource in
                            map(MapFeature.get_subclass, resource_names)
                            if map_feature_is_creatable(iuser, resource)]
    else:
        resource_classes = []

    context = {
        'fields_for_add_tree': [
            (_('Tree Height'), 'Tree.height')
        ],
        'resource_classes': resource_classes,
        'only_one_resource_class': len(resource_classes) == 1,
    }
    add_map_info_to_context(context, instance)
    return context
Exemple #3
0
def get_map_view_context(request, instance):
    if request.user and not request.user.is_anonymous():
        iuser = request.user.get_instance_user(instance)
        resource_classes = [
            resource for resource in instance.resource_classes
            if map_feature_is_creatable(iuser, resource)
        ]
    else:
        resource_classes = []

    context = {
        'fields_for_add_tree': [(_('Tree Height'), 'Tree.height')],
        'resource_classes':
        resource_classes,
        'only_one_resource_class':
        len(resource_classes) == 1,
        'polygon_area_units':
        get_unit_abbreviation(
            get_units(instance, 'greenInfrastructure', 'area')),
        'q':
        request.GET.get('q'),
    }
    add_map_info_to_context(context, instance)
    return context
Exemple #4
0
 def test_map_feature_is_not_creatable(self):
     self.assertFalse(
         perms.map_feature_is_creatable(self.role_no, RainBarrel))
Exemple #5
0
 def test_map_feature_is_creatable(self):
     self._add_builtin_permission(self.role_yes, RainBarrel,
                                  'add_rainbarrel')
     self.assertTrue(
         perms.map_feature_is_creatable(self.role_yes, RainBarrel))
Exemple #6
0
 def test_map_feature_is_not_creatable(self):
     self.assertFalse(
         perms.map_feature_is_creatable(self.role_no, RainBarrel))
Exemple #7
0
 def test_map_feature_is_creatable(self):
     self._add_builtin_permission(self.role_yes, RainBarrel,
                                  'add_rainbarrel')
     self.assertTrue(
         perms.map_feature_is_creatable(self.role_yes, RainBarrel))