Example #1
0
    def get(self):
        template = JINJA_ENVIRONMENT.get_template(
            '/templates/publicArtPiece.html')

        itemNumber = self.request.get('itemNumber')
        artpiece = ArtPiece.query(ArtPiece.itemNumber == itemNumber).get()
        photo = File.query(File.key == artpiece.picture).get()
        artist = Artist.query(Artist.key == artpiece.artist).get()

        #create a comma separated string of categories
        categories = ndb.get_multi(artpiece.categories)
        categoryNamesList = []
        for category in categories:
            categoryNamesList.append(str(category.categoryName))
        categoriesString = ",".join(categoryNamesList)

        #check for additional sizes if this is a master or a slave piece
        additionalPieces = []
        if artpiece.masterArtFlag:
            slavePieces = ArtPiece.query(
                ArtPiece.masterArtPiece == artpiece.key)
            for slavepiece in slavePieces:
                additionalPieces.append(slavepiece)
        if artpiece.slaveArtFlag:
            masterArtPiece = ArtPiece.query(
                ArtPiece.key == artpiece.masterArtPiece).get()
            otherSlavePieces = ArtPiece.query(
                ArtPiece.masterArtPiece == masterArtPiece.key,
                ArtPiece.key <> artpiece.key)
            additionalPieces.append(masterArtPiece)
            for slavepiece in otherSlavePieces:
                additionalPieces.append(slavepiece)

        #generate the appropriate html to link to these other pieces if they exist
        additionalSizes = ""
        if len(additionalPieces) > 0:
            additionalSizes += "<h5>Also Available in Other Sizes:</h5><ul>"
            for additionalPiece in additionalPieces:
                additionalSizes += "<a href=\"/artpiece?itemNumber=" + additionalPiece.itemNumber + "\"><li>" + additionalPiece.name + " (" + additionalPiece.priceDisplay + ")</li></a>"
            additionalSizes += "</ul>"

        templateVars = {
            "title": artpiece.name,
            "additionalSizes": additionalSizes,
            "artpiece": artpiece,
            "artist": artist,
            "photo": photo,
            "categories": categoriesString
        }

        self.response.write(template.render(templateVars))
Example #2
0
 def get(self):
     allArt = ArtPiece.query()
     for art in allArt:
         artKey = art.key
         artpiece = ndb.get(artKey)
         artpiece.remove_from_search_index()
         artKey.delete()
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('/templates/publicArtPiece.html')

        itemNumber =  self.request.get('itemNumber')
        artpiece = ArtPiece.query(ArtPiece.itemNumber==itemNumber).get()
        photo = File.query(File.key==artpiece.picture).get()
        artist = Artist.query(Artist.key==artpiece.artist).get()

        #create a comma separated string of categories
        categories = ndb.get_multi(artpiece.categories)
        categoryNamesList = []
        for category in categories:
            categoryNamesList.append(str(category.categoryName))
        categoriesString = ",".join(categoryNamesList)

        #check for additional sizes if this is a master or a slave piece
        additionalPieces = []
        if artpiece.masterArtFlag:
            slavePieces=ArtPiece.query(ArtPiece.masterArtPiece==artpiece.key)
            for slavepiece in slavePieces:
                additionalPieces.append(slavepiece)
        if artpiece.slaveArtFlag:
            masterArtPiece = ArtPiece.query(ArtPiece.key==artpiece.masterArtPiece).get()
            otherSlavePieces=ArtPiece.query(ArtPiece.masterArtPiece==masterArtPiece.key,ArtPiece.key<>artpiece.key)
            additionalPieces.append(masterArtPiece)
            for slavepiece in otherSlavePieces:
                additionalPieces.append(slavepiece)

        #generate the appropriate html to link to these other pieces if they exist
        additionalSizes = ""
        if len(additionalPieces) > 0:
            additionalSizes += "<h5>Also Available in Other Sizes:</h5><ul>"
            for additionalPiece in additionalPieces:
                additionalSizes += "<a href=\"/artpiece?itemNumber=" + additionalPiece.itemNumber + "\"><li>" + additionalPiece.name + " (" + additionalPiece.priceDisplay + ")</li></a>"
            additionalSizes += "</ul>"

        templateVars = {
                        "title" : artpiece.name,
                        "additionalSizes": additionalSizes,
                        "artpiece": artpiece,
                        "artist": artist,
                        "photo": photo,
                        "categories": categoriesString}

        self.response.write(template.render(templateVars))
