コード例 #1
0
ファイル: retrievepass.py プロジェクト: filipmares/SynapSync
    def post(self):
	
        email = self.request.get('txtEmail')
        datastore = DataStoreInterface()        
        emailObj = EmailProcessor()
        
        if emailObj.isValidEmail(email) <> 1:
			render.doRender(self, 'retrieve.html', {'error' : 'Invalid email address format!'})
        elif datastore.userExists(email) <> 1:
            render.doRender(self, 'retrieve.html', {'error' : 'Email address has not been registered!'})
        else:
            subject = "SynapSync email password Retrieval for " + email
            password = datastore.getUserPass(email)
            body = """
            Hi,
            
            You are receiving the following email because your password was requested. 
            
            Your info is: 
            
            email: """ + email + """
            password: """ + password + """
            
            Thanks,
            
            SynapSync Team"""
            
            emailObj.sendSupportEmail(email, subject, body) 
            render.doRender(self,'retrieve.html', {'confirmation' : 'Password sent to ' + email})
コード例 #2
0
ファイル: settings.py プロジェクト: filipmares/SynapSync
	def post(self):
	
		datastore = DataStoreInterface()
		
		email = self.request.get('txtEmail')
		first = self.request.get('txtFirstName')
		last = self.request.get('txtLastName')
		#password code should go here
		company = self.request.get('txtCompanyName')
		street = self.request.get('txtStreetAddress')
		city = self.request.get('txtCity')
		state = self.request.get('txtState')
		zip = self.request.get('txtZip')
		country = self.request.get('txtCountry')
		phone = self.request.get('txtPhoneNumber')
		site = self.request.get('txtWebsite')
		
		#self.response.out.write(company)
		
		userAttributes = [first, last]
		companyAttributes = [company, street, city, state, zip, country, phone, site]
		
		if ((datastore.changeCompanyInfo(company, companyAttributes)) and (datastore.changeUserInfo(email, userAttributes))):
			render.doRender(self, 'controlpanel.html', {'message':'Changed Information'})
		else:
			render.doRender(self, 'settings.html', {'error':'Could not change in database'})
コード例 #3
0
ファイル: main.py プロジェクト: filipmares/SynapSync
	def post(self):
		
		self.session = Session()
		datastore = DataStoreInterface()
		
		email = self.request.get('txtEmail').strip()
		password = self.request.get('txtPassword')
		
		self.session.delete_item('user')
		
		#Check for any fields left empty
		if email == '' or password == '':
			render.doRender(self, 'main.html', {'error' : 'Please fill in all the details'})
			return
		
		username = datastore.loginUser(email, password)
		
		if datastore.isUser(email)== 1:
			if datastore.checkPass(email, password)==1:	
				self.session['user'] = username			
				self.redirect('controlpanel.html')
			else:
				render.doRender(self, 'main.html', {'error' : 'Wrong password'})
		else:
			render.doRender(self, 'main.html', {'error' : 'Email Address does not exist'})
コード例 #4
0
ファイル: profiles.py プロジェクト: filipmares/SynapSync
	def post(self):
		datastore = DataStoreInterface()
		email = self.request.get('txtEmail').strip()
		profileName = self.request.query_string.replace('company=', '')
		datastore.addEmailSubscriber(profileName, email)
		
		self.redirect('profiles.html?company='+profileName)
コード例 #5
0
ファイル: contact.py プロジェクト: filipmares/SynapSync
 def post(self):
     datastore = DataStoreInterface()  
     
     email = datastore.getAdminEmail('synapsync')      
     if (email <> 'null'):
         emailObj = EmailProcessor()
         subject = self.request.get('txtSubject')
         body = self.request.get('txtContent')
         
         emailObj.sendSupportEmail(email, subject, body) 
         render.doRender(self,'contact.html', {'confirmation' : 'Email sent!'})
コード例 #6
0
    def __init__(self, service, handler, twitterName='', oauth_callback='/', **request_params):
        self.service = service
        self.service_info = OAUTH_APP_SETTINGS[service]
        self.service_key = None
        self.handler = handler
        self.request_params = request_params
        self.oauth_callback = oauth_callback
		
        if service == 'twitter':
            datastore = DataStoreInterface()
            self.token = datastore.getUserToken(twitterName)
コード例 #7
0
ファイル: postAction.py プロジェクト: filipmares/SynapSync
 def get(self):
 
     self.session = Session()
     
     datastore = DataStoreInterface()
     query = self.request.query_string
     
     actionType = query.split('%')[0].split('&')[0].replace('action=','')
     postId = query.split('%')[0].split('&')[1].replace('id=','')
     
     if datastore.changePostStatus(postId, actionType) == 1:
         self.redirect('controlpanel.html')
