Пример #1
0
 def get(self):
     datastore = DataStoreInterface()
     formatter = StringFormatter()
     
     path = self.request.query_string
     params =  path.split('/')
     company = params[0].replace('company=','')
     postId = params[1].replace('id=','')
     
     post = datastore.getPost(company, postId)
     
     for p in post:
         update = formatter.formatPost(p, company)
     
     render.doRender(self, 'update.html', {'update' : update})
     
Пример #2
0
	def get(self):
	
		datastore = DataStoreInterface()
		formatter = StringFormatter()
		
		path = self.request.query_string.replace('company=', '')
		posts = datastore.getPosts(path, 25)
		companies = datastore.getCompanyInfo(path) 
		company = datastore.getCompanyName(path)
		
		info=''
		for c in companies:
			info = formatter.formatCompanyInfo(c)
				
		postList=[]
		for p in posts:
			postList.append(formatter.formatPost(p, p.dbProfileName))
		render.doRender(self, 'profiles.html', {'posts': postList, 'company': company , 'info': info, 'profileName' : path})
Пример #3
0
	def get(self):		
		self.session = Session()	
		if 'user' in self.session:
			user = self.session['user']	
			datastore = DataStoreInterface()
		
			formatter = StringFormatter()
			company = formatter.getCompanyProfileName(user)
			email = formatter.getEmail(user)
			
			twitter_oauth_handler.setTwitterAccounts(company)
			twitterAccounts = twitter_oauth_handler.getTwitterAccounts()
			
			facebookAccounts = datastore.getFacebookAccounts(company)
			
			#TWITTER MENTIONS QUERIED			
			mentions = []
			
			for name in twitterAccounts:
				numMention = 0
				client = OAuthClient('twitter', self, name)
				statuses = client.get('/statuses/mentions')
				if statuses == "Could not retrieve from social networks. The server could not be contacted at this time. Please try again later.":
					self.response.out.write(statuses)
					return
				for iteration in statuses:
					numMention += 1
					mention = Mentions()
					mention.dbCreatedTime = iteration['created_at']
					mention.dbMessage = iteration['text']
					mention.dbName = iteration['user']['screen_name']
					mention.dbPostID = str(iteration['id'])
					mention.dbReceiverName = iteration['in_reply_to_screen_name']
					mention.dbLink = 'From: <a href="http://twitter.com/'  + iteration['user']['screen_name']+'" target="_blank">'+ iteration['user']['name'] + '</a>'
					mentions.append(mention)
					if numMention == 5:
						break
		
			comments = []
			
			for name in facebookAccounts:
				fb = facebook.Facebook(API_KEY, SECRET_KEY)
				stream = fb.__call__('Stream.get', {'session_key':name.dbSessionKey, 'source_ids':[name.dbUid], 'limit':5})
				for post in stream['posts']:				
					replies = post['comments']['comment_list']
					numComment = 0
					for reply in replies:
						userInfo = fb.__call__('Users.getInfo', {'session_key':name.dbSessionKey, 'call_id':time(), 'uids':reply['fromid'], 'fields':['first_name', 'last_name']})
						username = userInfo[0]['first_name'] + ' ' + userInfo[0]['last_name']
						status = Comments()
						status.dbUserID = name.dbUid
						status.dbPostID = post['post_id']
						status.dbMessage = reply['text']
						status.dbLink = 'From: <a href="http://www.facebook.com/profile.php?ref=profile&id=' + str(reply['fromid']) + '" target="_blank">' + username + '</a>'
						status.dbReplyTo = 'In reply to: ' + post['message']
						comments.append(status)
						numComment += 1
						if numComment == 3:
							break
					if len(comments) == 10:
						break
						
			#getting saved posts 
			datastore = DataStoreInterface()
			formatter = StringFormatter()
			
			profileName = formatter.getCompanyProfileName(user)
		
			posts = datastore.getSavedPosts(profileName, 25)
			savedPosts = ''
			
			for r in posts:
				savedPosts += formatter.formatSavedPost(r, formatter.formatPost(r, profileName))
			
			#upload_url = blobstore.create_upload_url('/upload')	
			render.doRender(self, 'controlpanel.html', {'user': user, 'mentions': mentions, 'comments':comments, 'savedPosts': savedPosts, 'socialAccounts': twitterAccounts, 'facebookAccounts':facebookAccounts})
		else:
			self.redirect('main.html')