Example #4
0
    def post(self):
        artKeyString = self.request.get('deleteArtKey')

        #generate message
        artpiece = ArtPiece.get_by_id(int(artKeyString))
        artpiece.remove_from_search_index()
        message = "Successfully deleted artpiece: " + artpiece.name

        #delete category
        artpieceKey = artpiece.key
        artpieceKey.delete()

        self.response.write(message)
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('/templates/publicSearchResults.html')
        searchString =  self.request.get('searchString')

        matchingArt = []

        #search for Art that matches
        index = search.Index(name="ArtPiece_index")
        try:
            search_query = search.Query(
                query_string=searchString,
                options=search.QueryOptions(
                limit=100))
            results = index.search(search_query)
            # Iterate over the documents in the results
            for artpieceDocument in results:
                artpiece = ArtPiece.get_by_id(int(artpieceDocument.doc_id))
                matchingArt.append(artpiece)
        except search.Error:
            logging.exception('Search failed')


        #now generate the appropriate HTML for each result
        if len(matchingArt) > 0:
            matchingArtHTML = """<ul class="thumbnails">"""
            for artpiece in matchingArt:
                matchingArtHTML += "<a href=\"/artpiece?itemNumber=" + artpiece.itemNumber + """\">
                                        <li class="span3">
                                            <div class="thumbnail">
                                                <div class="thumbnailHolder"><img src=\"""" +  artpiece.picture.get().thumbnail + """\""></div>
                                                <div class="caption">
                                                    <div class="artpieceName"><h5>""" + artpiece.name + """</h5></div>
                                                    <p>""" + artpiece.priceDisplay + """</p>
                                                </div>
                                            </div>
                                        </li>
                                    </a>"""
            matchingArtHTML += "</ul>"

        else:
            matchingArtHTML="No matches found"


        templateVars = {
                        "title" : 'Search Results',
                        "matchingArt": matchingArtHTML,
                        "searchString": searchString
                       }

        self.response.write(template.render(templateVars))
Example #6
0
    def get(self):
        template = JINJA_ENVIRONMENT.get_template(
            '/templates/publicSearchResults.html')
        searchString = self.request.get('searchString')

        matchingArt = []

        #search for Art that matches
        index = search.Index(name="ArtPiece_index")
        try:
            search_query = search.Query(query_string=searchString,
                                        options=search.QueryOptions(limit=100))
            results = index.search(search_query)
            # Iterate over the documents in the results
            for artpieceDocument in results:
                artpiece = ArtPiece.get_by_id(int(artpieceDocument.doc_id))
                matchingArt.append(artpiece)
        except search.Error:
            logging.exception('Search failed')

        #now generate the appropriate HTML for each result
        if len(matchingArt) > 0:
            matchingArtHTML = """<ul class="thumbnails">"""
            for artpiece in matchingArt:
                matchingArtHTML += "<a href=\"/artpiece?itemNumber=" + artpiece.itemNumber + """\">
                                        <li class="span3">
                                            <div class="thumbnail">
                                                <div class="thumbnailHolder"><img src=\"""" + artpiece.picture.get(
                ).thumbnail + """\""></div>
                                                <div class="caption">
                                                    <div class="artpieceName"><h5>""" + artpiece.name + """</h5></div>
                                                    <p>""" + artpiece.priceDisplay + """</p>
                                                </div>
                                            </div>
                                        </li>
                                    </a>"""
            matchingArtHTML += "</ul>"

        else:
            matchingArtHTML = "No matches found"

        templateVars = {
            "title": 'Search Results',
            "matchingArt": matchingArtHTML,
            "searchString": searchString
        }

        self.response.write(template.render(templateVars))
Example #7
0
    def get(self):
        loginTitle = ""
        loginURL = ""
        user = users.get_current_user()
        if user:
            loginTitle = "logout"
            loginURL= users.create_logout_url('/')
        else:
            loginTitle = "login"
            loginURL= users.create_login_url('/')

        uploadURL = blobstore.create_upload_url('/admin/art/upload')
        categoriesList = {}
        masterItemNumberList = {}
        art = []

        #sort the art by artist name and then by artpiece name
        artists = Artist.query().order(Artist.firstName, Artist.lastName)
        for artist in artists:
            artistArt = ArtPiece.query().order(ArtPiece.name).filter(ArtPiece.artist==artist.key)
            for artpiece in artistArt:
                art.append(artpiece)

        for artpiece in art:
            #create a comma separated string of categories
            categoryNamesString = artpiece.categoryNames()
            categoriesList[artpiece.key] = categoryNamesString

            #check for null master art piece
            itemNumber = '' if artpiece.masterArtPiece is None else artpiece.masterArtPiece.get().itemNumber
            masterItemNumberList[artpiece.key] = itemNumber


        templateVars = {
                        "title" : "Manage Art",
                        "loginURL" : loginURL,
                        "loginTitle": loginTitle,
                        "art": art,
                        "categoriesList": categoriesList,
                        "masterItemNumberList": masterItemNumberList,
                        "uploadURL": uploadURL
                        }

        self.render_template("/templates/adminArt.html", templateVars)
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('/templates/publicArtistArt.html')

        artistID =  self.request.get('artistID')
        artist = Artist.get_by_id(int(artistID))
        artistKey = artist.key

        photos = {}
        art = ArtPiece.query(ArtPiece.artist==artistKey,ArtPiece.slaveArtFlag==False).order(ArtPiece.name)

        for artpiece in art:
            photos[artpiece.key] = artpiece.picture.get()

        templateVars = {
                        "title" : artist.firstName + " " + artist.lastName,
                        "artist": artist,
                        "art": art,
                        "photos": photos}

        self.response.write(template.render(templateVars))
Example #9
0
    def get(self):
        template = JINJA_ENVIRONMENT.get_template(
            '/templates/publicCategoryArt.html')

        categoryName = self.request.get('categoryName')
        category = Category.query(Category.categoryName == categoryName).get()
        categoryKey = category.key

        photos = {}
        artpieces = {}

        allArt = ArtPiece.query(ArtPiece.categories.IN([categoryKey]),
                                ArtPiece.slaveArtFlag == False)
        artistKeys = set([])
        for artpiece in allArt:
            #save the photo for this artipiece for later use
            photos[artpiece.key] = artpiece.picture.get()
            artistKeys.add(artpiece.artist)

        #get the list of artists who have art in this category
        artists = Artist.query(Artist.key.IN(list(artistKeys))).order(
            Artist.firstName, Artist.lastName)

        #create and save a list of artpieces for each artist that match this category
        for artist in artists:
            artistArt = []
            for artpiece in allArt:
                if artpiece.artist == artist.key:
                    artistArt.append(artpiece)
            artistArt.sort(key=lambda x: x.name)
            artpieces[artist.key] = artistArt

        templateVars = {
            "title": category.categoryName,
            "category": category,
            "artists": artists,
            "artpieces": artpieces,
            "photos": photos
        }

        self.response.write(template.render(templateVars))
