2024-04-05 02:45:27 +00:00
|
|
|
from django.http import HttpResponse, Http404
|
|
|
|
from rest_framework.views import APIView
|
|
|
|
from rest_framework.decorators import api_view
|
|
|
|
from rest_framework.response import Response
|
|
|
|
from django.shortcuts import render
|
|
|
|
from django.utils.decorators import method_decorator
|
|
|
|
from django.views.decorators.cache import cache_page
|
|
|
|
from datetime import datetime
|
|
|
|
from rest_framework import status
|
2024-05-07 21:40:10 +00:00
|
|
|
from .launchpad_singleton import get_launchpad
|
2024-04-05 02:45:27 +00:00
|
|
|
from .utils import fetch_group_members # Adjust the import path as necessary
|
2024-07-18 14:32:21 +00:00
|
|
|
from .utils import fetch_matrix_accounts # Adjust the import path as necessary
|
2024-04-05 02:45:27 +00:00
|
|
|
import pytz
|
|
|
|
import json
|
|
|
|
import requests
|
|
|
|
|
|
|
|
@api_view(['GET'])
|
2024-04-05 20:04:37 +00:00
|
|
|
#@cache_page(60 * 30) # Cache for 30 minutes
|
2024-04-05 02:45:27 +00:00
|
|
|
def group_members(self, group_name):
|
|
|
|
try:
|
|
|
|
result = fetch_group_members(group_name)
|
2024-04-05 02:50:08 +00:00
|
|
|
return Response(result)
|
2024-04-05 02:45:27 +00:00
|
|
|
except KeyError as e:
|
|
|
|
# Handle the case where the bug is not found
|
|
|
|
print(f"Group with name {group_name} was not found. Error: {e}")
|
|
|
|
return Response({'error': 'Group not found'}, status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except Exception as e:
|
|
|
|
# Handle other potential exceptions
|
|
|
|
print(f"An error occurred: {e}")
|
|
|
|
print(f"Error processing request for launchpad group {group_name}: {str(e)}")
|
|
|
|
return Response({'error': 'An error occurred processing your request'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
|
|
|
|
2024-07-18 14:32:21 +00:00
|
|
|
@api_view(['GET'])
|
|
|
|
#@cache_page(60 * 30) # Cache for 30 minutes
|
|
|
|
def matrix_profiles(self, profile_id):
|
|
|
|
try:
|
|
|
|
result = fetch_matrix_accounts(profile_id)
|
|
|
|
return Response(result)
|
|
|
|
except KeyError as e:
|
|
|
|
# Handle the case where the bug is not found
|
|
|
|
print(f"Profile with name {profile_id} was not found. Error: {e}")
|
|
|
|
return Response({'error': 'Group not found'}, status=status.HTTP_404_NOT_FOUND)
|
|
|
|
except Exception as e:
|
|
|
|
# Handle other potential exceptions
|
|
|
|
print(f"An error occurred: {e}")
|
|
|
|
print(f"Error processing request for launchpad profile {profile_id}: {str(e)}")
|
|
|
|
return Response({'error': 'An error occurred processing your request'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
|
|
|
|