def __init__(self, *args, **kwargs): client = kwargs.pop("client") super().__init__(*args, **kwargs) self.client = client self.organization = client.organization self.fields["config"].choices = Configuration.get_choices( self.organization) self.fields["address"].choices = Address.get_choices(self.organization) self.fields["media"].choices = Media.get_choices()
def __init__(self, *args, **kwargs): request = kwargs.pop("request") super().__init__(*args, **kwargs) self.client = request.user.profile self.request_lang = get_language_from_request(request) self.organization = self.client.organization self.fields["config"].choices = Configuration.get_choices( self.organization) self.fields["address"].choices = [ ("none", "Myself") ] + Address.get_choices(self.organization) self.fields["media"].choices = Media.get_choices( kind=None if self.client.can_order_physical else Media.VIRTUAL, display_units=self.client.is_limited, ) self.fields["kind"].choices = filter( lambda item: self.client.can_order_physical or item[0] != Media. PHYSICAL, self.KIND_CHOICES.items(), )
def __init__(self, *args, **kwargs): client = kwargs.pop("client") print(client, client.is_limited) super().__init__(*args, **kwargs) self.client = client self.organization = client.organization self.fields["config"].choices = Configuration.get_choices( self.organization) self.fields["address"].choices = [ ("none", "Myself") ] + Address.get_choices(self.organization) self.fields["media"].choices = Media.get_choices( kind=None if client.can_order_physical else Media.VIRTUAL, display_units=client.is_limited, ) self.fields["kind"].choices = filter( lambda item: client.can_order_physical or item[0] != Media. PHYSICAL, self.KIND_CHOICES.items(), )
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["config"].choices = Configuration.get_choices( self._client.organization )