예제 #1
0
	if (not _check_flood_protect(params['ip'][0])):
		return (False, '')
	if 'username' not in params or 'password' not in params:
		return (False,'')
	
	try:
		q = Query('SELECT gebr_id, gebr_wachtwoord FROM tblgebruiker WHERE gebr_naam = %s')
		q.run((params['username'][0],))
		results = q.rows()
	except DatabaseError:
		raise InternalServerError
	
	if (len(results) != 1):
		_add_flood_protect(params['ip'][0])
		return (False,'')
	if not sha512_crypt.verify(params['password'][0], results[0][1]):
		_add_flood_protect(params['ip'][0])
		return (False,'')
	
	#Generate session key
	session_key = _create_session(params['ip'][0], results[0][0])
	
	return (True, session_key)


add_handler("/login", handle_login)
add_handler("/users", handle_users)
add_handler("/setpassword", handle_setpassword)
add_handler("/adduser", handle_adduser)
log.info("User module initialized.")
예제 #2
0
		})
	
	return ver_overview

def handle_verenigingen(params, json_data):
	try:
		q = Query("""SELECT ver_id, ver_naam, ver_email, ver_basis_budget_id 
		             FROM tblvereniging""")
		q.run();
		rows = q.rows()
	except DatabaseError:
		raise InternalServerError
	
	ver_overview = []
	
	for row in rows:
		if not hasPermission(params, 'vereniging', row[0]):
			continue
		
		ver_overview.append({
			'id': row[0],
			'naam': row[1],
			'email': row[2],
			'basis_budget': row[3]
		})
	
	return ver_overview

add_handler('/verenigingen', handle_verenigingen)
log.info('Vereniging module initialized')
예제 #3
0
import logging
from madmin_server import InternalServerError, add_handler
from madmin_db import Query, DatabaseError

log = logging.getLogger(__name__)

def handle_barcodes(params, json_data):
	try:
		log.debug("Fetching barcode table.")
		q = Query("SELECT bar_ean, bar_prd_id FROM tblbarcode")
		q.run()
		log.debug("Fetching rows.")
		rows = q.rows()
		log.debug("Rows: %s", rows)
		return rows
	except DatabaseError:
		raise InternalServerError

add_handler("/barcodes", handle_barcodes)
log.info("Barcode module initialized.")
예제 #4
0
                                         prd_emballageprijs
                                  FROM tblproduct WHERE prd_verwijderd = 0
                                  AND prd_id = %s
                                  ORDER BY prd_id""")
        q_rel = Query("""SELECT prdrel_orig_prd_id, prdrel_rel_prd_id,
                                    prdrel_aantal
                             FROM tblproductrelation
                             WHERE prdrel_orig_prd_id = %s
                             ORDER BY prdrel_orig_prd_id""")
    except DatabaseError:
        raise InternalServerError

    for prd_id in params['product_id']:
        try:
            q_prod.run((prd_id,))
            rows_prod = q_prod.rows()

            q_rel.run((prd_id,))
            rows_rel = q_rel.rows()
        except DatabaseError:
            raise InternalServerError

        result += _convert_product_rows(rows_prod, rows_rel)

    return result

add_handler('/product/kantine', handle_kantine)
add_handler('/product/all', handle_product_all)
add_handler('/product', handle_product)
log.info("Product module initialized.")
예제 #5
0
            raise InternalServerError
            # Try to think up a way of making this more robust against partial execution of query

        i += 1

    return result

def _convert_datum(voorraad_el):
    voorraad_el['datum'] = str(voorraad_el['datum'])
    return voorraad_el

def handle_voorraad(params, json_data):
    if 'product_id' not in params:
        return []
    if not hasPermission(params, 'voorraad', None):
        return []

    result = []
    for prd_id in params['product_id']:
        voorraad = query_voorraad(prd_id)
        voorraad = map(_convert_datum, voorraad)
        result.append({
                'id': prd_id,
                'voorraad': voorraad
        })

    return result

add_handler('/voorraad', handle_voorraad)
log.info("Module voorraad initialized")
예제 #6
0
		             frgl_stukprijs, frgl_totprijs, frgl_btw, vrd_prd_id
		             FROM tblfactuur
		             LEFT JOIN tblfactuurregel ON fac_id = frgl_fac_id
		             LEFT JOIN tblvoorraad on frgl_vrd_id = vrd_id
		             LEFT JOIN tblproduct on vrd_prd_id = prd_id
		             WHERE fac_id = %s
		             ORDER BY fac_id""")
	except DatabaseError:
		raise InternalServerError
	
	result = []
	
	for fac_id in params['factuur_id']:
		try:
			q.run((fac_id,))
			regels = q.rows()
		except DatabaseError:
			raise InternalServerError
		
		result.extend(convert_factuur_rows(params, regels))
	
	return result



