From 8dbe46330725b9d72e97c0a8844b7736ddd372c3 Mon Sep 17 00:00:00 2001 From: Asma Saidi Date: Sun, 8 Feb 2015 12:09:43 +0100 Subject: [PATCH] First admin #92 --- slides.py | 25 +++++++++++++++---------- templates/admin.html | 33 ++++++++++++++++++--------------- templates/registration.html | 3 +++ 3 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 templates/registration.html diff --git a/slides.py b/slides.py index d0e8db2..b8c4a05 100755 --- a/slides.py +++ b/slides.py @@ -42,7 +42,7 @@ def get_admin(kwargs): def first_run(): import first_run first_run.init() - return redirect(url_for("index")) + return redirect(url_for("admin")) @app.route('/addCategory', methods=['GET', 'POST']) @login_required @@ -125,8 +125,8 @@ def add_slide(): # status=status, # message='This slide already exists' # ) - - + + @app.route('/deleteslide', methods=['GET', 'POST']) @login_required def delete_slide(): @@ -169,7 +169,7 @@ def delete_category(): s.category = uc.id db_session.add(s) category_controller.delete(category_id) - + db_session.commit() @@ -236,7 +236,7 @@ def update_category(): try: category_id = request.form['id'] c = CategoryModel.query.get(category_id) - + if c.name == "Uncategorised": return render_template( 'admin.html', @@ -248,7 +248,7 @@ def update_category(): ) c.name = request.form['title'] - + db_session.add(c) db_session.commit() status = True @@ -266,7 +266,7 @@ def update_category(): 'admin.html', status = False, categories = category_controller.list(), - message ="This Categorie already exists ! ") + message ="This Categorie already exists ! ") # retrives slides for a given category @app.template_filter('getSlides') @@ -288,7 +288,7 @@ def isValidURL(url): # Check if the branch 'gh-pages' exists import requests res = requests.get(url+'/tree/gh-pages') - + if(not res.ok): return "You have to create a 'gh-pages' branch" @@ -309,7 +309,7 @@ def admin(): current_app.logger.debug("debug admin") status = -1 if request.method == 'GET': - login = request.args.get('login') + login = request.args.get('login') return render_template('admin.html', categories=category_controller.list(), login=login) @@ -319,7 +319,12 @@ def admin(): categories=category_controller.list(), status=status ) - +@app.route('/registration') +def registration(): + return render_template( + 'registration.html', + categories=category_controller.list() + ) @app.errorhandler(404) def page_not_found(e): return render_template('404.html') diff --git a/templates/admin.html b/templates/admin.html index 0d79470..3efeea2 100755 --- a/templates/admin.html +++ b/templates/admin.html @@ -10,7 +10,10 @@

- Ooops ! You must be logged in to access this page ! + + Ooops ! You must be logged in to access this page ! +

Not registred yet? Join Here!

+

{% else %} @@ -119,24 +122,24 @@

Administration Panel

{% for c in categories %} - + {{ c.id }} - {{ c.name }} + {{ c.name }} - {% endfor %} + {% endfor %} - + - + @@ -334,7 +337,7 @@ - +