How to use the coderedcms.utils.attempt_protected_media_value_conversion function in coderedcms

To help you get started, we’ve selected a few coderedcms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coderedcorp / coderedcms / coderedcms / models / page_models.py View on Github external
def data_to_dict(self, processed_data, request):
        """
        Converts processed form data into a dictionary suitable
        for rendering in a context.
        """
        dictionary = {}

        for key, value in processed_data.items():
            new_key = key.replace('-', '_')
            if isinstance(value, list):
                dictionary[new_key] = ', '.join(value)
            else:
                dictionary[new_key] = utils.attempt_protected_media_value_conversion(request, value)

        return dictionary
github coderedcorp / coderedcms / coderedcms / forms.py View on Github external
def get_csv_response(self, context):
        filename = self.get_csv_filename()
        response = HttpResponse(content_type='text/csv; charset=utf-8')
        response['Content-Disposition'] = 'attachment;filename={}'.format(filename)

        writer = csv.writer(response)
        writer.writerow(context['data_headings'])
        for data_row in context['data_rows']:
            modified_data_row = []
            for cell in data_row:
                modified_cell = attempt_protected_media_value_conversion(self.request, cell)
                modified_data_row.append(modified_cell)

            writer.writerow(modified_data_row)
        return response