예제 #1
0
    def get(self):
        user = users.get_current_user()
        if user is None:
            pass

        postid = self.request.get("postid")
        print "postid"
        print postid

        postQuery = Post.query()
        for post in postQuery:
            if post.id == postid:
                postwant = post
                break

        if user in postwant.savedList:
            postwant.savedList.remove(user)
            postwant.savedCount = postwant.savedCount - 1
        else:
            postwant.savedList.append(user)
            postwant.savedCount = postwant.savedCount + 1

        postwant.put()
        print "IN post save"

        self.response.write(postwant.savedCount)
예제 #2
0
	def post(self):
		user = users.get_current_user()
		if user is None:
			pass

		comment = self.request.get("comment")
		postid = self.request.get("postid")


		NewComment = Comment(creator=user,
			content=comment)
		NewComment.put()

		print "comment"
		print comment
		
		# print "postid"
		# print postid

		postQuery= Post.query()
		for post in postQuery:
			if post.id == postid:
				postwant=post
				break

		postwant.commentList.append(NewComment)
		postwant.put()

		params = urllib.urlencode({'postid': postid})
		self.redirect('/Post?'+params)
예제 #3
0
    def post(self):
        user = users.get_current_user()
        if user is None:
            pass

        comment = self.request.get("comment")
        postid = self.request.get("postid")

        NewComment = Comment(creator=user, content=comment)
        NewComment.put()

        print "comment"
        print comment

        # print "postid"
        # print postid

        postQuery = Post.query()
        for post in postQuery:
            if post.id == postid:
                postwant = post
                break

        postwant.commentList.append(NewComment)
        postwant.put()

        params = urllib.urlencode({'postid': postid})
        self.redirect('/Post?' + params)
예제 #4
0
    def get(self):
        user = users.get_current_user()
        if user is None:
            pass

        postid = self.request.get("postid")
        giftImageList = []
        giftArticleList = []
        giftHyperinkList = []
        commentTimeList = []

        postQuery = Post.query()
        for post in postQuery:
            print "in post query"
            if post.id == postid:
                postwant = post
                break

        if user in postwant.savedList:
            Postsave = True
        else:
            Postsave = False

        if post.creator == user:
            OwnerLogin = True
        else:
            OwnerLogin = False

        for gift in postwant.giftList:
            # print "length"
            # print len(postwant.giftList)
            # print "what is gift"
            # print gift.hyperLink
            # print "imageurl"
            # print images.get_serving_url(gift.image)

            giftImageList.append(images.get_serving_url(gift.image))
            giftArticleList.append(gift.article)
            giftHyperinkList.append(str(gift.hyperLink))

        for item in postwant.commentList:
            # Sun Dec 13 2015 20:15:57 GMT-0600 (CST)
            ttime = '{0:%a} {0:%b} {0:%d} {0:%Y} {0:%X}'.format(
                item.date) + " GMT-0600 (CST)"
            commentTimeList.append(ttime)

        template_values = {
            'loginURL': users.create_login_url(self.request.uri),
            'logoutURL': users.create_logout_url('/'),
            'user': user,
            'postwant': postwant,
            'giftImageList': giftImageList,
            'giftArticleList': giftArticleList,
            'giftHyperinkList': giftHyperinkList,
            'OwnerLogin': OwnerLogin,
            'Postsave': Postsave,
            'commentTimeList': commentTimeList
        }
        template = JINJA_ENVIRONMENT.get_template('post.html')
        self.response.write(template.render(template_values))
예제 #5
0
	def get(self):
		user = users.get_current_user()
		if user is None:
			pass

		postid = self.request.get("postid")
		print "postid"
		print postid

		postQuery= Post.query()
		for post in postQuery:
			if post.id == postid:
				postwant=post
				break

		if user in postwant.savedList:
			postwant.savedList.remove(user)
			postwant.savedCount=postwant.savedCount-1
		else:
			postwant.savedList.append(user)
			postwant.savedCount=postwant.savedCount+1
		
		postwant.put()
		print "IN post save"

		self.response.write(postwant.savedCount)
예제 #6
0
	def get(self):
		user = users.get_current_user()
		searchContents = self.request.get("searchContent")

		if searchContents != "":
			searchWords = searchContents.split(' ')
			for i in range(0,len(searchWords)):
				searchWords[i]=str(searchWords[i].lower())
			print searchWords
		
		PostsList = []
		PostPreviewList=[]
		
		for post in Post.query().order(Post.lastUpdateDate):
			p_word =[]
			for item in post.name.split(' '):
				p_word.append(item.lower())
			for item in post.tags:
				p_word.append(item.lower())

			for item in p_word:
				if item in searchWords:
					PostsList.append(post)
					try:
						previewImage = images.get_serving_url(post.giftList[0].image)
					except Exception,e:
						previewImage = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTt9ALzNY6Ef_7To_OnTLEkUpXYu6jW6-DB4oi6JRxD2mdBdD293lcUdg"
					PostPreviewList.append(previewImage)
