Пример #1
0
	def change_profile(self):
		UserStore.delete('current_user')

		if UserStore.exists('friends_loaded'):
			UserStore.delete('friends_loaded')
			
		interest_tags = self.tags.text.splitlines()

		j = { 
			'Description': self.description.text if self.description.text is not None else '',
			'Twitter_Link': self.twitter.text if self.twitter.text is not None else '',
			'Instagram_Link': self.instagram.text if self.instagram.text is not None else '',
			'Spotify_Link': self.spotify.text if self.spotify.text is not None else '',
			'LinkedIn_Link':self.linked_in.text if self.linked_in.text is not None else ''
		}

		user_edits = User_Requests.edit(
			UserStore.get('user_info')['id'],
			UserStore.get('user_info')["token"],
			j
		)

		user_tags = User_Requests.add_tags(
			UserStore.get('user_info')['id'],
			UserStore.get('user_info')["token"],
			interest_tags
		)

		App.get_running_app().go_screen(7)
Пример #2
0
	def populate_profile(self, *args):
		
		self.user_pictures.clear_widgets()
		self.tag_grid.clear_widgets()

		this_user = User_Requests.get_info(
			UserStore.get('user_info')['id'],
			UserStore.get('user_info')["token"]
		)

		for pic in this_user['data']['pictures']:
			self.user_pictures.add_widget(
				AsyncImage(source=pic)
			)
		
		for tag in this_user['data']['tags']:
			self.tag_grid.add_widget(
				OutlinedButton(text='#' + tag)
			)

		self.fullname.text = this_user['data']["First_Name"] + " " + this_user['data']["Last_Name"]

		if this_user['data']["Description"] is not None or this_user['data']["Description"] == '':
			self.description.size_hint_y = None
			self.description.text = this_user['data']["Description"]
		else:
			self.description.size_hint_y = 0

		self.getText(this_user)

		UserStore.put('current_user', data=this_user['data'])
Пример #3
0
	def save_password(self, new_password):
		change = User_Requests.change_password(
			UserStore.get('user_info')['token'],
			new_password
		)

		if 'error' not in change:
			App.get_running_app().go_screen(7)
			Popup(
				title="Password Successfully Changed!",
				size_hint=(.5, .1)
			).open()
		else:
			Popup(
				title=change['error']['title'],
				content=Label(
					text=change['error']['description']
				),
				size_hint=(.8, .2)
			).open()

		# Hides the 'enter new password' section again
		self.prompt.text = ''
		self.new_pass.height = dp(0)
		self.new_pass.text = ''
		self.save.back_color = (192, 192, 192, 0)
		self.save.height = dp(0)
		self.save.text = ''
		self.pass_code.text = ''
Пример #4
0
	def save_user(self):

		if not re.match(r'\d{4}-\d{2}-\d{2}', self.dob.text):
			Popup(
				title='Input Error.',
				content=Label(
					text='Date is in the incorrect format.'
				),
				size_hint=(.8, .2)
			).open()
		else:
			j = {
				"Email": self.uni_email.text, "First_Name": self.first_name.text,
				"Last_Name": self.last_name.text, "DateOfBirth": self.dob.text, 
				"Password": self.password.text
			}

			created_user = User_Requests.create(j)
			if 'error' not in created_user:
				UserStore.put(
					'user_info',  
					token=created_user["access_token"], 
					id=created_user["data"]["User_ID"]
				)
				App.get_running_app().root.current = "account_verification"
			else:
				Popup(
					title=created_user['error']['title'],
					content=Label(
						text=created_user['error']['description']
					),
					size_hint=(.8, .2)
				).open()
Пример #5
0
	def populate(self):

		self.data = []

		friends = User_Requests.get_friend_requests(
			UserStore.get('user_info')["id"],
			UserStore.get('user_info')["token"]
		)

		if 'error' not in friends:
			index = 0
			for friend in friends['data']:
				self.data.append({
					'id':str(friend["User_ID"]),
					'name': friend["First_Name"]+" "+friend["Last_Name"],
					'picture': friend['Picture_Path'],
					'index': str(index)
				})
				index += 1
		else:
			Popup(
				title=friends['error']['title'],
				content=Label(
					text=friends['error']['description']
				),
				size_hint=(.8, .2)
			).open()
