warn of the cascading version delete (bug 621801)
This commit is contained in:
Родитель
9389ba32f5
Коммит
a921e929b3
|
@ -77,7 +77,8 @@
|
|||
</div>
|
||||
|
||||
<h3>{{ _('Version History') }}</h3>
|
||||
<div class="item" id="version-list">
|
||||
<div class="item" id="version-list"
|
||||
data-stats="{{ url('devhub.versions.stats', addon.slug) }}">
|
||||
<div class="item_wrapper">
|
||||
<table>
|
||||
<tr>
|
||||
|
@ -107,7 +108,7 @@
|
|||
</span>
|
||||
</td>
|
||||
<td class="file-status">
|
||||
{% for (count, status) in dev_files_status(version.all_files): %}
|
||||
{% for (count, status) in dev_files_status(version.all_files) %}
|
||||
<div>
|
||||
{# L10n: {0} is the number of files, {1} is the status #}
|
||||
{{ ngettext('{0} file is {1}', '{0} files are {1}', count)
|
||||
|
@ -145,10 +146,15 @@
|
|||
|
||||
<div id="modal-delete-version" class="modal modal-delete">
|
||||
<form method="post" action="{{ url('devhub.versions.delete', addon.slug) }}">
|
||||
<h3>{{ _('Delete Version') }}</h3>
|
||||
<h3>{{ _('Delete Version {version}') }}</h3>
|
||||
<p>
|
||||
{% trans %}
|
||||
Deleting your add-on version will remove it from the site.
|
||||
Deleting this version will permanently delete:
|
||||
<ul>
|
||||
<li id="del-files"></li>
|
||||
<li id="del-reviews"></li>
|
||||
</ul>
|
||||
Are you sure you wish to delete this version?
|
||||
{% endtrans %}
|
||||
</p>
|
||||
{{ csrf() }}
|
||||
|
|
|
@ -43,6 +43,8 @@ detail_patterns = patterns('',
|
|||
url('^versions/delete$', views.version_delete,
|
||||
name='devhub.versions.delete'),
|
||||
url('^versions/add$', views.version_add, name='devhub.versions.add'),
|
||||
url('^versions/stats$', views.version_stats,
|
||||
name='devhub.versions.stats'),
|
||||
url('^versions/(?P<version_id>\d+)$', views.version_edit,
|
||||
name='devhub.versions.edit'),
|
||||
url('^versions/(?P<version_id>\d+)/add$', views.version_add_file,
|
||||
|
|
|
@ -5,6 +5,7 @@ import json
|
|||
import os
|
||||
|
||||
from django import http
|
||||
from django.db.models import Count
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.utils.http import urlquote
|
||||
|
||||
|
@ -650,6 +651,15 @@ def version_bounce(request, addon_id, addon, version):
|
|||
raise http.Http404()
|
||||
|
||||
|
||||
@json_view
|
||||
@dev_required
|
||||
def version_stats(request, addon_id, addon):
|
||||
qs = (Version.objects.filter(addon=addon)
|
||||
.annotate(reviews=Count('reviews'), files=Count('files'))
|
||||
.values('id', 'version', 'reviews', 'files'))
|
||||
return dict((v['id'], v) for v in qs)
|
||||
|
||||
|
||||
Step = collections.namedtuple('Step', 'current max')
|
||||
|
||||
|
||||
|
|
|
@ -223,34 +223,37 @@ function initUploadIcon() {
|
|||
|
||||
function initVersions() {
|
||||
$('#modals').hide();
|
||||
var versions;
|
||||
$.getJSON($('#version-list').attr('data-stats'),
|
||||
function(json){ versions = json; });
|
||||
|
||||
$('#modal-delete-version').modal('.version-delete .remove',
|
||||
{ width: 400,
|
||||
callback:function(d){
|
||||
$('.version_id', this).val($(d.click_target).attr('data-version'));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$('#modal-cancel').modal('#cancel-review',
|
||||
{ width: 400
|
||||
});
|
||||
|
||||
|
||||
$('#modal-delete').modal('#delete-addon',
|
||||
{ width: 400,
|
||||
});
|
||||
|
||||
{width: 400,
|
||||
callback: function(d){
|
||||
/* This sucks because of ngettext. */
|
||||
var version = versions[$(d.click_target).attr('data-version')],
|
||||
header = $('h3', this),
|
||||
files = $('#del-files', this),
|
||||
reviews = $('#del-reviews', this);
|
||||
header.text(format(header.text(), version));
|
||||
files.text(format(ngettext('{files} file', '{files} files',
|
||||
version.files),
|
||||
version));
|
||||
reviews.text(format(ngettext('{reviews} review', '{reviews} reviews',
|
||||
version.reviews),
|
||||
version));
|
||||
$('.version_id', this).val(version.id);
|
||||
return true;
|
||||
}});
|
||||
|
||||
$('#modal-cancel').modal('#cancel-review', {width: 400});
|
||||
$('#modal-delete').modal('#delete-addon', {width: 400});
|
||||
$('#modal-disable').modal('#disable-addon',
|
||||
{ width: 400,
|
||||
callback:function(d){
|
||||
$('.version_id', this).val($(d.click_target).attr('data-version'));
|
||||
{width: 400,
|
||||
callback: function(d){
|
||||
$('.version_id', this).val($(d.click_target).attr('data-version'));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}});
|
||||
}
|
||||
|
||||
function initSubmit() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче