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('/')

        photos = {}
        categories = Category.query().order(Category.categoryName)

        for category in categories:
            photos[category.key] = category.picture.get()

        templateVars = {
            "title": "Manage Categories",
            "loginURL": loginURL,
            "loginTitle": loginTitle,
            "categories": categories,
            "photos": photos
        }

        self.render_template("/templates/adminCategories.html", templateVars)
Beispiel #2
0
    def post(self):
        show = Show()
        # show.key=ndb.Key('Show', int(request.form['id']))
        show.event_id = ndb.Key('Event', int(request.form['event_id']))
        show.client_id = ndb.Key('Client', int(request.form['client_id']))
        show.screen_id = ndb.Key('Screen_Layout', int(request.form['screen_id']))
        show.name = request.form['name']
        show.datetime = datetime.datetime.now()
        screen = ndb.Key('Screen_Layout', int(request.form['screen_id']))
        seats = screen.get().seats
        print type(seats)
        updated_seats = {}
        for each in seats:
            updated_seats[str(each['row'])+'-'+str(each['column'])]= {'status':4}
        show.seats = updated_seats
        res = show.put()

        # The below paragraph should be deleted later
        offset_id = 21
        prices = []
        print show.screen_id
        categories = Category.query(Category.screen_id == show.screen_id).fetch()
        for category in categories:
            price1 = Price(id=show.key.id() + offset_id, show_id=show.key, category_id=category.key, amount=500)
            offset_id += 1
            prices.append(price1)
        print "###"
        print prices
        for price in prices:
            price.put()

        # The above paragraph should be deleted later

        return jsonify({'id': res.id(), 'message': "Success"})
    def post(self):
        categoryName = self.request.get('categoryName')
        photoName = self.request.get('photoName')

        #get the photo specified by the user
        photo = File.query(File.file_name==photoName.upper()).get()

        #check to see if a category with that name already exists
        existingCategory = Category.query(Category.categoryName==categoryName).get()

        if existingCategory:
            #if an category with that name already exists, then update the information with the form data
            existingCategory.categoryName=categoryName
            existingCategory.picture=photo.key
            existingCategory.uploaded_by=users.get_current_user()

            existingCategory.put()
            existingCategory.add_to_search_index()
            message = "Successfully updated category record: " + existingCategory.categoryName

        else:
            #add a new category entry if no category with that name already exists
            category = Category(categoryName=categoryName, picture=photo.key, uploaded_by=users.get_current_user())
            category.put()
            category.add_to_search_index()
            message = "Successfully created category record: " + category.categoryName

        self.response.write(message)
    def get(self):
        photos = {}
        categories = Category.query().order(Category.categoryName)

        for category in categories:
            photos[category.key] = category.picture.get()
        html = ""
        for category in categories:
            html += """<tr>
                        <td>""" + category.categoryName + """</td>
                        <td>""" + photos[category.key].file_name + """</td>
                        <td>
                            <a data-toggle="modal"  href="#editCategoryModal" onclick="fillCategoryEditModalDefaults(""" + str(
                category.key.id()
            ) + ", '" + category.categoryName + "', '" + photos[
                category.key].file_name + """');" class="btn btn-medium">
                                <span class="glyphicon icon-edit"></span>
                            </a>
                            <a data-toggle="modal" data-id=\"""" + str(
                    category.key.id()
                ) + """\" href="#deleteCategoryModal" class="open-deleteCategoryModal btn btn-medium">
                                <span class="glyphicon icon-remove"></span>
                            </a>
                        </td>
                    </tr>"""

        self.response.write(html)
    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('/')

        photos = {}
        categories = Category.query().order(Category.categoryName)

        for category in categories:
            photos[category.key] = category.picture.get()

        templateVars = {
                        "title" : "Manage Categories",
                        "loginURL" : loginURL,
                        "loginTitle": loginTitle,
                        "categories": categories,
                        "photos": photos
                        }

        self.render_template("/templates/adminCategories.html", templateVars)
    def post(self):
        categoryName = self.request.get('categoryName')
        photoName = self.request.get('photoName')

        #get the photo specified by the user
        photo = File.query(File.file_name == photoName.upper()).get()

        #check to see if a category with that name already exists
        existingCategory = Category.query(
            Category.categoryName == categoryName).get()

        if existingCategory:
            #if an category with that name already exists, then update the information with the form data
            existingCategory.categoryName = categoryName
            existingCategory.picture = photo.key
            existingCategory.uploaded_by = users.get_current_user()

            existingCategory.put()
            existingCategory.add_to_search_index()
            message = "Successfully updated category record: " + existingCategory.categoryName

        else:
            #add a new category entry if no category with that name already exists
            category = Category(categoryName=categoryName,
                                picture=photo.key,
                                uploaded_by=users.get_current_user())
            category.put()
            category.add_to_search_index()
            message = "Successfully created category record: " + category.categoryName

        self.response.write(message)
