def clone(self, request, pk): """ Make a clone of this notice. """ notice = get_object_or_404(Notice, pk=pk) notice_clone = Notice() ignore_fields = [ 'guid', 'id', 'create_dt', 'update_dt', 'creator', 'creator_username', 'owner', 'owner_username' ] field_names = [ field.name for field in notice.__class__._meta.fields if field.name not in ignore_fields ] for name in field_names: setattr(notice_clone, name, getattr(notice, name)) notice_clone.notice_name = 'Clone of %s' % notice_clone.notice_name notice_clone.creator = request.user notice_clone.creator_username = request.user.username notice_clone.owner = request.user notice_clone.owner_username = request.user.username notice_clone.save() return redirect( reverse( 'admin:corporate_memberships_notice_change', args=[notice_clone.pk], ))
def clone(self, request, pk): """ Make a clone of this notice. """ notice = get_object_or_404(Notice, pk=pk) notice_clone = Notice() ignore_fields = ['guid', 'id', 'create_dt', 'update_dt', 'creator', 'creator_username', 'owner', 'owner_username'] field_names = [field.name for field in notice.__class__._meta.fields if field.name not in ignore_fields] for name in field_names: setattr(notice_clone, name, getattr(notice, name)) notice_clone.notice_name = 'Clone of %s' % notice_clone.notice_name notice_clone.creator = request.user notice_clone.creator_username = request.user.username notice_clone.owner = request.user notice_clone.owner_username = request.user.username notice_clone.save() return redirect(reverse( 'admin:corporate_memberships_notice_change', args=[notice_clone.pk], ))
def clone(self, request, pk): """ Make a clone of this notice. """ notice = get_object_or_404(Notice, pk=pk) notice_clone = Notice() ignore_fields = [ "guid", "id", "create_dt", "update_dt", "creator", "creator_username", "owner", "owner_username", ] field_names = [field.name for field in notice.__class__._meta.fields if field.name not in ignore_fields] for name in field_names: setattr(notice_clone, name, getattr(notice, name)) notice_clone.notice_name = "Clone of %s" % notice_clone.notice_name notice_clone.creator = request.user notice_clone.creator_username = request.user.username notice_clone.owner = request.user notice_clone.owner_username = request.user.username notice_clone.save() return redirect(reverse("admin:corporate_memberships_notice_change", args=[notice_clone.pk]))