コード例 #8
0
ファイル: main.py プロジェクト: filipmares/SynapSync
	def get(self):
	
		path = (self.request.path).replace('/', '')
		datastore = DataStoreInterface()
		
		if (path <> '') and (path <> 'main.html'):
			if (datastore.companyProfileExists(path) == 1):				
				path = 'profiles.html?company='+path
				self.redirect(path)
			else:
				self.response.out.write('404: File not Found')
		else:
			render.doRender(self,'main.html', {})
コード例 #9
0
ファイル: testEmail.py プロジェクト: filipmares/SynapSync
	def get(self):	
		emailObj = EmailProcessor()
		datastore = DataStoreInterface()
				
		emails =  [];
		emails = datastore.getEmailSubscriber('filipmares')
		
		output = ''
		
		for e in emails:
			output += e + '<br>'
		
		self.response.out.write(output)
コード例 #10
0
ファイル: update.py プロジェクト: filipmares/SynapSync
 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})
     
コード例 #11
0
ファイル: mobile.py プロジェクト: filipmares/SynapSync
 def get(self):
     formatter = StringFormatter()
     datastore = DataStoreInterface()
     
     queries = []
     queries = formatter.getValues(self.request.query_string)
     
     if len(queries) == 1:
         if (datastore.companyProfileExists(queries[0]) == 1):                
             posts = datastore.getPosts(queries[0], 5)
             
             for p in posts:
                 self.response.out.write(p.dbTitle + ' - ' + p.dbBody + '<br>')
         else:
             self.response.out.write('Company Not Found')
 
     else:
         self.response.out.write("unknown query")
コード例 #12
0
ファイル: profiles.py プロジェクト: filipmares/SynapSync
	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})
コード例 #13
0
ファイル: settings.py プロジェクト: filipmares/SynapSync
	def get(self):
		self.session = Session()

		if 'user' in self.session:
			formatter = StringFormatter()
			user = self.session['user']	
			company = formatter.getCompanyProfileName(user)
			email = formatter.getEmail(user)

			datastore = DataStoreInterface()
			twitterAccounts = datastore.getTwitterAccounts(company)
			facebookAccounts = datastore.getFacebookAccounts(company)
			
			uInfo = datastore.getUserInfo(email)
			
			for u in uInfo:
				firstName = u.dbFirstName 
				lastName = u.dbLastName
				
				
			
			cInfo = datastore.getCompanyInfo(company)
			
			for c in cInfo:
				cname = c.dbCompanyName
				stAddress = c.dbStreetAddress
				city = c.dbCity
				state = c.dbState
				zip = c.dbPostalCode
				country = c.dbCountry
				number = c.dbPhoneNumber
				cemail = c.dbAdministrator
				website = c.dbUrl

			if datastore.isAdmin(company, email) == 1:
				render.doRender(self, 'settings.html', {'isAdmin':email,'email':email,'firstName':firstName, 'lastName':lastName, 'socialAccounts' : twitterAccounts
													    ,'facebookAccounts':facebookAccounts, 'cname':cname, 'stAddress':stAddress, 'city':city, 'state':state, 'zip':zip
													    ,'country':country, 'number':number, 'cemail':cemail, 'website':website })
			else:
				render.doRender(self, 'settings.html', {'email':email})
		else:
			render.doRender(self, 'main.html', {})
コード例 #14
0
ファイル: cpanel.py プロジェクト: filipmares/SynapSync
	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')
