Example #1
0
class TweetCommands(CRUDMixin, db.Model):
	__tablename__ = 'tweetcommands'
	id = db.Column(db.Integer, primary_key=True)
	created = db.Column(db.Integer)	
	updated = db.Column(db.Integer)
	user = db.Column(db.String(100))
	command = db.Column(db.String(100))
	url = db.Column(db.String(400))
	instance_id = db.Column(db.Integer, db.ForeignKey('instances.id'))
	state = db.Column(db.Integer)

	# relationships
	instance = db.relationship('Instances', foreign_keys='TweetCommands.instance_id')

	def __init__(
		self,
		created=None,
		updated=None,
		user=None,
		command=None,
		url=None,
		instance_id=None,
		state=None
	):
		self.created = created
		self.updated = updated
		self.user = user
		self.command = command
		self.url = url
		self.instance_id = instance_id
		self.state = state
Example #2
0
class AdminModel(db.Model):

    #nombre tabla
    __tablename__ = 'admin'

    #columns
    admin_id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(50), nullable=True)
    last_name = db.Column(db.String(50), nullable=True)
    email = db.Column(db.String(50), unique=True, nullable=False)
    encrypted_password = db.Column(db.String(200), nullable=False)
    created_at = db.Column(db.DateTime(),
                           nullable=False,
                           default=datetime.datetime.now)
    updated_at = db.Column(db.DateTime(),
                           nullable=False,
                           default=datetime.datetime.now)

    #init data
    def __init__(self, first_name, last_name, email, encrypted_password):

        #declare data
        self.first_name = first_name
        self.last_name = last_name
        self.email = email
        self.encrypted_password = self.create_password(encrypted_password)

    #Generate Hash password
    def create_password(self, encrypted_password):
        return generate_password_hash(encrypted_password)
Example #3
0
class Shortcode(db.Model):
    __tablename__ = 'shortcodes'

    id = db.Column(db.Integer, primary_key=True)
    shortcode = db.Column(db.String(6), nullable=False, unique=True)
    url = db.Column(db.String(2000), nullable=False)
    created = db.Column(db.DateTime,
                        nullable=False,
                        default=datetime.datetime.utcnow())
    last_redirect = db.Column(db.DateTime, nullable=True)
    redirect_count = db.Column(db.Integer, nullable=False, default=0)

    # Length for shortcode
    _SHORTCODE_LENGTH = 6

    @classmethod
    def is_valid(cls, code):
        """
        Checks whether :code is valid
        A valid :code has a length of 6 characters and
        contains only alphanumeric characters or underscores
        """
        return len(code) == cls._SHORTCODE_LENGTH and all(
            c.isalnum() or c == '_' for c in code)

    @classmethod
    def generate_code(cls):
        """
        Generates a new code with 6 characters composed by
        alphanumeric characters or underscores.
        """
        return ''.join(
            random.choices(string.ascii_letters + string.digits + '_',
                           k=cls._SHORTCODE_LENGTH))
Example #4
0
class Entidade(db.Model):
    __tablename__ = 'entidades'

    entidade_id = db.Column(db.Integer, primary_key=True)
    nome = db.Column(db.String(), nullable=False)
    tipo_pessoa = db.Column(db.Enum(TipoPessoa))
    url_entidade = db.Column(db.String())
    descricao = db.Column(db.String())

    def __init__(self, nome, tipo_pessoa, url_entidade, descricao):
        self.nome = nome
        self.tipo_pessoa = tipo_pessoa
        self.url_entidade = url_entidade
        self.descricao = descricao

    def __repr__(self):
        return '<Entidade: %r>' % self.nome

    def serialize(self):
        tipo_p = None
        if self.tipo_pessoa:
            tipo_p = self.tipo_pessoa.value
        return {
            'entidade_id': self.entidade_id,
            'nome': self.nome,
            'tipo_pessoa': tipo_p,
            'url_entidade': self.url_entidade,
            'descricao': self.descricao
        }
