Example #1
0
def diff_submit(request):
    # Initialize data array and some default values.
    data = {}
    data['svn_diff_form'] = forms.DiffForm()
    data['svn_diff_error_message'] = ''
    if request.method == 'POST':
        form = forms.DiffForm(request.POST)
        if form.is_valid():
            try:
                controllers.SvnDiffMission.validate_diff_and_commit_if_ok(request.user.username, form.cleaned_data['diff'])
                controllers.set_mission_completed(request.user.get_profile(), 'svn_diff')
                return HttpResponseRedirect(reverse('svn_diff'))
            except controllers.IncorrectPatch, e:
                data['svn_diff_error_message'] = str(e)
        data['svn_diff_form'] = form
Example #2
0
def checkout_submit(request):
    # Initialize data array and some default values.
    data = {}
    data['svn_checkout_form'] = forms.CheckoutForm()
    data['svn_checkout_error_message'] = ''
    if request.method == 'POST':
        form = forms.CheckoutForm(request.POST)
        if form.is_valid():
            if form.cleaned_data['secret_word'] == controllers.SvnCheckoutMission.get_secret_word(request.user.username):
                controllers.set_mission_completed(request.user.get_profile(), 'svn_checkout')
                return HttpResponseRedirect(reverse(checkout))
            else:
                data['svn_checkout_error_message'] = 'The secret word is incorrect.'
        data['svn_checkout_form'] = form
    return checkout(request, data)
Example #3
0
def diff_submit(request):
    # Initialize data array and some default values.
    data = {}
    data['svn_diff_form'] = forms.DiffForm()
    data['svn_diff_error_message'] = ''
    if request.method == 'POST':
        form = forms.DiffForm(request.POST)
        if form.is_valid():
            try:
                controllers.SvnDiffMission.validate_diff_and_commit_if_ok(
                    request.user.username, form.cleaned_data['diff'])
                controllers.set_mission_completed(request.user.get_profile(),
                                                  'svn_diff')
                return HttpResponseRedirect(reverse(diff))
            except controllers.IncorrectPatch, e:
                data['svn_diff_error_message'] = str(e)
        data['svn_diff_form'] = form
Example #4
0
def checkout_submit(request):
    # Initialize data array and some default values.
    data = {}
    data['svn_checkout_form'] = forms.CheckoutForm(request.user.username)
    data['svn_checkout_error_message'] = ''
    if request.method == 'POST':
        form = forms.CheckoutForm(request.user.username, request.POST)
        if form.is_valid():
            controllers.set_mission_completed(request.user.get_profile(), 'svn_checkout')
            return HttpResponseRedirect(reverse('svn_checkout'))
        data['svn_checkout_form'] = form

    # If we get here, just hack up the request object to pretend it is a GET
    # so the dispatch system in the class-based view can use the GET handler.
    request.method = 'GET'

    return Checkout.as_view()(request, extra_context_data=data)
Example #5
0
def diff_submit(request):
    # Initialize data array and some default values.
    data = {}
    data['svn_diff_form'] = forms.DiffForm(request.user.username)
    data['svn_diff_error_message'] = ''
    if request.method == 'POST':
        wcdir = tempfile.mkdtemp()
        try:
            form = forms.DiffForm(request.user.username, wcdir, request.POST)
            if form.is_valid():
                form.commit_diff()
                controllers.set_mission_completed(request.user.get_profile(), 'svn_diff')
                return HttpResponseRedirect(reverse('svn_diff'))
        finally:
            shutil.rmtree(wcdir)
        data['svn_diff_form'] = form
    request.method = 'GET'
    return Diff.as_view()(request, extra_context_data=data)
Example #6
0
def checkout_submit(request):
    # Initialize data array and some default values.
    data = {}
    data['svn_checkout_form'] = forms.CheckoutForm()
    data['svn_checkout_error_message'] = ''
    if request.method == 'POST':
        form = forms.CheckoutForm(request.POST)
        if form.is_valid():
            if form.cleaned_data[
                    'secret_word'] == controllers.SvnCheckoutMission.get_secret_word(
                        request.user.username):
                controllers.set_mission_completed(request.user.get_profile(),
                                                  'svn_checkout')
                return HttpResponseRedirect(reverse(checkout))
            else:
                data[
                    'svn_checkout_error_message'] = 'The secret word is incorrect.'
        data['svn_checkout_form'] = form
    return checkout(request, data)
Example #7
0
 def setUp(self):
     # We fully mock the svnlook output, so the hook doesn't try to inspect a repository at all during the tests.
     controllers.set_mission_completed(Person.objects.get(user__username='******'), 'svn_diff')
Example #8
0
 def setUp(self):
     # We fully mock the svnlook output, so the hook doesn't try to inspect a repository at all during the tests.
     controllers.set_mission_completed(
         Person.objects.get(user__username='******'), 'svn_diff')