def diff(request, passed_data=None): state = GitMissionPageState(request, passed_data) state.this_mission_page_short_name = 'Diffing your changes' state.mission_step_prerequisite = 'git_checkout' data = state.as_dict_for_template_context() data['git_diff_form'] = forms.DiffForm() return (request, 'missions/git/diff.html', data)
def diff(request, passed_data=None): state = GitMissionPageState(request, passed_data) state.this_mission_page_short_name = 'Creating a patch' state.mission_step_prerequisite = 'git_checkout' data = state.as_dict_for_template_context() if 'git_diff_form' not in data: data['git_diff_form'] = forms.DiffForm() data['file_for_git_diff'] = 'hello.py' return (request, 'missions/git/diff.html', data)
def diff_submit(request): # Initialize data array and some default values. data = {} data['git_diff_form'] = forms.DiffForm() data['git_diff_error_message'] = '' if request.method == 'POST': form = forms.DiffForm(request.POST) if form.is_valid(): if controllers.GitDiffMission.validate_diff_and_commit_if_ok( request.user.username, form.cleaned_data['diff']): controllers.set_mission_completed(request.user.get_profile(), 'git_diff') return HttpResponseRedirect(reverse(diff)) else: data[ 'git_diff_error_message'] = "The patch file is incorrect. Give it another try!" data['git_diff_form'] = form return diff(request, data)
def diff_submit(request): # Initialize data array and some default values. data = {} data['git_diff_form'] = forms.DiffForm() data['git_diff_error_message'] = '' if request.method == 'POST': form = forms.DiffForm(request.POST) if form.is_valid(): if view_helpers.GitDiffMission.commit_if_ok( request.user.username, form.cleaned_data['diff']): view_helpers.set_mission_completed(request.user.get_profile(), 'git_diff') return HttpResponseRedirect(reverse(diff)) else: data[ 'git_diff_error_message'] = "Unable to commit the patch. Please check your patch and try again " else: return diff(request, {'git_diff_form': form}) data['git_diff_form'] = form return diff(request, data)