def extract_mission_upload(request): # Initialize data array and some default values. data = {} data['unpack_form'] = forms.ExtractUploadForm() data['unpack_success'] = False data['what_was_wrong_with_the_extracted_file'] = '' if request.method == 'POST': form = forms.ExtractUploadForm(request.POST, request.FILES) if form.is_valid(): if form.cleaned_data['extracted_file'].read( ) == view_helpers.UntarMission.get_contents_we_want(): data['unpack_success'] = True view_helpers.set_mission_completed(request.user.get_profile(), 'tar_extract') else: data[ 'what_was_wrong_with_the_extracted_file'] = 'The uploaded file does not have the correct contents.' data['unpack_form'] = form return unpacking(request, data)
def unpacking(request, passed_data={}): state = TarMissionPageState(request, passed_data) state.this_mission_page_short_name = 'Unpacking' data = state.as_dict_for_template_context() data['unpack_form'] = forms.ExtractUploadForm() return (request, 'missions/tar/unpacking.html', data)