Skip to content

Commit

Permalink
Merge branch 'master' into bmtcril/pii_annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
bmtcril authored Dec 4, 2024
2 parents 9f8dcda + 465e194 commit 5b0e27c
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 224 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [master]
pull_request:
branches: [master]

concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ Unreleased
----------
* nothing unreleased

[5.3.0]
--------
* refactor: Removed unused django setting.

[5.2.0]
--------
* feat: removed custom pagination for reporting configurations.

[5.1.0]
--------
* feat: update EnterpriseGroupMembershipSerializer to include learner course enrollment count
* feat: updated learner query to filter by full name

[5.0.0]
--------
* refactor: Removed `plotly_token/` API endpoint and related views from enterprise API.

[4.33.1]
--------
* feat: Creating enterprise customer members endpoint for admin portal
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "4.33.1"
__version__ = "5.3.0"
13 changes: 13 additions & 0 deletions enterprise/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ class EnterpriseGroupMembershipSerializer(serializers.ModelSerializer):
member_details = serializers.SerializerMethodField()
recent_action = serializers.SerializerMethodField()
status = serializers.CharField(required=False)
enrollments = serializers.SerializerMethodField()

class Meta:
model = models.EnterpriseGroupMembership
Expand All @@ -676,6 +677,7 @@ class Meta:
'recent_action',
'status',
'activated_at',
'enrollments',
)

def get_member_details(self, obj):
Expand All @@ -698,6 +700,17 @@ def get_recent_action(self, obj):
return f"Accepted: {obj.activated_at.strftime('%B %d, %Y')}"
return f"Invited: {obj.created.strftime('%B %d, %Y')}"

def get_enrollments(self, obj):
"""
Fetch all of user's enterprise enrollments
"""
if user := obj.enterprise_customer_user:
enrollments = models.EnterpriseCourseEnrollment.objects.filter(
enterprise_customer_user=user.user_id,
)
return len(enrollments)
return 0


class EnterpriseCustomerUserReadOnlySerializer(serializers.ModelSerializer):
"""
Expand Down
6 changes: 0 additions & 6 deletions enterprise/api/v1/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
notifications,
pending_enterprise_customer_admin_user,
pending_enterprise_customer_user,
plotly_auth,
)

router = DefaultRouter()
Expand Down Expand Up @@ -131,11 +130,6 @@
coupon_codes.CouponCodesView.as_view(),
name='request-codes'
),
re_path(
r'^plotly_token/(?P<enterprise_uuid>[A-Za-z0-9-]+)$',
plotly_auth.PlotlyAuthView.as_view(),
name='plotly-token'
),
re_path(
r'^enterprise_report_types/(?P<enterprise_uuid>[A-Za-z0-9-]+)$',
enterprise_customer_reporting.EnterpriseCustomerReportTypesView.as_view(),
Expand Down
2 changes: 1 addition & 1 deletion enterprise/api/v1/views/enterprise_customer_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get_members(self, request, *args, **kwargs):
au.id,
au.email,
au.date_joined,
coalesce(NULLIF(aup.name, ''), concat(au.first_name, ' ', au.last_name)) as full_name
coalesce(NULLIF(aup.name, ''), (au.first_name || ' ' || au.last_name)) as full_name
FROM enterprise_enterprisecustomeruser ecu
INNER JOIN auth_user as au on ecu.user_id = au.id
LEFT JOIN auth_userprofile as aup on au.id = aup.user_id
Expand Down
10 changes: 0 additions & 10 deletions enterprise/api/v1/views/enterprise_customer_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
from rest_framework import permissions, status
from rest_framework.authentication import SessionAuthentication
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.status import HTTP_200_OK, HTTP_404_NOT_FOUND
from rest_framework.views import APIView
Expand All @@ -18,14 +17,6 @@
from enterprise.utils import get_enterprise_customer


class ExpandDefaultPageSize(PageNumberPagination):
"""
Expands page size for the API.
Used to populate large reporting configurations.
"""
page_size = 100


class EnterpriseCustomerReportingConfigurationViewSet(EnterpriseReadWriteModelViewSet):
"""
API views for the ``enterprise-customer-reporting`` API endpoint.
Expand All @@ -35,7 +26,6 @@ class EnterpriseCustomerReportingConfigurationViewSet(EnterpriseReadWriteModelVi
serializer_class = serializers.EnterpriseCustomerReportingConfigurationSerializer
lookup_field = 'uuid'
permission_classes = [permissions.IsAuthenticated]
pagination_class = ExpandDefaultPageSize

USER_ID_FILTER = 'enterprise_customer__enterprise_customer_users__user_id'
FIELDS = (
Expand Down
62 changes: 0 additions & 62 deletions enterprise/api/v1/views/plotly_auth.py

This file was deleted.

14 changes: 10 additions & 4 deletions enterprise/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4696,13 +4696,19 @@ def _get_filtered_ecu_ids(self, user_query):
# https://docs.djangoproject.com/en/5.0/topics/security/
var_q = f"%{user_query}%"
sql_string = """
select entcu.id from enterprise_enterprisecustomeruser entcu
join auth_user au on entcu.user_id = au.id
where entcu.enterprise_customer_id = %s and au.email like %s;
with users as (
select ecu.id,
au.email,
coalesce(NULLIF(aup.name, ''), (au.first_name || ' ' || au.last_name)) as full_name
from enterprise_enterprisecustomeruser ecu
inner join auth_user au on ecu.user_id = au.id
left join auth_userprofile aup on au.id = aup.user_id
where ecu.enterprise_customer_id = %s
) select id from users where email like %s or full_name like %s;
"""
# Raw sql is picky about uuid format
customer_id = str(self.enterprise_customer.pk).replace("-", "")
ecus = EnterpriseCustomerUser.objects.raw(sql_string, (customer_id, var_q))
ecus = EnterpriseCustomerUser.objects.raw(sql_string, (customer_id, var_q, var_q))
return [ecu.id for ecu in ecus]

def _get_explicit_group_members(self, user_query=None, fetch_removed=False, pending_users_only=False,):
Expand Down
1 change: 0 additions & 1 deletion enterprise/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ def root(*args):
'facebook.com'
]

ENTERPRISE_PLOTLY_SECRET = "I am a secret"
ENTERPRISE_MANUAL_REPORTING_CUSTOMER_UUIDS = ['12aacfee8ffa4cb3bed1059565a57f06',]
EXEC_ED_LANDING_PAGE = 'https://www.edx-external.com/account'

Expand Down
Loading

0 comments on commit 5b0e27c

Please sign in to comment.