diff --git a/api/dashboard/campus/campus_views.py b/api/dashboard/campus/campus_views.py index ea9398af..58a0ff1a 100644 --- a/api/dashboard/campus/campus_views.py +++ b/api/dashboard/campus/campus_views.py @@ -10,6 +10,7 @@ from utils.utils import CommonUtils, DateTimeUtils from .dash_campus_helper import get_user_college_link from utils.permission import CustomizePermission, JWTUtils, role_required +from utils.exception import CustomException class CampusDetailsAPI(APIView): @@ -223,5 +224,9 @@ def get(self, request): serializer = serializers.WeeklyKarmaSerializer(user_org_link) return CustomResponse(response=serializer.data).get_success_response() + except Exception as e: - return CustomResponse(response=str(e)).get_failure_response() \ No newline at end of file + raise CustomException( + detail='somthing went wrong', + status_code=403 + ) diff --git a/api/dashboard/organisation/organisation_views.py b/api/dashboard/organisation/organisation_views.py index dcaeed36..a2190f16 100644 --- a/api/dashboard/organisation/organisation_views.py +++ b/api/dashboard/organisation/organisation_views.py @@ -218,9 +218,15 @@ def get(self, request, org_code): "id", "title", "code", + affiliation_uuid=F("affiliation__id"), + affiliation_name=F("affiliation__title"), + district_uuid=F("district__id"), district_name=F("district__name"), + zone_uuid=F("district__zone__id"), zone_name=F("district__zone__name"), + state_uuid=F("district__zone__state__id"), state_name=F("district__zone__state__name"), + country_uuid=F("district__zone__state__country__id"), country_name=F("district__zone__state__country__name"), ).annotate( karma=Sum( diff --git a/api/url_shortener/url_shortener_view.py b/api/url_shortener/url_shortener_view.py index 6bba3e9b..f5381b70 100644 --- a/api/url_shortener/url_shortener_view.py +++ b/api/url_shortener/url_shortener_view.py @@ -88,16 +88,32 @@ def delete(self, request, url_id): general_message="Url deleted successfully.." ).get_success_response() -class UrlAnalayticsAPI(APIView): - def get(self, request,url_id): + +class UrlAnalyticsAPI(APIView): + def get(self, request, url_id): url_shortener_object = UrlShortener.objects.get(id=url_id) - url_data = UrlShortenerTracker.objects.filter(url_shortener_id=url_shortener_object.id) + + url_data = UrlShortenerTracker.objects.filter( + url_shortener_id=url_shortener_object.id + ) + print(url_data) - location_data = UrlShortenerTracker.objects.filter(url_shortener=url_shortener_object) \ - .values('city', 'region', 'country') + + location_data = UrlShortenerTracker.objects.filter( + url_shortener=url_shortener_object + ).values( + 'city', + 'region', + 'country' + ) print(location_data) - # Browsers through which users accessed - browsers_data = UrlShortenerTracker.objects.filter(url_shortener=url_shortener_object) \ - .values('browser').count() + + # Browsers through which users accessed + browsers_data = UrlShortenerTracker.objects.filter( + url_shortener=url_shortener_object + ).values( + 'browser' + ).count() + print(browsers_data) diff --git a/api/url_shortener/urls.py b/api/url_shortener/urls.py index baf7d70b..f24bdd0a 100644 --- a/api/url_shortener/urls.py +++ b/api/url_shortener/urls.py @@ -8,5 +8,5 @@ path('list/', url_shortener_view.UrlShortenerAPI.as_view()), path('delete//', url_shortener_view.UrlShortenerAPI.as_view()), - path('get-analytics//', url_shortener_view.UrlAnalayticsAPI.as_view()), + path('get-analytics//', url_shortener_view.UrlAnalyticsAPI.as_view()), ]