예제 #1
0
파일: mixins.py 프로젝트: ivyminaywa/movies
class PersonDocMixin(object):
	# Birth Certificate
	bc_id = Column(String(20), index=True, nullable=True)
	bc_number = Column(String(20), index=True)
	bc_serial = Column(String(20), index=True)
	bc_place = Column(String(20), index=True)
	bc_scan = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	
	# NationalID
	citizenship = Column(String(20), default='Kenyan')
	nat_id_num = Column(String(15), index=True)
	nat_id_serial = Column(String(30), index=True)
	nat_id_scan = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	
	# Passport
	pp_no = Column(String(20), index=True)
	pp_issue_date = Column(Date)
	pp_issue_place = Column(String(40))
	pp_scan = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	pp_expiry_date = Column(Date)
	
	# Next of Kin
	kin1_name = Column(String(100))
	kin1_relation = Column(String(100))
	kin1_phone = Column(String(50))
	kin1_email = Column(String(125))
	kin1_addr = Column(Text)
	
	kin2_name = Column(String(100))
	kin1_relation = Column(String(100))
	kin2_phone = Column(String(50))
	kin2_email = Column(String(125))
	kin2_addr = Column(Text)
예제 #2
0
파일: photo.py 프로젝트: raynardj/wedding
class photoModel(Model, AuditMixin):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Text(), unique=True, nullable=False)
    photo = db.Column(
        ImageColumn(size=(1000, 1000, False),
                    thumbnail_size=(100, 100, False)))
    remark = db.Column(db.Text())

    def photo_img(self):
        im = ImageManager()
        if self.photo:
            return Markup('<a href="' + url_for('photoView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url(self.photo) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('photoView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

    def photo_img_thumbnail(self):
        im = ImageManager()
        if self.photo:
            return Markup('<a href="' + url_for('photoView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url_thumbnail(self.photo) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('photoView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')
예제 #3
0
class Property(Model):
	id = Column(Integer, primary_key=True)
	name = Column(String(500), unique=True, nullable=False)
	popularity = Column(String(500))
	district = Column(String(500))
	address = Column(String(500))
	region = Column(String(500))
	area = Column(String(500))
	price = Column(String(500))
	unit = Column(String(500))
	availability = Column(String(500))
	photo = Column(ImageColumn(size=(300, 300, True), thumbnail_size=(30, 30, True)))

	def photo_img(self):
		im = ImageManager()
		if self.photo:
			return Markup('<a href="' + url_for('PropertyModelView.show', pk=str(self.id)) +
			              '" class="thumbnail"><img src="' + im.get_url(self.photo) +
			              '" alt="Photo" class="img-rounded img-responsive"></a>')
		else:
			return Markup('<a href="' + url_for('PropertyModelView.show', pk=str(self.id)) +
			              '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

	def photo_img_thumbnail(self):
		im = ImageManager()
		if self.photo:
			return Markup('<a href="' + url_for('PropertyModelView.show', pk=str(self.id)) +
			              '" class="thumbnail"><img src="' + im.get_url_thumbnail(self.photo) +
			              '" alt="Photo" class="img-rounded img-responsive"></a>')
		else:
			return Markup('<a href="' + url_for('PropertyModelView.show', pk=str(self.id)) +
			              '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

	def __repr__(self):
		return self.name
예제 #4
0
class PredictImage(Model):
    __tablename__ = "predict_images"

    id = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String(100), nullable=False)
    image = Column(ImageColumn(size=(300, 300, True), thumbnail_size=(30, 30, True)))

    def __repr__(self):
        return self.name

    def image_name(self):
        return get_file_original_name(str(self.image))

    def photo_img(self):
        im = ImageManager()
        if self.image:
            return Markup('<a href="' + url_for('PredictImageModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url(self.image) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('PredictImageModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

    def photo_img_thumbnail(self):
        im = ImageManager()
        if self.image:
            return Markup('<a href="' + url_for('PredictImageModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url_thumbnail(self.image) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('PredictImageModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')
class Person(Model):
    id = Column(Integer, primary_key=True)
    name = Column(String(150), unique=True, nullable=False)
    photo = Column(
        ImageColumn(size=(300, 300, True), thumbnail_size=(30, 30, True)))

    def photo_img(self):
        im = ImageManager()
        if self.photo:
            return Markup('<a href="' + url_for('PersonModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url(self.photo) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('PersonModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

    def photo_img_thumbnail(self):
        im = ImageManager()
        if self.photo:
            return Markup('<a href="' + url_for('PersonModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url_thumbnail(self.photo) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('PersonModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')
예제 #6
0
class Employee(Model):
    id = Column(Integer, primary_key=True)
    full_name = Column(String(150), nullable=False)
    photo = Column(ImageColumn(thumbnail_size=(30, 30, True), size=(300, 300, True)))
    address = Column(Text(250), nullable=False)
    bank_number = Column(Integer, nullable=False)
    birthday = Column(Date, nullable=True)
    personal_phone = Column(String(20))
    department_id = Column(Integer, ForeignKey('department.id'), nullable=False)
    department = relationship("Department")
    function_id = Column(Integer, ForeignKey('function.id'), nullable=False)
    function = relationship("Function")
    gender_id = Column(Integer, ForeignKey('gender.id'), nullable=False)
    gender = relationship("Gender")
    photo = Column(ImageColumn(size=(300, 300, True), thumbnail_size=(30, 30, True)))
    begin_date = Column(Date, default=datetime.date.today(), nullable=True)

    def photo_img(self):
        im = ImageManager()
        if self.photo:
            return Markup('<a href="' + url_for('EmployeeModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url(self.photo) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('EmployeeModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

    def photo_img_thumbnail(self):
        im = ImageManager()
        if self.photo:
            return Markup('<a href="' + url_for('EmployeeModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url_thumbnail(self.photo) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('EmployeeModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

    def __repr__(self):
        return self.full_name

    def month_year(self):
        date = self.birthday or mindate
        return datetime.datetime(date.year, date.month, 1) or mindate

    def year(self):
        date = self.birthday or mindate
        return datetime.datetime(date.year, 1, 1)    
예제 #7
0
class VendorSites(Model):
    id = Column(Integer, primary_key=True)
    vendor_site_name = Column(String(150), nullable=False)
    vendor_site_image = Column(
        ImageColumn(size=(300, 300, True), thumbnail_size=(30, 30, True)))
    vendor_site_address = Column(String(500), default='Street', nullable=False)
    vendor_site_latitude = Column(Float, nullable=False)
    vendor_site_longitude = Column(Float, nullable=False)
    vendor_site_email = Column(String(150))
    vendor_site_telephone_number = Column(String(15))
    vendor_site_unique_website = Column(String(150))
    vendor_site_unique_description = Column(String(500))
    vendor_site_vendor_group_id = Column(Integer,
                                         ForeignKey('vendor_group.id'),
                                         nullable=False)
    vendor_site_vendor_group = relationship("VendorGroup")
    vendor_site_vendor_id = Column(Integer,
                                   ForeignKey('vendors.id'),
                                   nullable=False)
    vendor_site_vendor = relationship("Vendors")

    def __repr__(self):
        return self.vendor_site_name

    def vendor_img(self):
        im = ImageManager()
        if self.vendor_site_image:
            return Markup(
                '<a href="' +
                url_for('VendorSitesModelView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="' +
                im.get_url(self.vendor_site_image) +
                '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup(
                '<a href="' +
                url_for('VendorSitesModelView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>'
            )

    def vendor_img_thumbnail(self):
        im = ImageManager()
        if self.vendor_site_image:
            return Markup(
                '<a href="' +
                url_for('VendorSitesModelView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="' +
                im.get_url_thumbnail(self.vendor_site_image) +
                '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup(
                '<a href="' +
                url_for('VendorSitesModelView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>'
            )
예제 #8
0
class PersonDocMixin(object):
	# Birth Certificate
	bc_id = Column(String(20), index=True, unique=True, nullable=True)
	bc_number = Column(String(20), index=True)
	bc_serial = Column(String(20), index=True)
	bc_place = Column(String(20), index=True)
	bc_scan = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	
	# NationalID
	citizenship = Column(String(20), default='Kenyan')
	nat_id_num = Column(String(15), index=True, unique=True)
	nat_id_serial = Column(String(30), index=True)
	nat_id_scan = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	
	# Passport
	pp_no = Column(String(20), index=True)
	pp_issue_date = Column(Date)
	pp_issue_place = Column(String(40))
	pp_scan = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	pp_expiry_date = Column(Date)
예제 #9
0
class Model1(Model):
    id = Column(Integer, primary_key=True)
    field_string = Column(String(50), unique=True, nullable=False)
    field_integer = Column(Integer())
    field_float = Column(Float())
    field_date = Column(Date())
    field_file = FileColumn()
    field_image = ImageColumn()

    def __repr__(self):
        return str(self.field_string)
예제 #10
0
class Picture(db.Model):
    id = Column(Integer, primary_key=True)
    person_id = Column(Integer, ForeignKey('person.id'), nullable=False)
    person = relationship(Person, backref='pictures')
    validated = Column(Boolean)
    picture = Column(ImageColumn(size=(2048, 2048, False),
                                 thumbnail_size=(800, 800, True)),
                     nullable=False)

    def __repr__(self):
        return self.picture
예제 #11
0
class Product(db.Model):
    id = Column(Integer, primary_key=True, unique=True)
    name = Column(String(120), index=True)
    desc = Column(String(120), index=True)
    thumbnail = Column(
        ImageColumn(size=(300, 300, True), thumbnail_size=(30, 30, True)))
    price = Column(Float, index=True)
    discount = Column(Integer, index=True)
    tag = Column(String(10), index=True)
    created_at = Column(DateTime)
    sold = Column(Integer, index=True)
예제 #12
0
class Teams(Model):
    id = Column(Integer, primary_key=True)
    name = Column(String(30), nullable=False)
    flag = Column(
        ImageColumn(size=(48, 48, True), thumbnail_size=(30, 30, True)))
    groups_id = Column(Integer, ForeignKey('groups.id'), nullable=False)
    groups = relationship("Groups")

    @renders('flag')
    def flg_img(self):
        clean = self.flag.replace(' ', '%20')
        return Markup('<img src=/static/flags/' + clean + ' >')

    def __repr__(self):
        return self.name
예제 #13
0
class Person(Model):
    id = Column(Integer, primary_key=True)
    name = Column(String(150), unique=True, nullable=False)
    address = Column(String(564))
    birthday = Column(Date)
    photo = Column(
        ImageColumn(thumbnail_size=(30, 30, True), size=(300, 300, True)))
    personal_phone = Column(String(20))
    personal_celphone = Column(String(20))
    personal_email = Column(String(64))
    notes = Column(Text())
    business_function = Column(String(64))
    business_phone = Column(String(20))
    business_celphone = Column(String(20))
    business_email = Column(String(64))
    person_group_id = Column(Integer, ForeignKey("person_group.id"))
    person_group = relationship("PersonGroup")

    def photo_img(self):
        im = ImageManager()
        if self.photo:
            return Markup(
                '<a href="' +
                url_for("PersonModelView.show", pk=str(self.id)) +
                '" class="thumbnail"><img src="' + im.get_url(self.photo) +
                '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup(
                '<a href="' +
                url_for("PersonModelView.show", pk=str(self.id)) +
                '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive">'
                '</a>')

    def photo_img_thumbnail(self):
        im = ImageManager()
        if self.photo:
            return Markup(
                '<a href="' +
                url_for("PersonModelView.show", pk=str(self.id)) +
                '" class="thumbnail"><img src="' +
                im.get_url_thumbnail(self.photo) +
                '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup(
                '<a href="' +
                url_for("PersonModelView.show", pk=str(self.id)) +
                '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive">'
                '</a>')
예제 #14
0
파일: models.py 프로젝트: saiaaaaaa/fyp
class Item(Model):
    id = Column(Integer, primary_key=True)
    name = Column(String(50), unique=True, nullable=False)
    price = Column(Float, nullable=False)
    photo = Column(
        ImageColumn(size=(300, 300, True), thumbnail_size=(30, 30, True)))

    brand_id = Column(Integer, ForeignKey("brand.id"), nullable=False)
    brand = relationship("Brand", foreign_keys=[brand_id])
    category_id = Column(Integer, ForeignKey("category.id"), nullable=False)
    category = relationship("Category", foreign_keys=[category_id])
    origin_id = Column(Integer, ForeignKey("origin.id"), nullable=False)
    origin = relationship("Origin", foreign_keys=[origin_id])

    def photo_imgage(self):
        im = ImageManager()
        if self.photo:
            return Markup(
                '<a href="' +
                url_for('PersonModelView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="' + im.get_url(self.photo) +
                '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup(
                '<a href="' +
                url_for('PersonModelView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>'
            )

    def photo_thumbnail(self):
        im = ImageManager()
        if self.photo:
            return Markup(
                '<a href="' +
                url_for('PersonModelView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="' +
                im.get_url_thumbnail(self.photo) +
                '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup(
                '<a href="' +
                url_for('PersonModelView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>'
            )

    def __repr__(self):
        return self.name + " ($" + str(self.price) + ")"
예제 #15
0
파일: models.py 프로젝트: alxbetz/celltoxdb
class Estimated(Model):
    __tablename__ = 'estimated'
    exposure_id = Column(Integer, ForeignKey('exposure.id'), primary_key=True)
    ec50 = Column(Float)
    ec50_ci_upper = Column(Float)
    ec50_ci_lower = Column(Float)
    ec10 = Column(Float)
    ec10_ci_upper = Column(Float)
    ec10_ci_lower = Column(Float)
    ntc = Column(Float)
    slope = Column(Float)
    confidence_level = Column(Float)
    exceeds_direction = Column(String(10))
    exceeds_value = Column(Float)
    plot_png = Column(
        ImageColumn(size=(600, 600, True), thumbnail_size=(60, 60, True)))
    r_data = Column(LargeBinary)
    plot_data = Column(LargeBinary)
    exposure = relationship(Exposure,
                            back_populates="estimated",
                            cascade="all, delete")

    @renders('ec50')
    def ec50_format(self):

        if not self.ec50:
            if self.exceeds_direction:
                precision = get_float_prec(self.exceeds_value)
                if self.exceeds_direction == "greater":
                    return "> " + format_helper(self.exceeds_value, precision)
                else:
                    return "< " + format_helper(self.exceeds_value, precision)
            else:
                return ""

        precision = get_float_prec(self.ec50)
        return Markup("<b>"+ format_helper(self.ec50,precision) + "</b>" +\
                      ' (' + format_helper(self.ec50_ci_lower,precision) + \
                      '-' + format_helper(self.ec50_ci_upper,precision) +
                      ')')

    def dr_img(self):

        im = ImageManager()
        if self.plot_png:
            return Markup('<img src="' + im.get_url(self.plot_png) +\
              '" alt="Dose response plot" >')
예제 #16
0
class Media(Model):
    id = Column(Integer, primary_key=True)
    name = Column(String(50), unique=True, nullable=True)
    # path = Column(String(250), unique=True, nullable=True)
    photo = Column(
        ImageColumn(thumbnail_size=(30, 30, True), size=(300, 300, True)))
    # posted = Column(Date, default=today, nullable=False)
    news = relationship("News")
    news_id = Column(Integer, ForeignKey('news.id'), nullable=True)
    activities = relationship("Activity")
    activities_id = Column(Integer, ForeignKey('activity.id'), nullable=True)
    messages = relationship("Message")
    messages_id = Column(Integer, ForeignKey('message.id'), nullable=True)
    blocks = relationship("Pageblock")
    blocks_id = Column(Integer, ForeignKey('pageblock.id'), nullable=True)

    def photo_img(self):
        im = ImageManager()
        if self.name:
            return Markup(
                '<a href="' + url_for('MediaView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="' + im.get_url(self.photo) +
                '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup(
                '<a href="' + url_for('MediaView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>'
            )

    def photo_img_thumbnail(self):
        im = ImageManager()
        if self.name:
            return Markup(
                '<a href="' + url_for('MediaView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="' +
                im.get_url_thumbnail(self.photo) +
                '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup(
                '<a href="' + url_for('MediaView.show', pk=str(self.id)) +
                '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>'
            )

    def __repr__(self):
        return self.name
예제 #17
0
class Person(Model):
    id = Column(Integer, primary_key=True)
    name = Column(String(150), unique=True, nullable=False)
    address = Column(String(564))
    birthday = Column(Date)
    photo = Column(
        ImageColumn(thumbnail_size=(30, 30, True), size=(300, 300, True)))
    personal_phone = Column(String(20))
    personal_email = Column(String(64))
    notes = Column(Text())
    business_function = Column(String(64))
    business_email = Column(String(64))
    person_group_id = Column(Integer, ForeignKey('person_group.id'))
    person_group = relationship("PersonGroup")

    def __repr__(self):
        return self.name

    def month_year(self):
        date = self.birthday or mindate
        return datetime.datetime(date.year, date.month, 1) or mindate

    def year(self):
        date = self.birthday or mindate
        return datetime.datetime(date.year, 1, 1)

    def photo_img(self):
        im = ImageManager()
        if self.photo:
            return Markup('<a href="' + url_for('PersonModelView.show',pk=str(self.id)) +\
                          '" class="thumbnail"><img src="' + im.get_url(self.photo) +\
                          '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="'+ url_for('PersonModelView.show',pk=str(self.id)) +\
                          '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

    def photo_img_thumbnail(self):
        im = ImageManager()
        if self.photo:
            return Markup('<a href="' + url_for('PersonModelView.show',pk=str(self.id)) +\
                          '" class="thumbnail"><img src="' + im.get_url_thumbnail(self.photo) +\
                          '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="'+ url_for('PersonModelView.show',pk=str(self.id)) +\
                          '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')
예제 #18
0
class EmpresaDatos(Model):
    """
    # creo clase que sera mapeada como la tabla datosEmpresa
    """
    __tablename__ = 'datosEmpresa'
    id = Column(Integer, primary_key=True)
    compania = Column(String(50), unique=True)
    direccion = Column(String(255), unique=True)
    cuit = Column(String(30), unique=True, nullable=True)
    logo = Column(
        ImageColumn(size=(300, 300, True), thumbnail_size=(30, 30, True)))
    tipoClave_id = Column(Integer,
                          ForeignKey('tiposClave.id'),
                          nullable=False,
                          default=3)
    tipoClave = relationship("TipoClaves")
    idlocalidad = Column(Integer,
                         ForeignKey('localidad.idlocalidad'),
                         nullable=True)
    localidad = relationship("Localidad")
    __table_args__ = (UniqueConstraint("compania", "direccion"), )

    def __repr__(self):
        return f'{self.compania}'

    def photo_img(self):
        im = ImageManager()
        if self.logo:
            return Markup('<a href="' + url_for('Empresaview.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url(self.logo) +\
              '" alt="logo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('Empresaview.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="logo" class="img-responsive"></a>')

    def photo_img_thumbnail(self):
        im = ImageManager()
        if self.logo:
            return Markup('<a href="' + url_for('Empresaview.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url_thumbnail(self.logo) +\
              '" alt="logo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('Empresaview.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="logo" class="img-responsive"></a>')
예제 #19
0
class Products(Model):
    id = Column(Integer, primary_key=True)
    product_name = Column(String(150), unique=True, nullable=False)
    product_image = Column(ImageColumn(size=(300, 300, True),
                                       thumbnail_size=(30, 30, True)),
                           nullable=False)
    product_description = Column(String(500), nullable=False)
    product_price = Column(Float, nullable=False)
    product_group_id = Column(Integer,
                              ForeignKey('product_group.id'),
                              nullable=False)
    product_group = relationship("ProductGroup")
    product_sub_group_id = Column(Integer,
                                  ForeignKey('product_sub_group.id'),
                                  nullable=False)
    product_sub_group = relationship("ProductSubGroup")
    product_sub_sub_group_id = Column(Integer,
                                      ForeignKey('product_sub_sub_group.id'),
                                      nullable=False)
    product_sub_sub_group = relationship("ProductSubSubGroup")

    def __repr__(self):
        return self.product_name

    def product_img(self):
        im = ImageManager()
        if self.product_image:
            return Markup('<a href="' + url_for('ProductModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url(self.product_image) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('ProductModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

    def product_img_thumbnail(self):
        im = ImageManager()
        if self.product_image:
            return Markup('<a href="' + url_for('ProductModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url_thumbnail(self.product_image) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('ProductModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')
예제 #20
0
class Movie(Model):
    id = Column(Integer, primary_key=True)
    photo = Column(
        ImageColumn(size=(500, 500, True), thumbnail_size=(30, 30, True)))
    name = Column(String(150), unique=True, nullable=False)
    Type = Column(String(100), nullable=False)
    rating = Column(String(10))
    opening = Column(Date)
    time = Column(String(20))
    subtitle = Column(String(100))
    synopsis = Column(Text())
    cinema = Column(String(200))
    Director = Column(String(30))
    Cast = Column(String(300))
    event_group_id = Column(Integer, ForeignKey("event_group.id"))
    event_group = relationship("EventGroup")

    def photo_img(self):
        im = ImageManager()
        if self.photo:
            return Markup('<a href="' + url_for('MovieModelView.show', pk=str(self.id)) + \
                          '" class="thumbnail"><img src="' + im.get_url(self.photo) + \
                          '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('MovieModelView.show', pk=str(self.id)) + \
                          '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

    def photo_img_thumbnail(self):
        im = ImageManager()
        if self.photo:
            return Markup('<a href="' + url_for('MovieModelView.show', pk=str(self.id)) + \
                          '" class="thumbnail"><img src="' + im.get_url_thumbnail(self.photo) + \
                          '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('MovieModelView.show', pk=str(self.id)) + \
                          '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

    def __repr__(self):
        return self.name
예제 #21
0
class Vendors(Model):
    id = Column(Integer, primary_key=True)
    vendor_name = Column(String(150))
    vendor_logo = Column(
        ImageColumn(size=(300, 300, True), thumbnail_size=(30, 30, True)))
    vendor_address = Column(String(500), default='Street', nullable=False)
    vendor_email = Column(String(150))
    vendor_telephone_number = Column(String(15))
    vendor_website = Column(String(150))
    vendor_description = Column(String(500))
    vendor_group_id = Column(Integer,
                             ForeignKey('vendor_group.id'),
                             nullable=False)
    vendor_group = relationship('VendorGroup')

    # vendor_group = relationship('VendorGroup', secondary=assoc_vendorgroup_vendors, backref='vendorgroup')

    def __repr__(self):
        return self.vendor_name

    def photo_img(self):
        im = ImageManager()
        if self.vendor_logo:
            return Markup('<a href="' + url_for('VendorModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url(self.vendor_logo) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('VendorModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')

    def photo_img_thumbnail(self):
        im = ImageManager()
        if self.vendor_logo:
            return Markup('<a href="' + url_for('VendorModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="' + im.get_url_thumbnail(self.vendor_logo) +\
              '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup('<a href="' + url_for('VendorModelView.show',pk=str(self.id)) +\
             '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')
예제 #22
0
class DocMixin(object):
    query_class = DocQuery
    mime_type = Column(String(60), default='application/pdf')
    doc = Column(
        ImageColumn(thumbnail_size=(30, 30, True), size=(300, 300, True)))
    doc_text = Column(Text)
    doc_binary = Column(FileColumn)
    doc_title = Column(String(200))
    subject = Column(String(100))
    author = Column(String(100))
    keywords = Column(String(200))
    comments = Column(Text)

    # Metadata
    doc_type = Column(String(5), default='pdf')
    char_count = Column(Integer)
    word_count = Column(Integer)
    lines = Column(Integer)
    paragraphs = Column(Integer)

    file_size_bytes = Column(Integer)
    producer_prog = Column(String(40))
    immutable = Column(Boolean, default=False)

    page_size = Column(String(40))
    page_count = Column(Integer)
    hashx = Column(String(40))

    # if is Audio
    audio_duration_secs = Column(Integer)
    audio_frame_rate = Column(Integer)
    audio_channels = Column(Integer)

    search_vector = Column(TSVectorType('doc_text', 'doc_title'))

    # Automatically updated hashx
    @observes('doc_text')
    def doc_text_observer(self, doc_text):
        self.hashx = hashlib.sha256(doc_text).hexdigest()
예제 #23
0
class DocMixin(object):
	mime_type = Column(String(60), default='application/pdf')
	doc = Column(ImageColumn(thumbnail_size=(30, 30, True), size=(300, 300, True)))
	doc_text = Column(Text)
	doc_binary = Column(FileColumn)
	doctitle = Column(String(200))
	subject = Column(String(100))
	author = Column(String(100))
	keywords = Column(String(200))
	comments = Column(Text)
	
	# Metadata
	doc_type = Column(String(5), default='pdf')
	char_count = Column(Integer)
	word_count = Column(Integer)
	lines = Column(Integer)
	paragraphs = Column(Integer)
	
	file_size_bytes = Column(Integer)
	producer_prog = Column(String(40))
	immutable = Column(Boolean, default = False)
	
	page_size = Column(String(40))
	page_count = Column(Integer)
	
	# if is Audio
	audio_duration_secs = Column(Integer)
	audio_frame_rate = Column(Integer)
	audio_channels = Column(Integer)
	
	# Hashes
	def _get_hash(self, data):
		return sha256(data).hexdigest()
	
	
	bin_hash = Column(String(20))
예제 #24
0
class BiometricMixin(object):
    # Biodata
    blood_group = Column(String(3))
    striking_features = Column(Text)
    height_m = Column(Float, nullable=True)
    weight_kg = Column(Float, nullable=True)
    eye_colour = Column(String(20))
    hair_colour = Column(String(20))
    complexion = Column(String(50))
    religion = Column(String(20))
    ethnicity = Column(String(40))

    # Biometrics
    fp_lthumb = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
    pgm = Column(BYTEA)
    wsq = Column(BYTEA)
    xyt = Column(BYTEA)
    fp_left2 = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
    fp_left3 = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
    fp_left4 = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
    fp_left5 = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
    fp_rthumb = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
    fp_right2 = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
    fp_right3 = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
    fp_right4 = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
    fp_right5 = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))

    palm_left = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
    palm_right = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))

    eye_left = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
    eye_right = Column(
        ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
예제 #25
0
class Doctor(Model):
    id = Column(Integer, primary_key=True)
    name = Column(String(150), unique=True, nullable=False)
    specialty = Column(String(564))
    street_address = Column(String(564))
    location = Column(String(564))
    MDL1_class = Column(Date)
    bio = Column(Text())
    photo = Column(
        ImageColumn(thumbnail_size=(120, 120, True), size=(600, 600, True)))
    personal_phone = Column(String(20))
    email = Column(String(64))
    publications = Column(Text())
    notes = Column(Text())
    work_phone = Column(String(20))

    def photo_img(self):
        im = ImageManager()
        if self.photo:
            return Markup(
                '<a href="' +
                url_for("DoctorModelView.show", pk=str(self.id)) +
                '" class="thumbnail"><img src="' + im.get_url(self.photo) +
                '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup(
                '<a href="' +
                url_for("DoctorModelView.show", pk=str(self.id)) +
                '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive">'
                '</a>')

    def photo_img_thumbnail(self):
        im = ImageManager()
        if self.photo:
            return Markup(
                '<a href="' +
                url_for("DoctorModelView.show", pk=str(self.id)) +
                '" class="thumbnail"><img src="' +
                im.get_url_thumbnail(self.photo) +
                '" alt="Photo" class="img-rounded img-responsive"></a>')
        else:
            return Markup(
                '<a href="' +
                url_for("DoctorModelView.show", pk=str(self.id)) +
                '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive">'
                '</a>')


# class Publication(Model):
#     id = Column(Integer, primary_key=True)
#     title = Column(String(150), unique=True, nullable=False)
#     journal = Column(String(564))
#     author_id = Column(Integer, ForeignKey('doctor.id'), nullable=False))
#     author = relationship("Author")
#     date = Column(Date)
#     url = Column(String(564))

#     @renders("url")
#     def render_url(self):
#         return Markup('<a href="' + url + '" target="_blank" >' + "Go to link" + "</a>")

#     def __repr__(self):
#         return self.name
예제 #26
0
class ProductImage(db.Model):
    product_id = Column(Integer, ForeignKey(Product.id), primary_key=True)
    product = relationship(Product)
    image = Column(
        ImageColumn(size=(300, 300, True), thumbnail_size=(30, 30, True)))
예제 #27
0
class WebMixin(object):
    # Where
    scheme = Column(String(10), default='http', nullable=False)
    domain = Column(String(300))
    web_netloc = Column(String(400))
    web_path = Column(String(1000))
    web_params = Column(String(1000))
    web_query = Column(String(1000))
    web_fragment = Column(String(1000))

    full_url = Column(String(1000))
    url = Column(
        String(1000), nullable=False
    )  # Use this to load the list of urls, we process url to get the other things
    canonical_link = Column(String(1000))
    link_hash = Column(String(128))  # So that we never re-crawl the link
    content_hash = Column(
        String(128))  # We dont want the same content over and over

    _salt = Column(String(12))

    @hybrid_property
    def salt(self):
        """Generates a cryptographically random salt and sets its Base64 encoded
		version to the salt column, and returns the encoded salt.
		"""
        if not self.id and not self._salt:
            self._salt = b64encode(os.urandom(8))

        return self._salt

    # What
    title = Column(String(300))
    description = Column(String(200))
    html = Column(Text)
    txt = Column(Text)
    summary = Column(Text, default='')
    # keywords = Column(String(500))
    asset = Column(
        ImageColumn(thumbnail_size=(30, 30, True), size=(300, 300, True)))
    lang = Column(String(20))
    tags = Column(String(500))
    word_count = Column(Integer)
    category_count = Column(Integer)
    article_count = Column(Integer)
    link_count = Column(Integer)  # Number of links on the page
    apparent_encoding = Column(String(15))

    # Who : Setup in the model
    author = Column(String(500))

    # When
    publish_date = Column(DateTime)
    download_date = Column(DateTime, default=func.now())
    edit_date = Column(DateTime, default=func.now())

    # Admin
    version = Column(String(20))
    is_downloaded = Column(Boolean, default=False)
    is_image = Column(Boolean, default=False)
    is_video = Column(Boolean, default=False)
    is_feed = Column(Boolean, default=False)
    is_text = Column(Boolean, default=False)
    has_risk_words = Column(Boolean)

    # Ranking
    of_interest = Column(Boolean, default=False)
    ranking = Column(Integer,
                     CheckConstraint('(ranking >= 0) and (ranking <=10)'))
    for_review = Column(Boolean, default=False)

    # Trinary Ranking
    is_positive = Column(Boolean, default=False)
    is_negative = Column(Boolean, default=False)
    is_neutral = Column(Boolean, default=True)
    iterations = Column(Integer, default=0)

    # Sentiment Analysis
    sentiment = Column(String(100))
    sentiment_colour = Column(String(50))

    # Proper Nouns
    noun_count = Column(Integer)
    nouns = Column(Text)
예제 #28
0
class PersonMixin(object):
    # prn_id = Column(Integer, index=True)
    # prn = Column(String(6), unique=True, index=True)
    id = Column(Integer, autoincrement=True, primary_key=True)
    firstname = Column(String(40), nullable=False, index=True)
    surname = Column(String(40), nullable=False, index=True)
    othernames = Column(String(40), nullable=True, index=True)
    dob = Column(Date, default=func.now())

    marital_status = Column(String(10))
    photo = Column(
        ImageColumn(thumbnail_size=(30, 30, True), size=(300, 300, True)))

    # @declared_attr
    # def age_today(self):
    # 	today = date.today()
    # 	born = self.dob
    # 	return today.year - born.year - ((today.month, today.day) < (born.month, born.day))

    age_today = Column(Integer)

    @hybrid_property
    def _age_today(self):
        """Property calculated from (current time - :attr:`User.date_of_birth` - leap days)"""
        if self.dob:
            today = (datetime.utcnow() + timedelta(hours=self.timezone)).date()
            birthday = self.dob
            if isinstance(birthday, datetime):
                birthday = birthday.date()
            age = today - (birthday or (today - timedelta(1)))
            self._age_today = (
                age.days - calendar.leapdays(birthday.year, today.year)) / 365
            return self._age_today
        return -1

    @declared_attr
    def age(self):
        if isinstance(self.dob, datetime):
            doby = self.dob.date()
        else:
            doby = mindate
        dur = humanize.naturaltime(datetime.now().date() - doby)
        return Markup('<span class="no-wrap">{}</span>'.format(dur))

    # @declared_attr
    @hybrid_property
    def dob_month_year(self):
        if isinstance(self.dob, datetime):
            doby = self.dob.date()
        else:
            doby = mindate
        return datetime(doby.year, doby.month, 1)

    def month_year(self):
        date = self.dob or mindate
        return datetime(date.year, date.month, 1) or mindate

    def year(self):
        date = self.dob or mindate
        return datetime(date.year, 1, 1)

    def ViewName(self):
        return self.__class__.__name__ + 'View.show'

    def __repr__(self):
        return '(' + str(self.id) + ') ' + self.firstname + ' ' + self.surname