diff --git a/catalogedit/views.py b/catalogedit/views.py index e618681..7e50519 100644 --- a/catalogedit/views.py +++ b/catalogedit/views.py @@ -53,8 +53,16 @@ def save_catalog(request): id = data.get('id') if id: - log.debug('saving existing catalog, id {}'.format(id)) - cat = get_object_or_404(Catalog, id=id, owner=request.user) + try: + cat = Catalog.objects.get(id=id) + + if cat.owner == request.user: + log.debug('saving existing catalog, id {}'.format(id)) + else: + log.debug('copying public catalog, id {}'.format(id)) + cat = Catalog(owner=request.user, season=cat.season, region=cat.region) + except ObjectDoesNotExist: + raise Http404("Catalog not found") else: season = Season.objects.get(id=data.get('season')) region = Region.objects.get(id=data.get('region'))