mirror of
https://github.com/aronwk-aaron/MSState-Library-ETD.git
synced 2026-05-05 02:19:11 -05:00
DB Integration
This commit is contained in:
committed by
Jordan Stremming
parent
1853951880
commit
cbb1321cd8
+2
-1
@@ -41,7 +41,6 @@ def create_app():
|
||||
return isinstance(field, HiddenField)
|
||||
|
||||
app.jinja_env.globals['bootstrap_is_hidden_field'] = is_hidden_field_filter
|
||||
|
||||
return app
|
||||
|
||||
|
||||
@@ -66,6 +65,8 @@ def register_extensions(app):
|
||||
scss = Bundle('scss/site.scss', filters='libsass', output='site.css')
|
||||
assets.register('scss_all', scss)
|
||||
|
||||
db.create_all(app=app)
|
||||
|
||||
|
||||
def register_blueprints(app):
|
||||
"""Register blueprints for Flask app
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy.sql import func
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_migrate import Migrate
|
||||
@@ -85,7 +86,7 @@ class Submission(db.Model):
|
||||
__tablename__ = 'submissions'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(db.Integer(), db.ForeignKey('users.id', ondelete='CASCADE'))
|
||||
user_id: Column = db.Column(db.Integer(), db.ForeignKey('users.id', ondelete='CASCADE'))
|
||||
title = db.Column(db.Unicode(), nullable=False, server_default=u'')
|
||||
abstract = db.Column(db.Unicode(), nullable=False, server_default=u'')
|
||||
# TODO: Make Enum type for this
|
||||
|
||||
+10
-1
@@ -1,5 +1,7 @@
|
||||
from flask import render_template, Blueprint
|
||||
|
||||
from app.models import Submission, User
|
||||
|
||||
tad_blueprint = Blueprint('tad', __name__)
|
||||
|
||||
|
||||
@@ -40,4 +42,11 @@ def portfolio():
|
||||
@tad_blueprint.route('/tad/catalog')
|
||||
def catalog():
|
||||
"""Catalog of TADs"""
|
||||
return render_template('tad/catalog.jinja2')
|
||||
|
||||
tads = Submission.query \
|
||||
.join(User, User.id == Submission.user_id) \
|
||||
.add_columns(User.id, User.first_name, User.last_name, Submission.id, Submission.title, Submission.started) \
|
||||
.filter(User.id == Submission.user_id) \
|
||||
.filter(Submission.user_id == User.id)
|
||||
|
||||
return render_template('tad/catalog.jinja2', tads=tads)
|
||||
|
||||
@@ -40,27 +40,19 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Kendrick, Katelyn</td>
|
||||
<td>I've run out of funny titles.</td>
|
||||
<td>Spring 2019</td>
|
||||
<td><a href="{{ url_for('tad.view', tad_id=1) }}" class="btn btn-primary" role="button"
|
||||
aria-disabled="true">Link</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Streamming, Jordan</td>
|
||||
<td>Banging your head against the keyboard can produce valid code.</td>
|
||||
<td>Spring 2019</td>
|
||||
<td><a href="{{ url_for('tad.view', tad_id=2) }}" class="btn btn-primary" role="button"
|
||||
aria-disabled="true">Link</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Kimbrell, Aaron</td>
|
||||
<td>What even is psychology?</td>
|
||||
<td>Spring 2019</td>
|
||||
<td><a href="{{ url_for('tad.view', tad_id=3) }}" class="btn btn-primary" role="button"
|
||||
aria-disabled="true">Link</a></td>
|
||||
</tr>
|
||||
|
||||
{% if tads %}
|
||||
{% for tad in tads %}
|
||||
<tr>
|
||||
<td>{{ tad.last_name }}, {{ tad.first_name }}</td>
|
||||
<td>{{ tad.title }}</td>
|
||||
<td>{{ tad.started }}</td>
|
||||
<td><a href="{{ url_for('tad.view', tad_id=tad.id) }}" class="btn btn-primary" role="button"
|
||||
aria-disabled="true">Link</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user