mirror of
https://github.com/macports/macports-webapp.git
synced 2026-07-13 03:18:42 -07:00
18 lines
414 B
Python
18 lines
414 B
Python
from rest_framework import serializers
|
|
|
|
|
|
class FollowedPortsSerializer(serializers.Serializer):
|
|
usr = None
|
|
ports = serializers.SerializerMethodField()
|
|
|
|
def get_context(self):
|
|
usr = self.context.get('user')
|
|
return usr
|
|
|
|
def get_ports(self, obj):
|
|
usr = self.get_context()
|
|
if not usr:
|
|
return []
|
|
|
|
return usr.ports.all().values_list('name', flat=True)
|