Пример #6
0
	def build(self):
		if UserStore.exists('current_user'):
			UserStore.delete('current_user')

		if UserStore.exists('friends_loaded'):
			UserStore.delete('friends_loaded')

		if UserStore.exists('curr_profile'):
			UserStore.delete('curr_profile')

		if UserStore.exists('curr_event'):
			UserStore.delete('curr_event')

		self.screens = {} # Empty screen list
		self.available_screens = sorted([	
			'app_settings', 'change_password', 'create_event', 'eventfind', 'friends', 'match', 'match_profile', 'profile',
		'report_event', 'report_user', 'view_event']) # Explicitly sets the available screens
		self.screen_names = self.available_screens 
		curdir = dirname(__file__)
		self.available_screens = [join(curdir, 'data', 'screens', '{}.kv'.format(fn).lower()) for fn in self.available_screens] # Create a list of available screens from the kv files
		#self.go_screen(5) # goto match screen 
		
		if UserStore.exists("user_info"):
			if UserStore.get('user_info')["token"] is not None:
				query = User_Requests.login({}, auth_token=UserStore.get('user_info')["token"])
				if 'error' not in query:
					self.root.current = "main"
					self.go_screen(5)

		return self.root
Пример #7
0
	def populate_match(self, uid=None):

		UserStore.put('curr_profile', id=UserStore.get('curr_profile')['id'], viewed=True)

		this_user = User_Requests.get_info(
			uid,
			UserStore.get('user_info')["token"]
		)

		for pic in this_user['data']['pictures']:
			self.user_pictures.add_widget(
				AsyncImage(source=pic)
			)
		
		for tag in this_user['data']['tags']:
			self.tag_grid.add_widget(
				OutlinedButton(text='#' + tag)
			)

		self.user_id = str(uid)
		self.fullname.text = this_user['data']["First_Name"] + " " + this_user['data']["Last_Name"]

		if this_user['data']["Description"] is not None or this_user['data']["Description"] == '':
			self.description.size_hint_y = None
			self.description.text = this_user['data']["Description"]
		else:
			self.description.size_hint_y = 0

		self.getText(this_user)
Пример #8
0
 def test_user_login_manual(self):
     with TestUser() as user:
         output = User_Requests.login({
             'Email':
             user._user_info['Email'],
             'Password':
             user._user_info['Password']
         })
         print(output)
         self.assertIsNotNone(output)
Пример #9
0
	def save_profile(self):

		interest_tags = self.tags.text.splitlines()

		j = { 
			'Description': self.description.text if self.description.text is not None else '',
			'Twitter_Link': self.twitter.text if self.twitter.text is not None else '',
			'Instagram_Link': self.instagram.text if self.instagram.text is not None else '',
			'Spotify_Link': self.spotify.text if self.spotify.text is not None else '',
			'LinkedIn_Link':self.linked_in.text if self.linked_in.text is not None else ''
		}

		user_edits = User_Requests.edit(
			UserStore.get('user_info')['id'],
			UserStore.get('user_info')["token"],
			j
		)

		user_tags = User_Requests.add_tags(
			UserStore.get('user_info')['id'],
			UserStore.get('user_info')["token"],
			interest_tags
		)
Пример #10
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     sleep(5)
     resp = User_Requests.delete(self._resp['data']['User_ID'],
                                 self._resp['access_token'])
     if resp is not None:
         print('Deleted User: {id}, {fname} {lname}'.format(
             id=self._resp['data']['User_ID'],
             fname=self._user_info['First_Name'],
             lname=self._user_info['Last_Name']))
     else:
         print('Failed to deleted User: {id}, {fname} {lname}'.format(
             id=self._resp['data']['User_ID'],
             fname=self._user_info['First_Name'],
             lname=self._user_info['Last_Name']))
Пример #11
0
	def decline_request(self, user_id):
		request = User_Requests.decline_friend_request(
			user_id,
			UserStore.get('user_info')["token"]
		)
		if 'error' not in request:
			App.get_running_app().go_screen(5)
		else:
			Popup(
				title=request['error']['title'],
				content=Label(
					text=request['error']['description']
				),
				size_hint=(.8, .2)
			).open()
Пример #12
0
	def accept_request(self, user_id):
		request = User_Requests.accept_friend_request(
			user_id,
			UserStore.get('user_info')["token"]
		)
		if 'error' not in request:
			self.delete_entry()
		else:
			Popup(
				title=request['error']['title'],
				content=Label(
					text=request['error']['description']
				),
				size_hint=(.8, .2)
			).open()
Пример #13
0
	def verify(self, code):
		verif = User_Requests.verify(
			UserStore.get('user_info')['id'],
			UserStore.get('user_info')["token"],
			code
		)

		if 'error' not in verif:
			App.get_running_app().root.current = 'profile_creation'
		else:
			Popup(
				title=verif['error']['title'],
				content=Label(
					text=verif['error']['description']
				),
				size_hint=(.8, .2)
			).open()
