コード例 #1
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)
コード例 #2
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)
コード例 #3
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)
コード例 #4
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)
コード例 #5
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)
コード例 #6
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)
コード例 #7
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)
コード例 #8
0
 def get(self):
     render.render_page(self, 'settings.html', 'Settings')