Example #1
0
 def get(self):
     params = {
         'user': app_global.unicode(self.session.get('user')),
         'user_id': app_global.unicode(self.session.get('user_id')),
         'email': app_global.unicode(self.session.get('email'))
         
     }
     app_global.render_template(self, 'newUserSuccess.html', params)
Example #2
0
def create_comment(userID, text, imgID, username, time_created):
    comment = ImageComment()
    comment.imgID = str(imgID)
    comment.userID = str(app_global.unicode(userID))
    comment.text = text
    comment.uploadedBy = app_global.unicode(username)
    comment.upload_date = time_created
    comment.put()
Example #3
0
 def get(self):
     # images = imagesModels.getImages()
     
     
     params = {
         'page': '',
         'logo':'pitt_logo.png',
         'photo_name':'photo3.jpg', 
         'photo_name2':'banner2.jpg',
         'photo_name3':'banner1.jpg',
         'user': app_global.unicode(self.session.get('user')),
         'user_id': app_global.unicode(self.session.get('user_id'))
      }
     
     app_global.render_template(self,'index.html', params)
Example #4
0
def addImage(categoryID, total, title, image_url, user, minPrice, maxPrice, priceRange, brand, clothingType, username, tag_name):
    image = Image()
    image.total = total
    image.categoryID = categoryID
    image.title = title
    image.image_url = image_url
    image.user = str(user)
    image.minPrice = minPrice
    image.maxPrice = maxPrice
    image.priceRange = priceRange
    image.brand = brand
    image.clothingType = clothingType
    image.uploadedBy = app_global.unicode(username)
    key = image.put()
    memcache.add(str(image.key.id()), value=image)
    logging.debug('Added ' + str(image.key.id()) + ' to the cache')
    
#    users = ImageTag.query()
#    for u in users.fetch():
#        u.key.delete()
    
    for element in tag_name:
        image_tag = ImageTag()
        image_tag.imageKey = str(key.id())
        image_tag.tag_name = element
        image_tag.put()
Example #5
0
    def post(self):
        imgURL = self.request.get('imgURL');
        imgID = self.request.get('imgID');


        user_id = app_global.unicode(self.session.get('user_id'))
        user = app_global.unicode(self.session.get('user'))

        params = {
            'user_id': user_id,
            'page': 'profile',
            'user': user,
            'imgURL': imgURL,
            'imgID': imgID
        }

        app_global.render_template(self,'addItems.html', params)
    def get(self):
        
        user_id = app_global.unicode(self.session.get('user_id'))
        user = app_global.unicode(self.session.get('user'))
        description = app_global.unicode(self.session.get('description'))
        gender = app_global.unicode(self.session.get('gender'))
        email = app_global.unicode(self.session.get('email'))

        params = {
            'user_id': user_id,
            'user': user,
            'description': description,
            'gender': gender,
            'email': email
        }

 
        app_global.render_template(self,'updateprofile.html', params)
Example #7
0
    def post(self):
        email = app_global.unicode(str(self.session.get('email')))
        imgURL = self.request.get('imgURL')

        print 'post pic'
        print email
        print imgURL

        userModel.setProfilePic(imgURL, email)

        self.session['imgURL'] = imgURL
        
        self.redirect('/profile')
Example #8
0
 def get(self):                                                  # /userFunctions
     user = app_global.unicode(self.session.get('user'))
     message = self.request.get('message')
     
     params = {
         'user': user,
         'user_id': self.session.get('user_id'),
         'message': message
     }
     
     userModel.getUsers()
     
     
     app_global.render_template(self, 'login.html', params)
	def post(self):
		email = app_global.unicode(self.session.get('email'))
		item = self.request.get('item')
		print item

		if item == "name":
			newN = self.request.get('newName')
			print newN
			if len(newN) > 0:
				print "change name"
				userModel.changeName(email, newN)
				self.session['user'] = newN
			self.redirect("/updateprofile")


		elif item == "password":
			p1 = self.request.get('newPass1')
			p2 = self.request.get('newPass2')
			if p1 == p2:
				userModel.changePass(email, p1)
				self.session['pass'] = p1
			self.redirect("/updateprofile")


		elif item == "gender":
			gen = self.request.get('gender')
			userModel.changeGender(email, gen)
			self.session['gender'] = gen
			self.redirect("/updateprofile")


		else:
			des = self.request.get('des')
			userModel.changeDescription(email, des)
			self.session['description'] = des
			self.redirect("/updateprofile")
Example #10
0
def deleteLike(user_id, photo_id):
    like = Like.query(Like.userID==str(app_global.unicode(user_id)), Like.imgID==str(photo_id)).fetch(1)
    like[0].key.delete()
Example #11
0
def addLike(userID, imgID, username):
    like = Like()
    like.imgID = str(imgID)
    like.userID = str(app_global.unicode(userID))
    like.uploadedBy = app_global.unicode(username)
    like.put()
