Exemplo n.º 1
0
def mongo_delete_photographer_by_name(name):
    try:
        ph = Photographer.objects(display_name=name).get()
    except (Photographer.DoesNotExist, Photographer.MultipleObjectsReturned):
        return False
    except (pymongo.errors.AutoReconnect,
            pymongo.errors.ServerSelectionTimeoutError,
            pymongo.errors.NetworkTimeout) as e:
        raise
    ph.delete()
    return True
def mongo_get_photographer(photographer_id):
    ph = Photographer.objects(id=ObjectId(photographer_id)).get()
    return ph
def mongo_check(display_name):
    count = Photographer.objects(display_name=display_name).count()
    return count
Exemplo n.º 4
0
def delete_photographer(photographer_id):
    ph = Photographer.objects(id=ObjectId(photographer_id)).get().delete()
    return 'NoContent', 204
Exemplo n.º 5
0
def mongo_update_photographer_by_name(name, new_first_name, new_last_name, new_interests):
    ph = Photographer.objects(display_name=name).update(first_name=new_first_name, last_name=new_last_name, interests=new_interests)
Exemplo n.º 6
0
def mongo_delete_photographer_by_name(name):
    ph = Photographer.objects(display_name=name).get().delete()
Exemplo n.º 7
0
def mongo_get_photographer_by_name(name):
    ph = Photographer.objects(display_name=name).get()
    return ph
Exemplo n.º 8
0
def mongo_update_photographers_by_name(display_name, first_name, last_name,
                                       interests):
    ph = Photographer.objects(display_name=display_name).update(
        first_name=first_name, last_name=last_name, interests=interests)
    return ph