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 encrypted key to form metadata in ProjectViewSet list #2759

Merged
merged 1 commit into from
Jan 15, 2025
Merged
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
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
@@ -2,6 +2,7 @@
"""
Test ProjectViewSet module.
"""

import json
import os
from collections import OrderedDict
@@ -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()

@@ -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", []),
]
20 changes: 10 additions & 10 deletions onadata/apps/api/viewsets/project_viewset.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
"""
The /projects API endpoint implementation.
"""

import logging

from django.core.cache import cache
@@ -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
@@ -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,
@@ -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
@@ -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

@@ -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}"
4 changes: 3 additions & 1 deletion onadata/libs/serializers/project_serializer.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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,
@@ -262,6 +263,7 @@ class Meta:
"formid",
"id_string",
"is_merged_dataset",
"encrypted",
"contributes_entities_to",
"consumes_entities_from",
)
Loading