Example #12
0
    def get(self):
        result = list()

        #user_id = request.args.get(user_id)
        user_id = app_global.unicode(self.session.get('user_id'))
        profile = self.request.get('page')
        adored = self.request.get('adored')
            

        if user_id is None:
            user_id = -1

        #Not profile page
        if (profile != "profile"):
            queryImg = Image.query()            # get all images
        #Profile page
        else:
            #queryImg = Image.query()
            queryImg = Image.query(Image.user == str(user_id))
        
        queryImg = queryImg.order(-Image.time_created)
        queryLike = Like.query()            # get likes
        queryComment = ImageComment.query() # get comments
        
        
        #likedByYou = queryLike.filter(Like.userID == str(user_id)).fetch(projection=[Like.imgID])
        likes = queryLike.filter(Like.userID == str(user_id)).fetch(projection=[Like.imgID])
        
        likedByYou = set()
        # add imgID's of images the current user liked to the set likedByYou
        for item in likes:
            likedByYou.add(item.imgID)
     
        images = queryImg.fetch()
        
        if adored is not None and adored == "true":
            likes = Like.query(Like.userID == str(user_id))
            relevantPicIDs = []
            for instance in likes.fetch():
                relevantPicIDs.append(int(instance.imgID))
            queryImg = Image.query().order(-Image.time_created)
            allPics = queryImg.fetch()
            images = []
            for pic in allPics:
                if pic.key.id() in relevantPicIDs:
                    images.append(pic)
            queryLike = Like.query()
        
       
        
        for i in range(0,len(images)):
            im = {}
            key = str(images[i].key.id())
           
            tagObj = ImageTag.query(ImageTag.imageKey == key).fetch(projection=[ImageTag.tag_name])
            tag_arr = []
            for tag in tagObj:
                tag_arr.append(tag.tag_name)
            
            im['uploaded_by'] = images[i].uploadedBy
            im['tags'] = tag_arr
            im['img_id'] = str(images[i].key.id())
            # im['total'] = images[i].total
            im['title'] = images[i].title
            im['image_url'] = images[i].image_url
            im['user_id'] = images[i].user
            im['total_likes'] = queryLike.filter(Like.imgID == im['img_id']).count()

            comments = queryComment.filter(ImageComment.imgID ==  im['img_id'])
            comments = comments.order(-ImageComment.upload_date).fetch()              
            im['comments'] = [c.to_dict() for c in comments]
    
            if adored is not None and adored == "true" and (str(user_id) == str(images[i].user)):
                im['deleteOption'] = "active"
                im['profilePicOption'] = "active"

            if im['img_id'] in likedByYou:
                im['adored'] = True
            else:
                im['adored'] = False

                
            for elem in comments:
                elem.commentID = elem.key.id()
                if elem.userID == str(user_id):
                    elem.yours = 1 #i only check if it exists later on

            result.append(im)
            
            
        #return json.dumps(result[0])
        self.response.out.write(json.dumps(result))
Example #13
0
    def get(self):

        # images = imagesModels.getImages()
        
         

        #The following 10 lines of code just wipe the entire images, likes, comments datastore.
#        
#        users = userModel.Users.query()
#        for u in users.fetch():
#            u.key.delete()
#        
#        ims = imagesModel.Image.query()
#        for im in ims.fetch():
#            im.key.delete()
#
#        likes = imagesModel.Like.query()
#        for like in likes.fetch():
#                like.key.delete()
#                
#        coms = imagesModel.ImageComment.query()
#        for com in coms.fetch():
#                com.key.delete()
                
                
#        for i in range(1,17):
#            photo = {}
#            photo['name'] = 'girl'+ str(i) + '.jpg';
#            if i%2==0:
#                photo['adored'] = True;
#            else:
#                photo['adored'] = False;
#            photo_list.append(photo)

        #getImages(user_id, maxPrice, brandName, clothingType)