예제 #7
0
	def get(self):
		postid = self.request.get("postid")
		post_query = Post.query()
		for s in post_query:
			if s.id==postid:
				time.sleep(0.5)

		print "in gift transter"
		params = urllib.urlencode({'postid': postid})
		self.redirect('/Post?'+params)
예제 #8
0
    def post(self):
        deletePostlist = []
        deletePostlist = self.request.get_all('deleteCheckbox')
        post_query = Post.query()

        for p in post_query:
            if p.id in deletePostlist:
                for i in range(0, len(p.giftList)):
                    images.delete_serving_url(p.giftList[i].image)
                    blobstore.delete(p.giftList[i].image, rpc=None)
                p.key.delete()
        self.redirect('/manage')
예제 #9
0
	def post(self):
		deletePostlist =[]
		deletePostlist=self.request.get_all('deleteCheckbox')
		post_query = Post.query()

		for p in post_query:
			if p.id in deletePostlist:
				for i in range(0,len(p.giftList)):
					images.delete_serving_url(p.giftList[i].image)
					blobstore.delete(p.giftList[i].image,rpc=None)
				p.key.delete()
		self.redirect('/manage')
예제 #10
0
    def post(self):
        hashid = hash(time.time())
        user = users.get_current_user()
        allTag = self.request.get("tags")
        tagList = allTag.split(" ")

        #print "taglist",tagList
        # print "name is "
        # print self.request.get("name")

        post = Post(id=str(hashid),
                    name=self.request.get("name"),
                    creator=user,
                    savedCount=0,
                    savedList=[],
                    sharetoSocialCount=0,
                    commentList=[],
                    tags=tagList,
                    giftList=[])
        post.put()

        params = urllib.urlencode({'postid': hashid})
        self.redirect('/GiftAdd/' + str(hashid))
예제 #11
0
	def post(self):
		hashid = hash(time.time())
		user = users.get_current_user()
		allTag = self.request.get("tags")
		tagList = allTag.split(" ")

		#print "taglist",tagList
		# print "name is "
		# print self.request.get("name")

		post = Post(id = str(hashid),
					name = self.request.get("name"),
					creator = user,
					savedCount = 0,
					savedList =[],
					sharetoSocialCount = 0,
					commentList = [],
					tags = tagList,
					giftList=[])
		post.put()

		params = urllib.urlencode({'postid': hashid})
		self.redirect('/GiftAdd/'+str(hashid))
예제 #12
0
	def get(self):
		user = users.get_current_user()
		# if user is None:
		# 	pass

		postid = self.request.get("postid")
		postQuery= Post.query()
		for post in postQuery:
			if post.id == postid:
				postwant=post
				break
		
		print "IN post share"

		postwant.sharetoSocialCount=postwant.savedCount+1
		postwant.put()
		self.response.write(postwant.sharetoSocialCount)
예제 #13
0
    def get(self):
        user = users.get_current_user()
        if user is None:
            pass
        PostsList = []
        PostPreviewList = []

        for post in Post.query().order(Post.lastUpdateDate):
            PostsList.append(post)
            try:
                previewImage = images.get_serving_url(post.giftList[0].image)
            except Exception, e:
                previewImage = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTt9ALzNY6Ef_7To_OnTLEkUpXYu6jW6-DB4oi6JRxD2mdBdD293lcUdg"
                # if previewImage is None:
                # 	pass

            PostPreviewList.append(previewImage)
예제 #14
0
    def get(self):
        user = users.get_current_user()
        # if user is None:
        # 	pass

        postid = self.request.get("postid")
        postQuery = Post.query()
        for post in postQuery:
            if post.id == postid:
                postwant = post
                break

        print "IN post share"

        postwant.sharetoSocialCount = postwant.savedCount + 1
        postwant.put()
        self.response.write(postwant.sharetoSocialCount)
예제 #15
0
    def get(self):
        user = users.get_current_user()
        if user is None:
            pass
        PostsList = []
        PostPreviewList = []

        for post in Post.query().order(Post.lastUpdateDate):
            PostsList.append(post)
            try:
                previewImage = images.get_serving_url(post.giftList[0].image)
            except Exception, e:
                previewImage = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTt9ALzNY6Ef_7To_OnTLEkUpXYu6jW6-DB4oi6JRxD2mdBdD293lcUdg"
            # if previewImage is None:
            # 	pass

            PostPreviewList.append(previewImage)
예제 #16
0
	def get(self):
		user = users.get_current_user()
		if user is None:
			self.redirect('/')

		Postowned = []
		PostPreviewList =[]
		'''
			find out all posts&activity by a user
		'''
		
		for post in Post.query().order(-Post.lastUpdateDate):
			if post.creator == user:
				Postowned.append(post)
				try:
					previewImage = images.get_serving_url(post.giftList[0].image)
				except Exception,e:
					previewImage = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTt9ALzNY6Ef_7To_OnTLEkUpXYu6jW6-DB4oi6JRxD2mdBdD293lcUdg"
				PostPreviewList.append(previewImage)
