Skip to content

Commit

Permalink
Merge pull request #337 from maykinmedia/feature/905-profile-order-do…
Browse files Browse the repository at this point in the history
…cuments

[#905] order documents in profile
  • Loading branch information
annashamray authored Nov 21, 2022
2 parents d5c38f5 + aebd585 commit de5a4fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/open_inwoner/accounts/tests/test_profile_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from open_inwoner.pdc.tests.factories import CategoryFactory

from ..choices import LoginTypeChoices
from .factories import ActionFactory, ContactFactory, UserFactory
from .factories import ActionFactory, ContactFactory, DocumentFactory, UserFactory


class ProfileViewTests(WebTest):
Expand Down Expand Up @@ -93,6 +93,23 @@ def test_deactivate_account_digid(self):
self.assertEquals(response.status_code, 302)
self.assertEquals(response.url, reverse("digid:logout"))

def test_get_documents_sorted(self):
"""
check that the new document is shown first
"""
doc_old = DocumentFactory.create(name="some-old", owner=self.user)
doc_new = DocumentFactory.create(name="some-new", owner=self.user)

response = self.app.get(self.url, user=self.user)
self.assertEquals(response.status_code, 200)

file_tags = response.html.find(class_="file-list").find_all(
class_="file-list__list-item"
)
self.assertEquals(len(file_tags), 2)
self.assertTrue(doc_new.name in file_tags[0].prettify())
self.assertTrue(doc_old.name in file_tags[1].prettify())


class EditProfileTests(WebTest):
def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/accounts/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_context_data(self, **kwargs):
.order_by("end_date")
.first()
)
context["files"] = self.request.user.documents.all()
context["files"] = self.request.user.get_all_files()
context["theme_text"] = self.request.user.get_interests()
context["action_text"] = _(
f"{Action.objects.connected(self.request.user).filter(status=StatusChoices.open).count()} acties staan open."
Expand Down

0 comments on commit de5a4fe

Please sign in to comment.