Exemplo n.º 1
0
 def post(self):
     user = users.get_current_user()
     if user:
         # Retrieve data from form
         title = self.request.get('title')
         content = self.request.get('content')
         days = int(self.request.get('days'))
         hours = int(self.request.get('hours'))
         # Convert 'on' or 'off' from checkbox to True or False
         important_original = self.request.get('important')
         if important_original == 'on':
             important = True
         else:
             important = False
         # Retrieve person and home objects
         person = login.is_roommate_account_initialized(user)
         person_name = Person.query().filter(
             Person.user_id == person.user_id).fetch()[0].name
         home = Home.query().filter(Home.key == person.home_key).fetch()
         # Calculate expiration time
         cur_time = time.time()
         expir_time = cur_time + days * 24 * 60 * 60 + hours * 60 * 60
         # Create and put new sticky
         new_sticky = Sticky(title=title,
                             content=content,
                             important=important,
                             author=person_name,
                             home_key=person.home_key,
                             expiration=expir_time)
         new_sticky.put()
         render.render_page(self, 'stickyCreated.html', "Sticky Created")
         helpers.redirect(self, '/dashboard', 1000)
Exemplo n.º 2
0
 def post(self):
     user = users.get_current_user()
     person = login.is_roommate_account_initialized(user)
     home = Home.query(Home.key == person.home_key).fetch()[0]
     home_key = home.key
     chore_name = self.request.get('chore_name')
     duration = int(self.request.get('days'))
     cur_time = time.time()
     duration = duration * 24 * 60 * 60
     end_time = cur_time + duration
     workers = []
     workers_names = []
     for p in home.occupants:
         if self.request.get(p) == 'on':
             workers.append(p)
             per = Person.query().filter(
                 Person.user_id == p).fetch()[0].name
             workers_names.append(per)
     chore = Chore(home_key=home_key,
                   workers_names=workers_names,
                   chore_name=chore_name,
                   duration=duration,
                   end_time=end_time,
                   workers=workers)
     chore.put()
     render.render_page(self, 'choreCreated.html', 'Chore Created')
     helpers.redirect(self, '/dashboard', 1000)
Exemplo n.º 3
0
 def get(self):
     user = users.get_current_user()
     if user:
         person = login.is_roommate_account_initialized(user)
         if person:
             if (person.do_not_disturb):
                 person.do_not_disturb = False
                 data = {'dnd_state': 'Do not disturb is off.'}
                 person.put()
             else:
                 person.do_not_disturb = True
                 data = {'dnd_state': 'DO NOT DISTURB!'}
                 person.put()
                 sender_address = 'Roommates <*****@*****.**>'
                 occupants = Home.query().filter(
                     Home.key == person.home_key).fetch()[0].occupants
                 for occupant in occupants:
                     receipient = Person.query().filter(
                         Person.user_id == occupant).fetch()[0]
                     receipient = receipient.email_address
                     if receipient == person.email_address:
                         logging.info(occupant)
                     else:
                         helpers.send_dnd_mail(sender_address, person.name,
                                               receipient)
             render.render_page_with_data(self, 'doNotDisturb.html',
                                          "Do Not Disturb Toggle", data)
             helpers.redirect(self, '/dashboard', 1000)
         else:
             helpers.redirect(self, '/', 0)
     else:
         helpers.redirect(self, '/', 0)
Exemplo n.º 4
0
 def get(self):
     user = users.get_current_user()
     if user:
         person = login.is_roommate_account_initialized(user)
         if person:
             render.render_page(self, 'createSticky.html',
                                "Create a Sticky")
         else:
             helpers.redirect(self, '/', 0)
     else:
         helpers.redirect(self, '/', 0)
Exemplo n.º 5
0
 def get(self):
     user = users.get_current_user()
     if user:
         person = login.is_roommate_account_initialized(user)
         if person:
             render_data = helpers.getDashData(self, person)
             render.render_page_with_data(self, 'dashboard.html',
                                          person.name + "'s Dashboard",
                                          render_data)
         else:
             helpers.redirect(self, '/', 0)
     else:
         helpers.redirect(self, '/', 0)
Exemplo n.º 6
0
 def post(self):
     user = users.get_current_user()
     if user:
         person = login.is_roommate_account_initialized(user)
         sticky_title = self.request.get('sticky_title')
         sticky_content = self.request.get('sticky_content')
         sticky = Sticky.query().filter(
             Sticky.content == sticky_content, Sticky.title == sticky_title,
             Sticky.author == person.user_id).fetch()
         sticky = sticky[0]
         sticky.key.delete()
     render.render_page(self, "stickyDeleted.html", "Sticky Deleted!")
     helpers.redirect(self, '/dashboard', 1000)
Exemplo n.º 7
0
 def get(self):
     # Get current google account that is signed in
     user = users.get_current_user()
     # Check if there is a user signed in
     if user:
         person = login.is_roommate_account_initialized(user)
         if person:
             if person.home_key:
                 helpers.redirect(self, '/', 0)
         render.render_page_without_header(self, 'newJoinHome.html',
                                           'Join a Room')
     # If there is no user, prompt client to login
     else:
         helpers.redirect(self, '/', 0)
Exemplo n.º 8
0
    def get(self):
        # Get current google account that is signed in
        user = users.get_current_user()

        # Check if there is a user signed in
        if user:

            person = login.is_roommate_account_initialized(user)
            if person:
                None

        # If there is no user, prompt client to login
        else:
            helpers.redirect(self, '/', 0)
Exemplo n.º 9
0
 def post(self):
     user = users.get_current_user()
     person = login.is_roommate_account_initialized(user)
     home = Home.query(Home.key == person.home_key).fetch()[0]
     bill_name = self.request.get('bill_name')
     payer_id = self.request.get('payer')
     payer_name = Person.query().filter(
         Person.user_id == payer_id).fetch()[0].name
     home_key = home.key
     bill = Bills(bill_name=bill_name,
                  home_key=home_key,
                  payer_id=payer_id,
                  payer_name=payer_name)
     bill.put()
     render.render_page(self, 'billsCreated.html', 'Bill Created')
     helpers.redirect(self, '/dashboard', 1000)
Exemplo n.º 10
0
 def post(self):
     user = users.get_current_user()
     if user:
         person = login.is_roommate_account_initialized(user)
         chore_home_key = person.home_key
         chore_name = self.request.get('chore_name')
         chore_end_time = float(self.request.get('chore_end_time'))
         chore = Chore.query().filter(
             Chore.chore_name == chore_name,
             Chore.home_key == chore_home_key).fetch()
         chore = chore[0]
         if chore.completed:
             chore.completed = False
         else:
             chore.completed = True
         chore.put()
     render.render_page(self, "choreCompleted.html", "Chore Completed")
     helpers.redirect(self, '/dashboard', 1000)
Exemplo n.º 11
0
 def get(self):
     user = users.get_current_user()
     if user:
         person = login.is_roommate_account_initialized(user)
         if person:
             home = Home.query(Home.key == person.home_key).fetch()[0]
             possible_payers = []
             for user_id in home.occupants:
                 p = Person.query().filter(
                     Person.user_id == user_id).fetch()[0]
                 possible_payers.append(p)
             data = {'payers': possible_payers}
             render.render_page_with_data(self, 'bills.html',
                                          'Assign a Bill', data)
         else:
             helpers.redirect(self, '/', 0)
     else:
         helpers.redirect(self, '/', 0)
Exemplo n.º 12
0
 def get(self):
     user = users.get_current_user()
     if user:
         person = login.is_roommate_account_initialized(user)
         if person:
             home = Home.query(Home.key == person.home_key).fetch()[0]
             rotation_list = []
             for user_id in home.occupants:
                 p = Person.query().filter(
                     Person.user_id == user_id).fetch()[0]
                 rotation_list.append(p)
             data = {'rotation_list': rotation_list}
             render.render_page_with_data(self, 'chores.html',
                                          'Create a Chore', data)
         else:
             helpers.redirect(self, '/', 0)
     else:
         helpers.redirect(self, '/', 0)
