Commit 05d28d6c authored by Stefano Rivera's avatar Stefano Rivera

Merge branch 'export-bursaries' into 'master'

Add simplified bursaries CSV export

See merge request !25
parents f05777ed 39884212
......@@ -2,7 +2,7 @@ from django.conf.urls import url
from exports.views import (
AttendeeAccommExport, AttendeeBadgeExport, ChildCareExport, FoodExport,
TalksExport, SpecialDietExport,
TalksExport, SpecialDietExport, BursaryExport,
)
urlpatterns = [
......@@ -10,10 +10,16 @@ urlpatterns = [
name='attendee_admin_export_accomm'),
url(r'^attendees/admin/export/badges/$', AttendeeBadgeExport.as_view(),
name='attendee_admin_export_badges'),
url(r'^attendees/admin/export/food/$', FoodExport.as_view()),
url(r'^attendees/admin/export/food/$', FoodExport.as_view(),
name='attendee_admin_export_food'),
url(r'^attendees/admin/export/special_diets/'
r'(?P<date>[0-9-]+)/(?P<meal>[a-z]+)/$', SpecialDietExport.as_view()),
url(r'^attendees/admin/export/child_care/$', ChildCareExport.as_view()),
url(r'^attendees/admin/export/child_care/$', ChildCareExport.as_view(),
name='attendee_admin_export_childcare'),
url(r'^attendees/admin/export/bursaries/$', BursaryExport.as_view(),
name='attendee_admin_export_bursaries'),
url(r'^talks/admin/export/$', TalksExport.as_view(),
name='talks_admin_export'),
]
exports = [{'url': u.name, 'name': u.callback.view_class.name} for u in urlpatterns if u.name]
......@@ -3,6 +3,7 @@ import csv
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Q
from django.http import HttpResponse
from django.views.generic import ListView
......@@ -11,6 +12,7 @@ from wafer.talks.models import Talk
from bursary.models import Bursary
from front_desk.models import CheckIn
from register.models import Accomm, Attendee, ChildCare, Meal
from bursary.models import Bursary
class CSVExportView(ListView):
......@@ -64,6 +66,7 @@ class AttendeeAdminMixin(PermissionRequiredMixin):
class AttendeeBadgeExport(AttendeeAdminMixin, CSVExportView):
name = 'Attendee badges'
model = Attendee
filename = "attendee_badges.csv"
ordering = ('user__username',)
......@@ -74,6 +77,7 @@ class AttendeeBadgeExport(AttendeeAdminMixin, CSVExportView):
class AttendeeAccommExport(AttendeeAdminMixin, CSVExportView):
name = 'Accommodation'
model = Accomm
filename = "attendee_accommodation.csv"
ordering = ('attendee__user__username',)
......@@ -87,6 +91,7 @@ class AttendeeAccommExport(AttendeeAdminMixin, CSVExportView):
class ChildCareExport(AttendeeAdminMixin, CSVExportView):
name = 'Childcare'
model = ChildCare
filename = "attendee_child_care.csv"
ordering = ('attendee__user__username',)
......@@ -100,6 +105,7 @@ class ChildCareExport(AttendeeAdminMixin, CSVExportView):
class TalksExport(PermissionRequiredMixin, CSVExportView):
name = 'Talks'
model = Talk
permission_required = 'talks.edit_private_notes'
filename = "talk_evaluations.csv"
......@@ -119,6 +125,7 @@ class TalksExport(PermissionRequiredMixin, CSVExportView):
class FoodExport(AttendeeAdminMixin, CSVExportView):
name = 'Food'
model = Meal
filename = "meals.csv"
ordering = ('date', 'meal',)
......@@ -187,6 +194,7 @@ class FoodExport(AttendeeAdminMixin, CSVExportView):
class SpecialDietExport(AttendeeAdminMixin, CSVExportView):
name = 'Special diets'
filename = "diets.csv"
ordering = ('attendee__user__username',)
columns = [
......@@ -258,3 +266,33 @@ class SpecialDietExport(AttendeeAdminMixin, CSVExportView):
'special_diet': '',
}
writer.writerow([row.get(key) for key in self.columns])
class BursaryExport(AttendeeAdminMixin, CSVExportView):
name = 'Bursaries'
filename = "bursaries.csv"
columns = [
'user.username',
'user.userprofile.display_name',
'user.email',
'user.attendee.country',
'travel_status',
'food_status',
'accommodation_status',
]
approved = ('pending', 'accepted',)
def get_queryset(self):
return Bursary.objects.filter(
Q(travel_status__in=self.approved)
| Q(food_status__in=self.approved)
| Q(accommodation_status__in=self.approved)
).exclude(
user__attendee__id=None, # exclude unregistered people
).prefetch_related(
'user',
'user__attendee',
'user__userprofile',
).order_by('user__username')
......@@ -69,4 +69,8 @@
<p>
<a class="btn btn-info" href="{% url 'front_desk.rooms' %}">Room Assignments</a>
</p>
<h2>Data exports:</h2>
{% for export in exports %}
<a class="btn btn-info" href="{% url export.url %}">{{ export.name }}</a>
{% endfor %}
{% endblock %}
......@@ -24,6 +24,8 @@ from front_desk.forms import (
RegisterOnSiteForm, SearchForm, ShoesForm, TShirtForm)
from front_desk.models import CheckIn
from exports.urls import exports
log = logging.getLogger(__name__)
shirt_sizes = dict(settings.DEBCONF_T_SHIRT_SIZES)
......@@ -56,6 +58,7 @@ class Dashboard(CheckInPermissionMixin, TemplateView):
'form': form,
'results': results[:20],
'num_results': len(results),
'exports': exports,
})
return context
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment