Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Add DELETE endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
CM Lubinski committed Jul 14, 2016
1 parent 12ac9a1 commit af55411
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions regcore/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
mapping['notice'][verb] = wnotice.add
mapping['preamble'][verb] = wdocument.add
mapping['regulation'][verb] = wdocument.add
mapping['diff']['DELETE'] = wdiff.delete
mapping['layer']['DELETE'] = wlayer.delete
mapping['notice']['DELETE'] = wnotice.delete
mapping['preamble']['DELETE'] = wdocument.delete
mapping['regulation']['DELETE'] = wdocument.delete


# Re-usable URL patterns.
Expand Down
7 changes: 7 additions & 0 deletions regcore_write/views/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ def add(request, label_id, old_version, new_version):
storage.for_diffs.insert(
label_id, old_version, new_version, request.json_body)
return success()


@secure_write
def delete(request, label_id, old_version, new_version):
"""Delete the diff from the db"""
storage.for_diffs.delete(label_id, old_version, new_version)
return success()
9 changes: 8 additions & 1 deletion regcore_write/views/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@secure_write
@json_body
def add(request, doc_type, label_id, version=None):
"""Add this regulation node and all of its children to the db"""
"""Add this document node and all of its children to the db"""
try:
node = request.json_body
jsonschema.validate(node, REGULATION_SCHEMA)
Expand Down Expand Up @@ -67,3 +67,10 @@ def add_node(node, parent=None):

storage.for_documents.bulk_delete(doc_type, label_id, version)
storage.for_documents.bulk_insert(to_save, doc_type, version)


@secure_write
def delete(request, doc_type, label_id, version=None):
"""Delete this document node and all of its children from the db"""
storage.for_documents.bulk_delete(doc_type, label_id, version)
return success()
11 changes: 11 additions & 0 deletions regcore_write/views/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ def add(request, name, doc_type, doc_id):
return success()


@secure_write
def delete(request, name, doc_type, doc_id):
"""Delete the layer node and all of its children from the db"""
params = standardize_params(doc_type, doc_id)
if params.doc_type not in ('preamble', 'cfr'):
return user_error('invalid doc type')

storage.for_layers.bulk_delete(name, params.doc_type, params.doc_id)
return success()


def child_layers(layer_params, layer_data):
"""We are generally given a layer corresponding to an entire regulation.
We need to split that layer up and store it per node within the
Expand Down
7 changes: 7 additions & 0 deletions regcore_write/views/notice.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ def add(request, docnum):
storage.for_notices.delete(docnum)
storage.for_notices.insert(docnum, notice)
return success()


@secure_write
def delete(request, docnum):
"""Delete the notice from the db"""
storage.for_notices.delete(docnum)
return success()

0 comments on commit af55411

Please sign in to comment.