Skip to content
Snippets Groups Projects
Commit fe27c3d5 authored by Marte Fossum's avatar Marte Fossum
Browse files

Merge branch 'GREG-337-show-created-and-updated-fields' into 'master'

GREG-337: Add fields created and updated to endpoints

See merge request !391
parents 5232d016 4504c36d
No related branches found
No related tags found
1 merge request!391GREG-337: Add fields created and updated to endpoints
Pipeline #182174 passed
...@@ -27,7 +27,10 @@ class ConsentTypeSerializer(ModelSerializer): ...@@ -27,7 +27,10 @@ class ConsentTypeSerializer(ModelSerializer):
"user_allowed_to_change", "user_allowed_to_change",
"valid_from", "valid_from",
"choices", "choices",
"created",
"updated",
) )
read_only_fields = ["created", "updated"]
class ConsentTypeSerializerBrief(ModelSerializer): class ConsentTypeSerializerBrief(ModelSerializer):
......
...@@ -33,5 +33,7 @@ class SponsorOrgUnitsSerializer(ModelSerializer): ...@@ -33,5 +33,7 @@ class SponsorOrgUnitsSerializer(ModelSerializer):
"hierarchical_access", "hierarchical_access",
"automatic", "automatic",
"source", "source",
"created",
"updated",
] ]
read_only_fields = ["sponsor", "organizational_unit"] read_only_fields = ["sponsor", "organizational_unit", "created", "updated"]
...@@ -24,8 +24,12 @@ class PersonSerializer(serializers.ModelSerializer): ...@@ -24,8 +24,12 @@ class PersonSerializer(serializers.ModelSerializer):
"roles", "roles",
"consents", "consents",
"meta", "meta",
"created",
"updated",
] ]
read_only_fields = ["created", "updated"]
class PersonSearchSerializer(serializers.ModelSerializer): class PersonSearchSerializer(serializers.ModelSerializer):
person_id = serializers.CharField(source="id") person_id = serializers.CharField(source="id")
......
...@@ -9,4 +9,14 @@ class SponsorSerializer(serializers.ModelSerializer): ...@@ -9,4 +9,14 @@ class SponsorSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Sponsor model = Sponsor
fields = ["id", "feide_id", "first_name", "last_name", "work_email", "orgunits"] fields = [
"id",
"feide_id",
"first_name",
"last_name",
"work_email",
"orgunits",
"created",
"updated",
]
read_only_fields = ["created", "updated"]
...@@ -38,4 +38,6 @@ def test_get_consent_type(client, consent_type_foo: ConsentType): ...@@ -38,4 +38,6 @@ def test_get_consent_type(client, consent_type_foo: ConsentType):
"text_nn": "Nei", "text_nn": "Nei",
}, },
], ],
"created": consent_type_foo.created.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
"updated": consent_type_foo.updated.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
} }
...@@ -122,18 +122,10 @@ def test_person_create(client): ...@@ -122,18 +122,10 @@ def test_person_create(client):
url = reverse("v1:person-list") url = reverse("v1:person-list")
response = client.post(url, {"first_name": "foo木👍أ", "last_name": "غbar水"}) response = client.post(url, {"first_name": "foo木👍أ", "last_name": "غbar水"})
results = response.json() results = response.json()
assert results == { assert results.get("first_name") == "foo木👍أ"
"id": 1, assert results.get("last_name") == "غbar水"
"first_name": "foo木👍أ", assert results.get("created") is not None
"last_name": "غbar水", assert results.get("updated") is not None
"gender": None,
"date_of_birth": None,
"registration_completed_date": None,
"identities": [],
"roles": [],
"consents": [],
"meta": None,
}
@pytest.mark.django_db @pytest.mark.django_db
......
...@@ -25,6 +25,8 @@ def test_get_consents(client, consent_type_foo, consent_type_bar): ...@@ -25,6 +25,8 @@ def test_get_consents(client, consent_type_foo, consent_type_bar):
"name_nn": "F", "name_nn": "F",
"user_allowed_to_change": True, "user_allowed_to_change": True,
"valid_from": "2018-01-20", "valid_from": "2018-01-20",
"created": consent_type_foo.created.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
"updated": consent_type_foo.updated.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
}, },
{ {
"choices": [ "choices": [
...@@ -41,5 +43,7 @@ def test_get_consents(client, consent_type_foo, consent_type_bar): ...@@ -41,5 +43,7 @@ def test_get_consents(client, consent_type_foo, consent_type_bar):
"name_nn": "B", "name_nn": "B",
"user_allowed_to_change": True, "user_allowed_to_change": True,
"valid_from": "2018-01-20", "valid_from": "2018-01-20",
"created": consent_type_bar.created.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
"updated": consent_type_bar.updated.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
}, },
] ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment