Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def process_form_cell(request, cell):
if isinstance(cell, str) and cell.startswith(cr_settings['PROTECTED_MEDIA_URL']):
return utils.get_protected_media_link(request, cell, render_link=True)
if utils.uri_validator(str(cell)):
return mark_safe("<a href="{0}">{1}</a>".format(cell, cell))
return cell
def convert_to_amp(value):
"""
Converts HTML to AMP.
"""
if isinstance(value, RichText):
value = richtext(value.source)
return mark_safe(utils.convert_to_amp(value))
def event_generate_single_ical_for_event(request):
if request.method == "POST":
event_pk = request.POST['event_pk']
event_page_models = CoderedEventPage.__subclasses__()
dt_start_str = utils.fix_ical_datetime_format(request.POST['datetime_start'])
dt_end_str = utils.fix_ical_datetime_format(request.POST['datetime_end'])
dt_start = datetime.strptime(dt_start_str, "%Y-%m-%dT%H:%M:%S%z") if dt_start_str else None
dt_end = datetime.strptime(dt_end_str, "%Y-%m-%dT%H:%M:%S%z") if dt_end_str else None
for event_page_model in event_page_models:
try:
event = event_page_model.objects.get(pk=event_pk)
break
except event_page_model.DoesNotExist:
pass
ical = Calendar()
ical.add_component(event.create_single_ical(dt_start=dt_start, dt_end=dt_end))
response = HttpResponse(ical.to_ical(), content_type="text/calendar")
response['Filename'] = "{0}.ics".format(event.slug)
response['Content-Disposition'] = 'attachment; filename={0}.ics'.format(event.slug)
return response
raise Http404()
def event_generate_single_ical_for_event(request):
if request.method == "POST":
event_pk = request.POST['event_pk']
event_page_models = CoderedEventPage.__subclasses__()
dt_start_str = utils.fix_ical_datetime_format(request.POST['datetime_start'])
dt_end_str = utils.fix_ical_datetime_format(request.POST['datetime_end'])
dt_start = datetime.strptime(dt_start_str, "%Y-%m-%dT%H:%M:%S%z") if dt_start_str else None
dt_end = datetime.strptime(dt_end_str, "%Y-%m-%dT%H:%M:%S%z") if dt_end_str else None
for event_page_model in event_page_models:
try:
event = event_page_model.objects.get(pk=event_pk)
break
except event_page_model.DoesNotExist:
pass
ical = Calendar()
ical.add_component(event.create_single_ical(dt_start=dt_start, dt_end=dt_end))
response = HttpResponse(ical.to_ical(), content_type="text/calendar")
response['Filename'] = "{0}.ics".format(event.slug)
response['Content-Disposition'] = 'attachment; filename={0}.ics'.format(event.slug)
return response