Skip to content

Commit

Permalink
[#1163] Use ckan.model.State instead of vdm.sqlalchemy.State
Browse files Browse the repository at this point in the history
This makes us a bit less tied to vdm.
  • Loading branch information
vitorbaptista committed Aug 16, 2013
1 parent 7c60ba4 commit ad2de00
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
5 changes: 2 additions & 3 deletions ckan/logic/action/get.py
Expand Up @@ -7,7 +7,6 @@

from pylons import config
import sqlalchemy
import vdm.sqlalchemy

import ckan.lib.dictization
import ckan.logic as logic
Expand Down Expand Up @@ -666,7 +665,7 @@ def user_list(context, data_dict):
)

# Filter deleted users
query = query.filter(model.User.state != vdm.sqlalchemy.State.DELETED)
query = query.filter(model.User.state != model.State.DELETED)

## hack for pagination
if context.get('return_query'):
Expand Down Expand Up @@ -1178,7 +1177,7 @@ def user_autocomplete(context, data_dict):
limit = data_dict.get('limit', 20)

query = model.User.search(q)
query = query.filter(model.User.state != vdm.sqlalchemy.State.DELETED)
query = query.filter(model.User.state != model.State.DELETED)
query = query.limit(limit)

user_list = []
Expand Down
4 changes: 2 additions & 2 deletions ckan/migration/versions/070_add_state_column_to_user_table.py
@@ -1,11 +1,11 @@
import vdm.sqlalchemy
import ckan.model


def upgrade(migrate_engine):
migrate_engine.execute(
'''
ALTER TABLE "user" ADD COLUMN "state" text NOT NULL DEFAULT '%s'
''' % vdm.sqlalchemy.State.ACTIVE
''' % ckan.model.State.ACTIVE
)


Expand Down
4 changes: 2 additions & 2 deletions ckan/model/follower.py
Expand Up @@ -80,8 +80,8 @@ def _get(cls, follower_id=None, object_id=None):
.filter(sqlalchemy.and_(follower_alias.id == follower_id,\
cls.follower_id == follower_alias.id,\
cls.object_id == object_alias.id,\
follower_alias.state != vdm.sqlalchemy.State.DELETED,\
object_alias.state != vdm.sqlalchemy.State.DELETED,\
follower_alias.state != ckan.model.State.DELETED,\
object_alias.state != ckan.model.State.DELETED,\
object_alias.id == object_id))

return query
Expand Down
4 changes: 2 additions & 2 deletions ckan/model/group.py
Expand Up @@ -195,8 +195,8 @@ def packages(self, with_private=False, limit=None,

query = meta.Session.query(_package.Package).\
filter(
or_(_package.Package.state == vdm.sqlalchemy.State.ACTIVE,
_package.Package.state == vdm.sqlalchemy.State.PENDING)). \
or_(_package.Package.state == model.State.ACTIVE,
_package.Package.state == model.State.PENDING)). \
filter(group_table.c.id == self.id).\
filter(member_table.c.state == 'active')

Expand Down
4 changes: 3 additions & 1 deletion ckan/model/user.py
Expand Up @@ -167,7 +167,9 @@ def number_administered_packages(self):
return q.count()

def is_deleted(self):
return self.state == vdm.sqlalchemy.State.DELETED
# have to import here to avoid circular imports
import ckan.model as model
return self.state == model.State.DELETED

def is_in_group(self, group):
return group in self.get_group_ids()
Expand Down

0 comments on commit ad2de00

Please sign in to comment.