Esempio n. 1
0
class WindTurbine(db.Document):
    _id = db.ObjectIdField()
    case_id = db.IntField(unique=True)  # Unique stable identification number.
    faa_ors = db.StringField(
    )  # Unique identifier for cross-reference to the Federal Aviation Administration (FAA) digital obstacle files.
    faa_asn = db.StringField(
    )  # Unique identifier for cross-reference to the FAA obstruction evaluation airport airspace analysis dataset.
    usgs_pr_id = db.IntField(
    )  # Unique identifier for cross-reference to the 2014 USGS turbine dataset.
    t_state = db.StringField()  # State where turbine is located.
    t_county = db.StringField()  # County where turbine is located.
    t_fips = db.StringField(
    )  # State and county fips where turbine is located, based on spatial join of turbine points with US state and county.
    p_name = db.StringField(
    )  # Name of the wind power project that the turbine is a part of
    p_year = db.IntField(
    )  # Year that the turbine became operational and began providing power. Note this may differ from the year that construction began.
    p_tnum = db.IntField()  # Number of turbines in the wind power project.
    p_cap = db.FloatField(
    )  # Cumulative capacity of all turbines in the wind power project in megawatts (MW).
    t_manu = db.StringField(
    )  # Turbine manufacturer - name of the original equipment manufacturer of the turbine.
    t_model = db.StringField(
    )  # Turbine model - manufacturer's model name of each turbine.
    t_cap = db.IntField(
    )  # Turbine rated capacity - stated output power at rated wind speed from manufacturer, AWEA, and/or internet resources in kilowatts (kW).
    t_hh = db.FloatField()  # Turbine hub height in meters (m).
    t_rd = db.FloatField()  # Turbine rotor diameter in meters (m).
    t_rsa = db.FloatField()  # Turbine rotor swept area in square meters (m2).
    t_ttlh = db.FloatField(
    )  # Turbine total height from ground to tip of a blade at its apex in meters (m).
    t_conf_atr = db.IntField(
    )  # Level of confidence in the turbine attributes (1 - no confidence, 3 - full confidence)
    t_conf_loc = db.IntField(
    )  # Level of confidence in turbine location (1 - no turbine in image, 3 - turbine in image)
    t_img_date = db.DateTimeField(
    )  # Date of image used to visually verify turbine location.
    t_img_srce = db.StringField(
    )  # Source of image used to visually verify turbine location.
    longitude = db.FloatField(
    )  # Longitude of the turbine point, in decimal degrees.
    latitude = db.FloatField(
    )  # Latitude of the turbine point, in decimal degrees.
    eia_id = db.IntField(
    )  # Plant ID from Energy Information Administration (EIA).
    #updated = db.DateTimeField()
    created = db.DateTimeField(default=datetime.datetime.utcnow)

    meta = {'collection': 'wind_turbines'}

    # https://stackoverflow.com/questions/10252010/serializing-class-instance-to-json
    # https://stackoverflow.com/questions/7907596/json-dumps-vs-flask-jsonify
    # https://stackoverflow.com/questions/16586180/typeerror-objectid-is-not-json-serializable
    def to_json(self):
        return {
            'id': str(self._id),
            'name': self.p_name,
            'latitude': self.latitude,
            'longitude': self.longitude
        }
class Equipment(db.Document):
    mac_address = db.StringField(primary_key=True)
    name = db.StringField()
    description = db.StringField()
    samppling_frequency = db.IntField()
    sensors = db.ListField(db.ReferenceField('Sensor'), default=list)
    available = db.BooleanField()
Esempio n. 3
0
class User(UserMixin, db.Document):
    created_at = db.DateTimeField(default=datetime.datetime.now, required=True)
    email = db.StringField(max_length=255, required=True)
    username = db.StringField(max_length=255, required=False)
    password = db.StringField(required=True)
    active = db.BooleanField(default=False)
    roles = db.ListField(db.ReferenceField(Role), default=[])
    #email confirmation
    confirmed_at = db.DateTimeField()
    #tracking
    last_login_at = db.DateTimeField()
    current_login_at = db.DateTimeField()
    last_login_ip = db.StringField()
    current_login_ip = db.StringField()
    login_count = db.IntField()

    def __unicode__(self):
        return '%s' % self.id

    def __repr__(self):
        return "%s %s %s" % (self.username, self.id, self.email)

    def get_id(self):
        return unicode(self.id)

    meta = {
        'allow_inheritance': True,
        'indexes': ['-created_at', 'email', 'username'],
        'ordering': ['-created_at']
    }
Esempio n. 4
0
class Equipment(db.Model):
    mac_address = db.Column(db.String(), primary_key=True)
    name = db.Column(db.StringField())
    description = db.Column(db.StringField())
    samppling_frequency = db.Column(db.IntField())
    sensors = db.relationship('Sensor', backref='equipment', lazy=True)
    available = db.Column(db.Boolean(True))
Esempio n. 5
0
class Thought(db.Document):
    dys_thought = db.StringField(required=True)
    user = db.StringField(required=True)
    rational = db.StringField(required=False)
    distress = db.IntField(required=True)
    distortion = db.StringField(required=True)
    timestamp = db.StringField(required=True, default=datetime.now())
Esempio n. 6
0
class Apartment(db.Document):
    title = db.StringField()
    url = db.StringField()
    price = db.IntField()
Esempio n. 7
0
class User(db.Document):

    created_at = db.DateTimeField(default=datetime.datetime.now, required=True)

    user_id = db.SequenceField(unique=True)

    is_admin = db.BooleanField(default=False)

    email = db.StringField()

    name = db.StringField(max_length=50)

    lang = db.StringField(max_length=3)
    bio = db.StringField()
    location = db.StringField()
    # Available for hire or not
    hireable = db.BooleanField(default=False)

    github_username = db.StringField(max_length=50)
    github_id = db.IntField()

    twitter_username = db.StringField(max_length=50)
    facebook_username = db.StringField(max_length=100)
    website = db.StringField(max_length=50)

    oauth_token = db.StringField()
    oauth_secret = db.StringField()

    _password = db.StringField()

    @property
    def password(self):
        return self._password

    @password.setter
    def password(self, password):
        self._password = bcrypt.generate_password_hash(password)

    def check_password(self, password):
        return bcrypt.check_password_hash(self._password, password)

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

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return str(self.id)

    # helpers
    def getGithub(self):
        if self.github_username:
            return "https://github.com/%s" % (self.github_username)
        return ''

    def getTwitter(self):
        if self.twitter_username:
            return "https://twitter.com/%s" % (self.twitter_username)
        return ''

    def getFacebook(self):
        if self.facebook_username:
            return "https://facebook.com/%s" % (self.facebook_username)
        return ''

    def getName(self):
        return '%s' % self.name or self.github_username

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

    meta = {'ordering': ['-created_at']}