From 8a3ac21d61fe204d81dd2d3daecd69bf6b3a068a Mon Sep 17 00:00:00 2001 From: marcsello Date: Sat, 28 Nov 2020 23:49:36 +0100 Subject: [PATCH] Created purchase template --- src/app.py | 4 ++-- src/templates/purchase.html | 44 ++++++++++++++++++++++++++++++++----- src/views/__init__.py | 3 ++- src/views/purchaseview.py | 15 +++++++++++++ 4 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 src/views/purchaseview.py diff --git a/src/app.py b/src/app.py index 05b244e..4237739 100644 --- a/src/app.py +++ b/src/app.py @@ -10,7 +10,7 @@ from flask_mail import Mail from utils import Config from utils import health_database_status, init_security_real_good from utils import storage -from views import ItemView, ProfileView, UploadView, IndexView, ContentView +from views import ItemView, ProfileView, UploadView, IndexView, ContentView, PurchaseView from models import db @@ -45,7 +45,7 @@ CORS(app) Mail(app) storage.init_app(app) -for view in [ItemView, ProfileView, UploadView, IndexView, ContentView]: +for view in [ItemView, ProfileView, UploadView, IndexView, ContentView, PurchaseView]: view.register(app, trailing_slash=False) health.add_check(health_database_status) diff --git a/src/templates/purchase.html b/src/templates/purchase.html index f344da7..ea76ffb 100644 --- a/src/templates/purchase.html +++ b/src/templates/purchase.html @@ -3,13 +3,45 @@ {% block content %} {% if current_user.is_authenticated %}
-

File Upload

-
-
-

-
+

Purchase animation

+
+
+
+

You are about to purchase the following item:

+ + + + + + + + + + + + + + + +
Name{{ item.name }}
Uploader{{ item.uploader.name }}
Upload date{{ item.upload_date }}
+
+
+ {{ item.name }} + +
+
+
+ +
+
+

+ +

+
+
{% else %} -

Log in to upload an animation.

+

Log in to purchase an animation.

{% endif %} {% endblock %} \ No newline at end of file diff --git a/src/views/__init__.py b/src/views/__init__.py index ab1ce67..7a70967 100644 --- a/src/views/__init__.py +++ b/src/views/__init__.py @@ -2,4 +2,5 @@ from .profileview import ProfileView from .uploadview import UploadView from .itemview import ItemView from .indexview import IndexView -from .contentview import ContentView \ No newline at end of file +from .contentview import ContentView +from .purchaseview import PurchaseView diff --git a/src/views/purchaseview.py b/src/views/purchaseview.py new file mode 100644 index 0000000..a04dfb8 --- /dev/null +++ b/src/views/purchaseview.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +from flask import render_template +from flask_classful import FlaskView + +from flask_security.decorators import login_required +from flask_security import current_user + +from models import Item + + +class PurchaseView(FlaskView): + + def get(self, id_:int): + item = Item.query.get_or_404(id_) + return render_template('purchase.html', item=item)