Exemple #1
0
from flask_cors import cross_origin

from app.blueprints.base_blueprint import (
    Blueprint,
    BaseBlueprint,
    request,
    Security,
    Auth,
)
from app.controllers.user_employment_controller import UserEmploymentController

url_prefix = "{}/user_employment_history".format(BaseBlueprint.base_url_prefix)
user_employment_blueprint = Blueprint(
    "user_employment", __name__, url_prefix=url_prefix
)
user_employment_controller = UserEmploymentController(request)


@user_employment_blueprint.route("/user/<int:user_id>", methods=["GET"])
# @cross_origin(supports_credentials=True)
@Auth.has_permission(["view_user_employment_history"])
# @swag_from('documentation/get_all_user_employment_history.yml')
def list_user_employment_history(user_id):
    return user_employment_controller.list_user_employment_history(user_id)


@user_employment_blueprint.route(
    "/user-single/<int:user_employment_id>", methods=["GET"]
)
# @cross_origin(supports_credentials=True)
@Auth.has_permission(["view_user_employment_history"])
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.account_controller import AccountController

url_prefix = '{}/accounts'.format(BaseBlueprint.base_url_prefix)
account_blueprint = Blueprint('account', __name__, url_prefix=url_prefix)

account_controller = AccountController(request)
""" Student BluePrints """


@account_blueprint.route('/student/signup', methods=['POST'])
@Security.validator([
    'first_name|required', 'last_name|required',
    'email|not-exist|student|email', 'email|required', 'password|required'
])
def student_register():
    return account_controller.register(admin=False)


@account_blueprint.route('/student/<int:id>', methods=['PUT', 'PATCH'])
@Auth.has_permission('student')
def update_student_account(id):
    return account_controller.update_student_account(id, admin=False)


@account_blueprint.route('/student/me', methods=['GET'])
@Auth.has_permission('student')
def me():
    return account_controller.fetch_student_account(id=0, admin=False)

from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, Security, request, Auth
from app.controllers.attribute_controller import AttributeController
from flasgger import swag_from

url_prefix = '{}/attributes'.format(BaseBlueprint.base_url_prefix)
attribute_blueprint = Blueprint('attribute', __name__, url_prefix=url_prefix)
attribute_controller = AttributeController(request)


@attribute_blueprint.route('', methods=['GET'])
@Auth.has_permission('view_attribute')
@swag_from('documentation/get_all_attributes.yml')
def list_attributes():
	return attribute_controller.list_attributes()




@attribute_blueprint.route('/<int:attribute_id>', methods=['GET'])
@Auth.has_permission('view_attribute')
@swag_from('documentation/get_single_attribute.yml')
def get_attribute(attribute_id):
	return attribute_controller.get_attribute(attribute_id)


@attribute_blueprint.route('/values/<int:attribute_id>', methods=['GET'])
@Auth.has_permission('view_attribute')
@swag_from('documentation/get_attribute_values.yml')
def get_attribute_values(attribute_id):
	return attribute_controller.get_attribute_values(attribute_id)
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.vendor_controller import VendorController
from app.utils.auth import Auth
from flasgger import swag_from

vendor_blueprint = Blueprint('vendor', __name__, url_prefix='{}/vendors'.format(BaseBlueprint.base_url_prefix))


vendor_controller = VendorController(request)


@vendor_blueprint.route('/', methods=['GET'])
@swag_from('documentation/get_all_vendors_per_page.yml')
def list_vendors():
	return vendor_controller.list_vendors()


@vendor_blueprint.route('/deleted/', methods=['GET'])
@swag_from('documentation/get_deleted_vendors_per_page.yml')
def list_deleted_vendors():
	return vendor_controller.list_deleted_vendors()


@vendor_blueprint.route('/suspended/', methods=['GET'])
@swag_from('documentation/get_suspended_vendors_per_page.yml')
def list_suspended_vendors():
	return vendor_controller.list_suspended_vendors()


@vendor_blueprint.route('/<int:vendor_id>', methods=['GET'])
@swag_from('documentation/get_vendor_by_id.yml')
Exemple #5
0
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, Security, request, Auth
from app.controllers.user_controller import UserController