コード例 #15
0
ファイル: cpanel.py プロジェクト: filipmares/SynapSync
	def post (self):
		#intialization of variables
		self.session = Session()
		user = self.session['user']		
		datastore = DataStoreInterface()
		status = ''
		error=''
		message=''
			
		#formatting of user cached account
		formatter = StringFormatter()
		company = formatter.getCompany(user)
		profileName = formatter.getCompanyProfileName(user)
		email = formatter.getEmail(user)
		
		#retrieving content from form fields		
		title = self.request.get('txtTitle')
		id = formatter.formatID(title)
		content = self.request.get('txtContent')
		file = self.request.get("file")
		btnClicked = formatter.getButtonType(self.request.body)
			
		if title<>'':
			
			postLink = ('synapsync.com/update.html?company=%s/id=%s'%(profileName, id))


			bitly = BitLy(BITLY_USER, BITLY_KEY)
			postLink = bitly.shorten(postLink)
			
			#self.response.out.write(postLink)
			#return	

			postAttributes = [company, profileName, email, title, content, id]
			
			#if no file attached then just place type None else use attached file
			if file == '':
				postAttributes.append(None)
			else:
				postAttributes.append(file)
				
			postAttributes.append(postLink)
			
			response = ''
			if (btnClicked == 'Post'):
				status = 'Posted'
				postAttributes.append(status)
				emailObj = EmailProcessor()
			
				
				emails =  []

				emails = datastore.getEmailSubscriber(profileName)
				
				for e in emails:
					if (e <> None and e <> ''):				
						emailObj.sendAnnounceEmail(company, e.strip() , title, content + ' ' + postLink)
			
				#twitter
				#twitterAccounts = datastore.getTwitterAccounts(profileName)
			
				facebookAccounts = datastore.getFacebookAccounts(profileName)
				twitterAccounts = datastore.getTwitterAccounts(profileName)
				twitter = twitterAccounts
				for name in twitter:
					client = OAuthClient('twitter', self, name)
					response = client.post('/statuses/update', status = title + '\n' + postLink)
				for name in facebookAccounts:
					fb = facebook.Facebook(API_KEY, SECRET_KEY)
					fbResponse = fb.__call__('Stream.publish', {'session_key':name.dbSessionKey, 'message':title + '\n' + postLink, 'target_id':name.dbUid, 'uid':name.dbUid})

			elif (btnClicked == 'Save'):
				status = 'Saved'
				postAttributes.append(status)
		
			datastore.putPost(postAttributes)
			
			if response == "SynapSync could not post to Twitter. The server could not be contacted at this time. Please try again later.":
				self.response.out.write(response)
				return
			
		else:
			error = 'Please fill the Title and Content fields below!' 
		self.redirect('controlpanel.html')
コード例 #16
0
ファイル: register.py プロジェクト: filipmares/SynapSync
 def post(self):
 
   if (self.request.get('txtInviteCode') == 'SYNAPSE'):
       self.session = Session()
       datastore = DataStoreInterface()
   
       #collection of text box contents
       firstName = self.request.get('txtFirstName')
       lastName = self.request.get('txtLastName')
       company = self.request.get('txtCompany')
       email = self.request.get('txtEmail')
       password = self.request.get('txtPass1')
       repassword = self.request.get('txtPass2')
   
       #create session variable 
       self.session.delete_item('user')
       
       #create emailPOrcessor object
       emailObj = EmailProcessor()
               
       #check email address validity
       if emailObj.isValidEmail(email) == 0:
           render.doRender(self, 'register.html', {'error' : 'Invalid email address. Please input a valid email address.'})
           return
   
       #Ensure that the passwords match
       if password <> repassword:
           render.doRender(self, 'register.html', {'error' : 'Password did not match'})
           return
   
       #Check for any fields left empty
       if firstName == '' or lastName == '' or  company == '' or email == '' or password == '' or repassword == '':
           render.doRender(self, 'register.html', {'error' : 'Please fill in all the details'})
           return
   
       #See if the user already exists in the database
       if datastore.userExists(email) == 1:
           render.doRender(self, 'register.html', {'error' : 'The account associated with the email already exists'})
           return
   
       #check if company exists
       #IF it doesn't THEN add user as administrator and create company ELSE add user as editor
       if datastore.companyExists(company) == 0:
           if datastore.addUser([email, password, firstName, lastName, company, 'Administrator']) == 0:
               self.doRender(self, 'register.html', {'error' : 'Database could not add User: Adding a new user requires 6 attributes to be specified.'})
               return
               
           profileName = company.replace(' ', '').lower()
           if datastore.addCompany([company, profileName, email]) == 0:
               self.doRender(self, 'register.html', {'error' : 'Database could not add Company:  Adding a new company requires 3 attributes to be specified.'})
               return
       else:
           if datastore.addUser([email, password, firstName, lastName, company, 'Editor']) == 0:
               self.doRender(self, 'register.html', {'error' : 'Database could not add User: Adding a new user requires 6 attributes to be specified.'})
               return
   
       #create session variable based on email and company name
       username = company + " - " + email
       self.session['user'] = username
       self.redirect('controlpanel.html')
   else:
       render.doRender(self, 'register.html', {'error' : 'Sorry at this time SynapSync is open only to a limited number of users. Please check back at another time. <br><br>Thanks,<br> The SynapSync Team'})