mirror of
https://github.com/peter-tanner/money-manager.git
synced 2024-11-30 22:30:18 +08:00
18 lines
548 B
Python
18 lines
548 B
Python
|
from django.shortcuts import render
|
||
|
|
||
|
from django.http import HttpResponseRedirect
|
||
|
from django.urls import reverse
|
||
|
from django.contrib import messages
|
||
|
from .models import Expense
|
||
|
|
||
|
|
||
|
def restore_item(request, item_id):
|
||
|
try:
|
||
|
item = Expense.objects.get(pk=item_id)
|
||
|
item.deleted = False
|
||
|
item.save()
|
||
|
messages.success(request, "Item restored successfully.")
|
||
|
except Expense.DoesNotExist:
|
||
|
messages.error(request, "Item not found.")
|
||
|
return HttpResponseRedirect(reverse("admin:expenses_expense_changelist"))
|