url_prefix = '{}/user'.format(BaseBlueprint.base_url_prefix)
user_blueprint = Blueprint('user', __name__, url_prefix=url_prefix)
user_controller = UserController(request)


@user_blueprint.route('/', strict_slashes=False, methods=['POST'])
@Security.validator([
    'firstName|required:string', 'lastName|required:string',
    'emailAddress|required:string', 'password|required:string'
])
def create_user():
    return user_controller.create_user()


@user_blueprint.route('/upload', strict_slashes=False, methods=['POST'])
def upload_picture():
    return user_controller.upload_picture()


@user_blueprint.route('/login/', strict_slashes=False, methods=['POST'])
@Security.validator(
    ['emailAddress|required:string', 'password|required:string'])
def login():
    return user_controller.login()


@user_blueprint.route('/reset', strict_slashes=False, methods=['PUT'])
@Security.validator(
"""
Module to deal with the menu templates
"""

from flasgger import swag_from

from app.blueprints.base_blueprint import (Auth, BaseBlueprint, Blueprint,
                                           request)
from app.controllers.menu_template_controller import MenuTemplateController
from app.models.menu_template import MenuTemplate
from app.utils.security import Security

url_prefix = '{}/menu_template'.format(BaseBlueprint.base_url_prefix)

menu_template_blueprint = Blueprint(
    'menu_template', __name__, url_prefix=url_prefix)
menu_template_controller = MenuTemplateController(request)


@menu_template_blueprint.route('/', methods=['POST'])
@Auth.has_role('admin')
@Security.validator(['name|required', 'mealPeriod|required:enum_MealPeriods', 'description|required'])
@swag_from('documentation/menu_template.yml')
def create_menu_template():
    return menu_template_controller.create()


@menu_template_blueprint.route('/', methods=['GET'])
@Security.validate_query_params(MenuTemplate)
@Auth.has_role('admin')
@swag_from('documentation/menu_template.yml')
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, Security, request, Auth
from app.controllers.flight_seats_controller import FlightSeatController

url_prefix = '{}/flightSeat'.format(BaseBlueprint.base_url_prefix)
flight_seat_blueprint = Blueprint('flight_seat',
                                  __name__,
                                  url_prefix=url_prefix)
flight_seat_controller = FlightSeatController(request)


@flight_seat_blueprint.route('/<int:flight_id>/',
                             strict_slashes=False,
                             methods=['GET'])
def list_flight_seats(flight_id):
    return flight_seat_controller.get_all_seats_on_flight(flight_id)


@flight_seat_blueprint.route('/available/<int:flight_id>/',
                             strict_slashes=False,
                             methods=['GET'])
def get_available_seats_on_flight(flight_id):
    return flight_seat_controller.get_available_seats_on_flight(flight_id)


@flight_seat_blueprint.route('/unavailable/<int:flight_id>/',
                             strict_slashes=False,
                             methods=['GET'])
def get_unavailable_seats_on_flight(flight_id):
    return flight_seat_controller.get_unavailable_seats_on_flight(flight_id)
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.home_controller import HomeController

url_prefix = '{}/'.format(BaseBlueprint.base_url_prefix)
home_blueprint = Blueprint('home', __name__, url_prefix=url_prefix)

home_controller = HomeController(request)


@home_blueprint.route('/', methods=['GET'])
def homepage():
    return home_controller.home_page()


@home_blueprint.route('/', methods=['POST'])
@Security.validator(['search_string|required:string'])
def homepage():
    return home_controller.search_words()
Exemple #9
0
"""
Module to deal with Activity logs
"""
from flasgger import swag_from
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request
from app.controllers.activity_controller import ActivityController
from app.utils.security import Security


activity_blueprint = Blueprint('activity', __name__, url_prefix='{}/activities'.format(BaseBlueprint.base_url_prefix))
activity_controller = ActivityController(request)


@activity_blueprint.route('/range', methods=['GET'])
@Security.url_validator(['date_range|required:range'])
@swag_from('documentation/get_activities_by_date.yml')
def list_activities_date_range():
    return activity_controller.list_by_date_range()


@activity_blueprint.route('/action_range', methods=['GET'])
@Security.url_validator(['action_type|required:enum_options', 'date_range|required:range'])
@swag_from('documentation/get_activities_by_date_and_action_type.yml')
def list_activities_action_type_date_range():
    return activity_controller.list_by_action_type_and_date_range()
Exemple #10
0
from flask_cors import cross_origin

from app.blueprints.base_blueprint import (
    Blueprint,
    BaseBlueprint,
    request,
    Security,
    Auth,
)
from app.controllers.skill_category_controller import SkillCategoryController

url_prefix = "{}/skills_categories".format(BaseBlueprint.base_url_prefix)
skills_category_blueprint = Blueprint(
    "skills_category", __name__, url_prefix=url_prefix
)
skills_category_controller = SkillCategoryController(request)


@skills_category_blueprint.route("/", methods=["GET"])
# @cross_origin(supports_credentials=True)
@Auth.has_permission(["view_skills_categories"])
# @swag_from('documentation/get_all_skill_categories.yml')
def list_skill_categories():
    return skills_category_controller.list_skills_categories()


@skills_category_blueprint.route("/<int:skill_category_id>", methods=["GET"])
# @cross_origin(supports_credentials=True)
@Auth.has_permission(["view_skills_categories"])
# @swag_from('documentation/get_skill_category_by_id.yml')
def get_skill_category(skill_category_id):
Exemple #11
0
from flasgger import swag_from

from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.department_controller import DepartmentController

url_prefix = '{}/'.format(BaseBlueprint.base_url_prefix)
department_blueprint = Blueprint('department', __name__, url_prefix=url_prefix)
department_controller = DepartmentController(request)


@department_blueprint.route('', methods=['GET'])
@Auth.has_permission('view_department')
@swag_from('documentation/get_all_departments.yml')
def list_departments():
    return department_controller.list_departments()


@department_blueprint.route('/<int:department_id>', methods=['GET'])
@Auth.has_permission('view_department')
@swag_from('documentation/get_single_department.yml')
def get_department(department_id):
    return department_controller.get_department(department_id)
Exemple #12
0
from app.blueprints.base_blueprint import (
    Blueprint,
    BaseBlueprint,
    request,
    Security,
    Auth,
)
from app.controllers.client_controller import ClientController

# from flasgger import swag_from

url_prefix = "{}/clients".format(BaseBlueprint.base_url_prefix)
client_blueprint = Blueprint("client", __name__, url_prefix=url_prefix)
client_controller = ClientController(request)
""" CLIENTS """


@client_blueprint.route("/", methods=["GET"])
@Auth.has_permission(["view_clients"])
# @swag_from('documentation/get_all_clients.yml')
def list_clients():
    return client_controller.list_clients()


@client_blueprint.route("/engineers", methods=["GET"])
@Auth.has_permission(["view_clients"])
# @swag_from('documentation/get_all_clients.yml')
def list_client_engineers():
    return client_controller.list_client_engineers()

from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.auth_controller import AuthController

url_prefix = '{}/auth'.format(BaseBlueprint.base_url_prefix)
auth_blueprint = Blueprint('auth', __name__, url_prefix=url_prefix)

auth_controller = AuthController(request)


@auth_blueprint.route('/login', methods=['POST'])
@Security.validator(['email|required', 'password|required'])
def login():
    return auth_controller.login()


@auth_blueprint.route('/admin/login', methods=['POST'])
@Security.validator(['email|required', 'password|required'])
def admin_login():
    return auth_controller.login(admin=True)
from flasgger import swag_from

from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.category_controller import CategoryController

url_prefix = '{}/'.format(BaseBlueprint.base_url_prefix)
category_blueprint = Blueprint('categories', __name__, url_prefix=url_prefix)
category_controller = CategoryController(request)


@category_blueprint.route('', methods=['GET'])
@Auth.has_permission('view_category')
@swag_from('documentation/get_all_categories.yml')
def list_categories():
    return category_controller.list_categories()


@category_blueprint.route('/<int:category_id>', methods=['GET'])
@Auth.has_permission('view_category')
@swag_from('documentation/get_single_category.yml')
def get_category(category_id):
    return category_controller.get_category(category_id)


@category_blueprint.route('/inDepartment/<int:department_id>', methods=['GET'])
@Auth.has_permission('view_category')
@swag_from('documentation/get_category_department.yml')
def get_category_department(department_id):
    return category_controller.get_category_department(department_id)

"""
Module to deal with meal sessions
"""
from flasgger import swag_from

from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request
from app.controllers.meal_session_controller import MealSessionController
from app.utils.security import Security
from app.utils.auth import Auth

meal_session_blueprint = Blueprint('meal_session',
                                   __name__,
                                   url_prefix='{}/meals'.format(
                                       BaseBlueprint.base_url_prefix))
meal_session_controller = MealSessionController(request)


@meal_session_blueprint.route('/session', methods=['POST'])
@Auth.has_role('admin')
@Security.validator([
    'name|required:enum_MealSessionNames', 'date|required:date',
    'startTime|required:time', 'endTime|required:time', 'locationId|int'
])
@swag_from('documentation/create_meal_session.yml')
def create():
    return meal_session_controller.create_session()


@meal_session_blueprint.route('/session/<int:meal_session_id>',
                              methods=['PUT'])
@Auth.has_role('admin')
Exemple #16
0
from flasgger import swag_from

from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.vendor_rating_controller import VendorRatingController
from app.utils.auth import Auth

rating_blueprint = Blueprint('rating',
                             __name__,
                             url_prefix='{}/ratings'.format(
                                 BaseBlueprint.base_url_prefix))

vendor_rating_controller = VendorRatingController(request)


@rating_blueprint.route('/vendor/<int:vendor_id>', methods=['GET'])
@Auth.has_permission('view_ratings')
@swag_from('documentation/get_vendor_ratings.yml')
def list_ratings(vendor_id):
    '''Gets all the ratings for a given vendor'''
    return vendor_rating_controller.list_ratings(vendor_id)


@rating_blueprint.route('/<int:rating_id>', methods=['GET'])
@Auth.has_permission('view_ratings')
@swag_from('documentation/get_vendor_rating_by_id.yml')
def get_vendor_rating(rating_id):
    return vendor_rating_controller.get_vendor_rating(rating_id)


@rating_blueprint.route('/', methods=['POST'])
@Security.validator([
Exemple #17
0
'''A module of FAQ blueprint'''
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Auth
from app.controllers.faq_controller import FaqController
from app.utils.security import Security
from app.models import Faq
from flasgger import swag_from


faq_blueprint = Blueprint('faq', __name__, url_prefix='{}/faqs'.format(BaseBlueprint.base_url_prefix))

faq_controller = FaqController(request)


@faq_blueprint.route('/', methods=['GET'])
@Security.validate_query_params(Faq)
@swag_from('documentation/get_faqs.yml')
def list_faqs():

    kwargs = faq_controller.get_params_dict()

    return faq_controller.list_faqs(**kwargs)


@faq_blueprint.route('/', methods=['POST'])
@Auth.has_role('admin')
@Security.validator(['category|required:enum_FaqCategoryType', 'question|required', 'answer|required'])
@swag_from('documentation/create_faq.yml')
def create_faq():

    return faq_controller.create_faq()
Exemple #18
0
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.vendor_engagement_controller import VendorEngagementController
from flasgger import swag_from

engagement_blueprint = Blueprint('engagements',
                                 __name__,
                                 url_prefix='{}/engagements'.format(
                                     BaseBlueprint.base_url_prefix))

vendor_engagement_controller = VendorEngagementController(request)


@engagement_blueprint.route('/', methods=['GET'])
@swag_from('documentation/get_all_vendor_engagements.yml')
def list_engagements():
    return vendor_engagement_controller.list_vendor_engagements()


@engagement_blueprint.route('/vendor/<int:vendor_id>', methods=['GET'])
@swag_from('documentation/get_all_vendor_engagements_by_vendor_id.yml')
def list_engagements_by_vendor(vendor_id):
    return vendor_engagement_controller.list_vendor_engagements_by_vendor(
        vendor_id)


@engagement_blueprint.route('/upcoming', methods=['GET'])
@swag_from('documentation/get_all_upcoming_vendor_engagement.yml')
def upcoming_engagements():
    return vendor_engagement_controller.upcoming_vendor_engagements()

Exemple #19
0
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, Security, request, Auth
from app.controllers.ticket_controller import TicketController


url_prefix = '{}/ticket'.format(BaseBlueprint.base_url_prefix)
ticket_blueprint = Blueprint('ticket', __name__, url_prefix=url_prefix)
ticket_controller = TicketController(request)


@ticket_blueprint.route('/', strict_slashes=False, methods=['GET'])
def list_ticket():
    return ticket_controller.get_tickets()


@ticket_blueprint.route('/<int:ticket_id>/', strict_slashes=False, methods=['GET'])
def get_ticket(ticket_id):
    return ticket_controller.get_ticket(ticket_id)


@ticket_blueprint.route('/', strict_slashes=False, methods=['POST'])
@Security.validator(['flightSeatId|required:int', 'status|required:string', 'userId|required:int'])
def create_ticket():
    return ticket_controller.create_ticket()


@ticket_blueprint.route('/<int:ticket_id>/', strict_slashes=False, methods=['PUT'])
@Security.validator(['flightSeatId|required:int', 'status|required:string', 'userId|required:int'])
def update_ticket(ticket_id):
    return ticket_controller.update_ticket(ticket_id)

Exemple #20
0
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, Security, request, Auth
from app.controllers.meal_item_controller import MealItemController
from app.models import MealItem
from flasgger import swag_from

url_prefix = '{}/meal-items'.format(BaseBlueprint.base_url_prefix)
meal_item_blueprint = Blueprint('meal_item', __name__, url_prefix=url_prefix)
meal_item_controller = MealItemController(request)


@meal_item_blueprint.route('/', methods=['GET'])
@Auth.has_permission('view_meal_item')
@Security.validate_query_params(MealItem)
@swag_from('documentation/get_all_meal_items.yml')
def list_meals():
    return meal_item_controller.list_meals()


# @meal_item_blueprint.route('/page/<int:page_id>', methods=['GET'])
# @swag_from('documentation/get_all_meal_items_page.yml')
# def list_meals_page(page_id):
# 	meals_per_page = int(request.args.get('per_page')) if request.args.get('per_page') != None else 10
# 	return meal_item_controller.list_meals_page(page_id, meals_per_page)


@meal_item_blueprint.route('/<int:meal_item_id>', methods=['GET'])
@Auth.has_permission('view_meal_item')
@swag_from('documentation/get_single_meal_item.yml')
def get_meal(meal_item_id):
    return meal_item_controller.get_meal(meal_item_id)
Exemple #21
0
from flask_cors import cross_origin

from app.blueprints.base_blueprint import (
    Blueprint,
    BaseBlueprint,
    request,
    Security,
    Auth,
)
from app.controllers.user_education_controller import UserEducationController

url_prefix = "{}/user_education".format(BaseBlueprint.base_url_prefix)
user_education_blueprint = Blueprint("user_education", __name__, url_prefix=url_prefix)
user_education_controller = UserEducationController(request)


@user_education_blueprint.route("/user/<int:user_id>", methods=["GET"])
# @cross_origin(supports_credentials=True)
@Auth.has_permission(["view_user_education"])
# @swag_from('documentation/get_all_user_education.yml')
def list_user_education(user_id):
    return user_education_controller.list_user_education(user_id)


@user_education_blueprint.route("/user-single/<int:user_education_id>", methods=["GET"])
# @cross_origin(supports_credentials=True)
@Auth.has_permission(["view_user_education"])
# @swag_from('documentation/get_user_education_by_id.yml')
def get_user_education(user_education_id):
    return user_education_controller.get_user_education(user_education_id)
Exemple #22
0
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Auth, Security
from app.controllers.user_controller import UserController
from flasgger import swag_from

user_blueprint = Blueprint('user',
                           __name__,
                           url_prefix='{}/users'.format(
                               BaseBlueprint.base_url_prefix))
user_controller = UserController(request)


@user_blueprint.route('/admin', methods=['GET'])
@Auth.has_permission('create_user_roles')
@swag_from('documentation/get_all_admin_users.yml')
def list_admin_users():
    return user_controller.list_admin_users()


@user_blueprint.route('/', methods=['GET'])
@Auth.has_permission('view_users')
@swag_from('documentation/get_all_users.yml')
def list_all_users():
    return user_controller.list_all_users()


@user_blueprint.route('/<int:id>/', methods=['DELETE'])
@Auth.has_permission('delete_user')
@swag_from('documentation/delete_user.yml')
def delete_user(id):
    return user_controller.delete_user(id)
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.lecture_controller import LectureController

url_prefix = '{}'.format(BaseBlueprint.base_url_prefix)
lecture_blueprint = Blueprint('lecture', __name__, url_prefix=url_prefix)

lecture_controller = LectureController(request)
""" Admin BluePrints """


@lecture_blueprint.route('/admin/events/<int:event_id>/lectures',
                         methods=['POST'])
@Auth.has_permission('admin')
def admin_create_event_lecture(event_id):
    return lecture_controller.create_lecture(event_id)


@lecture_blueprint.route(
    '/admin/events/<int:event_id>/lectures/<int:lecture_id>',
    methods=['PUT', 'PATCH'])
@Auth.has_permission('admin')
def admin_update_event_lecture(event_id, lecture_id):
    return lecture_controller.update_lecture(event_id, lecture_id)


@lecture_blueprint.route(
    '/admin/events/<int:event_id>/lectures/<int:lecture_id>/lecturers/add',
    methods=['POST'])
@Auth.has_permission('admin')
def admin_add_lecturers_to_event_lecture(event_id, lecture_id):
    return lecture_controller.add_lecturers_to_lecture(event_id, lecture_id)
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request

url_prefix = '{}/'.format(BaseBlueprint.base_url_prefix)
sample_blueprint = Blueprint('sample', __name__, url_prefix=url_prefix)


@sample_blueprint.route('/', methods=['GET'])
def hello():
    return '''
                <h1>Hello! Welcome to AirTech</h2>
            '''
"""
Module to deal with the about page
"""
from flasgger import swag_from

from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Auth
from app.controllers.about_controller import AboutController
from app.utils.security import Security

about_blueprint = Blueprint('about',
                            __name__,
                            url_prefix='{}/about'.format(
                                BaseBlueprint.base_url_prefix))
about_controller = AboutController(request)


@about_blueprint.route('/view', methods=['GET'])
@swag_from('documentation/get_about_page.yml')
def get_about_page():
    return about_controller.get_about_page()


@about_blueprint.route('/create_or_update', methods=['POST', 'PATCH'])
@Auth.has_role('admin')
@Security.validator(['data|required'])
@swag_from('documentation/create_about.yml')
def create_about_page():
    return about_controller.create_or_modify_about_page()
Exemple #26
0
"""
Module to deal with Activity logs
"""
from flasgger import swag_from
from flask_cors import cross_origin

from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request
from app.controllers.activity_controller import ActivityController
from app.utils.security import Security

activity_blueprint = Blueprint(
    "activity",
    __name__,
    url_prefix="{}/activities".format(BaseBlueprint.base_url_prefix),
)
activity_controller = ActivityController(request)


@activity_blueprint.route("/range", methods=["GET"])
# @cross_origin(supports_credentials=True)
@Security.url_validator(["date_range|required:range"])
@swag_from("documentation/get_activities_by_date.yml")
def list_activities_date_range():
    return activity_controller.list_by_date_range()


@activity_blueprint.route("/action_range", methods=["GET"])
# @cross_origin(supports_credentials=True)
@Security.url_validator(
    ["action_type|required:enum_options", "date_range|required:range"])
@swag_from("documentation/get_activities_by_date_and_action_type.yml")
Exemple #27
0
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, Security, request, Auth
from app.controllers.location_controller import LocationController


url_prefix = '{}/location'.format(BaseBlueprint.base_url_prefix)
location_blueprint = Blueprint('location', __name__, url_prefix=url_prefix)
location_controller = LocationController(request)


@location_blueprint.route('/', strict_slashes=False, methods=['GET'])
def list_locations():
    return location_controller.get_locations()


@location_blueprint.route('/<int:location_id>/', strict_slashes=False, methods=['GET'])
def get_location(location_id):
    return location_controller.get_location(location_id)


@location_blueprint.route('/', strict_slashes=False, methods=['POST'])
@Security.validator(['locationCode|required:string', 'location|required:string'])
@Auth.has_permission('create_locations')
def create_location():
    return location_controller.create_location()


@location_blueprint.route('/<int:location_id>/', strict_slashes=False, methods=['PUT'])
@Security.validator(['locationCode|required:string', 'location|required:string'])
@Auth.has_permission('update_locations')
def update_location(location_id):
    return location_controller.update_location(location_id)
from flasgger import swag_from

from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request
from app.controllers import ReportsController

reports_blueprint = Blueprint('reports',
                              __name__,
                              url_prefix='{}/reports'.format(
                                  BaseBlueprint.base_url_prefix))

reports_controller = ReportsController(request)


@reports_blueprint.route('/', methods=['GET'])
@swag_from('documentation/get_report.yml')
def dashboard_summary():
    return reports_controller.dashboard_summary()


@reports_blueprint.route('/taps/daily/', methods=['GET'])
@swag_from('documentation/daily_taps.yml')
def daily_taps():
    return reports_controller.daily_taps()
'''A module of menu blueprint'''
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.menu_controller import MenuController
from flasgger import swag_from

menu_blueprint = Blueprint('menu', __name__, url_prefix='{}/admin/menus'.format(BaseBlueprint.base_url_prefix))
user_menu_blueprint = Blueprint('user_menu', __name__, url_prefix='{}/menus'.format(BaseBlueprint.base_url_prefix))

menu_controller = MenuController(request)


"""Menu"""
@menu_blueprint.route('/', methods=['POST'])
@Security.validator([
	'date|required:date', 'mealPeriod|required',
	'mainMealId|required:int', 'allowedSide|required:int',
	'allowedProtein|required:int', 'sideItems|required:list_int',
	'proteinItems|required:list_int', 'vendorEngagementId|required:int',
	'sideItems|exists|meal_item|id', 'proteinItems|exists|meal_item|id',
	'mainMealId|exists|meal_item|id'
	])
@Auth.has_permission('create_menu')
@swag_from('documentation/create_menu.yml')
def create_menu():
	'''Blueprint function for creating a menu'''
	return menu_controller.create_menu()


@menu_blueprint.route('/<int:menu_id>', methods=['DELETE'])
@Auth.has_permission('delete_menu')
@swag_from('documentation/delete_menu.yml')
from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.event_controller import EventController

url_prefix = '{}'.format(BaseBlueprint.base_url_prefix)
event_blueprint = Blueprint('event', __name__, url_prefix=url_prefix)

event_controller = EventController(request)
""" Admin BluePrints """


@event_blueprint.route('/admin/events', methods=['POST'])
@Security.validator(['name|required'])
@Auth.has_permission('admin')
def create_event():
    return event_controller.create_event()


@event_blueprint.route('/admin/events/<int:event_id>',
                       methods=['PUT', 'PATCH'])
@Auth.has_permission('admin')
def update_event(event_id):
    return event_controller.update_event(event_id)


@event_blueprint.route('/admin/events', methods=['GET'])
@Auth.has_permission('admin')
def admin_fetch_events():
    return event_controller.fetch_events(student=False)


@event_blueprint.route('/admin/events/<int:event_id>', methods=['GET'])