Пример #1
0
 def get(self):
     #lists all projects a user can see
     
     #check login status
     project_member = login.getProjectMember()
     if project_member is None:
         self.redirect(login.getLoginScreen(self.request.uri))
         return
     
     #NEED TO EXPORT TO TEMPLATE
     render = getProjectListTemplate(project_member.key().id())
     if render is not None:
         self.response.out.write(render)
         return
     else:
         #commented out since we'll have the htm make an ajax update call on load
         #defs = getProjectListForUser(project_member.key().id())
         defs = {'u_name': project_member.name,
                 'u_id': project_member.key().id(),
                 'logout': login.getLogoutScreen("/")
                }
         
         template = jinja_environment.get_template('project_list.htm')
         render = template.render(defs)
         storeProjectListTemplate(project_member.key().id(), render)
     
     self.response.out.write(render)
Пример #2
0
 def post(self):
     #creates an invite email+hash to add a person to a project and logs it in db
     
     #check if project given
     project_id = self.request.get("p", default_value=None)
     if (project_id is None):
         logging.error("pj_id_invalid %s" % project_id)
         self.error(500)
         return
     
     project = Project.get_by_id(int(project_id))
     if project is None:
         logging.error("pj_notfound %s" % project_id)
         self.error(500)
         return
         
         
     #check if email given
     email = self.request.get("e", default_value=None)
     if (email is None):
         logging.error("eaddy_invalid %s" % email)
         self.error(500)
         return
     
     #check login status
     project_member = login.getProjectMember(deny_access=True)
     if project_member is None:
         # - deny access
         self.error(500)
         return
         
     login.inviteUser(email, project, project_member)
     
     self.response.out.write("1")
Пример #3
0
 def get(self):
     #returns a list of users that are members of a specific project
     #only works if user is logged in and member of project
     
     #check if project given
     project_id = self.request.get("p", default_value=None)
     if (project_id is None):
         logging.error("pj_id_invalid %s" % project_id)
         self.error(500)
         return
     
     project = Project.get_by_id(int(project_id))
     if project is None:
         logging.error("pj_notfound %s" % project_id)
         self.error(500)
         return
     
     #check login status
     project_member = login.getProjectMember(deny_access=True)
     if project_member is None or not checkProjectMembership(project, project_member):
         # - deny access
         self.error(500)
         return        
     
     users = []
     for key in project.users:
         pm = db.get(key)
         user = (pm.name, pm.key().id())
         users.append(user)
     
     
     #self.response.headers['Content-Type'] = 'application/json'
     self.response.out.write(json.dumps(users))
Пример #4
0
 def get(self):
     #given a list of users, returns a corresponding list of is_active
     
     #check login status
     project_member = login.getProjectMember(deny_access=True)
     if project_member is None:
         # - deny access
         self.error(500)
         return        
     
     #self.response.headers['Content-Type'] = 'application/json'
     
     users = self.request.get("users", default_value=None)
     if (users is None):
         self.error(500)
         return
         
     try:
         user_list = json.loads(users)
         active_list = []
         
         for user_id in user_list:
             active_list.append(getIsTyping(user_id))
             
         self.response.out.write(json.dumps(active_list))
         return
         
     except ValueError:
         return
Пример #5
0
    def get(self):
        #gets all of the data for a project - INCLUDING POSTS AND TODOS
        #this is what the browser pings when it wants to see what's changed
         
        #MAKE HEAVY USE OF MEMCACHE HERE TO CHECK IF UPDATED SINCE CACHE, IF NOT USE CACHE
         
        #We need to handle case of user not being member of project - no access page
        #returns a memcache lookup of the proj_key_lastupdated
        
        #check login status
        pjc = login.getProjectMember(deny_access=True)
        if pjc is None:
            self.error(500)
            return
        
        project_id = self.request.get("p", default_value=None)
        if project_id is None:
            logging.error("pj_id_invalid %s" % project_id)
            self.error(500)
            return
    
        project = Project.get_by_id(int(project_id))
        if project is None:
            logging.error("pj_notfound %s" % project_id)
            self.error(500)
            return
            
        #check permissions
        if pjc.key() not in project.users:
            self.error(500)
            return
        
    
        updated = project_handler.getProjectLastUpdated(project_id)
        last_checked = self.request.get("l", default_value='null')
        try:
            last = datetime.datetime.fromtimestamp(float(last_checked))
    
            if updated < last:   #short-circuit if the page wasn't updated recently to save lots of bandwidth
                self.response.out.write("0")
                return
        
        except ValueError:
            pass  #if no last_checked, just send the whole page anyways
        
        
            
        json_dat = getProjectData(project)
        
        #self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json_dat)
        
        
        
        
             
