Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #787 from pypa/docs_destroy_in_warehouse
Browse files Browse the repository at this point in the history
destroy documentation using warehouse now
  • Loading branch information
ewdurbin authored Mar 25, 2018
2 parents bc85fed + 1437f9d commit b3393a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 54 deletions.
16 changes: 7 additions & 9 deletions templates/pkg_edit.pt
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,14 @@ uncheck the button below</p>

<p>If you would like to <b>DESTROY</b> any existing documentation hosted at
<a tal:attributes="href string:http://pythonhosted.org/${data/name}"
tal:content="string:http://pythonhosted.org/${data/name}"></a>
Use this button, There is <b>no undo</b>.
tal:content="string:http://pythonhosted.org/${data/name}"></a>: Please use
<tal:x tal:condition="python:'testpypi' in app.config.url">
<a href="https://test.pypi.org/manage/projects/">the Warehouse test instance</a>
</tal:x>
<tal:x tal:condition="python:'testpypi' not in app.config.url">
<a href="https://pypi.org/manage/projects/">Warehouse</a>
</tal:x>
</p>
<form tal:attributes="action app/url_path" method="POST"
enctype="multipart/form-data">
<input type="hidden" name=":action" value="doc_destroy" />
<input type="hidden" name="name" tal:attributes="value data/name" />
<input type="submit" value="Destroy Documentation" />
</form>

<p></p>

</metal:fill>
Expand Down
45 changes: 0 additions & 45 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2456,51 +2456,6 @@ def doc_upload(self):
)
)

#
# Documentation Destruction
#
@must_tls
def doc_destroy(self):
# make sure the user is identified
if not self.authenticated:
raise Unauthorised, \
"You must be identified to edit package information"

# only allow via WebUI
self.csrf_check()

# figure the package name and version
name = version = None
if self.form.has_key('name'):
name = self.form['name']
if not name:
raise FormError, 'No package name given'

# make sure the user has permission to do stuff
if not (self.store.has_role('Owner', name) or
self.store.has_role('Admin', name) or
self.store.has_role('Maintainer', name)):
raise Forbidden, \
"You are not allowed to edit '%s' package information"%name

try:
self.store.lock_docs(name)
except store.LockedException:
raise FormError, "Error: Another doc modification is in progress."

# Assume the file is valid; remove any previous data
if self.docs_fs.exists(name):
for dirname, files in self.docs_fs.walk(name, search="depth"):
for filename in files:
self.docs_fs.remove(os.path.join(dirname, filename))
self.docs_fs.removedir(dirname)

self.store.set_has_docs(name, value=False)
self.store.log_docs(name, version, 'docdestroy')
self.store.changed()
self.write_template('message.pt', title='Documentation Destroyed',
message='Documentation Destroyed for %s.' % (name,),)

#
# Reverse download for Google AppEngine
#
Expand Down

0 comments on commit b3393a4

Please sign in to comment.