Beispiel #1
0
def catalog_xml(catalog):
    c = models.select_catalog(catalog)
    if c is not None:
        return utils.xml_response(utils.dict_to_xml('catalog', c.serialize),
                                  200)
    else:
        abort(404)
Beispiel #2
0
def catalog_page(catalog):
	c = models.select_catalog(catalog)
	if c is not None:
		return  render_template("catalog.html",
			catalog=catalog,
			items=models.select_items_by_catalog(c))
	else:
		abort(404)
Beispiel #3
0
def catalog_page(catalog):
    c = models.select_catalog(catalog)
    if c is not None:
        return render_template("catalog.html",
                               catalog=catalog,
                               items=models.select_items_by_catalog(c))
    else:
        abort(404)
Beispiel #4
0
def edit_catalog(catalog):
	if request.method == 'POST':
		c = models.select_catalog(catalog)
		if c is None:
			flash('Catalog does not exist!')
			return redirect('/')
		if c.created_user is None or c.created_user == login_session['uid']:
			models.update_catalog(c, request.form['name'])
			flash('Successfully updated catalog: ' + request.form['name'])
		else:
			flash('You are NOT authenticated to edit this catalog: ' + c.name)
		return redirect('/')
	else:
		c = models.select_catalog(catalog)
		if c.created_user is not None and c.created_user != login_session['uid']:
			flash('You are NOT authenticated to edit this catalog: ' + c.name)
			return redirect('/')
		return render_template('edit_catalog.html',
			catalog=models.select_catalog(catalog))
Beispiel #5
0
def del_catalog(catalog):
	c = models.select_catalog(catalog)
	if c is None:
		flash('Catalog does not exist!')
		return redirect('/')
	if c.created_user is None or c.created_user == login_session['uid']:
		models.delete_catalog(c)
		flash('Successfully deleted catalog: ' + c.name)
	else:
		flash('You are NOT authenticated to delete this catalog: ' + c.name)
	return redirect('/')
Beispiel #6
0
def edit_catalog(catalog):
    if request.method == 'POST':
        c = models.select_catalog(catalog)
        if c is None:
            flash('Catalog does not exist!')
            return redirect('/')
        if c.created_user is None or c.created_user == login_session['uid']:
            models.update_catalog(c, request.form['name'])
            flash('Successfully updated catalog: ' + request.form['name'])
        else:
            flash('You are NOT authenticated to edit this catalog: ' + c.name)
        return redirect('/')
    else:
        c = models.select_catalog(catalog)
        if c.created_user is not None and c.created_user !=\
           login_session['uid']:
            flash('You are NOT authenticated to edit this catalog: ' + c.name)
            return redirect('/')
        return render_template('edit_catalog.html',
                               catalog=models.select_catalog(catalog))
Beispiel #7
0
def del_catalog(catalog):
    c = models.select_catalog(catalog)
    if c is None:
        flash('Catalog does not exist!')
        return redirect('/')
    if c.created_user is None or c.created_user == login_session['uid']:
        models.delete_catalog(c)
        flash('Successfully deleted catalog: ' + c.name)
    else:
        flash('You are NOT authenticated to delete this catalog: ' + c.name)
    return redirect('/')
Beispiel #8
0
def new_item(catalog):
	if request.method == 'POST':
		c = models.select_catalog(catalog)
		if c is not None:
			image = None
			if 'image' in request.files:
				image = store_image(request.files['image'])
			models.insert_item(login_session['uid'], request.form['name'], c, request.form['description'], image)
			flash('Successfully created a new item: ' + request.form['name'])
		else:
			flash('Catalog does not exist!')
		return redirect('/')
	else:
		return render_template('new_item.html',
			catalog=catalog)
Beispiel #9
0
def new_item(catalog):
    if request.method == 'POST':
        c = models.select_catalog(catalog)
        if c is not None:
            image = None
            if 'image' in request.files:
                image = store_image(request.files['image'])
            models.insert_item(login_session['uid'], request.form['name'], c,
                               request.form['description'], image)
            flash('Successfully created a new item: ' + request.form['name'])
        else:
            flash('Catalog does not exist!')
        return redirect('/')
    else:
        return render_template('new_item.html', catalog=catalog)
Beispiel #10
0
def catalog_xml(catalog):
	c = models.select_catalog(catalog)
	if c is not None:
		return utils.xml_response(utils.dict_to_xml('catalog', c.serialize), 200)
	else:
		abort(404)
Beispiel #11
0
def catalog_json(catalog):
	c = models.select_catalog(catalog)
	if c is not None:
		return utils.json_response(c.serialize, 200)
	else:
		abort(404)
Beispiel #12
0
def catalog_json(catalog):
    c = models.select_catalog(catalog)
    if c is not None:
        return utils.json_response(c.serialize, 200)
    else:
        abort(404)