Skip to content

Commit

Permalink
See CHANGELOG tag v3.50.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jpnavarro committed Jan 31, 2025
1 parent 2134ed5 commit ffb8454
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v3.50.0 2025-01-31 JP
- New cider/v1/contacts/ view

v3.49.0 2025-01-27 JP
- Enhance cider/v1/info_resourceid/ to return node_count (CTT-419)
- Enhance cider/v1/access-active-groups/ to return resource summary (CTT-420)
Expand Down
5 changes: 5 additions & 0 deletions Operations_Warehouse_Django/cider/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class Meta:
model = CiderInfrastructure
fields = ( 'other_attributes', )

class CiderInfrastructure_ACCESSContacts_Serializer( serializers.ModelSerializer ):
class Meta:
model = CiderInfrastructure
fields = ( 'protected_attributes', )

class CiderInfrastructure_Summary_Serializer(serializers.ModelSerializer):
cider_view_url = serializers.SerializerMethodField()
cider_data_url = serializers.SerializerMethodField()
Expand Down
22 changes: 22 additions & 0 deletions Operations_Warehouse_Django/cider/templates/contacts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends "web/base_nav_none.html" %}

{% block title %}Resource Contacts{% endblock %}

{% block content %}

<h1>ACCESS Active Resource Contacts</h1>

<table>
<tr>
<th>Contact Role</th>
<th>E-mails</th>
</tr>
{% for key, item in results.items %}
<tr>
<td style="vertical-align:top">{{key}}</td>
<td>{{item}}</td>
</tr>
{% endfor %}
</table>

{% endblock %}
2 changes: 1 addition & 1 deletion Operations_Warehouse_Django/cider/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
path(r'v1/access-online-services/', CiderInfrastructure_v1_ACCESSOnlineServicesList.as_view(), name='cider-accessonlineserviceslist-v1'),
path(r'v1/access-science-gateways/', CiderInfrastructure_v1_ACCESSScienceGatewaysList.as_view(), name='cider-accesssciencegatewayslist-v1'),
path(r'v1/coco/', CiderInfrastructure_v1_ACCESSComputeCompare.as_view(), name='cider-accesscomputecompare-v1'),
# path(r'v1/contacts/', CiderInfrastructure_v1_ACCESSContacts.as_view(), name='cider-accesscontacts-v1'),
path(r'v1/contacts/', CiderInfrastructure_v1_ACCESSContacts.as_view(), name='cider-accesscontacts-v1'),
path(r'v1/features/', CiderFeatures_v1_List.as_view(), name='cider-featurelist-v1'),
path(r'v1/features/category_id/<str:category_id>/', CiderFeatures_v1_Detail.as_view(), name='cider-featuredetail-categoryid-v1'),
path(r'v1/groups/', CiderGroups_v1_List.as_view(), name='cider-grouplist-v1'),
Expand Down
43 changes: 28 additions & 15 deletions Operations_Warehouse_Django/cider/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,34 @@ def get(self, request, format=None, **kwargs):
coco_data = mk_html_table( coco_data )
return MyAPIResponse( { 'results': coco_data }, template_name='coco.html' )

#class CiderInfrastructure_v1_ACCESSContacts(GenericAPIView):
# '''
# ACCESS Active Resource Contacts
# '''
# permission_classes = (IsAuthenticated,)
# renderer_classes = (TemplateHTMLRenderer, JSONRenderer)
# serializer_class = CiderInfrastructure_ACCESSContacts_Serializer
# def get(self, request, format=None, **kwargs):
# returnformat = request.query_params.get('format' )
# objects = CiderInfrastructure_Active_Filter( type='Compute' )
# serializer = CiderInfrastructure_OtherAttrs_Serializer(objects, context={'request': request}, many=True)
# coco_data = cider_to_coco( { 'results': serializer.data } )
# if returnformat != 'json':
# coco_data = mk_html_table( coco_data )
# return MyAPIResponse( { 'results': coco_data }, template_name='contacts.html' )
class CiderInfrastructure_v1_ACCESSContacts(GenericAPIView):
'''
ACCESS Active Resource Contacts
'''
permission_classes = (IsAuthenticated,)
renderer_classes = (TemplateHTMLRenderer, JSONRenderer)
serializer_class = CiderInfrastructure_ACCESSContacts_Serializer
def get(self, request, format=None, **kwargs):
returnformat = request.query_params.get('format' )
objects1 = CiderInfrastructure_Active_Filter( type='Compute' )
objects2 = CiderInfrastructure_Active_Filter( type='Storage' )
all_contacts = {}
for resource in chain(objects1, objects2):
if 'contacts' not in resource.protected_attributes:
continue
for contact in resource.protected_attributes['contacts']:
for ct in contact['contact_types']:
if ct not in all_contacts:
all_contacts[ct] = set()
all_contacts[ct].add(f"{contact['name']} <{contact['email']}>")
sorted_contacts = {}
if returnformat == 'html':
for key in sorted(all_contacts):
sorted_contacts[key] = ', '.join(sorted(all_contacts[key]))
else:
for key in sorted(all_contacts):
sorted_contacts[key] = sorted(all_contacts[key])
return MyAPIResponse( { 'results': sorted_contacts }, template_name='contacts.html' )

class CiderInfrastructure_v1_ACCESSActiveList(GenericAPIView):
'''
Expand Down

0 comments on commit ffb8454

Please sign in to comment.