Example #5
0
class Localizacao(db.Model):
    __tablename__ = 'localizacoes'

    localizacao_id = db.Column(db.Integer, primary_key=True)
    acao_id = db.Column(db.Integer,
                        db.ForeignKey('acoes.acao_id'),
                        nullable=False)
    endereco = db.Column(db.String())
    latitude = db.Column(db.String())
    longitude = db.Column(db.String())
    horario = db.Column(db.String())
    obs = db.Column(db.String())

    def __init__(self, acao_id, endereco, latitude, longitude, horario, obs):
        self.acao_id = acao_id
        self.endereco = endereco
        self.latitude = latitude
        self.longitude = longitude
        self.horario = horario
        self.obs = obs

    def __repr__(self):
        return '<Localizacao: %r>' % self.endereco

    def serialize(self):
        return {
            'localizacao_id': self.localizacao_id,
            'acao_id': self.acao_id,
            'endereco': self.endereco,
            'latitude': self.latitude,
            'longitude': self.longitude,
            'horario': self.horario,
            'obs': self.obs
        }
class Studentdetail(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer,
                        db.ForeignKey('user.id'),
                        nullable=False,
                        unique=True)
    name_surname = db.Column(db.String(150), nullable=False)
    description = db.Column(db.String(800))
    university = db.Column(db.String(120), nullable=False)
    class_level = db.Column(db.Integer, nullable=False)
    gpa = db.Column(db.Float, nullable=False)
    active = db.Column(db.Boolean, nullable=False, default=True)
    github = db.Column(db.String(180))
    linkedin = db.Column(db.String(180))
    img = db.Column(db.Text, nullable=True)
    imgname = db.Column(db.Text, nullable=True)
    mimetype = db.Column(db.Text, nullable=True)
    advertisements = db.relationship('Advertisement',
                                     secondary=advertisement_studentdetail,
                                     lazy='subquery',
                                     backref=db.backref('studentdetails',
                                                        lazy=True))
    keywords = db.relationship('Keyword',
                               secondary=studentdetail_keyword,
                               lazy='subquery',
                               backref=db.backref('studentdetails', lazy=True))

    def __repr__(self):
        return f"Studentdetail('{self.id}', '{self.name_surname}', '{self.university}')"
Example #7
0
class Service(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    address = db.Column(db.String(100), index=True)
    name = db.Column(db.String(80), index=True)
    time_of_last_change_of_state = db.Column(db.DateTime())
    previous_state = db.Column(db.Integer, index=True)
    current_state = db.Column(db.Integer, index=True)
    time_of_added = db.Column(db.DateTime())
    organization_id = db.Column(db.Integer, db.ForeignKey('organization.id'))
    service_repairer_id = db.Column(db.Integer,
                                    db.ForeignKey('user.id'),
                                    nullable=True)
    users = db.relationship("Subscription", back_populates="service")

    def __init__(self, address, name, time_of_added, organization_id):
        self.address = address
        self.name = name
        self.time_of_added = time_of_added
        self.organization_id = organization_id
        self.previous_state = ServiceState.unspecified
        self.current_state = ServiceState.unspecified

    def dump(self):
        return {
            "service": {
                'id': self.id,
                'address': self.address,
                'name': self.name,
                'organization_id': self.organization_id
            }
        }
Example #8
0
class User(db.Model):
    __tablename__ = 'user'

    id = db.Column(db.Integer, primary_key=True)
    _username = db.Column(db.String(32), index=True)
    _password_hash = db.Column(db.String(128))
    _email = db.Column(db.String(120), index=True, unique=True)

    dogs = db.relationship('Dog', back_populates='user')

    @property
    def is_authenticated(self):
        return True

    @property
    def is_active(self):
        return True

    @property
    def is_anonymous(self):
        return False

    def get_id(self):
        try:
            return unicode(self.id)
        except NameError:
            return str(self.id)

    def __init__(self, username, password_hash, email):
        self._username = username
        self._password_hash = password_hash
        self._email = email
Example #9
0
class Todo(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80), unique=False, nullable=False)
    detail = db.Column(db.String(120), unique=False, nullable=False)

    def __repr__(self):
        return '<Todo %r>' % self.title
Example #10
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    login = db.Column(db.String(120))
    password = db.Column(db.String(64))

    def __init__(self, *args, **kwargs):
        super(User, self).__init__(*args, **kwargs)
        self.password = generate_password_hash(self.password)

    # Flask-Login integration
    def is_authenticated(self):
        return True

    def is_anonymous(self):
        return False

    def is_active(self):
        return True

    def get_id(self):
        return self.id

    # Required for administrative interface
    def __unicode__(self):
        return self.login

    def __repr__(self):
        return '<User for {0}>'.format(self.login)