Пример #14
0
	def login_click(self):
		j = { "Email": self.uni_email.text, "Password": self.password.text}
		user_details = User_Requests.login(j)
		if 'error' not in user_details:
			UserStore.put(
				'user_info',  
				token=user_details["access_token"], 
				id=user_details["data"]["User_ID"]
			)
			App.get_running_app().root.current = "main"
			App.get_running_app().go_screen(5)
		else:
			Popup(
				title=user_details['error']['title'],
				content=Label(
					text=user_details['error']['description']
				),
				size_hint=(.8, .2)
			).open()
Пример #15
0
	def add_user(self, user_id):
		request = User_Requests.send_friend_request(
			user_id,
			UserStore.get('user_info')["token"]
		)

		if 'error' not in request:
			UserStore.put(
				'marked_users', 
				id=[user_id] if not UserStore.exists('marked_users') \
					else UserStore.get('marked_users')['id'] + [user_id]
			)
			App.get_running_app().go_screen(5)
		else:
			Popup(
				title=requests['error']['title'],
				content=requests['error']['description'],
				size_hint=(.5, .1)
			).open()
Пример #16
0
	def select(self, filename):
		try:
			popupWindow = Popup(
				title="Photo Selection",
				content=Label(
					text="Photo selected and saved! \n \n Click anywhere on the \n screen to continue...",
					font_size=14, halign='center'),
				size_hint=(None, None), size=(200, 200)
			)
			popupWindow.open()

			user_image = User_Requests.upload_image(
				UserStore.get('user_info')["token"],
				filename[0]
			)

			self.filechooser.selection.clear()
			
		except:
			pass
Пример #17
0
	def populate(self):

		print('REPOPULATING')
		self.data = []

		matches = User_Requests.get_matches(
			UserStore.get('user_info')["token"]
		)

		marked_users = []
		if UserStore.exists('marked_users'):
			marked_users = UserStore.get('marked_users')['id']

		print(marked_users)
		if 'error' not in matches:
			for match in matches['data']:
				if str(match['User_ID']) not in marked_users:
					tags = ''
					for i in range(0,len(match['Matches'])):
						if i < 3:
							tags += '#{}'.format(match['Matches'][i])
							if i != len(match['Matches']) - 1:
								tags += '\n'
						else:
							tags += '...'
							break

					self.data.append({
						'id':str(match["User_ID"]),
						'name': match["First_Name"]+" "+match["Last_Name"],
						'tags':tags,
						'picture': match['Picture_Path']
					})
		else:
			Popup(
				title=matches['error']['title'],
				content=Label(
					text=matches['error']['description']
				),
				size_hint=(.8, .2)
			).open()
Пример #18
0
	def populate(self):
		events = User_Requests.get_feed(
			UserStore.get('user_info')["token"],
			limit = 100
		)

		if 'error' not in events:
			for e in events['data']:
				self.data.append({
					'id':str(e['Event_ID']),
					'name': e["Name"], 
					'imagePath': e["Picture_Path"],
					'attendees': e['Attendees'],
				})
		else:
			Popup(
				title=events['error']['title'],
				content=Label(
					text=events['error']['description']
				),
				size_hint=(.8, .2)
			).open()
Пример #19
0
	def populate(self):

		friends = User_Requests.get_friends(
			UserStore.get('user_info')["id"],
			UserStore.get('user_info')["token"]
		)

		if 'error' not in friends:
			for friend in friends['data']:
				self.data.append({
					'id':str(friend["User_ID"]),
					'name': friend["First_Name"]+" "+friend["Last_Name"],
					'picture': friend['Picture_Path']
				})
		else:
			Popup(
				title=friends['error']['title'],
				content=Label(
					text=friends['error']['description']
				),
				size_hint=(.8, .2)
			).open()

		UserStore.put('friends_loaded', value=True)
Пример #20
0
	def on_enter(self):
		get_code = User_Requests.get_change_password_code(
			UserStore.get('user_info')['token']
		)
Пример #21
0
 def __init__(self):
     self._user_info = self.get_user_info()
     self._resp = User_Requests.create(self._user_info)
Пример #22
0
 def test_user_login_auto(self):
     with TestUser() as user:
         output = User_Requests.login({},
                                      auth_token=user._resp['access_token'])
         print(output)
         self.assertIsNotNone(output)