def test_artwork_create(self): dbArtwork = Artwork.query.filter( Artwork.name == 'ooblegoogleboogleshrooodlepoodle').first() if dbArtwork: db.session.delete(dbArtwork) db.session.commit() artwork = Artwork(16, 'ooblegoogleboogleshrooodlepoodle', 22, styleId='1', description='Something', typeId='1', mediumId=1, supportTypeId=1, height='22', width='33', framed=1) db.session.add(artwork) db.session.commit() dbArtwork = Artwork.query.filter( Artwork.name == 'ooblegoogleboogleshrooodlepoodle').first() assert dbArtwork db.session.delete(artwork) db.session.commit() dbArtwork = Artwork.query.filter( Artwork.name == 'ooblegoogleboogleshrooodlepoodle').first() assert dbArtwork == None
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 validate(self): rv = Form.validate(self) self.rv = rv if not rv: return False self.artwork = Artwork(current_user.id, self.title.data, self.cost.data, styleId=self.style.data, supportTypeId=self.support_type.data, typeId=self.type.data, height=self.height.data, width=self.width.data, mediumId=self.medium.data, framed=self.framed.data, description=self.description.data) self.artwork.is_reviewd = app.config['DEBUG'] try: db.session.add(self.artwork) db.session.commit() except IntegrityError as e: db.session.rollback() app.logger.debug(e) return False return True
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 _browse(): type = request.args.get('type', -1, type=int) medium = request.args.get('medium', -1, type=int) art = Artwork.reviewedArt().all() return jsonify(arts=[a.json() for a in art])
def home(): artwork = Artwork.reviewedArt().order_by( Artwork.created_on).limit(10).all() return render_template('home.html', recentArtwork=artwork)
def home(): artwork = Artwork.reviewedArt().order_by(Artwork.created_on).limit(10).all() return render_template('home.html', recentArtwork = artwork)