Example #11
0
class author_table(db.Model):
    author_id = db.Column(db.Integer, primary_key=True)
    author_firstname = db.Column(db.String(255))
    author_lastname = db.Column(db.String(255))

    def __repr__(self):
        return '<Author FirstName: {} \n Author Lastname: {}'.format(self.author_firstname, self.author_lastname)
Example #12
0
class Targets_done(db.Model):
    __tablename__ = 'targets_done'

    id = db.Column(db.Integer, primary_key=True)
    source_id = db.Column(db.Integer, db.ForeignKey('source.id'))
    target_url = db.Column(db.String(100), index=True)
    target_abonnenten = db.Column(db.Integer)
    target_abonniert = db.Column(db.Integer)
    match = db.Column(db.String(10))
    datum_bearbeitet = db.Column(db.DateTime, default=datetime.utcnow)
    pics_liked = db.Column(db.Integer)
    followed = db.Column(db.DateTime)
    unfollowed = db.Column(db.DateTime)
    followed_back = db.Column(db.DateTime)
    t5_indicator = db.Column(db.String(3))
    t1_indicator = db.Column(db.String(3))
    t5_timestamp = db.Column(db.DateTime)
    t1_timestamp = db.Column(db.DateTime)

    def __init__(self, target_url, target_abonnenten, target_abonniert,
                 source_id):
        self.target_url = target_url
        self.target_abonnenten = target_abonnenten
        self.target_abonniert = target_abonniert
        self.source_id = source_id

    def __repr__(self):
        return f"Target-URL: {self.target_url} bearbeitet am {self.datum_bearbeitet}, Anzahl Abonnenten: {self.target_abonnenten}, Anzahl Abonniert: {self.target_abonniert}"
Example #13
0
class Trip(db.Model):
    trip_id = db.Column(db.Integer, primary_key=True)
    starttime = db.Column(db.DateTime, nullable=True, default="")
    stoptime = db.Column(db.DateTime, nullable=True, default="")
    bikeid = db.Column(db.Integer, nullable=True, default="")
    from_station_id = db.Column(db.Integer, nullable=True, default="")
    to_station_id = db.Column(db.Integer, nullable=True, default="")
    to_station_name = db.Column(db.String(150), nullable=True, default="")
    usertype = db.Column(db.String(100), nullable=True, default="Customer")
    gender = db.Column(db.String(30), nullable=True, default="")
    birthday = db.Column(db.String(12), nullable=True, default="")
    trip_duration = db.Column(db.Integer, nullable=True, default="")

    def __init__(self, trip_id, starttime, stoptime, bikeid, from_station_id,
                 to_station_id, to_station_name, usertype, gender, birthday,
                 trip_duration):
        self.trip_id = trip_id
        self.starttime = starttime
        self.stoptime = stoptime
        self.bikeid = bikeid
        self.from_station_id = from_station_id
        self.to_station_id = to_station_id
        self.to_station_name = to_station_name
        self.usertype = usertype
        self.gender = gender
        self.birthday = birthday
        self.trip_duration = trip_id
Example #14
0
class User(db.Model):

    __tablename__ = "users"

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    email = db.Column(db.String(255), unique=True, nullable=False)
    password = db.Column(db.String(255), nullable=False)
    registered_on = db.Column(db.DateTime, nullable=False)
    admin = db.Column(db.Boolean, nullable=False, default=False)

    def __init__(self, email, password, admin=False):
        self.email = email
        self.password = bcrypt.generate_password_hash(
            password,
            current_app.config.get("BCRYPT_LOG_ROUNDS")).decode("utf-8")
        self.registered_on = datetime.datetime.now()
        self.admin = admin

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self.id

    def __repr__(self):
        return "<User {0}>".format(self.email)
