зеркало из https://github.com/mozilla/FlightDeck.git
Merge pull request #115 from seanmonstar/bug-726126-broken_packages
Bug 726126 broken packages
This commit is contained in:
Коммит
7d2085fc61
|
@ -19,7 +19,7 @@ from django.http import (HttpResponseRedirect, HttpResponse,
|
|||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.paginator import Paginator, EmptyPage, InvalidPage
|
||||
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
|
||||
from django.db import IntegrityError
|
||||
from django.db import IntegrityError, transaction
|
||||
from django.db.models import Q, ObjectDoesNotExist
|
||||
from django.views.decorators.cache import never_cache
|
||||
from django.views.decorators.http import require_POST
|
||||
|
@ -955,6 +955,7 @@ def save(request, id_number, type_id, revision_number=None,
|
|||
|
||||
|
||||
@login_required
|
||||
@transaction.commit_on_success
|
||||
def create(request, type_id):
|
||||
"""
|
||||
Create new Package (Add-on or Library)
|
||||
|
@ -970,15 +971,7 @@ def create(request, type_id):
|
|||
description=description,
|
||||
type=type_id)
|
||||
|
||||
try:
|
||||
item.save()
|
||||
except ValidationError, err:
|
||||
if NON_FIELD_ERRORS in err.message_dict:
|
||||
return HttpResponseForbidden(
|
||||
"You already have a %s with that name (%s)" % (
|
||||
escape(settings.PACKAGE_SINGULAR_NAMES[type_id]),
|
||||
item.full_name))
|
||||
return HttpResponseForbidden(str(err))
|
||||
item.save()
|
||||
|
||||
return HttpResponseRedirect(reverse(
|
||||
'jp_%s_latest' % item.get_type_name(), args=[item.id_number]))
|
||||
|
|
Загрузка…
Ссылка в новой задаче