Skip to content

Commit

Permalink
add encrypted key in ProjectViewSet list (#2759)
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri authored Jan 15, 2025
1 parent 568fe1f commit 9bae488
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 3 additions & 1 deletion onadata/apps/api/tests/viewsets/test_project_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Test ProjectViewSet module.
"""

import json
import os
from collections import OrderedDict
Expand Down Expand Up @@ -60,8 +61,8 @@
BaseProjectSerializer,
ProjectSerializer,
)
from onadata.libs.utils.user_auth import get_user_default_project
from onadata.libs.utils.cache_tools import PROJ_OWNER_CACHE, safe_key
from onadata.libs.utils.user_auth import get_user_default_project

User = get_user_model()

Expand Down Expand Up @@ -196,6 +197,7 @@ def test_projects_list(self):
("formid", self.xform.pk),
("id_string", "transportation_2011_07_25"),
("is_merged_dataset", False),
("encrypted", False),
("contributes_entities_to", None),
("consumes_entities_from", []),
]
Expand Down
20 changes: 10 additions & 10 deletions onadata/apps/api/viewsets/project_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
The /projects API endpoint implementation.
"""

import logging

from django.core.cache import cache
Expand All @@ -17,7 +18,7 @@
from onadata.apps.api import tools as utils
from onadata.apps.api.permissions import ProjectPermissions
from onadata.apps.api.tools import get_baseviewset_class
from onadata.apps.logger.models import Project, XForm, ProjectInvitation
from onadata.apps.logger.models import Project, ProjectInvitation, XForm
from onadata.apps.main.models import UserProfile
from onadata.apps.main.models.meta_data import MetaData
from onadata.libs.data import strtobool
Expand All @@ -28,6 +29,11 @@
from onadata.libs.mixins.labels_mixin import LabelsMixin
from onadata.libs.mixins.profiler_mixin import ProfilerMixin
from onadata.libs.pagination import StandardPageNumberPagination
from onadata.libs.serializers.project_invitation_serializer import (
ProjectInvitationResendSerializer,
ProjectInvitationRevokeSerializer,
ProjectInvitationSerializer,
)
from onadata.libs.serializers.project_serializer import (
BaseProjectSerializer,
ProjectSerializer,
Expand All @@ -36,19 +42,13 @@
RemoveUserFromProjectSerializer,
ShareProjectSerializer,
)
from onadata.libs.utils.common_tools import report_exception
from onadata.libs.serializers.user_profile_serializer import UserProfileSerializer
from onadata.libs.serializers.xform_serializer import (
XFormCreateSerializer,
XFormSerializer,
)
from onadata.libs.serializers.project_invitation_serializer import (
ProjectInvitationSerializer,
ProjectInvitationRevokeSerializer,
ProjectInvitationResendSerializer,
)
from onadata.libs.utils.cache_tools import PROJ_OWNER_CACHE, safe_delete
from onadata.libs.utils.common_tools import merge_dicts
from onadata.libs.utils.common_tools import merge_dicts, report_exception
from onadata.libs.utils.export_tools import str_to_bool
from onadata.libs.utils.project_utils import propagate_project_permissions_async
from onadata.settings.common import DEFAULT_FROM_EMAIL, SHARE_PROJECT_SUBJECT
Expand Down Expand Up @@ -83,7 +83,7 @@ class ProjectViewSet(
pagination_class = StandardPageNumberPagination

def get_serializer_class(self):
"""Return BaseProjectSerializer class when listing projects."""
"""Override `get_serializer_class."""
if self.action == "list":
return BaseProjectSerializer

Expand Down Expand Up @@ -164,7 +164,7 @@ def forms(self, request, **kwargs):
)

return Response(serializer.data, status=status.HTTP_201_CREATED)
if survey['type'] and survey['text']:
if survey["type"] and survey["text"]:
error_message = f"{survey['type']}:{survey['text']}"
else:
error_message = f"{survey}"
Expand Down
4 changes: 3 additions & 1 deletion onadata/libs/serializers/project_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Project Serializer module.
"""

from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.cache import cache
Expand All @@ -16,9 +17,9 @@
get_or_create_organization_owners_team,
get_organization_members_team,
)
from onadata.apps.main.models.user_profile import UserProfile
from onadata.apps.logger.models.project import Project
from onadata.apps.logger.models.xform import XForm
from onadata.apps.main.models.user_profile import UserProfile
from onadata.libs.permissions import (
ManagerRole,
OwnerRole,
Expand Down Expand Up @@ -262,6 +263,7 @@ class Meta:
"formid",
"id_string",
"is_merged_dataset",
"encrypted",
"contributes_entities_to",
"consumes_entities_from",
)
Expand Down

0 comments on commit 9bae488

Please sign in to comment.