Creating User Template
#controllers/user.py
import config, copy
from flask import render_template
from models.userdb import Userdb
class User():
def __init__(self):
self.userdb = Userdb()
def get_user(self, id):
vdict = copy.deepcopy(config.vdict)
vdict['user'] = self.userdb.select(1, id=id)
return vdict
<!--templates/user.html-->
{% extends "base.html" %}
{% block head %}
{{ super() }}
<link href="/static/styles/fuser.css" rel="stylesheet" >
{% endblock %}
{% block content %}
<h3><span class="user-title">{{ data['user'][1] }}</span></h3>
<p class="user-meta">
{% if 'logged-in' in session %}
<span><a href="/dashboard/user/edit/{{ data['user'][0] }}"><img src="/static/images/edit.png" /></a>
<a href="/dashboard/user/delete/{{ data['user'][0] }}"><img src="/static/images/delete.png" /></a>
</span>
{% endif %}
</p>
<article class="user-body">{{ data['user'][4]|safe }}</a></article>
<div style="margin-top:20px;" id="disqus_thread"></div>
<script>
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://khmerweb.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{% endblock %}
/*static/styles/user.css*/
#main{
display: grid;
grid-template-columns: 75% auto;
grid-gap: 20px;
margin-top: 30px;
}
#main #content, #main #sidebar{
background: lavender;
min-height: 400px;
}
#main #content{
padding: 20px;
}
#main #content .user-title{
font: 20px/1.5 Oswald, Koulen;
}
#main #content .user-body{
margin-top: 30px;
}
#main #content .user-body img{
width: 100%;
}
#main #content .user-meta{
margin: 20px 0;
}
#main #content .user-meta span{
float: right;
position: relative;
top: -15px;
}
#main #content .user-meta img{
width: 30px;
margin-left: 5px;
}
@media only screen and (max-width: 600px){
#main{
grid-template-columns: 100%;
padding: 20px;
}
}
GitHub: "https://github.com/Sokhavuth/E-Learning
Heroku: https://khmerweb-elearning.herokuapp.com/

Comments
Post a Comment