Add export for recent training only
This commit is contained in:
parent
5cf2e5d8d5
commit
ce392da8c8
3 changed files with 9 additions and 5 deletions
|
|
@ -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/(?P<scope>all)?/?$', views.stages_export, name='stages_export'),
|
||||
|
||||
url(r'^institutions/$', views.CorporationListView.as_view(), name='corporations'),
|
||||
url(r'^institutions/(?P<pk>\d+)/$', views.CorporationView.as_view(), name='corporation'),
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@
|
|||
<h2>Importation/exportation</h2>
|
||||
<ul>
|
||||
<li><a href="{% url 'tabimport' %}">Importer des données</a></li>
|
||||
<li><a href="{% url 'stages_export' %}">Exporter les données de stages</a></li>
|
||||
<li><a href="{% url 'stages_export' %}">Exporter les données de stages</a> (récentes)</li>
|
||||
<li><a href="{% url 'stages_export' 'all' %}">Exporter les données de stages</a> (toutes)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue