Creating Dashboard Areas
#routes/dashboard.py from flask_classful import FlaskView, route from controllers.dashboard.signup import Signup from controllers.dashboard.index import Index class Dashboard(FlaskView): def __init__(self): super().__init__() self.signup = Signup() self.index = Index() @route('/') def dashboard_index(self): return self.index.index() @route('/logout/') def logout(self): return self.index.logout() @route('/signup/', methods={'GET', 'POST'}) def dashboard_signup(self): return self.signup.signup()
#templates/dashboard/index.py import config, copy, lib from flask import render_template, request, session, redirect from models.userdb import Userdb class Index(): def __init__(self): self.userdb = Userdb() def index(self): vdict = copy.deepcopy(config.vdict) vdict['site_title'] = "ទំព័រគ្រប់គ្រង" if 'logged-in' in session: return render_template('dashboard/index.html', data=vdict) return redirect('/login/') def logout(self): session.pop('logged-in', None) return redirect('/')
<!--templates/dashboard/index.html--> {% extends 'base.html' %} {% block head %} {{ super() }} <link href="/static/styles/dashboard/index.css" rel="stylesheet"> {% endblock %} {% block header %} <nav id='menu'> <div class="menu-outer region"> <div id="logo"> <a href="/"><img src="/static/images/site_logo.png" /></a> <a href="/dashboard/">{{ data['site_title'] }}</a> </div> <form id="search"> <select id="search-option"> <option>ការផ្សាយ</option> </select> <input type="text" placeholder="Search" required /> <input type="submit" value="ស្វែងរក" /> </form> <div class="logout"> <a href="/dashboard/logout/">ចេញក្រៅ</a> </div> </div> </nav> {% endblock %} {% block main %} <div id="sidebar"> {% block sidebar %} {% endblock %} </div> <div id="content"> {% block content %} {% endblock %} </div> {% endblock %}
/*static/styles/dashboard/index.css*/ body{ background: grey; } #menu{ background: lightgrey; border-bottom: 10px solid rgb(56, 56, 56) } .menu-outer{ grid-template-columns: 35% auto 20%; } #menu a{ color: black; } #menu #search{ grid-template-columns: 20% auto 15%; } #menu #search #search-option{ font: 14px/1.5 Vidaloka, OdorMeanChey; } #menu .logout{ text-align: right; } #main{ margin-top: 5px; display: grid; grid-template-columns: 25% auto; grid-gap: 15px; min-height: 470px; } #main #sidebar, #main #content{ background: lightgrey; }
GitHub: "https://github.com/Sokhavuth/ETV
Heroku: https://khmerweb-etv.herokuapp.com/
Comments
Post a Comment