def browse(): start = time.time() filterType = utils.intOrNone(request.args.get('type', None)) filterMedium = utils.intOrNone(request.args.get('medium', None)) mediums = Medium.all() styles = Style.all() types = Type.all() supports = Support.all() baseQuery = Artwork.reviewedArt().order_by(Artwork.created_on) if filterType: baseQuery = baseQuery.filter(Artwork.type == filterType) if filterMedium: baseQuery = baseQuery.filter(Artwork.medium == filterMedium) artwork = baseQuery.all() app.logger.debug('Queries took: %fs' % (time.time() - start)) return render_template('browse.html', artwork=artwork, numArts=len(artwork), mediums=mediums, styles=styles, types=types, supports=supports, filterType=filterType, filterMedium=filterMedium)
def upload(): errors = None if request.method == 'POST': uploadForm = UploadForm(request.form, csrf_enabled=False) try: if uploadForm.validate_on_submit(): app.logger.debug('validated') if utils.uploadArtwork(uploadForm.artwork, uploadForm.artworkImage.data): return redirect(uploadForm.artwork.link) else: flash( 'There was an error uploading your image, please try again' ) else: app.logger.debug('failed to validate:<%s>' % uploadForm.errors) except ValueError as ve: errors = ['%s' % ve] mediums = Medium.all() styles = Style.all() types = Type.all() supports = Support.all() return render_template('uploadNew.html', mediums=mediums, styles=styles, types=types, supports=supports, errors=errors)
def browse(): start = time.time() filterType = utils.intOrNone(request.args.get('type',None)) filterMedium = utils.intOrNone(request.args.get('medium',None)) mediums = Medium.all() styles = Style.all() types = Type.all() supports = Support.all() baseQuery = Artwork.reviewedArt().order_by(Artwork.created_on) if filterType: baseQuery = baseQuery.filter(Artwork.type == filterType) if filterMedium: baseQuery = baseQuery.filter(Artwork.medium == filterMedium) artwork = baseQuery.all() app.logger.debug('Queries took: %fs' % (time.time() - start) ) return render_template('browse.html', artwork=artwork, numArts = len(artwork), mediums=mediums,styles=styles,types=types,supports=supports, filterType=filterType, filterMedium=filterMedium)
def upload(): errors = None if request.method == 'POST': uploadForm = UploadForm(request.form, csrf_enabled=False) try: if uploadForm.validate_on_submit(): app.logger.debug('validated') if utils.uploadArtwork(uploadForm.artwork,uploadForm.artworkImage.data): return redirect(uploadForm.artwork.link) else: flash('There was an error uploading your image, please try again') else: app.logger.debug('failed to validate:<%s>'%uploadForm.errors) except ValueError as ve: errors=['%s'%ve] mediums = Medium.all() styles = Style.all() types = Type.all() supports = Support.all() return render_template('uploadNew.html', mediums=mediums,styles=styles,types=types,supports=supports, errors=errors)