diff --git a/common/urls.py b/common/urls.py index 8b9ad0e..3760f5b 100644 --- a/common/urls.py +++ b/common/urls.py @@ -16,7 +16,7 @@ urlpatterns = patterns('', url(r'^data-import/', include('tabimport.urls')), url(r'^attribution/$', views.AttributionView.as_view(), name='attribution'), - url(r'^stages/export/$', 'stages.views.stages_export', name='stages_export'), + url(r'^stages/export/(?Pall)?/?$', views.stages_export, name='stages_export'), url(r'^institutions/$', views.CorporationListView.as_view(), name='corporations'), url(r'^institutions/(?P\d+)/$', views.CorporationView.as_view(), name='corporation'), diff --git a/stages/views.py b/stages/views.py index 264a40f..eb0fffa 100644 --- a/stages/views.py +++ b/stages/views.py @@ -248,7 +248,7 @@ NON_ATTR_EXPORT_FIELDS = [ ('Courriel contact - copie', None), ] -def stages_export(request): +def stages_export(request, scope=None): from datetime import date from openpyxl import Workbook from openpyxl.styles import Font, Style @@ -272,8 +272,11 @@ def stages_export(request): # Export trainings for a specific period query = Training.objects.filter(availability__period_id=period_filter) else: - # Export all trainings in the database - query = Training.objects.all() + if scope and scope == 'all': + # Export all trainings in the database + query = Training.objects.all() + else: + query = Training.objects.filter(availability__period__end_date__gt=school_year_start()) # Prepare "default" contacts (when not defined on training) default_contacts = dict((c, '') for c in Corporation.objects.all().values_list('name', flat=True)) diff --git a/templates/admin/index.html b/templates/admin/index.html index 9261f63..933ecdb 100644 --- a/templates/admin/index.html +++ b/templates/admin/index.html @@ -73,7 +73,8 @@

Importation/exportation