Beispiel #1
0
def add_tree_photo(request, instance, feature_id, tree_id=None):
    error = None
    try:
        _, tree = add_tree_photo_helper(request, instance, feature_id, tree_id)
        photos = tree.photos()
    except ValidationError as e:
        trees = Tree.objects.filter(pk=tree_id)
        if len(trees) == 1:
            photos = trees[0].photos()
        else:
            photos = []
        # TODO: Better display error messages in the view
        error = "; ".join(e.messages)
    return {"photos": map(context_dict_for_photo, photos), "error": error}
Beispiel #2
0
def add_tree_photo(request, instance, feature_id, tree_id=None):
    error = None
    try:
        _, tree = add_tree_photo_helper(request, instance, feature_id, tree_id)
        photos = tree.photos()
    except ValidationError as e:
        trees = Tree.objects.filter(pk=tree_id)
        if len(trees) == 1:
            photos = trees[0].photos()
        else:
            photos = []
        # TODO: Better display error messages in the view
        error = '; '.join(e.messages)
    return {'photos': map(context_dict_for_photo, photos), 'error': error}
Beispiel #3
0
def add_tree_photo(request, instance, feature_id, tree_id=None):
    error = None
    try:
        __, tree = add_tree_photo_helper(
            request, instance, feature_id, tree_id)
        photos = tree.photos()
    except ValidationError as e:
        trees = Tree.objects.filter(pk=tree_id)
        if len(trees) == 1:
            photos = trees[0].photos()
        else:
            photos = []
        # TODO: Better display error messages in the view
        error = '; '.join(e.messages)
    return {'photos': [context_dict_for_photo(request, photo)
                       for photo in photos],
            'error': error}
Beispiel #4
0
def add_photo(request, instance, plot_id):
    treephoto, __ = add_tree_photo_helper(request, instance, plot_id)

    return context_dict_for_photo(request, treephoto)
Beispiel #5
0
def add_photo(request, instance, plot_id):
    treephoto, _ = add_tree_photo_helper(request, instance, plot_id)

    return context_dict_for_photo(treephoto)