Very basic CSV "export"

This commit is contained in:
Vidir Valberg Gudmundsson 2017-08-22 13:00:42 +02:00
parent 0edcaeb11e
commit 0cdee23b30
3 changed files with 15 additions and 1 deletions

View file

@ -39,4 +39,9 @@
</table>
<h4>CSV</h4>
<textarea rows=10 cols=100>
{{ csv }}
</textarea>
{% endblock %}

View file

@ -0,0 +1,3 @@
title,submitter email,status,instances,video recording
{% for proposal in proposals %}{{ proposal.title }},{{ proposal.user.email }},{{ proposal.proposal_status }},{% for instance in proposal.event.instances.all %}When: {{ instance.when.lower|date:"l d. b H:i" }} - {{ instance.when.upper|date:"H:i" }} Where: {{ instance.location.name }}{% endfor %},{{ proposal.event.video_recording }}
{% endfor %}
Can't render this file because it contains an unexpected character in line 2 and column 194.

View file

@ -13,6 +13,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib import messages
from django.urls import reverse
from django.db.models import Q
from django.template import Engine, Context
import icalendar
@ -323,5 +324,10 @@ class ProgramControlCenter(CampViewMixin, TemplateView):
camp=self.camp
).select_related('user', 'event')
context['proposals'] = proposals
return context
engine = Engine.get_default()
template = engine.get_template('control/proposal_overview.csv')
csv = template.render(Context(context))
context['csv'] = csv
return context