def patchsingle_submit(request): # Initialize data array and some default values. data = {} data['patchsingle_form'] = forms.PatchSingleUploadForm() data['patchsingle_success'] = False data['patchsingle_error_message'] = '' if request.method == 'POST': form = forms.PatchSingleUploadForm(request.POST, request.FILES) if form.is_valid(): if form.cleaned_data['patched_file'].read() == open( view_helpers.PatchSingleFileMission.NEW_FILE).read(): set_mission_completed(request.user.get_profile(), 'diffpatch_patchsingle') data['patchsingle_success'] = True else: data[ 'patchsingle_error_message'] = 'The file did not match the contents it should have.' data['patchsingle_form'] = form return single_file_patch(request, data)
def single_file_patch(request, passed_data={}): state = DiffPatchMissionPageState(request, passed_data) state.this_mission_page_short_name = 'Single file patch' data = state.as_dict_for_template_context() data['patchsingle_form'] = forms.PatchSingleUploadForm() return (request, 'missions/diffpatch/single_file_patch.html', data)