Implemented basic item view
This commit is contained in:
parent
3ce60047ff
commit
9a204bd3ba
@ -1,45 +1,37 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
<h3 class="card-header">Animation by {{ image.creator }}</h3>
|
<h3 class="card-header">Animation by {{ item.uploader.name }}</h3>
|
||||||
<!-- <div class="card-body">-->
|
|
||||||
<!-- <h5 class="card-title">Special title treatment</h5>-->
|
|
||||||
<!-- <h6 class="card-subtitle text-muted">Support card subtitle</h6>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<img src="{{image.preview}}" class="card-img" style="padding: 30px" alt="{{image.name}}">
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">{{ image.name }}</p>
|
<h4>
|
||||||
|
<p class="card-text">{{ item.name }}</p>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<img src="{{ url_for('ContentView:preview', id_=item.id) }}" class="card-img" style="padding: 30px"
|
||||||
|
alt="{{ item.name }}">
|
||||||
|
|
||||||
|
<div class="card-text text-center">
|
||||||
|
{% if purchased %}
|
||||||
|
<a href="{{ url_for('ContentView:caff', id_=item.id) }}" class="btn btn-lg btn-success"
|
||||||
|
target="_self">Download</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="#" class="btn btn-lg btn-primary" target="_blank">Purchase</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
|
||||||
<table class="table table-responsive">
|
|
||||||
<tbody>
|
|
||||||
<tr class="table-active">
|
|
||||||
<th scope="row">Creator</th>
|
|
||||||
<td>{{ image.creator }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="table-active">
|
|
||||||
<th scope="row">Creation date</th>
|
|
||||||
<td>{{ image.creation_date }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<a href="{{ url_for('download', id=image.id) }}" class="card-link" target="_blank">Download</a>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer text-muted">
|
<div class="card-footer text-muted">
|
||||||
Uploaded: {{ image.upload_date }}
|
Uploaded: {{ item.upload_date }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if current_user.is_authenticated %}
|
{% if current_user.is_authenticated %}
|
||||||
<div class="card">
|
<div class="card my-2">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form>
|
<form>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Write a comment</legend>
|
<legend>Write a comment</legend>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<textarea class="form-control" id="commentTextarea" rows="3" ,
|
<textarea class="form-control" id="commentTextarea" rows="3"
|
||||||
placeholder="Type your comment here"></textarea>
|
placeholder="Type your comment here"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
@ -49,21 +41,22 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if comments %}
|
{% if item.comments %}
|
||||||
{% for comment in comments %}
|
{% for comment in item.comments %}
|
||||||
<div class="card">
|
<div class="card my-2">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="card-title">{{ comment.user }}</h4>
|
<h4 class="card-title">{{ comment.commenter.name }}</h4>
|
||||||
<h6 class="card-subtitle mb-2 text-muted">{{ comment.date }}</h6>
|
<h6 class="card-subtitle mb-2 text-muted">{{ comment.date }}</h6>
|
||||||
<p class="card-text">{{ comment.text }}</p>
|
<p class="card-text">{{ comment.text }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="card">
|
<div class="card my-2">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p>No comments yet.</p>
|
<p>No comments yet.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="my-4"></div>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -1,6 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
from flask import render_template
|
||||||
from flask_classful import FlaskView
|
from flask_classful import FlaskView
|
||||||
|
from flask_security import current_user
|
||||||
|
|
||||||
|
from models import db, Comment, Item, Purchase
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Item VIEW
|
Item VIEW
|
||||||
@ -14,11 +17,14 @@ __version__text__ = "1"
|
|||||||
|
|
||||||
class ItemView(FlaskView):
|
class ItemView(FlaskView):
|
||||||
|
|
||||||
def index(self):
|
def get(self, id_: int):
|
||||||
pass
|
item = Item.query.get_or_404(id_)
|
||||||
|
|
||||||
def download(self):
|
if not current_user.is_authenticated:
|
||||||
pass
|
purchased = False
|
||||||
|
else:
|
||||||
|
p = Purchase.query.filter(
|
||||||
|
db.and_(Purchase.purchaser_id == current_user.id, Purchase.item_id == id_)).first()
|
||||||
|
purchased = bool(p)
|
||||||
|
|
||||||
def delete(self):
|
return render_template('item.html', item=item, purchased=purchased)
|
||||||
pass
|
|
||||||
|
Loading…
Reference in New Issue
Block a user