2121from api .base .serializers import YearmonthField
2222from api .nodes .serializers import CompoundIDField
2323from api .base .exceptions import RelationshipPostMakesNoChanges
24- from api .base .utils import absolute_reverse
2524
2625
2726class InstitutionSerializer (JSONAPISerializer ):
@@ -205,30 +204,6 @@ def create(self, validated_data):
205204 }
206205
207206
208- class InstitutionSummaryMetricSerializer (JSONAPISerializer ):
209-
210- class Meta :
211- type_ = 'institution-summary-metrics'
212-
213- id = IDField (source = 'institution_id' , read_only = True )
214- public_project_count = ser .IntegerField (read_only = True )
215- private_project_count = ser .IntegerField (read_only = True )
216- user_count = ser .IntegerField (read_only = True )
217-
218- links = LinksField ({
219- 'self' : 'get_absolute_url' ,
220- })
221-
222- def get_absolute_url (self , obj ):
223- return absolute_reverse (
224- 'institutions:institution-summary-metrics' ,
225- kwargs = {
226- 'institution_id' : self .context ['request' ].parser_context ['kwargs' ]['institution_id' ],
227- 'version' : 'v2' ,
228- },
229- )
230-
231-
232207class UniqueDeptIDField (CompoundIDField ):
233208 """Creates a unique department ID of the form "<institution-id>-<dept-id>"."""
234209
@@ -255,74 +230,9 @@ class Meta:
255230 name = ser .CharField (read_only = True )
256231 number_of_users = ser .IntegerField (read_only = True )
257232
258- links = LinksField ({
259- 'self' : 'get_absolute_url' ,
260- })
261-
262- filterable_fields = frozenset ([
263- 'id' ,
264- 'name' ,
265- 'number_of_users' ,
266- ])
267233
268- def get_absolute_url (self , obj ):
269- return absolute_reverse (
270- 'institutions:institution-department-metrics' ,
271- kwargs = {
272- 'institution_id' : self .context ['request' ].parser_context ['kwargs' ]['institution_id' ],
273- 'version' : 'v2' ,
274- },
275- )
276-
277-
278- class OldInstitutionUserMetricsSerializer (JSONAPISerializer ):
234+ class InstitutionUserMetricsSerializer (JSONAPISerializer ):
279235 '''serializer for institution-users metrics
280-
281- used only when the INSTITUTIONAL_DASHBOARD_2024 feature flag is NOT active
282- (and should be removed when that flag is permanently active)
283- '''
284-
285- class Meta :
286- type_ = 'institution-users'
287-
288- id = IDField (source = 'user_id' , read_only = True )
289- user_name = ser .CharField (read_only = True )
290- public_projects = ser .IntegerField (source = 'public_project_count' , read_only = True )
291- private_projects = ser .IntegerField (source = 'private_project_count' , read_only = True )
292- department = ser .CharField (read_only = True )
293-
294- user = RelationshipField (
295- related_view = 'users:user-detail' ,
296- related_view_kwargs = {'user_id' : '<user_id>' },
297- )
298-
299- links = LinksField ({
300- 'self' : 'get_absolute_url' ,
301- })
302-
303- filterable_fields = frozenset ([
304- 'id' ,
305- 'user_name' ,
306- 'public_projects' ,
307- 'private_projects' ,
308- 'department' ,
309- ])
310-
311- def get_absolute_url (self , obj ):
312- return absolute_reverse (
313- 'institutions:institution-user-metrics' ,
314- kwargs = {
315- 'institution_id' : self .context ['request' ].parser_context ['kwargs' ]['institution_id' ],
316- 'version' : 'v2' ,
317- },
318- )
319-
320-
321- class NewInstitutionUserMetricsSerializer (JSONAPISerializer ):
322- '''serializer for institution-users metrics
323-
324- used only when the INSTITUTIONAL_DASHBOARD_2024 feature flag is active
325- (and should be renamed without "New" when that flag is permanently active)
326236 '''
327237
328238 class Meta :
@@ -360,11 +270,6 @@ class Meta:
360270 )
361271 contacts = ser .SerializerMethodField ()
362272
363- links = LinksField ({})
364-
365- def get_absolute_url (self ):
366- return None # there is no detail view for institution-users
367-
368273 def get_contacts (self , obj ):
369274 user = OSFUser .load (obj ._d_ ['user_id' ])
370275 if not user :
@@ -381,11 +286,8 @@ def get_contacts(self, obj):
381286 return list (results )
382287
383288
384- class NewInstitutionSummaryMetricsSerializer (JSONAPISerializer ):
289+ class InstitutionSummaryMetricsSerializer (JSONAPISerializer ):
385290 '''serializer for institution-summary metrics
386-
387- used only when the INSTITUTIONAL_DASHBOARD_2024 feature flag is active
388- (and should be renamed without "New" when that flag is permanently active)
389291 '''
390292
391293 class Meta :
@@ -414,11 +316,6 @@ class Meta:
414316 related_view_kwargs = {'institution_id' : '<institution_id>' },
415317 )
416318
417- links = LinksField ({})
418-
419- def get_absolute_url (self ):
420- return None # there is no detail view for institution-users
421-
422319
423320class InstitutionRelated (JSONAPIRelationshipSerializer ):
424321 id = ser .CharField (source = '_id' , required = False , allow_null = True )
0 commit comments