Example #15
0
class Comptes(db.Model):
    id_compte = db.Column(db.String(50), primary_key=True)
    id_client = db.Column(db.String(50), db.ForeignKey('client.username'))
    type_compte = db.Column(db.Enum(TypeCompte))
    rib = db.Column(db.String(50))
    solde = db.Column(db.Float(20))
    date_creation = db.Column(db.Date)

    @classmethod
    def creation_compteban(cls, id_client):
        client = User.query.get(id_client)
        if client is not None:
            this_comtpe = Comptes(
                id_compte=(random.randint(1000000000, 9999999999)),
                type_compte='COURANT',
                date_creation=str(date.today()),
                rib=str(random.randint(1000000000, 9999999999)),
                solde=0.0,
                id_client=id_client)
            User.populate(this_comtpe)
        else:
            flash(_l("Insertion Problem"))

    def solvabilite(self, valeur_virement=0):
        return self.sode >= valeur_virement
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    pin = db.Column(db.String(4), unique=False, nullable=False)
    is_admin = db.Column(db.Boolean(), unique=False, default=False)
    date_created = db.Column(db.DateTime,
                             unique=False,
                             default=datetime.utcnow)
    prediction = db.relationship('Prediction',
                                 cascade="all,delete",
                                 backref='parent')

    def __init__(self, username):
        self.username = username
        self.pin = self.create_pin()
        self.is_admin = self.admin_status()

    def create_pin(self):
        if self.username == 'admin':
            return Config.ADMIN_PIN
        else:
            return ''.join([str(random.randint(0, 9)) for _ in range(4)])

    def admin_status(self):
        if self.username == 'admin':
            return True
        else:
            False

    def __repr__(self):
        return f'<User({self.id}, {self.pin}, {self.is_admin})>'
class Advertisement(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    companydetail_id = db.Column(db.Integer,
                                 db.ForeignKey('companydetail.id'),
                                 nullable=False)
    date_posted = db.Column(db.Date, nullable=False, default=date.today())
    deadline = db.Column(db.Date,
                         nullable=False,
                         default=date.today() + relativedelta(months=+1))
    title = db.Column(db.String(120), nullable=False)
    description = db.Column(db.String(800), nullable=False)
    keywords = db.relationship('Keyword',
                               secondary=advertisement_keyword,
                               lazy='subquery',
                               backref=db.backref('advertisements', lazy=True))

    users = db.relationship('User',
                            secondary=advertisement_users,
                            lazy='subquery',
                            backref=db.backref('advertisements', lazy=True))

    responses = db.relationship('Response', backref='advertisement')

    def __repr__(self):  #alihan
        return f"Advertisement('{self.id}', '{self.title}')"
Example #18
0
class Comptes(db.Model):
    id_compte = db.Column(db.String(50), primary_key=True)
    # id_client = db.Column(db.String(50), db.ForeignKey('client.username'))
    type_compte = db.Column(db.Enum(TypeCompte))
    rib = db.Column(db.String(50))
    solde = db.Column(db.Float(20))
    date_creation = db.Column(db.Date)
Example #19
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(15), index=True)
    surname = db.Column(db.String(40), index=True)
    email = db.Column(db.String(80), index=True)
    password = db.Column(db.String(100), index=True)
    fcm_token = db.Column(db.String(200), index=True)
    organizations = db.relationship("User_Organization_mapping",
                                    back_populates="user")
    services = db.relationship("Subscription", back_populates="user")
    in_repairing = db.relationship("Service")

    def __init__(self, name, surname, email, password):
        self.name = name
        self.surname = surname
        self.email = email
        self.password = password

    def __repr__(self):
        return 'Name: {0} \nSurname: {1} \nE-mail: {2}'.format(
            self.name, self.surname, self.email)

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return unicode(self.id)
Example #20
0
class SharingStation(db.Model):
    __tablename__ = 'sharing_station'
    id = db.Column(db.Integer(), primary_key=True)

    created = db.Column(db.DateTime())
    updated = db.Column(db.DateTime())
    active = db.Column(db.Integer())

    name = db.Column(db.String(255))
    slug = db.Column(db.String(255))
    external_id = db.Column(db.String(255))

    vehicle_free = db.Column(db.Integer())
    vehicle_all = db.Column(db.Integer())
    station_type = db.Column(
        db.Integer()
    )  # 1 Fahrrad 2 Lastenrad 3 Fahrradanhänger 4 PKW 5 Transporter 6 Fahrradbox

    lat = db.Column(db.Numeric(precision=10, scale=7))
    lon = db.Column(db.Numeric(precision=10, scale=7))

    vehicle = db.relationship("Vehicle",
                              backref="SharingStation",
                              lazy='dynamic')

    sharing_provider_id = db.Column(db.Integer,
                                    db.ForeignKey('sharing_provider.id'))

    def __init__(self):
        pass

    def __repr__(self):
        return '<Region %r>' % self.name
Example #21
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    image_file = db.Column(db.String(20),
                           nullable=False,
                           default='default.jpg')
    password = db.Column(db.String(60), nullable=False)
    posts = db.relationship('Post', backref='author', lazy=True)

    def get_reset_token(self, expires_sec=1800):
        s = Serializer(current_app.config['SECRET_KEY'], expires_sec)
        return s.dumps({'user_id': self.id}).decode('utf-8')

    @staticmethod
    def verify_reset_token(token):
        s = Serializer(current_app.config['SECRET_KEY'])
        try:
            user_id = s.loads(token)['user_id']
        except:
            return None
        return User.query.get(user_id)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.image_file}')"
Example #22
0
class TrafficItem(db.Model):
  __tablename__ = 'traffic_item'
  id = db.Column(db.Integer(), primary_key=True)
  
  created = db.Column(db.DateTime())
  updated = db.Column(db.DateTime())
  active = db.Column(db.Integer())
  
  name = db.Column(db.String(255))
  slug = db.Column(db.String(255))
  external_id = db.Column(db.String(255))
  
  item_type = db.Column(db.Integer()) # 1 Baustelle 2 Auto-Parkplatz 3 Fahrrad-Ständer 4 Verkehrszählung 5 Sperranhänger
  raw_status = db.Column(db.Integer()) # 1 komplett roh, 2 verarbeitet
  is_meta = db.Column(db.Integer())
  
  zoom_from = db.Column(db.Integer())
  zoom_till = db.Column(db.Integer())
  
  lat = db.Column(db.Numeric(precision=10,scale=7))
  lon = db.Column(db.Numeric(precision=10,scale=7))
  
  area = db.Column(db.Text())
  
  traffic_item_provider_id = db.Column(db.Integer, db.ForeignKey('traffic_item_provider.id'))
  traffic_item_meta = db.relationship("TrafficItemMeta", backref="TrafficItem", lazy='dynamic')
  
  def __init__(self):
    pass

  def __repr__(self):
    return '<TrafficItem %r>' % self.name
Example #23
0
class NaMidia(db.Model):
    __tablename__ = 'na_midia'

    na_midia_id = db.Column(db.Integer, primary_key=True)
    acao_id = db.Column(db.Integer,
                        db.ForeignKey('acoes.acao_id'),
                        nullable=False)
    midia_url = db.Column(db.String())
    midia = db.Column(db.String())

    def __init__(self, acao_id, midia_url, midia):
        self.acao_id = acao_id
        self.midia_url = midia_url
        self.midia = midia

    def __repr__(self):
        return '<NaMidia: %r>' % self.midia_url

    def serialize(self):
        return {
            'na_midia_id': self.na_midia_id,
            'acao_id': self.acao_id,
            'midia_url': self.midia_url,
            'midia': self.midia
        }
Example #24
0
class Region(db.Model):
  __tablename__ = 'region'
  
  id = db.Column(db.Integer(), primary_key=True)
  name = db.Column(db.String(255))
  slug = db.Column(db.String(255), unique=True)
  created = db.Column(db.DateTime())
  updated = db.Column(db.DateTime())
  active = db.Column(db.Integer())
  
  osm_id = db.Column(db.Integer())
  geo_json = db.Column(db.Text())
  rgs = db.Column(db.String(255))
  region_level = db.Column(db.Integer())
  postalcode = db.Column(db.String(255))
  fulltext = db.Column(db.String(255))
  
  lat = db.Column(db.Numeric(precision=10,scale=7))
  lon = db.Column(db.Numeric(precision=10,scale=7))
  
  def __init__(self):
    pass

  def __repr__(self):
    return '<Hoster %r>' % self.name
