from flask import Blueprint, jsonify, render_template, abort, redirect, url_for, request organizationtype_pages = Blueprint('organizationtypes', __name__) #from .model import Organizationtype #, Organizationtypeschema #from .model import SectionSchema #from datetime import datetime #import json #from src import clogger from src.organizationtypes.controller import controller #from src.database import db_session, read_json #import flask @organizationtype_pages.route("/") @organizationtype_pages.route("") @organizationtype_pages.route(".json") def index(): organizationtypes=controller.get_all() return jsonify(organizationtypes=organizationtypes) @organizationtype_pages.route("/",methods=['GET']) @organizationtype_pages.route("/.json",methods=['GET']) def get(id): organizationtype=controller.get(id) return jsonify(organizationtype=organizationtype) @organizationtype_pages.route("/",methods=['GET']) @organizationtype_pages.route("/.json",methods=['GET']) def get_articles(id): articles=controller.get_articles(id) return jsonify(articles=articles) @organizationtype_pages.route("/",methods=['PUT']) @organizationtype_pages.route("/.json",methods=['PUT']) def update(id): o,errors=controller.update(id,request) return jsonify(organizationtype=o,errors=errors) @organizationtype_pages.route("/",methods=['POST']) @organizationtype_pages.route("",methods=['POST']) @organizationtype_pages.route(".json",methods=['POST']) def create(): organizationtype=controller.create(request) # a=read_json(request) # organizationtype=Organizationtype(a["organizationtype"]) # controller. # db_session.add(organizationtype) # db_session.commit() return jsonify(organizationtype=organizationtype)