Example #10
0
    def get(self):
        categoriesList = {}
        art = []

        #sort the art by artist name and then by artpiece name
        artists = Artist.query().order(Artist.firstName, Artist.lastName)
        for artist in artists:
            artistArt = ArtPiece.query().order(ArtPiece.name).filter(ArtPiece.artist==artist.key)
            for artpiece in artistArt:
                art.append(artpiece)

        for artpiece in art:
            categories = ndb.get_multi(artpiece.categories)
            categoryNamesList = []
            for category in categories:
                categoryNamesList.append(str(category.categoryName))
            categoryNamesString = ",".join(categoryNamesList)
            categoriesList[artpiece.key] = categoryNamesString
        html = ""
        for artpiece in art:
            html+="""<tr>
                        <td>""" + artpiece.artist.get().firstName  + " " +  artpiece.artist.get().lastName + """</td>
                        <td>""" + artpiece.name + """</td>
                        <td>""" + artpiece.itemNumber + """</td>
                        <td>""" + categoriesList[artpiece.key] + """</td>
                        <td>""" + artpiece.priceDisplay + """</td>
                        <td>
                            <a data-toggle="modal"  href="#editArtModal" onclick="fillEditArtModalDefaults(""" + str(artpiece.key.id()) + ",'" + artpiece.artist.get().firstName + " " + artpiece.artist.get().lastName + "', '" + categoriesList[artpiece.key] + "', '" + artpiece.name + "', '" + artpiece.price + "', '" + artpiece.itemNumber + "', '" + artpiece.width + "', '" + artpiece.height + "', '" + artpiece.depth + "', '" + artpiece.weight + "', '" + artpiece.description + "', '" + artpiece.colors + "', '" + artpiece.mediums + "', '" + ('' if artpiece.masterArtPiece is None else artpiece.masterArtPiece.get().itemNumber) + "', '" + artpiece.picture.get().file_name + """');" class="btn btn-medium">
                                <span class="glyphicon icon-edit"></span>
                            </a>
                            <a data-toggle="modal" data-id=\"""" + str(artpiece.key.id()) + """\" href="#deleteArtModal" class="open-deleteArtModal btn btn-medium">
                                <span class="glyphicon icon-remove"></span>
                            </a>
                        </td>
                    </tr>"""

        self.response.write(html)
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('/templates/publicCategoryArt.html')

        categoryName =  self.request.get('categoryName')
        category = Category.query(Category.categoryName==categoryName).get()
        categoryKey = category.key

        photos = {}
        artpieces = {}

        allArt = ArtPiece.query(ArtPiece.categories.IN([categoryKey]),ArtPiece.slaveArtFlag==False)
        artistKeys = set([])
        for artpiece in allArt:
            #save the photo for this artipiece for later use
            photos[artpiece.key] = artpiece.picture.get()
            artistKeys.add(artpiece.artist)

        #get the list of artists who have art in this category
        artists = Artist.query(Artist.key.IN(list(artistKeys))).order(Artist.firstName, Artist.lastName)

        #create and save a list of artpieces for each artist that match this category
        for artist in artists:
            artistArt = []
            for artpiece in allArt:
                if artpiece.artist==artist.key:
                    artistArt.append(artpiece)
            artistArt.sort(key=lambda x: x.name)
            artpieces[artist.key] = artistArt

        templateVars = {
                        "title" : category.categoryName,
                        "category": category,
                        "artists": artists,
                        "artpieces": artpieces,
                        "photos": photos}

        self.response.write(template.render(templateVars))
Example #12
0
    def get(self):
        template = JINJA_ENVIRONMENT.get_template(
            '/templates/publicArtistArt.html')

        artistID = self.request.get('artistID')
        artist = Artist.get_by_id(int(artistID))
        artistKey = artist.key

        photos = {}
        art = ArtPiece.query(ArtPiece.artist == artistKey,
                             ArtPiece.slaveArtFlag == False).order(
                                 ArtPiece.name)

        for artpiece in art:
            photos[artpiece.key] = artpiece.picture.get()

        templateVars = {
            "title": artist.firstName + " " + artist.lastName,
            "artist": artist,
            "art": art,
            "photos": photos
        }

        self.response.write(template.render(templateVars))