Exemplo n.º 13
0
 def post(self):
     user = users.get_current_user()
     if user:
         person = login.is_roommate_account_initialized(user)
         sticky_title = self.request.get('sticky_title')
         sticky_content = self.request.get('sticky_content')
         sticky_author = self.request.get('sticky_author')
         sticky = Sticky.query().filter(
             Sticky.content == sticky_content,
             Sticky.title == sticky_title).fetch()
         sticky = sticky[0]
         if sticky.completed:
             sticky.completed = False
         else:
             sticky.completed = True
         sticky.put()
     render.render_page(self, "stickyToggle.html",
                        "Sticky Completed Toggled")
     helpers.redirect(self, '/dashboard', 1000)
Exemplo n.º 14
0
def removeFromRoom(self, user):
	person = login.is_roommate_account_initialized(user)
	
	if person:
		home = Home.query().filter(Home.key == person.home_key).fetch()[0]
		logging.info("Person: ")
		logging.info(person)
		logging.info("Home Occupants: ")
		logging.info(home.occupants)
	else:
		logging.info("no person")
	
	#Removes person from record of Home
	if person.user_id in home.occupants:
		home.occupants.remove(person.user_id)
		logging.info("Home occupants: ")
		logging.info(home.occupants)
		chores = Chore.query().filter(Chore.home_key == home.key)
		bills = Bills.query().filter(Bills.home_key == home.key)
		if len(home.occupants) == 0:
			
			for c in chores:
				c.key.delete()
			
			for b in bills:
				b.key.delete()
			home.key.delete()
		else: #Creo que esto funcione
			for c in chores:
				if person.user_id in c.workers:
					c.workers.remove(person.user_id)
			for b in bills:
				if b.payer_id == person.user_id:
					b.key.delete()
			home.put()
		#Find stickies associated with person
		stickies = Sticky.query().filter(Sticky.author == person.user_id)
		for note in stickies:
			note.key.delete()
		#Updates person and home entries
		person.key.delete()
Exemplo n.º 15
0
    def get(self):
        # Get current google account that is signed in
        user = users.get_current_user()
        # Check if there is a user signed in
        if user:
            # Check if user has an account set up
            person = login.is_roommate_account_initialized(
                user)  #Change to check if in home

            if person:
                if login.is_in_room(self, person):
                    helpers.redirect(self, '/dashboard', 0)
            # Otherwise, prompt user to create account
                else:
                    helpers.redirect(self, '/newJoinHome', 0)  #/new_join_home
            else:
                #redirect to create account page
                helpers.redirect(self, '/newJoinHome', 0)  #/new_join_home
        # If there is no user, prompt client to login
        else:
            login.render_login_page(self)
Exemplo n.º 16
0
 def get(self):
     user = users.get_current_user()
     if user:
         person = login.is_roommate_account_initialized(user)
         if person:
             if (person.location):
                 person.location = False
                 person.put()
             else:
                 person.location = True
                 person.put()
             if (person.location):
                 data = {'check_in_state': 'Checked In!'}
             else:
                 data = {'check_in_state': 'Checked Out!'}
             render.render_page_with_data(self, 'checkInState.html',
                                          "Check In or Out", data)
             helpers.redirect(self, '/dashboard', 1000)
         else:
             helpers.redirect(self, '/', 0)
     else:
         helpers.redirect(self, '/', 0)
Exemplo n.º 17
0
    def get(self):
        # Get current google account that is signed in
        user = users.get_current_user()
        # Check if there is a user signed in
        if user:
            person = login.is_roommate_account_initialized(user)
            if person:
                # Get the authorized Http object created by the decorator.
                http = decorator.http()
                # Call the service using the authorized Http object.
                now = datetime.datetime.utcnow().isoformat(
                ) + 'Z'  # 'Z' indicates UTC time
                requestResults = service.events().list(
                    calendarId='primary',
                    timeMin=now,
                    maxResults=10,
                    singleEvents=True,
                    orderBy='startTime').execute(http=http)

            else:
                helpers.redirect(self, '/', 0)
        # If there is no user, prompt client to login
        else:
            helpers.redirect(self, '/', 0)