add_handler('/factuur', handle_factuur)
add_handler('/factuur/create', handle_factuur_create)
add_handler('/factuur/vereniging', handle_factuur_vereniging)
add_handler('/factuur/leverancier', handle_factuur_leverancier)
log.info("Factuur module initialized.")
예제 #7
0
		             frgl_type, prd_naam, frgl_omschrijving, frgl_aantal,
		             frgl_stukprijs, frgl_totprijs, frgl_btw, vrd_prd_id
		             FROM tblfactuur
		             LEFT JOIN tblfactuurregel ON fac_id = frgl_fac_id
		             LEFT JOIN tblvoorraad on frgl_vrd_id = vrd_id
		             LEFT JOIN tblproduct on vrd_prd_id = prd_id
		             WHERE fac_id = %s
		             ORDER BY fac_id""")
    except DatabaseError:
        raise InternalServerError

    result = []

    for fac_id in params['factuur_id']:
        try:
            q.run((fac_id, ))
            regels = q.rows()
        except DatabaseError:
            raise InternalServerError

        result.extend(convert_factuur_rows(params, regels))

    return result


add_handler('/factuur', handle_factuur)
add_handler('/factuur/create', handle_factuur_create)
add_handler('/factuur/vereniging', handle_factuur_vereniging)
add_handler('/factuur/leverancier', handle_factuur_leverancier)
log.info("Factuur module initialized.")
예제 #8
0
def budget_vereniging_query(vereniging_id):
    try:
        q = Query('SELECT bdgt_id FROM tblbudget WHERE bdgt_ver_id = %s')
        q.run((vereniging_id, ))
        result = q.rows()
    except DatabaseError:
        raise InternalServerError

    budget_ids = []

    for row in result:
        budget_ids.append(result[0][0])

    return budget_ids


def budget_update(budget_id, value_change):
    try:
        q = Query(
            'UPDATE tblbudget SET bdgt_current = bdgt_current + %s WHERE bdgt_id = %s'
        )
        q.run((value_change, budget_id))
    except DatabaseError:
        raise InternalServerError


add_handler('/budget', handle_budget)
add_handler('/budget/vereniging', handle_budget_vereniging)
log.info("Budget module initialized")
예제 #9
0
    return ver_overview


def handle_verenigingen(params, json_data):
    try:
        q = Query("""SELECT ver_id, ver_naam, ver_email, ver_basis_budget_id 
		             FROM tblvereniging""")
        q.run()
        rows = q.rows()
    except DatabaseError:
        raise InternalServerError

    ver_overview = []

    for row in rows:
        if not hasPermission(params, 'vereniging', row[0]):
            continue

        ver_overview.append({
            'id': row[0],
            'naam': row[1],
            'email': row[2],
            'basis_budget': row[3]
        })

    return ver_overview


add_handler('/verenigingen', handle_verenigingen)
log.info('Vereniging module initialized')
예제 #10
0
			'naam': row[4]
		})
	
	return result

def budget_vereniging_query(vereniging_id):
	try:
		q = Query('SELECT bdgt_id FROM tblbudget WHERE bdgt_ver_id = %s')
		q.run((vereniging_id,))
		result = q.rows()
	except DatabaseError:
		raise InternalServerError
	
	budget_ids = []
	
	for row in result:
		budget_ids.append(result[0][0])
	
	return budget_ids

def budget_update(budget_id, value_change):
	try:
		q = Query('UPDATE tblbudget SET bdgt_current = bdgt_current + %s WHERE bdgt_id = %s')
		q.run((value_change, budget_id))
	except DatabaseError:
		raise InternalServerError

add_handler('/budget', handle_budget)
add_handler('/budget/vereniging', handle_budget_vereniging)
log.info("Budget module initialized")
예제 #11
0
    if 'username' not in params or 'password' not in params:
        return (False, '')

    try:
        q = Query(
            'SELECT gebr_id, gebr_wachtwoord FROM tblgebruiker WHERE gebr_naam = %s'
        )
        q.run((params['username'][0], ))
        results = q.rows()
    except DatabaseError:
        raise InternalServerError

    if (len(results) != 1):
        _add_flood_protect(params['ip'][0])
        return (False, '')
    if not sha512_crypt.verify(params['password'][0], results[0][1]):
        _add_flood_protect(params['ip'][0])
        return (False, '')

    #Generate session key
    session_key = _create_session(params['ip'][0], results[0][0])

    return (True, session_key)


add_handler("/login", handle_login)
add_handler("/users", handle_users)
add_handler("/setpassword", handle_setpassword)
add_handler("/adduser", handle_adduser)
log.info("User module initialized.")
예제 #12
0
import logging
from madmin_server import InternalServerError, add_handler
from madmin_db import Query, DatabaseError

log = logging.getLogger(__name__)

def handle_barcodes(params, json_data):
    try:
        log.debug("Fetching barcode table.")
        q = Query("SELECT bar_ean, bar_prd_id FROM tblbarcode")
        q.run()
        log.debug("Fetching rows.")
        rows = q.rows()
        log.debug("Rows: %s", rows)
        return rows
    except DatabaseError:
        raise InternalServerError

add_handler("/barcodes", handle_barcodes)
log.info("Barcode module initialized.")