def get(self, key): if key != '': user = User.get(key) else: user = self.current_user if user: template_values = models.get_paginated_foldmen(self, user, self.current_user) if self.current_user.id == user.id: for foldman in template_values['finished_foldmen']: if self.current_user.id in foldman.not_viewed_fb_uids: foldman.not_viewed = True template_values['user'] = user self.render(template_values, 'user.html') else: self.error(404)
def get(self, action, key = None): if(action == 'view'): foldman = models.Foldman.get(key) if foldman and not foldman.finished == None: template_values = { 'foldman': foldman, 'parts': models.Part.all().filter('foldman = ', foldman) } if self.current_user: if self.current_user.id in foldman.not_viewed_fb_uids: foldman.not_viewed_fb_uids.remove(self.current_user.id) foldman.put() self.render(template_values, 'foldmen_view.html') else: self.error(404) elif(action == 'cleanup'): models.unblock_inactive() # foldmen = models.Foldman.all().fetch(1000) # for f in foldmen: # if len(f.not_viewed_fb_uids) < 2: # f.not_viewed_fb_uids = [] # f.put() # # foldmen = models.Foldman.all().fetch(1000) # for f in foldmen: # ids = [] # parts = models.Part.all().filter('foldman = ', f) # for p in parts: # if p.fb_uid and p.fb_uid not in ids: # ids.append(str(p.fb_uid)) # # self.response.out.write(p.fb_uid) # # self.response.out.write("\n") # # # self.response.out.write(ids) # f.parts_fb_uids = (ids) # f.put() # # self.response.out.write("1") # parts = models.Part.all().fetch(1000) # for part in parts: # if part.foldman.parts_finished == 1 and part.type == 'head': # part.last_finished = True # elif part.foldman.parts_finished == 2 and part.type == 'torso': # part.last_finished = True # else: # part.last_finished = False # part.put() #try: # foldman = part.foldman #except: # part.delete() else: template_values = models.get_paginated_foldmen(self) self.render(template_values, 'foldmen_list.html')