Skip to content

Commit

Permalink
Added state column to datarequest table
Browse files Browse the repository at this point in the history
Updated `delete_datarequest` action to soft delete
  • Loading branch information
MarkCalvert committed Sep 10, 2024
1 parent 7b50b10 commit 67816a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ckanext/datarequests/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion ckanext/datarequests/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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())

0 comments on commit 67816a4

Please sign in to comment.