Updates app to use date instead of boolean

This commit is contained in:
Mouse Reeve 2021-10-15 09:08:10 -07:00
parent b11b810ec9
commit 1b1e557800
3 changed files with 8 additions and 3 deletions

View file

@ -180,6 +180,7 @@ class InboxUpdate(TestCase):
datafile = pathlib.Path(__file__).parent.joinpath("../../data/ap_note.json")
status_data = json.loads(datafile.read_bytes())
status_data["id"] = status.remote_id
status_data["updated"] = "2021-12-13T05:09:29Z"
activity = self.update_json
activity["object"] = status_data
@ -189,4 +190,6 @@ class InboxUpdate(TestCase):
status.refresh_from_db()
self.assertEqual(status.content, "test content in note")
self.assertTrue(status.edited)
self.assertEqual(status.edited_date.year, 2021)
self.assertEqual(status.edited_date.month, 12)
self.assertEqual(status.edited_date.day, 13)

View file

@ -381,6 +381,7 @@ http://www.fish.com/"""
def test_create_status_edit_success(self, mock, *_):
"""update an existing status"""
status = models.Status.objects.create(content="status", user=self.local_user)
self.assertIsNone(status.edited_date)
view = views.CreateStatus.as_view()
form = forms.CommentForm(
{
@ -400,7 +401,7 @@ http://www.fish.com/"""
status.refresh_from_db()
self.assertEqual(status.content, "<p>hi</p>")
self.assertTrue(status.edited)
self.assertIsNotNone(status.edited_date)
def test_create_status_edit_permission_denied(self, *_):
"""update an existing status"""

View file

@ -8,6 +8,7 @@ from django.core.exceptions import ValidationError
from django.http import HttpResponse, HttpResponseBadRequest, Http404
from django.shortcuts import get_object_or_404, redirect
from django.template.response import TemplateResponse
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views import View
from django.views.decorators.http import require_POST
@ -62,7 +63,7 @@ class CreateStatus(View):
models.Status.objects.select_subclasses(), id=existing_status_id
)
existing_status.raise_not_editable(request.user)
existing_status.edited = True
existing_status.edited_date = timezone.now()
status_type = status_type[0].upper() + status_type[1:]