#       None is used to not consider that restriction

        user_id = app_global.unicode(self.session.get('user_id'))
    
        maxPrice = self.request.get('maxPrice')
        brandName = self.request.get('brand')
        clothingType = self.request.get('clothingType')
        
        if brandName == "":
            brandName = None
        if clothingType == "":
            clothingType = None
        if maxPrice == "":
            maxPrice = None
        
        #These things generate a price menu based on the prices. 
        #prices = [0, 25, 50] ==> priceOptions = ['$0-$25', '$25-$50', 'Over $50']
        priceOptions = list()
        lastValue = 0
        nextValue = prices[0]
        index = 0
        
        for i in range(0, len(prices)+1):
            if (i != len(prices)):
                priceOptions.append('$' + str(lastValue) + '-$' + str(nextValue))
            else:
                priceOptions.append('Over $' + str(nextValue))
            if (i < len(prices)-1):
                lastValue = nextValue
                index += 1
                nextValue = prices[index]
        
        
        #[25, 50]
        #['0-25', '25-50', 'Over 50'] 
        #This part just changes the option '25-50', etc. to an actual number for the filter.
        # '$0-$25' ==> minimumPrice = 0, maximumPrice = 25
        # Note: for maximum value. ie. over 1000, I use minimumPrice = highest + 1 (so 1001)
        # and maximumPrice = highest + 2 (so 1002).
        
        if maxPrice is not None:
            index = priceOptions.index(maxPrice)
            if index < len(priceOptions)-1:
                    maximumPrice = prices[index]
                    if (index-1 > -1):
                        minimumPrice = prices[index-1]
                    else:
                        minimumPrice = 0
            else:
                maximumPrice = prices[len(prices)-1] + 2
                minimumPrice = prices[len(prices)-1] + 1
        else:
            minimumPrice = None
            maximumPrice = None
       
        #This list is used to narrow the images down when filtering.
        restrictionList = list()
        restrictionList.append(minimumPrice)
        restrictionList.append(maximumPrice)
        restrictionList.append(brandName)
        restrictionList.append(clothingType)
        

        
        upload_url = blobstore.create_upload_url('/uploadImage')    

        
        user_id = app_global.unicode(self.session.get('user_id'))
        user = app_global.unicode(self.session.get('user'))
        imgURL = app_global.unicode(self.session.get('imgURL'))
        description = app_global.unicode(self.session.get('description'))
        gender = app_global.unicode(self.session.get('gender'))

        params = {
#            'photos': images,
            #'photos_json': json.dumps(images),
            'profilePicURL': imgURL,
            'user_id': user_id,
            'page': 'profile',
            'user': user,
            #'user_id': None, #testing when user is logged out
            'upload_url': upload_url,
            'brands': brands,
            'types': types,
            'prices': prices,
            'priceOptions': priceOptions,
            'description': description,
            'gender': gender,
            'deleteOption': user_id
        }

 
        app_global.render_template(self,'profile.html', params)
Example #14
0
    def get(self):
        # images = imagesModels.getImages()

        # The following 10 lines of code just wipe the entire images, likes, comments datastore.
        #
        #        users = userModel.Users.query()
        #        for u in users.fetch():
        #            u.key.delete()

        #        ims = imagesModel.Image.query()
        #        for im in ims.fetch():
        #            im.key.delete()
        #
        #        likes = imagesModel.Like.query()
        #        for like in likes.fetch():
        #                like.key.delete()
        #
        #        coms = imagesModel.ImageComment.query()
        #        for com in coms.fetch():
        #                com.key.delete()
        #

        #        for i in range(1,17):
        #            photo = {}
        #            photo['name'] = 'girl'+ str(i) + '.jpg';
        #            if i%2==0:
        #                photo['adored'] = True;
        #            else:
        #                photo['adored'] = False;
        #            photo_list.append(photo)

        # getImages(user_id, maxPrice, brandName, clothingType)
        #       None is used to not consider that restriction

        user_id = self.session.get("user_id")

        maxPrice = self.request.get("maxPrice")
        brandName = self.request.get("brand")
        clothingType = self.request.get("clothingType")

        if brandName == "":
            brandName = None
        if clothingType == "":
            clothingType = None
        if maxPrice == "":
            maxPrice = None

        # These things generate a price menu based on the prices.
        # prices = [0, 25, 50] ==> priceOptions = ['$0-$25', '$25-$50', 'Over $50']
        priceOptions = list()
        lastValue = 0
        nextValue = prices[0]
        index = 0

        for i in range(0, len(prices) + 1):
            if i != len(prices):
                priceOptions.append("$" + str(lastValue) + "-$" + str(nextValue))
            else:
                priceOptions.append("Over $" + str(nextValue))
            if i < len(prices) - 1:
                lastValue = nextValue
                index += 1
                nextValue = prices[index]

        # [25, 50]
        # ['0-25', '25-50', 'Over 50']
        # This part just changes the option '25-50', etc. to an actual number for the filter.
        # '$0-$25' ==> minimumPrice = 0, maximumPrice = 25
        # Note: for maximum value. ie. over 1000, I use minimumPrice = highest + 1 (so 1001)
        # and maximumPrice = highest + 2 (so 1002).

        if maxPrice is not None:
            index = priceOptions.index(maxPrice)
            if index < len(priceOptions) - 1:
                maximumPrice = prices[index]
                if index - 1 > -1:
                    minimumPrice = prices[index - 1]
                else:
                    minimumPrice = 0
            else:
                maximumPrice = prices[len(prices) - 1] + 2
                minimumPrice = prices[len(prices) - 1] + 1
        else:
            minimumPrice = None
            maximumPrice = None

        # This list is used to narrow the images down when filtering.
        restrictionList = list()
        restrictionList.append(minimumPrice)
        restrictionList.append(maximumPrice)
        restrictionList.append(brandName)
        restrictionList.append(clothingType)

        upload_url = blobstore.create_upload_url("/uploadImage")

        params = {
            #            'photos': images,
            #'photos_json': json.dumps(images),
            "user_id": app_global.unicode(self.session.get("user_id")),
            "user": app_global.unicode(self.session.get("user")),
            #'user_id': None, #testing when user is logged out
            "upload_url": upload_url,
            "brands": brands,
            "types": types,
            "prices": prices,
            "priceOptions": priceOptions,
            "page": "gallery",
        }

        app_global.render_template(self, "gallery2.html", params)