diff options
author | 2022-05-04 13:01:38 +0100 | |
---|---|---|
committer | 2022-05-04 13:01:38 +0100 | |
commit | ae6433151de7b5a4cba6193cb1367649f412f704 (patch) | |
tree | 0426203d09792458a014873aa51246bf0c815ad9 | |
parent | ed1ddef86576520119b4ce2867100dfa3259f824 (diff) | |
download | victoria-ae6433151de7b5a4cba6193cb1367649f412f704.tar.gz victoria-ae6433151de7b5a4cba6193cb1367649f412f704.tar.bz2 victoria-ae6433151de7b5a4cba6193cb1367649f412f704.zip |
completed base package structure
-rw-r--r-- | victoria/__init__.py | 4 | ||||
-rw-r--r-- | victoria/admin/forms.py | 8 | ||||
-rw-r--r-- | victoria/admin/routes.py | 14 | ||||
-rw-r--r-- | victoria/admin/utils.py (renamed from victoria/portfolio/__init__.py) | 0 | ||||
-rw-r--r-- | victoria/config.py | 1 | ||||
-rw-r--r-- | victoria/errors/handlers.py | 17 | ||||
-rw-r--r-- | victoria/main/__init__.py | 0 | ||||
-rw-r--r-- | victoria/main/routes.py | 17 | ||||
-rw-r--r-- | victoria/models.py | 1 |
9 files changed, 58 insertions, 4 deletions
diff --git a/victoria/__init__.py b/victoria/__init__.py index 439c217..67f36f5 100644 --- a/victoria/__init__.py +++ b/victoria/__init__.py @@ -21,10 +21,10 @@ def create_app(config_class=Config): login_manager.init_app(app) mail.init_app(app) - from victoria.portfolio.routes import portfolio + from victoria.main.routes import main from victoria.admin.routes import admin from victoria.errors.handlers import errors - app.register_blueprint(portfolio) + app.register_blueprint(main) app.register_blueprint(admin) app.register_blueprint(errors) diff --git a/victoria/admin/forms.py b/victoria/admin/forms.py new file mode 100644 index 0000000..5faad3b --- /dev/null +++ b/victoria/admin/forms.py @@ -0,0 +1,8 @@ +from flask_wtf import FlaskForm +from flask_wtf.file import FileAllowed, FileField +from wtforms import StringField, SubmitField, BooleanField +from wtforms.validators import DataRequired, Length, Email, EqualTo, ValidationError +from flask_login import current_user +from victoria.models import Artist, Series, Work, Tag, License + + diff --git a/victoria/admin/routes.py b/victoria/admin/routes.py new file mode 100644 index 0000000..49f8b69 --- /dev/null +++ b/victoria/admin/routes.py @@ -0,0 +1,14 @@ +from flask import render_template, url_for, redirect, request, Blueprint +from flask_login import login_user, current_user, logout_user, login_required +from victoria import db +from victoria.models import Artist, Work, Series, Tag, License +from victoria.admin.forms import +from victoria.admin.utils import send_otp_email + +admin = Blueprint('admin', __name__) + +@admin.route("/admin", methods=['GET', 'POST']) +@login_required +def admin_dashboard(): + return render_template('admin.html', title='Admin Dashboard') + diff --git a/victoria/portfolio/__init__.py b/victoria/admin/utils.py index e69de29..e69de29 100644 --- a/victoria/portfolio/__init__.py +++ b/victoria/admin/utils.py diff --git a/victoria/config.py b/victoria/config.py index 7ec4a78..585f597 100644 --- a/victoria/config.py +++ b/victoria/config.py @@ -8,5 +8,4 @@ class Config: MAIL_USE_TLS = True MAIL_USERNAME = os.environ.get('EMAIL_USER') MAIL_PASSWORD = os.environ.get('EMAIL_PASS') - ADMIN_EMAIL = 'victoria@kennaugh.com' diff --git a/victoria/errors/handlers.py b/victoria/errors/handlers.py new file mode 100644 index 0000000..27ec84c --- /dev/null +++ b/victoria/errors/handlers.py @@ -0,0 +1,17 @@ +from flask import Blueprint, render_template + +errors = Blueprint('errors', __name__) + +@errors.app_errorhandler(404) +def error_404(error): + return render_template('errors/404.html'), 404 + +@errors.app_errorhandler(403) +def error_403(error): + return render_template('errors/403.html'), 403 + +@errors.app_errorhandler(500) +def error_500(error): + return render_template('errors/500.html'), 500 + + diff --git a/victoria/main/__init__.py b/victoria/main/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/victoria/main/__init__.py diff --git a/victoria/main/routes.py b/victoria/main/routes.py new file mode 100644 index 0000000..52eafa8 --- /dev/null +++ b/victoria/main/routes.py @@ -0,0 +1,17 @@ +from flask import Blueprint, request, render_template +from flaskblog.models import Post + +main = Blueprint('main', __name__) + +@main.route("/") +@main.route("/home") +def home(): + page = request.args.get('page', 1, type=int) + posts = Post.query.order_by(Post.date_posted.desc()).paginate(page=page, per_page=5) + return render_template('home.html', posts=posts) + +@main.route("/about") +def about(): + return render_template('about.html', title='About') + + diff --git a/victoria/models.py b/victoria/models.py index 85bf40e..a37724a 100644 --- a/victoria/models.py +++ b/victoria/models.py @@ -44,7 +44,6 @@ class Artist(db.Model, UserMixin): class Work(db.Model): id = db.Column(db.Integer, primary_key=True) image_file = db.Column(db.String(20), unique=True, nullable=False) - image_dimensions = db.Column(db.String(15), nullable=False) # pass in 'widthxheight' title = db.Column(db.String(120), nullable=False, default='Untitled') date = db.Column(db.DateTime), date_added = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) |