#in the future GetProjectDataHandler should actually just return data changed
# since a given date to save on update costs -- too much work for now
Пример #6
0
 def get(self):
     #check login status
     project_member = login.getProjectMember(deny_access=True)
     if project_member is None:
         self.error(500)
         return
         
     slot = self.request.get("slot", default_value=None)
     if slot is None:
         logging.error("slot_invalid %s" % project_id)
         self.error(500)
         return
     
     try:
         slot = int(slot)
         
     except ValueError:
         logging.error("slot_invalid %s" % slot)
         self.error(500)
         return    
         
     if slot < 1 or slot > 8:
         logging.error("slot_range_invalid %s" % slot)
         self.error(500)
         return
         
     #CHECK FOR PROJECTS OWNED BY PERSON THAT ALREADY OCCUPY THAT SLOT
     
     for key in project_member.own_projects:
         pj = db.get(key)
         if pj.slot == slot:
             logging.error("slot_occupied %s" % slot)
             self.error(500)
             return
         
         
     p = Project(name = "New Project",
                 slot = slot, 
                 creator = project_member,
                 users = [project_member.key()])
     p.put()
     
     t = Todo(name = 'Check out your new project',
              description = 'Click the X to delete this todo item',
              author = project_member,
              project_owner = p)
     t.put()
     
     p.tasks = [t.key()]
     p.put()
     
     project_member.own_projects.append(p.key())
     project_member.put()
     
     setProjectListNeedsUpdateForUser(project_member.key().id())
     
     self.redirect('/project?p=%s' % p.key().id())
Пример #7
0
 def post(self):
     #given the person is logged in, updates their is_active to true
     
     #check login status
     project_member = login.getProjectMember(deny_access=True)
     if project_member is None:
         # - deny access
         self.error(500)
         return
     else:
         setIsActive(project_member.user_id, True)
         self.response.out.write("1")
Пример #8
0
    def post(self):
        pass #adds a new post element to a top level todo, returns its key
             #it would be nice to detect @s here to send emails to people
        #adds a new todo element to a group, returns its key
        contents = self.request.get('c', default_value=None)
    
        if (contents is None):
            self.error(500)
            return
        
        #check login status
        pjc = login.getProjectMember(deny_access=True)
        if pjc is None:
            self.error(500)
            return
        
        todo_id = self.request.get("t", default_value=None)
        if todo_id is None:
            logging.error("td_id_invalid %s" % todo_id)
            self.error(500)
            return
            
        todo = Todo.get_by_id(int(todo_id))
        if todo is None:
            logging.error("td_notfound %s" % todo_id)
            self.error(500)
            return    
            
        project = todo.project_owner
        if project is None:
            logging.error("pj_notfound %s" % project_id)
            self.error(500)
            return
            
        #check permissions
        if pjc.key() not in todo.assigned_to.users:
            self.error(500)
            return
            
        p = Post(contents = utilities.ContentSanitizer.sanitize(contents),
                 author = pjc,
                 todo_owner = todo)
        p.put()
        
        todo.posts.append(p.key())
        todo.put()
        
        project_handler.projectJustUpdated(project)

        self.response.out.write("1")
Пример #9
0
 def get(self):
     #lists all projects a user can see for update cycle of projectListPageHandler
     
     #check login status
     project_member = login.getProjectMember()
     if project_member is None:
         self.error(500)
         return
     
     defs = getProjectListJSONForUser(project_member.key().id())
     
     
     #self.response.headers['Content-Type'] = 'application/json'
     self.response.out.write(defs)                
Пример #10
0
 def post(self):
     #if person logged in is a project head, removes a user from a project 
     #check login status
     pjc = login.getProjectMember()
     if pjc is None:
         self.error(500)
         return
     
     project_id = self.request.get("p", default_value=None)
     if project is None:
         logging.error("pj_id_invalid %s" % project_id)
         self.error(500)
         return
         
     project = Project.get_by_id(int(project_id))
     if project is None:
         logging.error("pj_notfound %s" % project_id)
         self.error(500)
         return    
         
     if project.creator is not pjc:
         self.error(500)
         return    
         
     rem_user_id = self.request.get("u", default_value=None)
     if rem_user_id is None:
         logging.error("remu_id_invalid %s" % rem_user_id)
         self.error(500)
         return
         
     rem_user = ProjectMember.get_by_id(int(rem_user_id))
     if rem_user is None:
         logging.error("remu_notfound %s" % rem_user_id)
         self.error(500)
         return    
         
     project_handler.setProjectListNeedsUpdateForUser(rem_user_id)
     project_handler.projectJustUpdated(project)
     
     for i in xrange(len(project.users)):
         if project.users[i] == rem_user_id:
             del project.users[i]
             project.put()
             self.request.out.write('1')
             return
             
     self.request.out.write('0')
