예제 #1
0
    def get_json_data(self, obj):

        allowed_custom_attributes_objs = models.CustomAttribute.query.all()
        allowed_custom_attributes = []

        for attribute in allowed_custom_attributes_objs:
            allowed_custom_attributes.append(attribute.name)

        custom_attributes = obj.custom_attributes

        if custom_attributes is None:
            return {}

        keys_to_pop = []
        for attribute_key in custom_attributes.keys():
            try:
                if 'uploaded_image_id' in custom_attributes[attribute_key]:
                    custom_attributes[attribute_key]['url'] = get_file_url(
                        custom_attributes[attribute_key]['value'])
            except TypeError:
                pass

            if len(allowed_custom_attributes
                   ) > 0 and attribute_key not in allowed_custom_attributes:
                keys_to_pop.append(attribute_key)

        for key in keys_to_pop:
            custom_attributes.pop(key)

        return custom_attributes
예제 #2
0
    def get_profile_url(self, obj):
        processed_profile_pictures = []
        if obj.matched_profile_pictures:
            for profile in obj.matched_profile_pictures:
                profile['url'] = get_file_url(profile['value'])

                processed_profile_pictures.append(profile)
        return processed_profile_pictures
예제 #3
0
 def file_url(self):
     return get_file_url(self.filename)