Example #13
0
    def post(self):
        artpieceKeyString = self.request.get('editArtKey')
        artpieceID = int(artpieceKeyString)
        artistString = self.request.get('editArtist')
        categoriesString = self.request.get('editCategories')
        name = self.request.get('editName')
        price = self.request.get('editPrice')
        priceDisplay = "$" + '{:20,.2f}'.format(Decimal(price))
        itemNumber = self.request.get('editItemNumber')
        width = self.request.get('editWidth')
        height = self.request.get('editHeight')
        depth = self.request.get('editDepth')
        weight = self.request.get('editWeight')
        description = self.request.get('editProductDescription')
        colors = self.request.get('editColors')
        mediums = self.request.get('editMediums')
        masterItemNum = self.request.get('editMasterArtNum')
        pictureName = self.request.get('editProductPhotoName')

        #find related objects to tie to this artpiece
        artistNameList=artistString.split(" ")
        artistFirstName=artistNameList[0]
        artistLastName=artistNameList[-1]
        artist = Artist.query(Artist.firstName==artistFirstName, Artist.lastName==artistLastName).get()
        categories = []
        categoriesList = categoriesString.split(",")
        for categoryString in categoriesList:
            category = Category.query(Category.categoryName==categoryString.strip()).get()
            categories.append(category)
        masterArtPiece = ArtPiece.query(ArtPiece.itemNumber==masterItemNum).get()
        photo = File.query(File.file_name==pictureName.upper()).get()

        #get the artpiece based on the key and update all fields accordingly
        artpiece = ArtPiece.get_by_id(artpieceID)

        artpiece.artist = artist.key
        artpiece.categories = []
        for category in categories:
            artpiece.categories.append(category.key)
        artpiece.colors = colors
        artpiece.depth = depth
        artpiece.description = description
        artpiece.height = height
        artpiece.itemNumber = itemNumber
        if masterArtPiece:
            artpiece.masterArtPiece = masterArtPiece.key
            artpiece.slaveArtFlag = True
            masterArtPiece.masterArtFlag = True
            masterArtPiece.put()
        artpiece.mediums = mediums
        artpiece.name = name
        artpiece.picture = photo.key
        artpiece.price = price
        artpiece.priceDisplay = priceDisplay
        artpiece.uploaded_by=users.get_current_user()
        artpiece.weight = weight
        artpiece.width = width

        artpiece.put()
        artpiece.add_to_search_index()

        message = "Successfully updated artpiece record: " + artpiece.name
        self.response.write(message)
