|
|
|
@ -14,6 +14,8 @@ from luncho.helpers import ForceJSON
|
|
|
|
|
|
|
|
|
|
from luncho.exceptions import AccountNotVerifiedException |
|
|
|
|
from luncho.exceptions import ElementNotFoundException |
|
|
|
|
from luncho.exceptions import UserIsNotAdminException |
|
|
|
|
from luncho.exceptions import NewMaintainerDoesNotExistException |
|
|
|
|
|
|
|
|
|
places = Blueprint('places', __name__) |
|
|
|
|
|
|
|
|
@ -126,6 +128,8 @@ def update_place(placeId):
|
|
|
|
|
HTTP/1.1 200 OK |
|
|
|
|
Content-Type: text/json |
|
|
|
|
|
|
|
|
|
{ "status": "OK" } |
|
|
|
|
|
|
|
|
|
**Request not in JSON format (400)**: |
|
|
|
|
:py:class:`RequestMustBeJSONException` |
|
|
|
|
|
|
|
|
@ -165,3 +169,43 @@ def update_place(placeId):
|
|
|
|
|
|
|
|
|
|
db.session.commit() |
|
|
|
|
return jsonify(status='OK') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@places.route('<placeId>/', methods=['DELETE']) |
|
|
|
|
@auth |
|
|
|
|
def delete_place(placeId): |
|
|
|
|
"""*Authenticated request* Delete the place. The user must be |
|
|
|
|
the maintainer of the place to delete it. |
|
|
|
|
|
|
|
|
|
**Success (200)**: |
|
|
|
|
|
|
|
|
|
.. sourcecode:: http |
|
|
|
|
|
|
|
|
|
HTTP/1.1 200 OK |
|
|
|
|
Content-Type: text/json |
|
|
|
|
|
|
|
|
|
{ "status": "OK" } |
|
|
|
|
|
|
|
|
|
**User is not administrator of the group (403)**: |
|
|
|
|
:py:class:`UserIsNotAdminException` |
|
|
|
|
|
|
|
|
|
**User not found (via token) (404)**: |
|
|
|
|
:py:class:`UserNotFoundException` |
|
|
|
|
|
|
|
|
|
**The place does not exist (404)**: |
|
|
|
|
:py:class:`ElementNotFoundException` |
|
|
|
|
|
|
|
|
|
**Authorization required (412)**: |
|
|
|
|
:py:class:`AuthorizationRequiredException` |
|
|
|
|
""" |
|
|
|
|
place = Place.query.get(placeId) |
|
|
|
|
if not place: |
|
|
|
|
raise ElementNotFoundException('Place') |
|
|
|
|
|
|
|
|
|
if not place.owner == request.user.username: |
|
|
|
|
raise UserIsNotAdminException() |
|
|
|
|
|
|
|
|
|
db.session.delete(place) |
|
|
|
|
db.session.commit() |
|
|
|
|
|
|
|
|
|
return jsonify(status='OK') |
|
|
|
|