def create_entry_for_snippet(request, snippet_id): """ Create a new entry for snippet and go to edit page. If an entry already exists, just go to edit page. """ snippet = get_object_or_404(Snippet, pk=snippet_id) audio_source = snippet.source if snippet.entry: messages.error(request, _("This snippet already has an entry assigned to it.")) return redirect('edit_entry', entry_id=snippet.entry_id) entry = Entry() entry.created_by = request.user entry.event = snippet.source.event entry.is_visible = audio_source.is_visible entry.is_approved = False entry.set_order_last() entry.save() snippet.entry = entry snippet.save() logging.getLogger('palanaeum.staff').info( "Assigning snippet %s to entry %s by %s", snippet.id, entry.id, request.user) return redirect('edit_entry', entry_id=snippet.entry_id)
def create_entry_for_image_source(request, source_id): """ Create an empty Entry for Image Source and assign it to the source. """ img_source = get_object_or_404(ImageSource, pk=source_id) entry = Entry() entry.event = img_source.event entry.is_visible = img_source.is_visible entry.created_by = request.user entry.save() img_source.entry = entry img_source.save() messages.success( request, _('New entry for image source has been created and linked.')) logging.getLogger('palanaeum.staff').info( "%s created new entry for image %s.", request.user, img_source.id) return redirect('edit_entry', entry_id=entry.id)