Example #14
0
    def post(self):
        blob_info = self.get_uploads()[0]

        #only act on the file if it is a .csv, .xls, or .xlsx file type
        if blob_info.content_type == "application/vnd.ms-excel" or blob_info.content_type == ".csv" or blob_info.content_type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
            blobdata=blobstore.BlobReader(blob_info)
            reader = csv.DictReader(blobdata,dialect='excel')
            self.response.headers['Content-Type'] = 'text/plain'
            message = ""
            editedMessage = ""
            createdMessage = ""

            for row in reader:
                artistString = row["Artist"]
                categoriesString = row["Categories"]
                name = row["Name of Piece"]
                price = row["Price($)"]
                priceDisplay = "$" + '{:20,.2f}'.format(Decimal(price))
                itemNumber = row["Item Number"]
                height = row["Height(in)"]
                depth = row["Depth(in)"]
                weight = row["Weight"]
                width = row["Width(in)"]
                description = row["Product Description"]
                colors = row["Colors"]
                mediums = row["Mediums"]
                masterItemNum = row["Master Art Piece (Item Number)"]
                pictureName = row ["Picture Name"]

                #find related objects to tie to this artpiece
                artistNameList=artistString.split(" ")
                artistFirstName=artistNameList[0]
                artistLastName=artistNameList[-1]
                artist = Artist.query(Artist.firstName==artistFirstName, Artist.lastName==artistLastName).get()
                categories = []
                categoriesList = categoriesString.split(",")
                for categoryString in categoriesList:
                    category = Category.query(Category.categoryName==categoryString.strip()).get()
                    categories.append(category)
                masterArtPiece = ArtPiece.query(ArtPiece.itemNumber==masterItemNum).get()
                photo = File.query(File.file_name==pictureName.upper()).get()

                #check if artpiece with this item number already exists
                existingArtPiece = ArtPiece.query(ArtPiece.itemNumber==itemNumber).get()

                if existingArtPiece:
                    #if an artpiece with that itemNumber is already stored then update the record with the new information
                    existingArtPiece.artist = artist.key
                    existingArtPiece.categories = []
                    for category in categories:
                        existingArtPiece.categories.append(category.key)
                    existingArtPiece.colors = colors
                    existingArtPiece.depth = depth
                    existingArtPiece.description = description
                    existingArtPiece.height = height
                    if masterArtPiece:
                        existingArtPiece.masterArtPiece = masterArtPiece.key
                        existingArtPiece.slaveArtFlag = True
                        masterArtPiece.masterArtFlag = True
                        masterArtPiece.put()
                    existingArtPiece.mediums = mediums
                    existingArtPiece.name = name
                    existingArtPiece.picture = photo.key
                    existingArtPiece.price = price
                    existingArtPiece.priceDisplay = priceDisplay
                    existingArtPiece.uploaded_by=users.get_current_user()
                    existingArtPiece.weight = weight
                    existingArtPiece.width = width

                    existingArtPiece.put()
                    existingArtPiece.add_to_search_index()

                    editedMessage += "<br>" + existingArtPiece.name

                else:
                    #otherwise create a new record for the artpiece
                    artPiece = ArtPiece(artist=artist.key, colors=colors, depth=depth, description=description, height=height, itemNumber=itemNumber, mediums=mediums, name=name, picture=photo.key, price=price, priceDisplay=priceDisplay, weight=weight, width=width, uploaded_by=users.get_current_user())
                    for category in categories:
                        artPiece.categories.append(category.key)
                    if masterArtPiece:
                        artPiece.masterArtPiece = masterArtPiece.key
                        artPiece.slaveArtFlag = True
                        masterArtPiece.masterArtFlag = True
                        masterArtPiece.put()

                    artPiece.put()
                    artPiece.add_to_search_index()

                    createdMessage += "<br>" + artPiece.name



            #no need to save the file in the blobstore
            blob_info.delete()

            message = "The following items were added to the database: <br>"
            message += createdMessage + "<br><br>"
            message+= "The following items were updated in the database: <br>"
            message += editedMessage

            self.response.write(message)
    def post(self):
        for blob_info in self.get_uploads():
            if not users.get_current_user():
                #if they are not logged in then delete all the upload data and redirect them to login
                for blob in self.get_uploads():
                    blob.delete()
                self.redirect(users.create_login_url("/"))
                return

            #if uploading a csv file, update the datastore to match records in file
            if blob_info.content_type == "application/vnd.ms-excel":
                blobdata=blobstore.BlobReader(blob_info)
                reader = csv.DictReader(blobdata,dialect='excel')
                self.response.headers['Content-Type'] = 'text/plain'

                for row in reader:
                    artist = row["Artist"]
                    categories = row["Categories"]
                    name = row["Name of Piece"]
                    price = row["Price($)"]
                    itemNumber = row["Item Number"]
                    width = row["Width(in)"]
                    height = row["Height(in)"]
                    depth = row["Depth(in)"]
                    weight = row["Weight"]
                    width = row["Width(in)"]
                    description = row["Product Description"]
                    colors = row["Colors"]
                    mediums = row["Mediums"]
                    masterNum = row["Master Art Piece (Item Number)"]
                    pictureName = row ["Picture Name"]

                    #check if artpiece with this item number already exists
                    qry = ArtPiece.query(ArtPiece.itemNumber==itemNumber)
                    existingArtPiece = qry.get()

                    #if existingArtPiece:
                        #if an artpiece with that itemNumber is already stored then update the record with the new information


                #delete and skip to the next file, we don't save excel files nor do we perform photo related code
                blob_info.delete()
                continue

            #otherwise we assume it is a photo (since it only allows jpg, png, gif, and csv)
            else:
                #check to see if a photo with that name already exists
                qry = File.query(File.file_name==blob_info.filename.upper())
                existingPhoto = qry.get()

                if existingPhoto:
                    #if a file with that name is already stored then replace the blob with the new uploaded file
                    blobstore.delete(existingPhoto.blob)
                    existingPhoto.blob = blob_info.key()
                    existingPhoto.uploaded_by=users.get_current_user()
                    existingPhoto.thumbnail=images.get_serving_url(blob_info.key(), size=200)
                    existingPhoto.url=images.get_serving_url(blob_info.key())

                    existingPhoto.put()
                else:
                    #add a new file entry if no file with that name already exists
                    file = File(blob=blob_info.key(), file_name=blob_info.filename.upper(), uploaded_by=users.get_current_user(), url=images.get_serving_url(blob_info.key()), thumbnail=images.get_serving_url(blob_info.key(), size=200))
                    file.put()

                self.redirect("/admin/photos/%s/success" % blob_info.key())
    def post(self):
        for blob_info in self.get_uploads():
            if not users.get_current_user():
                #if they are not logged in then delete all the upload data and redirect them to login
                for blob in self.get_uploads():
                    blob.delete()
                self.redirect(users.create_login_url("/"))
                return

            #if uploading a csv file, update the datastore to match records in file
            if blob_info.content_type == "application/vnd.ms-excel":
                blobdata = blobstore.BlobReader(blob_info)
                reader = csv.DictReader(blobdata, dialect='excel')
                self.response.headers['Content-Type'] = 'text/plain'

                for row in reader:
                    artist = row["Artist"]
                    categories = row["Categories"]
                    name = row["Name of Piece"]
                    price = row["Price($)"]
                    itemNumber = row["Item Number"]
                    width = row["Width(in)"]
                    height = row["Height(in)"]
                    depth = row["Depth(in)"]
                    weight = row["Weight"]
                    width = row["Width(in)"]
                    description = row["Product Description"]
                    colors = row["Colors"]
                    mediums = row["Mediums"]
                    masterNum = row["Master Art Piece (Item Number)"]
                    pictureName = row["Picture Name"]

                    #check if artpiece with this item number already exists
                    qry = ArtPiece.query(ArtPiece.itemNumber == itemNumber)
                    existingArtPiece = qry.get()

                    #if existingArtPiece:
                    #if an artpiece with that itemNumber is already stored then update the record with the new information

                #delete and skip to the next file, we don't save excel files nor do we perform photo related code
                blob_info.delete()
                continue

            #otherwise we assume it is a photo (since it only allows jpg, png, gif, and csv)
            else:
                #check to see if a photo with that name already exists
                qry = File.query(File.file_name == blob_info.filename.upper())
                existingPhoto = qry.get()

                if existingPhoto:
                    #if a file with that name is already stored then replace the blob with the new uploaded file
                    blobstore.delete(existingPhoto.blob)
                    existingPhoto.blob = blob_info.key()
                    existingPhoto.uploaded_by = users.get_current_user()
                    existingPhoto.thumbnail = images.get_serving_url(
                        blob_info.key(), size=200)
                    existingPhoto.url = images.get_serving_url(blob_info.key())

                    existingPhoto.put()
                else:
                    #add a new file entry if no file with that name already exists
                    file = File(blob=blob_info.key(),
                                file_name=blob_info.filename.upper(),
                                uploaded_by=users.get_current_user(),
                                url=images.get_serving_url(blob_info.key()),
                                thumbnail=images.get_serving_url(
                                    blob_info.key(), size=200))
                    file.put()

                self.redirect("/admin/photos/%s/success" % blob_info.key())