def copy_to_draft(request, id_str): try: item = MathItem.objects.get_by_name(id_str) except MathItem.DoesNotExist: return HttpResponseBadRequest() markup = item_to_markup(item) draft = DraftItem(created_by=request.user, item_type=item.item_type, body=markup) if item.parent: draft.parent = item.parent draft.save() return HttpResponseRedirect(reverse('show-draft', args=[draft.id]))
def new_item(request, item_type, parent=None): item = DraftItem(created_by=request.user, item_type=item_type, body='') if parent: item.parent = parent return edit_item(request, item)