Beispiel #7
0
    def post(self):
        # Got client ID from environ
        user_id = request.environ['USER_ID']
        client_id = user_id.get().detail_id

        print request.json['id']
        screen = Screen_Layout.get_by_id(request.json['id'])
        screen.name = request.json['name']
        prev_client_id = screen.client_id
        print client_id
        if prev_client_id != client_id:  # Later this is to be changed with token.
            return jsonify({"code": 400, "message": "Not authorized."})
        screen.location = request.json['location']

        prev_rows = screen.max_rows
        prev_cols = screen.max_columns

        if prev_rows != int(request.json['max_rows']) or prev_cols != int(
                request.json['max_columns']):
            screen.max_rows = int(request.json['max_rows'])
            screen.max_columns = int(request.json['max_columns'])
            # Deleting the categories of a seat after changing the screen structure.
            options = ndb.QueryOptions(keys_only=True)
            prev_categories = Category.query().filter(
                Category.screen_id == ndb.Key('Screen_Layout',
                                              request.json['id'])).fetch(
                                                  options=options)
            ndb.delete_multi(prev_categories)
            # We should add the new seat list for new seat grid and new categories for the updated Layout..
            seats = []
            categories = request.json['categories']
            print categories
            try:
                for each in categories:
                    category = Category()
                    category.screen_id = ndb.Key('Screen',
                                                 int(request.json['id']))
                    category.name = each['name']
                    category.seats = each['seats']
                    map(lambda seat: seats.append(seat), each['seats'])
                    category.put(
                    )  # Create categories for seat for a particular screen.
                # Adding seats for the screen fetched from categories
                screen.seats = seats
                res = screen.put()
                return jsonify({
                    "code":
                    200,
                    "id":
                    res.id(),
                    "message":
                    "Success changed layout and other informations."
                })
            except:
                return jsonify({"code": 500, "message": "server error"})
        return jsonify({
            "code": 200,
            "message": "Success changed some minor informations."
        })
    def get(self, screen_id):
        screen_id = ndb.Key(Screen_Layout, int(screen_id))
        categories = Category.query(Category.screen_id == screen_id).fetch()

        category_list = []
        for category in categories:
            category_list.append({
                "id": category.key.id(),
                'name': category.name
            })
        return jsonify(category_list)
Beispiel #9
0
 def get(self):
     list_of_category = Category.query().order(Category.name)
     return self.render_template("new_outcome.html", params= {"list_of_category": list_of_category})
 # def post(self, name):
 #     category = Category.query(Category.name == name).fetch(1)
 #     outcome = self.request.get("outcome")
 #     amount = float(self.request.get("amount"))
 #     form_date = self.request.get("time").split('-')
 #     time = date(int(form_date[0]), int(form_date[1]), int(form_date[2]))
 #     place = self.request.get("place")
 #     new_outcome = Outcome(category=category, outcome=outcome, amount=amount, time=time, place=place)
 #     new_outcome.put()
 #     return self.redirect_to("kategorija")
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('/templates/publicHome.html')

        photos = {}
        categories = Category.query().order(Category.categoryName)

        for category in categories:
            photos[category.key] = category.picture.get()

        templateVars = {
                        "title" : "Nick Michael's Fine Gallery",
                        "categories": categories,
                        "photos": photos}

        self.response.write(template.render(templateVars))
Beispiel #11
0
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('/templates/publicHome.html')

        photos = {}
        categories = Category.query().order(Category.categoryName)

        for category in categories:
            photos[category.key] = category.picture.get()

        templateVars = {
            "title": "Nick Michael's Fine Gallery",
            "categories": categories,
            "photos": photos
        }

        self.response.write(template.render(templateVars))
Beispiel #12
0
    def get(self, event_id, show_id):
        print request.headers
        event_id = int(event_id)
        show_id = int(show_id)
        show = ndb.Key(Show, show_id).get()
        show_screen = show.screen_id.get()
        screen_max_row_col = (show_screen.max_rows, show_screen.max_columns)
        seats_price_category = {}

        categories = Category.query(
            Category.screen_id == show.screen_id).fetch()
        for category in categories:
            price = Price.query(Price.show_id == show.key,
                                Price.category_id == category.key).get()
            if price is not None:
                price_amount = price.amount
            else:
                price_amount = 0
            for seat in category.seats:
                seats_price_category[(seat['row'], seat['column'])] = {
                    'price': price_amount,
                    'category': category.name
                }

        seats_info = {}
        for seat, description in show.seats.iteritems():
            row, column = seat.split('-')
            row = int(row)
            column = int(column)
            # seat_detail = seat
            seats_info[seat] = {
                'price': seats_price_category[(row, column)]['price'],
                'status': description['status'],
                'category': seats_price_category[(row, column)]['category']
            }
            # seat_detail['price'] = seats_price[(seat['row'], seat['column'])]
            # seats_info.append(seat_detail)
        print "now here"
        return jsonify({
            'show_id': show.key.id(),
            'screen_max_row_col': screen_max_row_col,
            'screen_seats': seats_info
        })
Beispiel #13
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))
    def get(self):
        photos = {}
        categories = Category.query().order(Category.categoryName)

        for category in categories:
            photos[category.key] = category.picture.get()
        html = ""
        for category in categories:
            html+="""<tr>
                        <td>""" + category.categoryName + """</td>
                        <td>""" + photos[category.key].file_name + """</td>
                        <td>
                            <a data-toggle="modal"  href="#editCategoryModal" onclick="fillCategoryEditModalDefaults(""" + str(category.key.id()) + ", '" + category.categoryName + "', '" + photos[category.key].file_name + """');" class="btn btn-medium">
                                <span class="glyphicon icon-edit"></span>
                            </a>
                            <a data-toggle="modal" data-id=\"""" + str(category.key.id()) + """\" href="#deleteCategoryModal" class="open-deleteCategoryModal 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))
Beispiel #16
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)
Beispiel #17
0
 def get(self):
     list_of_category = Category.query().order(Category.name)
     return self.render_template(
         "category_list.html",
         params={"list_of_category": list_of_category})
Beispiel #18
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)
Beispiel #19
0
 def get(self):
     category = Category.query().order(Category.name)
     return self.render_template("category_show.html",
                                 params={"category": category})