예제 #17
0
    def get(self):
        AppendList = []
        PostsList = []
        PostPreviewList = []
        StartIndex = self.request.get("index")
        # index is 16,32,48,64...

        fullList = Post.query().order(Post.lastUpdateDate).fetch(4, offset=StartIndex)
        # AppendList = fullList[StartIndex:StartIndex+4]

        for post in fullList:
            PostsList.append(post)
            try:
                previewImage = images.get_serving_url(post.giftList[0].image)
            except Exception, e:
                previewImage = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTt9ALzNY6Ef_7To_OnTLEkUpXYu6jW6-DB4oi6JRxD2mdBdD293lcUdg"
                # if previewImage is None:
                # 	pass
            PostPreviewList.append(previewImage)
            self.response.write()
예제 #18
0
    def get(self):
        user = users.get_current_user()
        if user is None:
            self.redirect('/')

        Postowned = []
        PostPreviewList = []
        '''
			find out all posts&activity by a user
		'''

        for post in Post.query().order(-Post.lastUpdateDate):
            if post.creator == user:
                Postowned.append(post)
                try:
                    previewImage = images.get_serving_url(
                        post.giftList[0].image)
                except Exception, e:
                    previewImage = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTt9ALzNY6Ef_7To_OnTLEkUpXYu6jW6-DB4oi6JRxD2mdBdD293lcUdg"
                PostPreviewList.append(previewImage)
예제 #19
0
	def post(self,postid):
		try:
			upload = self.get_uploads()
		except:
			assert(False)
			self.redirect('/')

		article = self.request.get("article")
		price = self.request.get("price")
		hyperLink= self.request.get("Link")
		# print "article"
		# print article
		# print "hyperLink"
		# print hyperLink
		# print "type of postid"
		# print type(postid)

		print "length of upload"
		print len(upload)
		# assert(False)

		post_query = Post.query()
		for s in post_query:
			if s.id==postid:
				for item in upload:
					gift=Gift()
					gift.image=item.key()
					gift.article=article
					gift.hyperLink=hyperLink
					gift.price=price
					gift.put()

					s.giftList.append(gift)
					s.lastUpdateDate=gift.date
					s.put()
				break
				
		#assert(False)

		params = urllib.urlencode({'postid': postid})
		self.redirect('/GiftTransfer?'+params)
예제 #20
0
    def get(self):
        AppendList = []
        PostsList = []
        PostPreviewList = []
        StartIndex = self.request.get("index")
        #index is 16,32,48,64...

        fullList = Post.query().order(Post.lastUpdateDate).fetch(
            4, offset=StartIndex)
        # AppendList = fullList[StartIndex:StartIndex+4]

        for post in fullList:
            PostsList.append(post)
            try:
                previewImage = images.get_serving_url(post.giftList[0].image)
            except Exception, e:
                previewImage = "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTt9ALzNY6Ef_7To_OnTLEkUpXYu6jW6-DB4oi6JRxD2mdBdD293lcUdg"
            # if previewImage is None:
            # 	pass
            PostPreviewList.append(previewImage)
            self.response.write()
예제 #21
0
	def get(self):
		user = users.get_current_user()
		if user is None:
			pass

		postid = self.request.get("postid")
		giftImageList =[]
		giftArticleList = []
		giftHyperinkList = []
		commentTimeList = []

		postQuery= Post.query()
		for post in postQuery:
			print "in post query"
			if post.id == postid:
				postwant=post
				break
		
		if user in postwant.savedList:
			Postsave = True
		else:
			Postsave = False


		if post.creator == user:
			OwnerLogin = True
		else:
			OwnerLogin =False 

		for gift in postwant.giftList:
			# print "length"
			# print len(postwant.giftList)
			# print "what is gift"
			# print gift.hyperLink
			# print "imageurl"
			# print images.get_serving_url(gift.image)
			
			giftImageList.append(images.get_serving_url(gift.image))
			giftArticleList.append(gift.article)
			giftHyperinkList.append(str(gift.hyperLink))

		for item in postwant.commentList:
			# Sun Dec 13 2015 20:15:57 GMT-0600 (CST)
			ttime = '{0:%a} {0:%b} {0:%d} {0:%Y} {0:%X}'.format(item.date)+" GMT-0600 (CST)"
			commentTimeList.append(ttime)

		template_values = {
			'loginURL':users.create_login_url(self.request.uri),
		    'logoutURL': users.create_logout_url('/'),
		    'user' : user,
		    'postwant':postwant,
		    'giftImageList':giftImageList,
		    'giftArticleList':giftArticleList,
		    'giftHyperinkList':giftHyperinkList,
		    'OwnerLogin':OwnerLogin,
		    'Postsave':Postsave,
		    'commentTimeList':commentTimeList

		}
		template = JINJA_ENVIRONMENT.get_template('post.html')
		self.response.write(template.render(template_values))