Wang Dingwei avatar Wang Dingwei committed 8168729

modified db structure

Comments (0)

Files changed (5)

 class Rule(db.Model):
     __tablename__ = 'rules'
-    name = db.Column(db.String(32), primary_key=True)
+    id = db.Column(db.Integer, primary_key=True)
+    name = db.Column(db.String(32))
     desc = db.Column(db.String(256))
     action = db.Column(db.String(256))
     __tablename__ = 'orders'
     po = db.Column(db.String(20), primary_key=True)
     time = db.Column(db.DateTime)
-    rule_name = db.Column(db.String(32), db.ForeignKey(''))
+    rule_id = db.Column(db.Integer, db.ForeignKey(''))
-    rule = db.relationship(Rule, backref=db.backref('orders', order_by=po))
+    rule = db.relationship(Rule, backref=db.backref('orders', order_by=time))
     def __init__(self, po, rule_name):
         self.po = po
         self.time =
-        self.rule_name = rule_nam
+        self.rule_name = rule_name
-        print result
         return render_template('result.html', result=result, notfound=notfound)
     return redirect(url_for('default_view'))
     return render_template('rules.html', rules=rules)
-def edit_rule(rule):
-    result = Rule.query.filter_by(name=rule).first()
+def edit_rule(id):
+    result = Rule.query.filter_by(id=id).first()
     return render_template('rule.html', rule=result)
 class Config(object):
     DEBUG = False
     TESTING = False
-    SQLALCHEMY_DATABASE_URI = 'sqlite:///test.db'
+    SQLALCHEMY_DATABASE_URI = 'sqlite:///F:\\Projects\\orderfilter\\test.db'
     SECRET_KEY = 'development'
 class ProductionConfig(Config):


 {% block body %}
 <form action="/result/" method="POST">
     <h2>Please enter PO here:</h2>
-    <textarea name="polist" COLS=40 ROWS=20></textarea>
+    <textarea name="polist" COLS=40 ROWS=15></textarea>
     <input type="submit" value="Submit">
 <p> Alternatively, you can see <a href={{ url_for("all_results") }}>all illegal PO</a> or <a href={{ url_for("get_rules") }}>all rules</a></p>


 <form action="/rules/" method="POST">
     <p>Name: <input type="text" readonly="readonly" name=rule_name value="{{
- }}" /></p>
-    <p>Description:</p>
-    <textarea name="rule_desc">{{ rule.desc }}</textarea>
-    <p>Action:</p>
-    <textarea name="rule_action">{{ rule.action }}</textarea>
+ }}" disabled="disabled" /></p>
+    Description:<br>
+    <textarea name="rule_desc" cols=40 rows=4 readonly="readonly"
+        disabled="disabled">{{ rule.desc }}</textarea><p>
+    Action:<br>
+    <textarea name="rule_action" cols=40 rows=4>{{ rule.action }}</textarea>
     <input type="submit" value="Submit">


 {% block body %}
 <table class="unit_info">
-    <tr><th>Name</th><th>Description</th><th>Action</th></tr>
+    <tr><th>ID</th><th>Name</th><th>Description</th><th>Action</th></tr>
     {% for rule in rules %}
-    <tr><td><a href="/rules/{{ }}">{{ }}</a></td>
+    <tr><td>{{}}</td>
+        <td><a href="/rules/{{ }}">{{ }}</a></td>
         <td>{{ rule.desc }}</td>
         <td>{{ rule.action }}</td></tr>
     {% endfor %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.