def post(self): if request.is_json: data = request.get_json() if "First Name" in data and "Last Name" in data and "Image URI" in data and "Team" in data: team = TeamHandler.read_by_name(data["Team"]) if team: player = PlayerHandler.insert( data["First Name"], data["Last Name"], data["Image URI"], team, ) return { "message": "New Player Created", "type": "info", "Player ID": player.id }, 201 else: return { "message": "Invalid Team Name", "type": "error" }, 400 else: return {"message": "Invalid JSON", "type": "error"}, 400 else: return { "message": "Request requires JSON format", "type": "error" }, 400
def put(self, id): if request.is_json: data = request.get_json() first_name = data.get("First Name", None) last_name = data.get("Last Name", None) image_uri = data.get("Image URI", None) team = None if "Team" in data: team = TeamHandler.read_by_name(data["Team"]) if team is None: return { "message": "Invalid Team Name", "type": "error" }, 400 player = PlayerHandler.update(id, first_name=first_name, last_name=last_name, image_uri=image_uri, team=team) return Utils.serialize_player(player) else: return { "message": "Request requires JSON format", "type": "error" }, 400
def put(self, id): if request.is_json: data = request.get_json() team_name = data.get("Team Name", None) logo_uri = data.get("Logo URI", None) team = TeamHandler.update(id, teamname=team_name, logoUri=logo_uri) return Utils.serialize_team(team), 200 else: return { "message": "Request requires JSON format", "type": "error" }, 400
def post(self): if request.is_json: data = request.get_json() if "Team Name" in data and "Logo URI" in data: team = TeamHandler.insert(data["Team Name"], data["Logo URI"]) return { "message": "New Team Created", "type": "info", "Team ID": team.id }, 201 else: return {"message": "Invalid JSON", "type": "error"}, 400 else: return { "message": "Request requires JSON format", "type": "error" }, 400
ActionsPageSettingsHandler(), ActionHandler(), AdminHandler(), AuthHandler(), CommunityHandler(), ContactUsPageSettingsHandler(), DownloadHandler(), DonatePageSettingsHandler(), DownloadHandler(), EventHandler(), GoalHandler(), GraphHandler(), HomePageSettingsHandler(), MessageHandler(), MiscellaneousHandler(), PolicyHandler(), SubscriberHandler(), SummaryHandler(), TagHandler(), TagCollectionHandler(), TeamHandler(), TeamsPageSettingsHandler(), TestimonialHandler(), UserHandler(), VendorHandler() ] urlpatterns = [] for handler in ROUTE_HANDLERS: urlpatterns.extend(handler.get_routes_to_views())
def get(self, id): return Utils.serialize_player_list( PlayerHandler.read_by_team(TeamHandler.read_by_id(id)))
from django.urls import path, re_path from django.conf.urls import url from .views import * from api.handlers.team import TeamHandler from api.handlers.action import ActionHandler team_handler = TeamHandler() action_handler = ActionHandler() urlpatterns = [ url(r'^$', ping), path('actions', actions), path('action/<int:id>', action), path('action/<int:id>/copy', action_copy), path('action/<int:id>/testimonials', action_testimonials), path('action-properties', action_properties), path('action-property/<int:id>', action_property), path('billing-statements', billing_statements), path('billing-statement/<int:id>', billing_statement), path('communities', communities), path('communities/stats', communities_stats), path('community/<int:cid>/stats', community_stats), path('community/<int:cid>', community), path('community/<int:cid>/full', community_profile_full), path('community/<int:cid>/actions', community_actions), path('community/<int:cid>/members', community_members), path('community/<int:cid>/impact', community_impact), path('community/<int:cid>/pages', community_pages), path('community/<int:cid>/events', community_events), path('community/<int:cid>/households', community_households), path('community/<int:cid>/teams', community_teams),
def get(self): if request.is_json: print(request.get_json()) return Utils.serialize_team_list(TeamHandler.read()), 200
def delete(self, id): TeamHandler.delete(id), 200
def get(self, id): return Utils.serialize_team(TeamHandler.read_by_id(id)), 200
from api.handlers.tag import TagHandler from api.handlers.tag_collection import TagCollectionHandler from api.handlers.team import TeamHandler from api.handlers.testimonial import TestimonialHandler from api.handlers.userprofile import UserHandler from api.handlers.vendor import VendorHandler urlpatterns = [] urlpatterns.extend(AboutUsPageSettingsHandler().get_routes_to_views()) urlpatterns.extend(ActionHandler().get_routes_to_views()) urlpatterns.extend(ActionsPageSettingsHandler().get_routes_to_views()) urlpatterns.extend(AdminHandler().get_routes_to_views()) urlpatterns.extend(CommunityHandler().get_routes_to_views()) urlpatterns.extend(ContactUsPageSettingsHandler().get_routes_to_views()) urlpatterns.extend(DonatePageSettingsHandler().get_routes_to_views()) urlpatterns.extend(EventHandler().get_routes_to_views()) urlpatterns.extend(GoalHandler().get_routes_to_views()) urlpatterns.extend(GraphHandler().get_routes_to_views()) urlpatterns.extend(MessageHandler().get_routes_to_views()) urlpatterns.extend(MiscellaneousHandler().get_routes_to_views()) urlpatterns.extend(PolicyHandler().get_routes_to_views()) urlpatterns.extend(SubscriberHandler().get_routes_to_views()) urlpatterns.extend(SummaryHandler().get_routes_to_views()) urlpatterns.extend(HomePageSettingsHandler().get_routes_to_views()) urlpatterns.extend(TagHandler().get_routes_to_views()) urlpatterns.extend(TagCollectionHandler().get_routes_to_views()) urlpatterns.extend(TeamHandler().get_routes_to_views()) urlpatterns.extend(TestimonialHandler().get_routes_to_views()) urlpatterns.extend(UserHandler().get_routes_to_views()) urlpatterns.extend(VendorHandler().get_routes_to_views())