Exemple #1
0
 def getAllNotesForOwner(self,ownerid):
      
      allNotes = []
      
      try:
           for note in Notes.objects(Q(ownerId=ownerid) & Q(noteDeletionDate__gt=datetime.now())):
                if ownerid not in note.excludedOwners:
                     doc = formNoteDict(note,ownerid)
                     allNotes.append(doc)
      except Exception, e:
           self.logger.error('getAllNotesForOwner_Exception')
           self.logger.error(str(e),exc_info=True)
           return {"data" : []}
Exemple #2
0
 def removeNoteForOwner(self,noteid,ownerid):
      
      excludeUpdate = False
      favUpdate = False
      ownUpdate = False
      dataInAllList = False
      
      try:
           for n in Notes.objects(id=noteid):
                note = n
                
           for o in Owners.objects(id=ownerid):
                owner = o
                
           
           excludedOwners = note.excludedOwners
           if ownerid not in excludedOwners:
                excludedOwners.append(ownerid)
                note.excludedOwners = excludedOwners
                excludeUpdate = True
                
           favedOwners = note.favedOwners
           if ownerid in favedOwners:
                favedOwners.remove(ownerid)
                note.favedOwners = favedOwners
                favUpdate = True
                
           favorites = owner.favorites
           
           if noteid in favorites:
                dataInAllList = True
                favorites.remove(noteid)
                owner.favorites = favorites
                ownUpdate = True
           
           if dataInAllList == True:
                if excludeUpdate == True and favUpdate == True and ownUpdate == True:
                     note.save()
                     owner.save()
           else:
                if excludeUpdate == True or favUpdate == True:
                     note.save()
                     owner.save
                     
           if note.ownerId.id == owner.id:
                note.delete()          
           
      except Exception, e:
           self.logger.error('removeNoteForOwner_Exception')
           self.logger.error(str(e),exc_info=True)
           return {"data" : {"error":"error in removing notes"}}
Exemple #3
0
     def addNotesToFav(self,noteid,ownerid):
          
          ownerUpate = False
          noteUpdate = False
          excludeUpdate = False
          
          try:
               for n in Notes.objects(id=noteid):
                   note = n
               favedOwners = note.favedOwners
               if ownerid not in favedOwners:
                    favedOwners.append(str(ownerid))
                    note.favedOwners = favedOwners
                    ownerUpate = True
               else:
                    favedOwners.remove(str(ownerid))
                    note.favedOwners = favedOwners
                    ownerUpate = True
                    
               excludedOwners = note.excludedOwners
               if ownerid in excludedOwners:
                    excludedOwners.remove(ownerid)
                    note.excludedOwners = excludedOwners
                    excludeUpdate = True
                
               for o in Owners.objects(id=ownerid):
                    owner = o
               
               favorites = owner.favorites
               if noteid not in favorites:
                    favorites.append(str(noteid))
                    owner.favorites = favorites
                    noteUpdate = True
               else:
                    favorites.remove(str(noteid))
                    owner.favorites = favorites
                    noteUpdate = True
               
               if ownerUpate == True and noteUpdate == True:
                         note.save()
                         owner.save()
               

          except Exception, e:
               self.logger.error('AddNotes_Exception')
               self.logger.error(str(e),exc_info=True)
               return {"data" : {"error":"error in updating fav to notes"}}
Exemple #4
0
 def getAllFavNotesForOwner(self,ownerid):
      
      notesList = []
      allNotes = []
      
      try:
           
           for o in Owners.objects(id=ownerid):
                notesList = o.favorites
           
           for noteid in notesList:
                for note in Notes.objects(Q(id=noteid) & Q(noteDeletionDate__gt=datetime.now())):
                          doc = formNoteDict(note,ownerid)
                          allNotes.append(doc)
      except Exception, e:
           self.logger.error('getAllNotesFav_Exception')
           self.logger.error(str(e),exc_info=True)
           return {"data" : []}
Exemple #5
0
def dropAllCollections():

    Owners.drop_collection()
    Notes.drop_collection()
Exemple #6
0
 def getCount(self,ownerid):
           return {"data" : {"count" :Notes.objects(noteDeletionDate__gt=datetime.now()).count()}}
Exemple #7
0
 def postNewNote(self,postdata):
      
      try:
           note = Notes()
           
           for o in Owners.objects(id=postdata['ownerid']):
                owner = o
           
           note.ownerId = owner
           note.noteType = postdata['notetype']
           note.noteText = postdata['notetext']
           note.noteTextColor = postdata['notetextcolor']
           note.noteTextFontSize = postdata['notetextfontsize']
           note.noteTextFont = postdata['notetextfont']
           note.notePinned = postdata['notepinned']
           note.creationDate = datetime.now()
           days = 3
           if postdata['pintype'] == 'Bronze':
                days = 7
           elif postdata['pintype'] == 'Silver':
                days = 15
           elif postdata['pintype'] == 'Gold':
                days = 40
           if note.notePinned == True:
                note.noteDeletionDate = datetime.now() + timedelta(days=days)
                ownerQ = OwnerQueries()
                ownerQ.updatePinCount(postdata['ownerid'],postdata['pintype'],-1)
           else:
                note.noteDeletionDate = datetime.now() + timedelta(days=5)
           note.excludedOwners = []
           note.favedOwners = []
           note.noteProperty = postdata['noteProperty']
           note.imageURL = postdata['imageurl']
           note.pinPoint = postdata['pinPoint']
    
           newNote = note.save()
           
           doc = formNoteDict(newNote,postdata['ownerid'])
                    
           
      except Exception,e:
           self.logger.error('postNewNote_Exception')
           self.logger.error(str(e),exc_info=True)
           data = {"data" : {"error" : "Error in posting note"}}
           return data