don't show disabled button plus some cleanup (bug 613594)
This commit is contained in:
Родитель
9a33c8f42e
Коммит
edbdba511d
|
@ -423,7 +423,8 @@ class Addon(amo.models.ModelBase):
|
|||
icon_type_split = self.icon_type.split('/')
|
||||
|
||||
# Get the closest allowed size without going over
|
||||
if size not in amo.ADDON_ICON_SIZES and size >= amo.ADDON_ICON_SIZES[0]:
|
||||
if (size not in amo.ADDON_ICON_SIZES and
|
||||
size >= amo.ADDON_ICON_SIZES[0]):
|
||||
size = [s for s in amo.ADDON_ICON_SIZES if s < size][-1]
|
||||
elif size < amo.ADDON_ICON_SIZES[0]:
|
||||
size = amo.ADDON_ICON_SIZES[0]
|
||||
|
@ -438,8 +439,8 @@ class Addon(amo.models.ModelBase):
|
|||
icon = amo.ADDON_ICONS[amo.ADDON_ANY]
|
||||
return settings.ADDON_ICON_BASE_URL + icon
|
||||
elif icon_type_split[0] == 'icon':
|
||||
return '%s/%s-%s.png' % (settings.ADDON_ICONS_DEFAULT_URL,
|
||||
icon_type_split[1], size)
|
||||
return '%s/%s-%s.png' % (settings.ADDON_ICONS_DEFAULT_URL,
|
||||
icon_type_split[1], size)
|
||||
else:
|
||||
return settings.ADDON_ICON_URL % (
|
||||
self.id, int(time.mktime(self.modified.timetuple())))
|
||||
|
@ -544,6 +545,10 @@ class Addon(amo.models.ModelBase):
|
|||
def is_persona(self):
|
||||
return self.type == amo.ADDON_PERSONA
|
||||
|
||||
@property
|
||||
def is_disabled(self):
|
||||
return self.status == amo.STATUS_DISABLED
|
||||
|
||||
def is_selfhosted(self):
|
||||
return self.status == amo.STATUS_LISTED
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
{# TODO(gkoberger): 'if' statements to decide what's shown; but wait until
|
||||
the status flags are done #}
|
||||
<a href="#" id="cancel-review">{{ _('Cancel Review Request') }}</a> ·
|
||||
<a href="#" id="disable-addon">{{ _('Disable Add-on') }}</a> ·
|
||||
{% if not addon.is_disabled %}<a href="#" id="disable-addon">{{ _('Disable Add-on') }}</a> ·{% endif %}
|
||||
<a href="#" id="delete-addon">{{ _('Delete Add-on') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -150,6 +150,7 @@
|
|||
</form>
|
||||
</div>
|
||||
|
||||
{% if not addon.is_disabled %}
|
||||
<div id="modal-disable" class="modal">
|
||||
<form method="post" action="{{ url('devhub.addons.disable', addon.id) }}">
|
||||
<h2>{{ _('Disable Add-on') }}</h2>
|
||||
|
@ -171,6 +172,7 @@
|
|||
{{ _('or') }} <a href="#" class="close">{{ _('Cancel') }}</a>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div id="modal-cancel" class="modal">
|
||||
<form method="post" action="">
|
||||
|
|
|
@ -1597,6 +1597,20 @@ class TestVersion(test_utils.TestCase):
|
|||
eq_(res.status_code, 302)
|
||||
eq_(Addon.objects.get(id=3615).status, status)
|
||||
|
||||
def test_disable_button(self):
|
||||
res = self.client.get(self.url)
|
||||
doc = pq(res.content)
|
||||
assert doc('#modal-disable')
|
||||
assert doc('#disable-addon')
|
||||
|
||||
def test_not_disable_button(self):
|
||||
self.addon.status = amo.STATUS_DISABLED
|
||||
self.addon.save()
|
||||
res = self.client.get(self.url)
|
||||
doc = pq(res.content)
|
||||
assert not doc('#modal-disable')
|
||||
assert not doc('#disable-addon')
|
||||
|
||||
|
||||
class TestVersionEdit(test_utils.TestCase):
|
||||
fixtures = ['base/apps', 'base/users', 'base/addon_3615',
|
||||
|
|
|
@ -266,8 +266,7 @@ def delete(request, addon_id, addon):
|
|||
@dev_required
|
||||
@post_required
|
||||
def disable(request, addon_id, addon):
|
||||
addon.status = amo.STATUS_DISABLED
|
||||
addon.save()
|
||||
addon.update(status=amo.STATUS_DISABLED)
|
||||
amo.log(amo.LOG.CHANGE_STATUS, addon.get_status_display(), addon)
|
||||
return redirect('devhub.versions', addon_id)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче