1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #controllers/dashboard/dashboard.py from flask import session from flask_classful import FlaskView, route from controllers.dashboard.category import Category from controllers.dashboard.post import Post class Dashboard(FlaskView): def __init__( self ): self .cat = Category() self .post = Post() @route ( '/' , methods = [ 'GET' , 'POST' ]) def index( self ): session[ 'page' ] = 0 return self .post.get_post() @route ( '/category/' , methods = [ 'GET' , 'POST' ]) def category( self ): session[ 'page' ] = 0 return self .cat.get_post() @route ( '/category/delete/<category>' ) def delete( self , category): return self .cat.delete(category) @route ( '/category/edit/<category>' ) def edit( self , category): return self .cat.edit(category) @route ( '/category/load/' ) def load( self ): session[ 'page' ] + = 1 return self .cat.load(session[ 'page' ]) dashboard = Dashboard() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #controllers/dashboard/post.py import config, copy from flask import render_template, session, redirect from lib import Lib from models.dashboard.postdb import Postdb from models.dashboard.categorydb import Categorydb class Post(): def __init__( self ): self .lib = Lib() self .post = Postdb() self .category = Categorydb() def get_post( self ): vdict = copy.deepcopy(config.vdict) vdict[ 'blog_title' ] = 'ចុះផ្សាយមេរៀន' vdict[ 'datetime' ] = self .lib.get_timezone() vdict[ 'categories' ] = self .category.select( 'all' ) if 'logged-in' in session: return render_template( 'dashboard/dashboard.html' , data = vdict) else : return redirect( '/login/' ) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | <!--templates/dashboard/dashboard.html--> <!DOCTYPE html> < html > < head > {% block head %} < meta charset = "UTF-8" /> < meta name = "viewport" content = "width=device-width, initial-scale=1.0" /> < meta name = "description" content = "This blog engine is built for e-learning" > < meta name = "robots" content = "index, follow" > < meta name = 'keywords' content = 'e-learning, learning, school, math, programming' > < title >{{data['blog_title']}}</ title > < script src = "/static/scripts/jQuery.js" ></ script > < script src = "/static/scripts/ckeditor/ckeditor.js" ></ script > < script src = '/static/scripts/base.js' ></ script > < script src = '/static/scripts/dashboard.js' ></ script > < link href = "/static/styles/base.css" rel = "stylesheet" > < link href = "/static/styles/dashboard.css" rel = "stylesheet" > < link href = "/static/fonts/setup.css" rel = 'stylesheet' > < link href = "/static/images/site_logo.png" rel = "shortcut icon" > {% endblock %} </ head > < body > < div id = "header" > {% block header %} < header id = "inner" class = "inner region" > < div id = "title" > < a href = "/" >< img src = "/static/images/site_logo.png" /></ a > < a >{{data['blog_title']}}</ a > </ div > < div id = "blog-search" > < form class = "search" action = "/search/backend/" method = "post" > < input type = "text" placeholder = "Search.." name = "fquery" required> < button type = "submit" >ស្វែងរក</ button > </ form > </ div > < div id = "logout" >< a href = "/login/logout/" >ចេញក្រៅ</ a ></ div > </ header > {% endblock %} </ div > < div id = "main" class = "main region" > {% block main %} < div id = "sidebar" > {% block sidebar %} < div >< a href = "/dashboard/" >< img src = "/static/images/posting.png" /></ a >< a href = "/dashboard/" >ចុះផ្សាយមេរៀន</ a ></ div > < div >< a href = "/category/" >< img src = "/static/images/categorizing.png" /></ a >< a href = "/dashboard/category/" >បង្កើតប្រភេទមេរៀន</ a ></ div > < div >< a href = "/paging" >< img src = "/static/images/paging.png" /></ a >< a href = "/paging" >បង្កើតទំព័រមាតិកា</ a ></ div > < div >< a href = "/uploading" >< img src = "/static/images/multimedia.png" /></ a >< a href = "/uploading" >ចំលងឯកសារ</ a ></ div > < div >< a href = "/addinguser" >< img src = "/static/images/user.png" /></ a >< a href = "/addinguser" >បន្ថែមសមាជិក</ a ></ div > < div >< a href = "/setting" >< img src = "/static/images/setting.png" /></ a >< a href = "/setting" >កំណត់ទំរង់លក្ខណៈ</ a ></ div > {% endblock %} </ div > < div id = "content" > {% block content %} < form id = 'post' action = '/dashboard/' method = "POST" > {% if 'post' in data %} < input id = 'post-title' value = "{{ data['post'][1] }}" name = "fpost-title" type = "text" placeholder = "ប្រភេទមេរៀន" required /> < textarea name = "fcontent" id = "editor" >{{ data['post'][2] }}</ textarea > {% else: %} < input id = 'post-title' value = "" name = "fpost-title" type = "text" placeholder = "ប្រភេទមេរៀន" required /> < textarea name = "fcontent" id = "editor" ></ textarea > {% endif %} < div id = "bottombar" > < input id = "submit" class = "bottom-widget" type = "submit" value = "ចុះផ្សាយ" > < select id = 'category' > {% if 'categories' in data %} {% for category in data['categories'] %} < option >{{ category[1] }}</ option > {% endfor %} {% endif %} </ select > < input id = "post-date" value = "{{ data['datetime'][0] }}" class = "post-time" type = "text" name = "fpost-date" required /> < input id = "post-time" value = "{{ data['datetime'][1] }}" class = "post-time" type = "text" name = "fpost-time" required /> < input disabled type = 'text' value = "{{ session['logged-in'] }}" id = "post-author" class = "post-time" name = "fpost-author" required /> </ div > </ form > < div id = "message" >{{ data['message'] }}</ div > < script src = "/static/scripts/ckeditor/config.js" ></ script > {% endblock %} </ div > {% endblock %} </ div > {% block item_listing %} < div id = "item-listing" class = "item-listing region" ></ div > {% endblock %} < div id = "footer" class = "footer region" > {% block footer %} < script >var base = new Base();</ script > {% endblock %} </ div > </ body > </ html > |
GitHub: "https://github.com/Sokhavuth/E-Learning
Heroku: https://khmerweb-elearning.herokuapp.com/