Commit 16aace48 authored by Sli's avatar Sli

Possibilité de changer l'url de la page d'admin + recherche par id de produit

parent 9fcc8a6e
......@@ -3,7 +3,7 @@
# @Author: Bartuccio Antoine (Sli) (klmp200)
# @Date: 2016-07-03 17:57:28
# @Last Modified by: klmp200
# @Last Modified time: 2016-11-14 02:29:45
# @Last Modified time: 2016-11-15 23:29:33
from bottle import Bottle, static_file, request, template, redirect
from bottle.ext import sqlite
......@@ -95,7 +95,7 @@ def DeleteTicket(db, db_id=None):
if db_id:
db.execute('DELETE from ticket where id=:id',
{"id": db_id})
redirect('/admin')
redirect(settings.ADMIN_PAGE_URL)
@app.route('/media/<file:path>')
......@@ -106,7 +106,7 @@ def Media(file=""):
return static_file(file, root="./media/")
@app.route('/admin', method='GET')
@app.route(settings.ADMIN_PAGE_URL, method='GET')
def DisplayAdmin(db):
"""
Get data from database based on get data:
......@@ -116,10 +116,11 @@ def DisplayAdmin(db):
form = ObtainGetArgs(request.query, ['id', 'verifKey'])
tickets = SearchDb(db, form)
return template('admin.simple', table=tickets, form=form,
banlist=get_banlist())
banlist=get_banlist(),
admin_url=settings.ADMIN_PAGE_URL)
@app.route('/admin/ajax', method='GET')
@app.route(settings.ADMIN_PAGE_URL + '/ajax', method='GET')
def DisplayAdminAjax(db):
"""
Get data from database same as DisplayAdmin
......@@ -194,7 +195,7 @@ def SearchDb(db, args):
Qwery used in db
"""
if args['id'] or args['verifKey']:
table = db.execute("SELECT * from ticket where upper(verifKey) like :key or id =:id",
table = db.execute("SELECT * from ticket where upper(verifKey) like :key or productType=:id",
{"key": '%' + args['verifKey'].upper() + '%',
"id": args['id']}).fetchall()
else:
......@@ -231,7 +232,7 @@ def EditTicketQuantity(db, id_ticket, nb):
if nb_new >= 0 and nb_new <= ticket['totalPlaces']:
db.execute('UPDATE ticket SET availablePlaces=:av WHERE id=:id',
{"av": nb_new, "id": id_ticket})
redirect('/admin')
redirect(settings.ADMIN_PAGE_URL)
def Validate(db, place_tot, verif_key, place_used, product_type):
......
......@@ -2,12 +2,14 @@
# @Author: klmp200
# @Date: 2016-11-05 19:58:43
# @Last Modified by: klmp200
# @Last Modified time: 2016-11-05 20:02:41
# @Last Modified time: 2016-11-15 23:21:42
HOST = '0.0.0.0'
PORT = '8080'
DEBUG = True
ADMIN_PAGE_URL = '/admin'
# Loads custom settings
try:
......
......@@ -13,8 +13,8 @@
<div class="pure-u-22-24 pure-u-md-10-12 pure-u-sm-22-24">
<h1>Database administration</h1>
<h2>Recherche</h2>
<form class="pure-form" method="get" action="/admin">
Recherche par id :
<form class="pure-form" method="get" action="{{admin_url}}">
Recherche par id de produit :
<input type="text" name="id" value="{{form['id']}}"/>
Clef de vérification :
<input type="text" name="verifKey" value="{{form['verifKey']}}"/>
......@@ -94,7 +94,7 @@
"id": getUrlParameter('id'),
"verifKey": getUrlParameter('verifKey')
};
$.get("/admin/ajax", args).done(function(data){
$.get("{{admin_url}}/ajax", args).done(function(data){
var to_write = "";
data['data'].forEach(function(ticket){
to_write += "<tr>";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment