Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Commit

Permalink
Add purge option to packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
powellchristoph committed Nov 10, 2014
1 parent d05b77b commit a3a812b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pyshop/config.py
Expand Up @@ -184,6 +184,12 @@ def includeme(config):
renderer=u'pyshop/account/delete.html',
permission=u'admin_view')

config.add_route(u'purge_package', u'/pyshop/purge/package/{package_id}')
config.add_view(u'pyshop.views.package.Purge',
route_name=u'purge_package',
renderer=u'pyshop/package/purge.html',
permission=u'admin_view')

# Current user can update it's information
config.add_route(u'edit_user', u'/pyshop/user')
config.add_view(u'pyshop.views.user.Edit',
Expand Down
6 changes: 6 additions & 0 deletions pyshop/templates/pyshop/package/list.html
Expand Up @@ -48,6 +48,7 @@
<th>{% trans %} last version {% endtrans %}</th>
<th>{% trans %} # downloads {% endtrans %}</th>
<th>{% trans %} source {% endtrans %}</th>
<th>{% trans %} remove {% endtrans %}</th>
</tr>
</thead>
<tbody>
Expand All @@ -68,6 +69,11 @@
{% trans %} mirror {% endtrans %}
{% endif %}
</td>
<td>
<a href="{{ route_url('purge_package', package_id=pkg.id) }}" class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-remove-sign"></span> purge
</a>
</td>
</tr>
{% endfor %}
</tbody>
Expand Down
3 changes: 3 additions & 0 deletions pyshop/templates/pyshop/package/purge.html
@@ -0,0 +1,3 @@
{% extends "/shared/form_delete.html" %}

{%block delete%}the package{% endblock%}?
10 changes: 9 additions & 1 deletion pyshop/views/package.py
Expand Up @@ -10,12 +10,13 @@

from pyshop.models import Package, Release, Classifier

from .base import View
from .base import View, DeleteView


log = logging.getLogger(__name__)



class List(View):

def render(self):
Expand Down Expand Up @@ -91,3 +92,10 @@ def render(self):

package = Package.by_name(self.session,
self.request.matchdict['package_name'])



class Purge(DeleteView):
model = Package
matchdict_key = 'package_id'
redirect_route = 'list_package'
3 changes: 2 additions & 1 deletion pyshop/views/simple.py
Expand Up @@ -233,7 +233,8 @@ def _create_release(self, package, data, session_users):
classifier = Classifier.by_name(self.session, name.decode('utf-8'))

while classifier:
release.classifiers.append(classifier)
if classifier not in release.classifiers:
release.classifiers.append(classifier)
if classifier not in package.classifiers:
package.classifiers.append(classifier)
classifier = classifier.parent
Expand Down

0 comments on commit a3a812b

Please sign in to comment.