Skip to content

Commit

Permalink
fix warnings from test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomatsubara committed Sep 3, 2013
1 parent 2f0d711 commit c823121
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
syntax: glob

*.swp
*.pyc
*pip-delete-this-directory.txt
/build
Expand Down
22 changes: 14 additions & 8 deletions everpad/provider/sync/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ def pull(self):
self._check_sharing_information(note, note_ttype)

resource_ids = self._receive_resources(note, note_ttype)
self._remove_resources(note, resource_ids)
if resource_ids:
self._remove_resources(note, resource_ids)

self.session.commit()
self._remove_notes()
Expand Down Expand Up @@ -240,13 +241,18 @@ def _create_conflict(self, note, note_ttype):

def _remove_notes(self):
"""Remove not exists notes"""
self.session.query(models.Note).filter((
~models.Note.id.in_(self._exists)
| ~models.Note.conflict_parent_id.in_(self._exists)
) & ~models.Note.action.in_((
const.ACTION_NOEXSIST, const.ACTION_CREATE,
const.ACTION_CHANGE, const.ACTION_CONFLICT,
))).delete(synchronize_session='fetch')
if self._exists:
q = ((~models.Note.id.in_(self._exists) |
~models.Note.conflict_parent_id.in_(self._exists)) &
~models.Note.action.in_((
const.ACTION_NOEXSIST, const.ACTION_CREATE,
const.ACTION_CHANGE, const.ACTION_CONFLICT)))
else:
q = (~models.Note.action.in_((
const.ACTION_NOEXSIST, const.ACTION_CREATE,
const.ACTION_CHANGE, const.ACTION_CONFLICT)))
self.session.query(models.Note).filter(q).delete(
synchronize_session='fetch')
self.session.commit()

def _receive_resources(self, note, note_ttype):
Expand Down
13 changes: 9 additions & 4 deletions everpad/provider/sync/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,13 @@ def _update_notebook(self, notebook_ttype):

def _remove_notebooks(self):
"""Remove not received notebooks"""
if self._exists:
q = (~models.Notebook.id.in_(self._exists)
& (models.Notebook.action != const.ACTION_CREATE)
& (models.Notebook.action != const.ACTION_CHANGE))
else:
q = ((models.Notebook.action != const.ACTION_CREATE)
& (models.Notebook.action != const.ACTION_CHANGE))

self.session.query(models.Notebook).filter(
~models.Notebook.id.in_(self._exists)
& (models.Notebook.action != const.ACTION_CREATE)
& (models.Notebook.action != const.ACTION_CHANGE)
).delete(synchronize_session='fetch')
q).delete(synchronize_session='fetch')
13 changes: 8 additions & 5 deletions everpad/provider/sync/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def pull(self):
self._remove_tags()

def _create_tag(self, tag_ttype):
"""Create notebook from server"""
"""Create tag from server"""
tag = models.Tag(guid=tag_ttype.guid)
tag.from_api(tag_ttype)
self.session.add(tag)
Expand All @@ -108,7 +108,10 @@ def _update_tag(self, tag_ttype):

def _remove_tags(self):
"""Remove not exist tags"""
self.session.query(models.Tag).filter(
~models.Tag.id.in_(self._exists)
& (models.Tag.action != const.ACTION_CREATE)
).delete(synchronize_session='fetch')
if self._exists:
q = (~models.Tag.id.in_(self._exists)
& (models.Tag.action != const.ACTION_CREATE))
else:
q = (models.Tag.action != const.ACTION_CREATE)
self.session.query(models.Tag).filter(q).delete(
synchronize_session='fetch')

0 comments on commit c823121

Please sign in to comment.