diff --git a/ckanext/datarequests/actions.py b/ckanext/datarequests/actions.py index eb8ba30..011e13a 100644 --- a/ckanext/datarequests/actions.py +++ b/ckanext/datarequests/actions.py @@ -647,7 +647,7 @@ def delete_datarequest(context, data_dict): raise tk.ObjectNotFound(tk._('Data Request %s not found in the data base') % datarequest_id) data_req = result[0] - session.delete(data_req) + data_req.delete() session.commit() # Send emails diff --git a/ckanext/datarequests/db.py b/ckanext/datarequests/db.py index ebac8db..10dd720 100644 --- a/ckanext/datarequests/db.py +++ b/ckanext/datarequests/db.py @@ -38,7 +38,7 @@ def uuid4(): return str(uuid.uuid4()) -class DataRequest(model.DomainObject): +class DataRequest(model.core.StatefulObjectMixin, model.DomainObject): @classmethod def get(cls, **kw): @@ -186,6 +186,7 @@ def get_datarequest_followers_number(cls, **kw): sa.Column('data_outputs_description', sa.types.Unicode(constants.DESCRIPTION_MAX_LENGTH), primary_key=False, default=u''), sa.Column('status', sa.types.Unicode(constants.MAX_LENGTH_255), primary_key=False, default=u'Assigned'), sa.Column('requested_dataset', sa.types.Unicode(constants.MAX_LENGTH_255), primary_key=False, default=u''), + sa.Column('state', sa.types.UnicodeText, default=model.core.State.ACTIVE), extend_existing=True ) @@ -286,3 +287,7 @@ def update_db(deprecated_model=None): if 'title' in meta.tables['datarequests'].columns and meta.tables['datarequests'].columns['title'].type.length == 100: log.info("DataRequests-UpdateDB: 'title' field exists and length is 100, changing to 1000 characters...") DDL('ALTER TABLE "datarequests" ALTER COLUMN "title" TYPE varchar(1000)').execute(model.Session.get_bind()) + + if 'state' not in meta.tables['datarequests'].columns: + log.info("DataRequests-UpdateDB: 'state' field does not exist, adding...") + DDL('ALTER TABLE "datarequests" ADD COLUMN "state" text COLLATE pg_catalog."default";').execute(model.Session.get_bind())