organizations&organizationtypes
This commit is contained in:
34
organizationtypes/model.py
Normal file
34
organizationtypes/model.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, Text, ForeignKey, Index, TIMESTAMP
|
||||
from sqlalchemy.orm import relationship, validates
|
||||
|
||||
from datetime import datetime
|
||||
from src.database import Base,db_session
|
||||
from marshmallow import Schema, fields, post_load, ValidationError
|
||||
from src import clogger
|
||||
import json
|
||||
import flask
|
||||
from src.models import Section
|
||||
import re
|
||||
|
||||
def validate_image(k, img):
|
||||
return True
|
||||
class FullOrganizationtypeSchema(Schema):
|
||||
id = fields.Integer()
|
||||
name = fields.String()
|
||||
image = fields.String()
|
||||
updated_at = fields.DateTime()
|
||||
created_at = fields.DateTime()
|
||||
|
||||
class Organizationtype(Base):
|
||||
__tablename__ = 'organizationtypes'
|
||||
name=Column(String(250), unique=True, nullable=False)
|
||||
organizations=relationship("Organization", back_populates="organizationtype")
|
||||
image=Column(String(250))
|
||||
|
||||
__schema__= FullOrganizationtypeSchema
|
||||
__whiteattrs__= ["url", "name", "image"]
|
||||
__jsonattrs__=None # None means all
|
||||
|
||||
def __init__(self, data={}):
|
||||
self.update(data,False)
|
||||
|
||||
Reference in New Issue
Block a user