Created purchase template

This commit is contained in:
Pünkösd Marcell 2020-11-28 23:49:36 +01:00
parent beb539f36e
commit 8a3ac21d61
4 changed files with 57 additions and 9 deletions

View File

@ -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)

View File

@ -3,13 +3,45 @@
{% block content %}
{% if current_user.is_authenticated %}
<div class="jumbotron">
<h1 class="display-3">File Upload</h1>
<br>
<form method="POST" action="">
<p><input type="submit" value="buy" class="btn btn-primary"></p>
</form>
<h1 class="display-3">Purchase animation</h1>
<div class="container">
<div class="row">
<div class="col-md-6 col-12">
<p>You are about to purchase the following item: </p>
<table class="table table-responsive">
<tbody>
<tr class="table-active">
<th scope="row">Name</th>
<td>{{ item.name }}</td>
</tr>
<tr class="table-active">
<th scope="row">Uploader</th>
<td>{{ item.uploader.name }}</td>
</tr>
<tr class="table-active">
<th scope="row">Upload date</th>
<td>{{ item.upload_date }}</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-6 col-12 text-right">
<img src="{{ url_for('ContentView:preview', id_=item.id) }}" class="card-img"
alt="{{ item.name }}">
</div>
</div>
</div>
<div class="mt-5 text-center">
<form method="POST" action="">
<p>
<button type="submit" class="btn btn-danger">Yes, purchase this item!</button>
</p>
</form>
</div>
</div>
{% else %}
<p><a href="{{ url_for_security('login') }}">Log in</a> to upload an animation.</p>
<p><a href="{{ url_for_security('login') }}">Log in</a> to purchase an animation.</p>
{% endif %}
{% endblock %}

View File

@ -2,4 +2,5 @@ from .profileview import ProfileView
from .uploadview import UploadView
from .itemview import ItemView
from .indexview import IndexView
from .contentview import ContentView
from .contentview import ContentView
from .purchaseview import PurchaseView

15
src/views/purchaseview.py Normal file
View File

@ -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)