Пример #11
0
 def post(self):
     #relocates a todo to a new place in the subtodo list
     new_place = self.request.get('i', default_value='n')
         
     #make an int
     try:
         new_place = int(new_place)
     except ValueError:
         self.error(500)
         return
     
     #check login status
     pjc = login.getProjectMember(deny_access=True)
     if pjc is None:
         self.error(500)
         return
     
     todo_id = self.request.get("t", default_value=None)
     if todo_id is None:
         logging.error("td_id_invalid %s" % todo_id)
         self.error(500)
         return
         
     todo = Todo.get_by_id(int(todo_id))
     if todo is None:
         logging.error("td_notfound %s" % todo_id)
         self.error(500)
         return    
         
     project = todo.project_owner
     if project is None:
         logging.error("pj_notfound %s" % project_id)
         self.error(500)
         return
         
     #check permissions
     if pjc.key() not in todo.assigned_to.users:
         self.error(500)
         return
     
     
     del todo.assigned_to.tasks[todo.assigned_to.tasks.index(todo.key())]
     todo.assigned_to.tasks.insert(new_place, todo.key())
     todo.assigned_to.put()
     
     
     project_handler.projectJustUpdated(project)
Пример #12
0
 def post(self):
     #adds a new todo element to a group, returns its key
     name = self.request.get('n', default_value=None)
     assignments = self.request.get('a', default_value='')
     description = self.request.get('d', default_value='')
 
     if (name is None):
         self.error(500)
         return
     
     #check login status
     pjc = login.getProjectMember(deny_access=True)
     if pjc is None:
         self.error(500)
         return
     
     project_id = self.request.get("p", default_value=None)
     if project_id is None:
         logging.error("pj_id_invalid %s" % project_id)
         self.error(500)
         return
         
     project = Project.get_by_id(int(project_id))
     if project is None:
         logging.error("pj_notfound %s" % project_id)
         self.error(500)
         return    
     
     #check permissions
     if pjc.key() not in todo.assigned_to.users:
         self.error(500)
         return
     
         
     t = Todo(name = utilities.ContentSanitizer.sanitize(name),
              description = utilities.ContentSanitizer.sanitize(description),
              tags = utilities.ContentSanitizer.sanitize(assignments),
              project_owner = project,
              author = pjc,
              assigned_to = matchProjectMembers(assignments, project))
     t.put()
     
     project.tasks.append(t.key())
     project.put()
     
     project_handler.projectJustUpdated(project)
Пример #13
0
    def get(self):
        #check login status
        pjc = login.getProjectMember()
        if pjc is None:
            self.redirect(login.getLoginScreen(self.request.uri))
            return
    
        project_id = self.request.get("p", default_value=None)
        if project_id is None:
            logging.error("pj_id_invalid %s" % project_id)
            self.error(500)
            return
        
        project = Project.get_by_id(int(project_id))
        if project is None:
            logging.error("pj_notfound %s" % project_id)
            self.error(500)
            return    
        
        #check permissions
        if pjc.key() not in project.users:
            self.error(500)
            return
        
        

        #NEED TO EXPORT TO TEMPLATE (using dat values)
        render = getProjectViewTemplate(project_id)
        if render is not None:
            self.response.out.write(render)
            return
        else:
            #commented out since we'll have the htm make an ajax update call on load
            #json_dat = page_update_handler(getProjectData(project)) #stored as JSON to make updates easier
            #defs = json.loads(json_dat)
            defs = {'u_name': pjc.name,
                    'u_id': pjc.key().id(),
                    'logout': login.getLogoutScreen("/"),
                    'pj_name': project.name
                   }
            
            template = jinja_environment.get_template('project_view.htm')
            render = template.render(defs)
            storeProjectViewTemplate(project_id, render)
        
        self.response.out.write(render)
Пример #14
0
 def post(self):
     #edits an existing todo 
     name = self.request.get('n', default_value=None)
     assignments = self.request.get('a', default_value=None)
     description = self.request.get('d', default_value=None)
     
     #check login status
     pjc = login.getProjectMember(deny_access=True)
     if pjc is None:
         self.error(500)
         return
     
     todo_id = self.request.get("t", default_value=None)
     if todo_id is None:
         logging.error("td_id_invalid %s" % todo_id)
         self.error(500)
         return
         
     todo = Todo.get_by_id(int(todo_id))
     if todo is None:
         logging.error("td_notfound %s" % todo_id)
         self.error(500)
         return    
         
     project = todo.project_owner
     if project is None:
         logging.error("pj_notfound %s" % project_id)
         self.error(500)
         return
         
     #check permissions
     if pjc.key().id() not in todo.assigned_to.users:
         self.error(500)
         return
     
     if name is not None:
         todo.name = utilities.ContentSanitizer.sanitize(name)
     if assignments is not None:
         todo.tags = utilities.ContentSanitizer.sanitize(assignments)
         todo.assigned_to = matchProjectMembers(assignments, project)
     if description is not None:
         todo.description = utilities.ContentSanitizer.sanitize(description)
     
     todo.put()
     
     project_handler.projectJustUpdated(project)
