models.py 1.16 KB
Newer Older
Benjamin S Waters's avatar
Benjamin S Waters committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from website import website
from datetime import datetime

db = SQLAlchemy(website)

class FeatureRequest(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    service_name = db.Column(db.String(80), db.ForeignKey('service.name'))
    service = db.relationship('Service',
         backref=db.backref('featurerequests', lazy='dynamic'))
    user = db.Column(db.String(80))
    entry_date = db.Column(db.DateTime)
    contact_email = db.Column(db.String(120))
    reason = db.Column(db.String(1028))

    def __init__(self, service, user,contact_email, reason, entry_date=None):
        self.service = service
        self.user = user
        if entry_date is None:
            entry_date = datetime.utcnow()
        self.entry_date = entry_date
        self.contact_email = contact_email
        self.reason = reason

    def __repr__(self):
        return '<ID %r>' % self.id

class Service(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return '<Name %r>' % self.name