Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add user info to doc status #61

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dowc/accounts/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class UserFactory(factory.django.DjangoModelFactory):
username = factory.Sequence(lambda n: f"user-{n}")
email = factory.Sequence(lambda n: f"user-{n}@kownsl.nl")
email = factory.Sequence(lambda n: f"user-{n}@dowc.nl")
password = factory.PostGenerationMethodCall("set_password", "secret")

class Meta:
Expand Down
7 changes: 6 additions & 1 deletion src/dowc/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,15 @@ class DocumentStatusSerializer(serializers.ModelSerializer):
help_text=_("URL-reference to document in DRC API."),
source="unversioned_url",
)
locked_by = serializers.EmailField(
read_only=True,
source="user.email",
help_text=_("Email address of user that created DocumentFile."),
)

class Meta:
model = DocumentFile
fields = ("document", "uuid")
fields = ("document", "uuid", "locked_by")
extra_kwargs = {
"uuid": {
"read_only": True,
Expand Down
6 changes: 6 additions & 0 deletions src/dowc/api/tests/test_documentfile_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,12 @@ def test_retrieve_documentfiles_on_url(self, m):
df1 = DocumentFileFactory.create(
unversioned_url="http://some-unversioned-url.com/1",
purpose=DocFileTypes.write,
user=self.user,
)
df2 = DocumentFileFactory.create(
unversioned_url="http://some-unversioned-url.com/2",
purpose=DocFileTypes.write,
user=self.user,
)

# Retrieve documentfiles with this data
Expand All @@ -502,10 +504,12 @@ def test_retrieve_documentfiles_on_url(self, m):
{
"document": "http://some-unversioned-url.com/1",
"uuid": str(df1.uuid),
"lockedBy": self.user.email,
},
{
"document": "http://some-unversioned-url.com/2",
"uuid": str(df2.uuid),
"lockedBy": self.user.email,
},
],
)
Expand All @@ -523,6 +527,7 @@ def test_retrieve_documentfiles_on_zaak(self, m):
unversioned_url="http://some-unversioned-url.com/2",
purpose=DocFileTypes.write,
zaak="http://some-other-zaak.nl/",
user=self.user,
)

# Retrieve documentfiles with this data
Expand All @@ -543,6 +548,7 @@ def test_retrieve_documentfiles_on_zaak(self, m):
{
"document": "http://some-unversioned-url.com/2",
"uuid": str(df2.uuid),
"lockedBy": self.user.email,
},
],
)
Expand Down
Loading