Esempio n. 1
0
def create_event():
    charge_types = api.list(ChargeType)
    locations = api.list(EventLocation)
    event_types = api.list(EventType)

    data = {
        "event_types": event_types,
        "charge_types": charge_types,
        "locations": locations
    }

    return render_template("event/view.html", **data)
Esempio n. 2
0
def list_charge_type():
    items = api.list(ChargeType, False)
    
    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("charge_type/list.html", items=items)
Esempio n. 3
0
def list_weather():
    items = api.list(WeatherCondition, False)

    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("weather/list.html", items=items)
Esempio n. 4
0
def list_event_role():
    items = api.list(EventRole, False)

    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("event_role/list.html", items=items)
Esempio n. 5
0
def newbook():
    form = UploadBookForm()

    if 'email' not in session:
        return redirect(url_for('auth.signin'))

    if request.method == 'POST':
        uid = db.session.query(User.user_id).filter(User.email == session['email']).scalar()

        isbnImg = "isbn" + str(form.isbn.data)
        image = api.list(isbnImg)

        sThumbnail = image['items'][0]['volumeInfo']['imageLinks']['smallThumbnail']
        lThumbnail = image['items'][0]['volumeInfo']['imageLinks']['thumbnail']

        book = Book(isbn=form.isbn.data, title=form.title.data, volume=form.volume.data,
                    author=form.author.data, publisher=form.publisher.data, year=form.year.data,
                    subject=form.subject.data, user_id=uid, smallThumbnail=sThumbnail,
                    largeThumbnail=lThumbnail)
        db.session.add(book)
        db.session.commit()

        auction = Auction(book_id=book.book_id, start_time=datetime.now(), end_time=form.endDate.data)
        db.session.add(auction)
        db.session.commit()

        return redirect(url_for('member.profile'))

    elif request.method == 'GET':
        return render_template('member/newbook.html', form=form)
Esempio n. 6
0
def list_location():
    items = api.list(EventLocation, False)

    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("location/list.html", items=items)
Esempio n. 7
0
def list_user():
    items = api.list(User, False)

    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("user/list.html", items=items)
Esempio n. 8
0
def list_partnership():
    items = api.list(Partnership, False)
    
    if not items and api.erred:
        Alert.bad(api.error)

    return render_template("partnership/list.html", items=items)
Esempio n. 9
0
def view_event(id):
    item = api.get(Event, id)

    charge_types = api.list(ChargeType)
    locations = api.list(EventLocation)
    event_types = api.list(EventType)
    
    if not item:
        Alert.bad("Could not find <strong>Event</strong> {}".format(id))
        return redirect("/events/")
    
    data = {
        "id": id,
        "name": item.name,
        "description": item.description,
        "event_types": event_types,
        "charge_types": charge_types,
        "locations": locations
    }

    return render_template("event/view.html", **data)
Esempio n. 10
0
def view_event_type(id):
    item = api.get(EventType, id)
    
    if not item:
        Alert.bad("Could not find <strong>Event Type</strong> {}".format(id))
        return redirect("/eventtypes/")
    
    charge_types = api.list(ChargeType)

    data = {
        "id": id,
        "name": item.name,
        "description": item.description,
        "charge_types": charge_types,
        "defaultchargetype": item.default_charge_type_id
    }

    return render_template("event_type/view.html", **data)
Esempio n. 11
0
def newbook():
    form = UploadBookForm()

    if 'email' not in session:
        return redirect(url_for('auth.signin'))

    if request.method == 'POST':
        uid = db.session.query(
            User.user_id).filter(User.email == session['email']).scalar()

        isbnImg = "isbn" + str(form.isbn.data)
        image = api.list(isbnImg)

        sThumbnail = image['items'][0]['volumeInfo']['imageLinks'][
            'smallThumbnail']
        lThumbnail = image['items'][0]['volumeInfo']['imageLinks']['thumbnail']

        book = Book(isbn=form.isbn.data,
                    title=form.title.data,
                    volume=form.volume.data,
                    author=form.author.data,
                    publisher=form.publisher.data,
                    year=form.year.data,
                    subject=form.subject.data,
                    user_id=uid,
                    smallThumbnail=sThumbnail,
                    largeThumbnail=lThumbnail)
        db.session.add(book)
        db.session.commit()

        auction = Auction(book_id=book.book_id,
                          start_time=datetime.now(),
                          end_time=form.endDate.data)
        db.session.add(auction)
        db.session.commit()

        return redirect(url_for('member.profile'))

    elif request.method == 'GET':
        return render_template('member/newbook.html', form=form)
Esempio n. 12
0
def create_event_type():
    charge_types = api.list(ChargeType)
    return render_template("event_type/view.html", charge_types=charge_types)