Пример #15
0
 def post(self):
     #lets people configure title, description, notepad of project
     title = self.request.get('t', default_value=None)
     description = self.request.get('d', default_value=None)
     notepad = self.request.get('n', default_value=None)
 
     if (title is None and description is None and notepad is None):
         self.error(500)
         return
     
     #check login status
     pjc = login.getProjectMember(deny_access=True)
     if pjc is None:
         self.error(500)
         return
     
     project_id = self.request.get("p", default_value=None)
     if project_id is None:
         logging.error("pj_id_invalid %s" % project_id)
         self.error(500)
         return
         
     project = Project.get_by_id(int(project_id))
     if project is None:
         logging.error("pj_notfound %s" % project_id)
         self.error(500)
         return    
         
     #check permissions
     if pjc.key() not in project.users:
         self.error(500)
         return
         
     if (title is not None):
         project.title = utilities.ContentSanitizer.sanitize(title)
     if (description is not None):
         project.description = utilities.ContentSanitizer.sanitize(description)
     if (notepad is not None):
         project.notepad = utilities.ContentSanitizer.sanitize(notepad)
     
     project.put()
     
     projectJustUpdated(project)
     
     self.response.out.write("1")
Пример #16
0
 def post(self):
     #check login status
     project_member = login.getProjectMember(deny_access=True)
     if project_member is None:
         self.error(500)
         return
         
     project_id = self.request.get("p", default_value=None)
     if project_id is None:
         logging.error("pj_id_invalid %s" % project_id)
         self.error(500)
         return
         
     project = Project.get_by_id(int(project_id))
     if project is None:
         logging.error("pj_notfound %s" % project_id)
         self.error(500)
         return    
     
     if project.creator.key().id() != project_member.key().id():
         logging.error("disagree %s" % project_id)
         self.error(500)
         return    
         
     #lots of db calls here
     for todo_id in project.tasks:
         logging.info(todo_id)
         t = db.get(todo_id)
         logging.info(t)
         db.delete(t.documents)
         db.delete(t.posts)
     
     db.delete(project.tasks)
         
     project.delete()
     
     del project_member.own_projects[project_member.own_projects.index(project.key())]
     project_member.put()
     
     clearProjectUpdated(project_id)
     setProjectListNeedsUpdateForUser(project_member.key().id())
     
     self.response.out.write("1")
Пример #17
0
 def post(self):
     #check login status
     project_member = login.getProjectMember(deny_access=True)
     if project_member is None:
         self.error(500)
         return
         
     todo_id = self.request.get("t", default_value=None)
     if todo_id is None:
         logging.error("td_id_invalid %s" % todo_id)
         self.error(500)
         return
         
     todo = Todo.get_by_id(int(todo_id))
     if todo is None:
         logging.error("td_notfound %s" % todo_id)
         self.error(500)
         return
         
     project = todo.project_owner
     if project is None:
         logging.error("pj_notfound %s" % project_id)
         self.error(500)
         return    
         
     #check permissions
     if pjc.key() not in todo.assigned_to.users:
         self.error(500)
         return
         
     
     db.delete(todo.documents)
     db.delete(todo.posts)
     
     del project.tasks[project.tasks.index(todo.key())]
     project.put()
         
     todo.delete()
     
     project_handlerprojectJustUpdated(project)
     
     self.response.out.write("1")
Пример #18
0
 def get(self):
     #checks an invite hash, asks them to login if not, then creates projectmember
     #finally redirects to the project page
     
     #check login status
     project_member = login.getProjectMember(deny_access=False)
     if project_member is None:
         self.redirect(login.getLoginScreen(self.request.uri))
         return
         
         
     project_handler.setProjectListNeedsUpdateForUser(project_member.key().id())
     project_handler.projectJustUpdated(project)
 
     success = login.checkInvite(project_member)
     if not success:
         self.response.headers['Content-Type'] = 'text/plain-text'
         self.response.out.write("""Invite was invalid or expired after 7 days.\n 
                                    Please get a new invite.""")
     else:
         self.redirect("/project?p=%s" % success.invited_to.key().id())