Example #25
0
class Album(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    sku = db.Column(db.String(255), nullable=False)
    artist_id = db.Column(db.Integer, db.ForeignKey(
        "artist.id"), nullable=False)
    title = db.Column(db.String(1024), nullable=False)
    year = db.Column(db.Integer, nullable=False)
    format = db.Column(db.String(255), nullable=False)
    price = db.Column(db.Float(), nullable=False)
    tracks = db.relationship('Track', backref='Album', lazy=True)

    @property
    def album_art(self):
        id_album = list(str(self.id))
        id_album.reverse()
        filepath = '/'.join(id_album)
        albumart = os.path.join(app.static_folder, 'albumart')
        filename = os.path.join(albumart, filepath, f'{self.id}.jpg')

        if os.path.exists(filename) and (os.path.getsize(filename) > 0):
            return f"/static/albumart/{filepath}/{self.id}.jpg"
        else:
            return "/static/img/no-albumart.svg"

    def __repr__(self):
        return f"Album('{self.name}')"
Example #26
0
class User(db.Model):
    id = db.Column(db.Integer(), primary_key=True, index=True, nullable=False)
    username = db.Column(db.String(40), index=True, nullable=False)
    feature = db.Column(db.String(200), nullable=True)

    def __repr__(self):
        return '<User %r>' % (self.username)
Example #27
0
class UserModel(db.Model):

    #nombre tabla
    __tablename__ = 'users'

    #columns
    id = db.Column(db.Integer, primary_key=True)
    fullname = db.Column(db.String(80), nullable=True)
    username = db.Column(db.String(80), unique=True, nullable=True)
    email = db.Column(db.String(256), unique=True, nullable=True)
    password = db.Column(db.String(128), nullable=False)
    created_at = db.Column(db.DateTime(),
                           nullable=False,
                           default=datetime.datetime.now)

    #init data
    def __init__(self, fullname, username, email, password):

        #declare data
        self.fullname = fullname
        self.username = username
        self.email = email
        self.password = self.create_password(password)

    #Generate Hash password
    def create_password(self, password):
        return generate_password_hash(password)

    #Verifique hash password
    def verify_password(self, password):
        return check_password_hash(self.password, password)
Example #28
0
class User(db.Model):
    __tablename__ = "users"
    id = Column(String(32), primary_key=True, unique=True)
    name = Column(String(200), nullable=False, primary_key=True)
    email = Column(String(200), nullable=False, primary_key=True)
    password_hash = db.Column(db.String(255), nullable=False)
    salt = db.Column(db.String(255), nullable=False)
    created_at = Column(DateTime)
    accesstokens = relationship("AccessToken", back_populates="users")

    def __init__(self, name, email, password):
        self.created_at = datetime.utcnow()
        self.id = str(uuid.uuid4().hex)
        self.name = name
        self.email = email
        self.salt = uuid.uuid4().hex
        self.password_hash = User.hash_password(salt=self.salt,
                                                password=password)

    def to_json(self):
        return {"id": self.id, "name": self.name, "email": self.email}

    def check_password(self, password):
        current_password = self.hash_password(self.salt, password)
        if (current_password == self.password_hash):
            return True
        else:
            return False

    @staticmethod
    def hash_password(salt, password):
        return hashlib.sha512((password + salt).encode('utf-8')).hexdigest()
Example #29
0
class Task(db.Model):

    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    time_added = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now(tz))
    time_updated = db.Column(db.DateTime,
                             default=datetime.now(tz),
                             onupdate=datetime.now(tz))

    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.String(250), nullable=False)
    deadline = db.Column(db.DateTime, nullable=False)

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    subject_id = db.Column(db.Integer,
                           db.ForeignKey('subject.id'),
                           nullable=False)

    comment = db.relationship('Comment',
                              backref='task',
                              lazy=True,
                              foreign_keys="Comment.task_id")

    def __repr__(self):
        return f"Task('{self.name}', '{self.description}', '{self.deadline}')"
Example #30
0
class TweetsDB(twunet.tweets.MongoDB, db.Model):
    """
        :param id : ID of the entry in the user database
        :type int
        :param host : host of the user database
        :type str
        :param port : port of user database
        :type int
        :param database : type of database
        :type str
        :param configuration : foreign key related to id of study name
        :type int

    """
    id = db.Column(db.Integer, primary_key=True)
    host = db.Column(db.String(255))
    port = db.Column(db.Integer)
    database = db.Column(db.String(255))
    configuration = db.Column(db.BigInteger, db.ForeignKey('study.id'))

    def __init__(self, host, port, database):
        """
        Initialization function : Initialize a Tweets database
        
        :param host: host address of the tweets database
        :type str
        :param port: port address of the tweets database
         :type int
        :param database: Database used
         :type str 
        """
        db.Model.__init__(self)
        twunet.tweets.MongoDB.__init__(self, host, port, database)