update hardcoded Mega views for 2018…
This commit is contained in:
parent
a750c62baf
commit
f297a1a0cf
2 changed files with 33 additions and 16 deletions
|
@ -191,14 +191,14 @@ class MegaHelpers:
|
|||
u2 = create_user('u2')
|
||||
u2.profile.save()
|
||||
|
||||
m = Event.objects.create(title='MEGA 2017')
|
||||
m = Event.objects.create(title='MEGA 2018')
|
||||
|
||||
cf1 = m.commentfields.create(name='Commentaire')
|
||||
cf1 = m.commentfields.create(name='Commentaires')
|
||||
cf2 = m.commentfields.create(
|
||||
name='Comment Field 2', fieldtype='char',
|
||||
)
|
||||
|
||||
option_type = m.options.create(name='Conscrit/Orga ?')
|
||||
option_type = m.options.create(name='Orga ? Conscrit ?')
|
||||
choice_orga = option_type.choices.create(value='Orga')
|
||||
choice_conscrit = option_type.choices.create(value='Conscrit')
|
||||
|
||||
|
|
|
@ -594,6 +594,19 @@ def export_members(request):
|
|||
return response
|
||||
|
||||
|
||||
# ----------------------------------------
|
||||
# Début des exports Mega machins hardcodés
|
||||
# ----------------------------------------
|
||||
|
||||
|
||||
MEGA_YEAR = 2018
|
||||
MEGA_EVENT_NAME = "MEGA 2018"
|
||||
MEGA_COMMENTFIELD_NAME = "Commentaires"
|
||||
MEGA_CONSCRITORGAFIELD_NAME = "Orga ? Conscrit ?"
|
||||
MEGA_CONSCRIT = "Conscrit"
|
||||
MEGA_ORGA = "Orga"
|
||||
|
||||
|
||||
def csv_export_mega(filename, qs):
|
||||
response = HttpResponse(content_type='text/csv')
|
||||
response['Content-Disposition'] = 'attachment; filename=' + filename
|
||||
|
@ -615,13 +628,13 @@ def csv_export_mega(filename, qs):
|
|||
|
||||
@buro_required
|
||||
def export_mega_remarksonly(request):
|
||||
filename = 'remarques_mega_2017.csv'
|
||||
filename = 'remarques_mega_{}.csv'.format(MEGA_YEAR)
|
||||
response = HttpResponse(content_type='text/csv')
|
||||
response['Content-Disposition'] = 'attachment; filename=' + filename
|
||||
writer = unicodecsv.writer(response)
|
||||
|
||||
event = Event.objects.get(title="MEGA 2017")
|
||||
commentfield = event.commentfields.get(name="Commentaire")
|
||||
event = Event.objects.get(title=MEGA_EVENT_NAME)
|
||||
commentfield = event.commentfields.get(name=MEGA_COMMENTFIELD_NAME)
|
||||
for val in commentfield.values.all():
|
||||
reg = val.registration
|
||||
user = reg.user
|
||||
|
@ -653,32 +666,36 @@ def export_mega_remarksonly(request):
|
|||
|
||||
@buro_required
|
||||
def export_mega_orgas(request):
|
||||
event = Event.objects.get(title="MEGA 2017")
|
||||
type_option = event.options.get(name="Conscrit/Orga ?")
|
||||
participant_type = type_option.choices.get(value="Orga").id
|
||||
event = Event.objects.get(title=MEGA_EVENT_NAME)
|
||||
type_option = event.options.get(name=MEGA_CONSCRITORGAFIELD_NAME)
|
||||
participant_type = type_option.choices.get(value=MEGA_ORGA).id
|
||||
qs = EventRegistration.objects.filter(event=event).filter(
|
||||
options__id=participant_type
|
||||
)
|
||||
return csv_export_mega('orgas_mega_2017.csv', qs)
|
||||
return csv_export_mega('orgas_mega_{}.csv'.format(MEGA_YEAR), qs)
|
||||
|
||||
|
||||
@buro_required
|
||||
def export_mega_participants(request):
|
||||
event = Event.objects.get(title="MEGA 2017")
|
||||
type_option = event.options.get(name="Conscrit/Orga ?")
|
||||
participant_type = type_option.choices.get(value="Conscrit").id
|
||||
event = Event.objects.get(title=MEGA_EVENT_NAME)
|
||||
type_option = event.options.get(name=MEGA_CONSCRITORGAFIELD_NAME)
|
||||
participant_type = type_option.choices.get(value=MEGA_CONSCRIT).id
|
||||
qs = EventRegistration.objects.filter(event=event).filter(
|
||||
options__id=participant_type
|
||||
)
|
||||
return csv_export_mega('participants_mega_2017.csv', qs)
|
||||
return csv_export_mega('conscrits_mega_{}.csv'.format(MEGA_YEAR), qs)
|
||||
|
||||
|
||||
@buro_required
|
||||
def export_mega(request):
|
||||
event = Event.objects.filter(title="MEGA 2017")
|
||||
event = Event.objects.filter(title=MEGA_EVENT_NAME)
|
||||
qs = EventRegistration.objects.filter(event=event) \
|
||||
.order_by("user__username")
|
||||
return csv_export_mega('all_mega_2017.csv', qs)
|
||||
return csv_export_mega('all_mega_{}.csv'.format(MEGA_YEAR), qs)
|
||||
|
||||
# ------------------------------
|
||||
# Fin des exports Mega hardcodés
|
||||
# ------------------------------
|
||||
|
||||
|
||||
@buro_required
|
||||
|
|
Loading…
Reference in a new issue