def diffsingle_submit(request): # Initialize data array and some default values. data = {} data['diffsingle_form'] = forms.DiffSingleUploadForm() data['diffsingle_success'] = False data['diffsingle_error_message'] = '' if request.method == 'POST': form = forms.DiffSingleUploadForm(request.POST) if form.is_valid(): try: view_helpers.DiffSingleFileMission.validate_patch( form.cleaned_data['diff']) set_mission_completed(request.user.get_profile(), 'diffpatch_diffsingle') data['diffsingle_success'] = True except view_helpers.IncorrectPatch, e: data['diffsingle_error_message'] = utf8(e) data['diffsingle_form'] = form
def single_file_diff(request, passed_data={}): state = DiffPatchMissionPageState(request, passed_data) state.this_mission_page_short_name = 'Single file diff' data = state.as_dict_for_template_context() data['diffsingle_form'] = forms.DiffSingleUploadForm() return (request, 'missions/diffpatch/single_file_diff.html', data)